| author | |
| committer | |
| log | 75d1b113aa6adf983497a78a0a0e61ecac7aaa54 |
| tree | 240b0c60d30190d94d672a6baacb5db479f9da74 |
| parent | 968d1ecf17c0a0774d43965332d00d4ad39743b9 |
10 files changed, 6201 insertions(+), 6201 deletions(-)
src/stage1/all_types.hpp+1096-1096| ... | ... | @@ -31,14 +31,14 @@ struct BuiltinFnEntry; |
| 31 | 31 | struct TypeStructField; |
| 32 | 32 | struct CodeGen; |
| 33 | 33 | struct ZigValue; |
| 34 | struct IrInstSrc; | |
| 35 | struct IrInstGen; | |
| 36 | struct IrInstGenCast; | |
| 37 | struct IrInstGenAlloca; | |
| 38 | struct IrInstGenCall; | |
| 39 | struct IrInstGenAwait; | |
| 34 | struct Stage1ZirInst; | |
| 35 | struct Stage1AirInst; | |
| 36 | struct Stage1AirInstCast; | |
| 37 | struct Stage1AirInstAlloca; | |
| 38 | struct Stage1AirInstCall; | |
| 39 | struct Stage1AirInstAwait; | |
| 40 | 40 | struct Stage1ZirBasicBlock; |
| 41 | struct IrBasicBlockGen; | |
| 41 | struct Stage1AirBasicBlock; | |
| 42 | 42 | struct ScopeDecls; |
| 43 | 43 | struct ZigWindowsSDK; |
| 44 | 44 | struct Tld; |
| ... | ... | @@ -122,7 +122,7 @@ struct Stage1Zir { |
| 122 | 122 | }; |
| 123 | 123 | |
| 124 | 124 | struct Stage1Air { |
| 125 | ZigList<IrBasicBlockGen *> basic_block_list; | |
| 125 | ZigList<Stage1AirBasicBlock *> basic_block_list; | |
| 126 | 126 | Buf *name; |
| 127 | 127 | ZigFn *name_fn; |
| 128 | 128 | size_t mem_slot_count; |
| ... | ... | @@ -311,7 +311,7 @@ struct ConstErrValue { |
| 311 | 311 | |
| 312 | 312 | struct ConstBoundFnValue { |
| 313 | 313 | ZigFn *fn; |
| 314 | IrInstGen *first_arg; | |
| 314 | Stage1AirInst *first_arg; | |
| 315 | 315 | AstNode *first_arg_src; |
| 316 | 316 | }; |
| 317 | 317 | |
| ... | ... | @@ -400,14 +400,14 @@ struct LazyValueAlignOf { |
| 400 | 400 | LazyValue base; |
| 401 | 401 | |
| 402 | 402 | IrAnalyze *ira; |
| 403 | IrInstGen *target_type; | |
| 403 | Stage1AirInst *target_type; | |
| 404 | 404 | }; |
| 405 | 405 | |
| 406 | 406 | struct LazyValueSizeOf { |
| 407 | 407 | LazyValue base; |
| 408 | 408 | |
| 409 | 409 | IrAnalyze *ira; |
| 410 | IrInstGen *target_type; | |
| 410 | Stage1AirInst *target_type; | |
| 411 | 411 | |
| 412 | 412 | bool bit_size; |
| 413 | 413 | }; |
| ... | ... | @@ -416,9 +416,9 @@ struct LazyValueSliceType { |
| 416 | 416 | LazyValue base; |
| 417 | 417 | |
| 418 | 418 | IrAnalyze *ira; |
| 419 | IrInstGen *sentinel; // can be null | |
| 420 | IrInstGen *elem_type; | |
| 421 | IrInstGen *align_inst; // can be null | |
| 419 | Stage1AirInst *sentinel; // can be null | |
| 420 | Stage1AirInst *elem_type; | |
| 421 | Stage1AirInst *align_inst; // can be null | |
| 422 | 422 | |
| 423 | 423 | bool is_const; |
| 424 | 424 | bool is_volatile; |
| ... | ... | @@ -429,8 +429,8 @@ struct LazyValueArrayType { |
| 429 | 429 | LazyValue base; |
| 430 | 430 | |
| 431 | 431 | IrAnalyze *ira; |
| 432 | IrInstGen *sentinel; // can be null | |
| 433 | IrInstGen *elem_type; | |
| 432 | Stage1AirInst *sentinel; // can be null | |
| 433 | Stage1AirInst *elem_type; | |
| 434 | 434 | uint64_t length; |
| 435 | 435 | }; |
| 436 | 436 | |
| ... | ... | @@ -438,9 +438,9 @@ struct LazyValuePtrType { |
| 438 | 438 | LazyValue base; |
| 439 | 439 | |
| 440 | 440 | IrAnalyze *ira; |
| 441 | IrInstGen *sentinel; // can be null | |
| 442 | IrInstGen *elem_type; | |
| 443 | IrInstGen *align_inst; // can be null | |
| 441 | Stage1AirInst *sentinel; // can be null | |
| 442 | Stage1AirInst *elem_type; | |
| 443 | Stage1AirInst *align_inst; // can be null | |
| 444 | 444 | |
| 445 | 445 | PtrLen ptr_len; |
| 446 | 446 | uint32_t bit_offset_in_host; |
| ... | ... | @@ -455,14 +455,14 @@ struct LazyValuePtrTypeSimple { |
| 455 | 455 | LazyValue base; |
| 456 | 456 | |
| 457 | 457 | IrAnalyze *ira; |
| 458 | IrInstGen *elem_type; | |
| 458 | Stage1AirInst *elem_type; | |
| 459 | 459 | }; |
| 460 | 460 | |
| 461 | 461 | struct LazyValueOptType { |
| 462 | 462 | LazyValue base; |
| 463 | 463 | |
| 464 | 464 | IrAnalyze *ira; |
| 465 | IrInstGen *payload_type; | |
| 465 | Stage1AirInst *payload_type; | |
| 466 | 466 | }; |
| 467 | 467 | |
| 468 | 468 | struct LazyValueFnType { |
| ... | ... | @@ -470,9 +470,9 @@ struct LazyValueFnType { |
| 470 | 470 | |
| 471 | 471 | IrAnalyze *ira; |
| 472 | 472 | AstNode *proto_node; |
| 473 | IrInstGen **param_types; | |
| 474 | IrInstGen *align_inst; // can be null | |
| 475 | IrInstGen *return_type; | |
| 473 | Stage1AirInst **param_types; | |
| 474 | Stage1AirInst *align_inst; // can be null | |
| 475 | Stage1AirInst *return_type; | |
| 476 | 476 | |
| 477 | 477 | CallingConvention cc; |
| 478 | 478 | bool is_generic; |
| ... | ... | @@ -482,8 +482,8 @@ struct LazyValueErrUnionType { |
| 482 | 482 | LazyValue base; |
| 483 | 483 | |
| 484 | 484 | IrAnalyze *ira; |
| 485 | IrInstGen *err_set_type; | |
| 486 | IrInstGen *payload_type; | |
| 485 | Stage1AirInst *err_set_type; | |
| 486 | Stage1AirInst *payload_type; | |
| 487 | 487 | Buf *type_name; |
| 488 | 488 | }; |
| 489 | 489 | |
| ... | ... | @@ -1651,13 +1651,13 @@ struct ZigFn { |
| 1651 | 1651 | size_t branch_quota; |
| 1652 | 1652 | AstNode **param_source_nodes; |
| 1653 | 1653 | Buf **param_names; |
| 1654 | IrInstGen *err_code_spill; | |
| 1654 | Stage1AirInst *err_code_spill; | |
| 1655 | 1655 | AstNode *assumed_non_async; |
| 1656 | 1656 | |
| 1657 | 1657 | AstNode *fn_no_inline_set_node; |
| 1658 | 1658 | AstNode *fn_static_eval_set_node; |
| 1659 | 1659 | |
| 1660 | ZigList<IrInstGenAlloca *> alloca_gen_list; | |
| 1660 | ZigList<Stage1AirInstAlloca *> alloca_gen_list; | |
| 1661 | 1661 | ZigList<ZigVar *> variable_list; |
| 1662 | 1662 | |
| 1663 | 1663 | Buf *section_name; |
| ... | ... | @@ -1669,8 +1669,8 @@ struct ZigFn { |
| 1669 | 1669 | AstNode *non_async_node; |
| 1670 | 1670 | |
| 1671 | 1671 | ZigList<GlobalExport> export_list; |
| 1672 | ZigList<IrInstGenCall *> call_list; | |
| 1673 | ZigList<IrInstGenAwait *> await_list; | |
| 1672 | ZigList<Stage1AirInstCall *> call_list; | |
| 1673 | ZigList<Stage1AirInstAwait *> await_list; | |
| 1674 | 1674 | |
| 1675 | 1675 | LLVMValueRef valgrind_client_request_array; |
| 1676 | 1676 | |
| ... | ... | @@ -2096,9 +2096,9 @@ struct CodeGen { |
| 2096 | 2096 | Buf *builtin_zig_path; |
| 2097 | 2097 | Buf *zig_std_special_dir; // Cannot be overridden; derived from zig_lib_dir. |
| 2098 | 2098 | |
| 2099 | IrInstSrc *invalid_inst_src; | |
| 2100 | IrInstGen *invalid_inst_gen; | |
| 2101 | IrInstGen *unreach_instruction; | |
| 2099 | Stage1ZirInst *invalid_inst_src; | |
| 2100 | Stage1AirInst *invalid_inst_gen; | |
| 2101 | Stage1AirInst *unreach_instruction; | |
| 2102 | 2102 | |
| 2103 | 2103 | ZigValue panic_msg_vals[PanicMsgIdCount]; |
| 2104 | 2104 | |
| ... | ... | @@ -2165,8 +2165,8 @@ struct ZigVar { |
| 2165 | 2165 | ZigValue *const_value; |
| 2166 | 2166 | ZigType *var_type; |
| 2167 | 2167 | LLVMValueRef value_ref; |
| 2168 | IrInstSrc *is_comptime; | |
| 2169 | IrInstGen *ptr_instruction; | |
| 2168 | Stage1ZirInst *is_comptime; | |
| 2169 | Stage1AirInst *ptr_instruction; | |
| 2170 | 2170 | // which node is the declaration of the variable |
| 2171 | 2171 | AstNode *decl_node; |
| 2172 | 2172 | ZigLLVMDILocalVariable *di_loc_var; |
| ... | ... | @@ -2268,9 +2268,9 @@ struct ScopeBlock { |
| 2268 | 2268 | |
| 2269 | 2269 | Buf *name; |
| 2270 | 2270 | Stage1ZirBasicBlock *end_block; |
| 2271 | IrInstSrc *is_comptime; | |
| 2271 | Stage1ZirInst *is_comptime; | |
| 2272 | 2272 | ResultLocPeerParent *peer_parent; |
| 2273 | ZigList<IrInstSrc *> *incoming_values; | |
| 2273 | ZigList<Stage1ZirInst *> *incoming_values; | |
| 2274 | 2274 | ZigList<Stage1ZirBasicBlock *> *incoming_blocks; |
| 2275 | 2275 | |
| 2276 | 2276 | AstNode *safety_set_node; |
| ... | ... | @@ -2325,8 +2325,8 @@ struct ScopeLoop { |
| 2325 | 2325 | Buf *name; |
| 2326 | 2326 | Stage1ZirBasicBlock *break_block; |
| 2327 | 2327 | Stage1ZirBasicBlock *continue_block; |
| 2328 | IrInstSrc *is_comptime; | |
| 2329 | ZigList<IrInstSrc *> *incoming_values; | |
| 2328 | Stage1ZirInst *is_comptime; | |
| 2329 | ZigList<Stage1ZirInst *> *incoming_values; | |
| 2330 | 2330 | ZigList<Stage1ZirBasicBlock *> *incoming_blocks; |
| 2331 | 2331 | ResultLocPeerParent *peer_parent; |
| 2332 | 2332 | ScopeExpr *spill_scope; |
| ... | ... | @@ -2340,7 +2340,7 @@ struct ScopeLoop { |
| 2340 | 2340 | struct ScopeRuntime { |
| 2341 | 2341 | Scope base; |
| 2342 | 2342 | |
| 2343 | IrInstSrc *is_comptime; | |
| 2343 | Stage1ZirInst *is_comptime; | |
| 2344 | 2344 | }; |
| 2345 | 2345 | |
| 2346 | 2346 | // This scope is created for a suspend block in order to have labeled |
| ... | ... | @@ -2439,11 +2439,11 @@ enum AtomicRmwOp { |
| 2439 | 2439 | // Phi instructions must be first in a basic block. |
| 2440 | 2440 | // The last instruction in a basic block must be of type unreachable. |
| 2441 | 2441 | struct Stage1ZirBasicBlock { |
| 2442 | ZigList<IrInstSrc *> instruction_list; | |
| 2443 | IrBasicBlockGen *child; | |
| 2442 | ZigList<Stage1ZirInst *> instruction_list; | |
| 2443 | Stage1AirBasicBlock *child; | |
| 2444 | 2444 | Scope *scope; |
| 2445 | 2445 | const char *name_hint; |
| 2446 | IrInstSrc *suspend_instruction_ref; | |
| 2446 | Stage1ZirInst *suspend_instruction_ref; | |
| 2447 | 2447 | |
| 2448 | 2448 | uint32_t ref_count; |
| 2449 | 2449 | uint32_t index; // index into the basic block list |
| ... | ... | @@ -2453,8 +2453,8 @@ struct Stage1ZirBasicBlock { |
| 2453 | 2453 | bool in_resume_stack; |
| 2454 | 2454 | }; |
| 2455 | 2455 | |
| 2456 | struct IrBasicBlockGen { | |
| 2457 | ZigList<IrInstGen *> instruction_list; | |
| 2456 | struct Stage1AirBasicBlock { | |
| 2457 | ZigList<Stage1AirInst *> instruction_list; | |
| 2458 | 2458 | Scope *scope; |
| 2459 | 2459 | const char *name_hint; |
| 2460 | 2460 | LLVMBasicBlockRef llvm_block; |
| ... | ... | @@ -2462,7 +2462,7 @@ struct IrBasicBlockGen { |
| 2462 | 2462 | // The instruction that referenced this basic block and caused us to |
| 2463 | 2463 | // analyze the basic block. If the same instruction wants us to emit |
| 2464 | 2464 | // the same basic block, then we re-generate it instead of saving it. |
| 2465 | IrInstSrc *ref_instruction; | |
| 2465 | Stage1ZirInst *ref_instruction; | |
| 2466 | 2466 | // When this is non-null, a branch to this basic block is only allowed |
| 2467 | 2467 | // if the branch is comptime. The instruction points to the reason |
| 2468 | 2468 | // the basic block must be comptime. |
| ... | ... | @@ -2475,246 +2475,246 @@ struct IrBasicBlockGen { |
| 2475 | 2475 | // Src instructions are generated by ir_gen_* functions in ir.cpp from AST. |
| 2476 | 2476 | // ir_analyze_* functions consume Src instructions and produce Gen instructions. |
| 2477 | 2477 | // Src instructions do not have type information; Gen instructions do. |
| 2478 | enum IrInstSrcId : uint8_t { | |
| 2479 | IrInstSrcIdInvalid, | |
| 2480 | IrInstSrcIdDeclVar, | |
| 2481 | IrInstSrcIdBr, | |
| 2482 | IrInstSrcIdCondBr, | |
| 2483 | IrInstSrcIdSwitchBr, | |
| 2484 | IrInstSrcIdSwitchVar, | |
| 2485 | IrInstSrcIdSwitchElseVar, | |
| 2486 | IrInstSrcIdSwitchTarget, | |
| 2487 | IrInstSrcIdPhi, | |
| 2488 | IrInstSrcIdUnOp, | |
| 2489 | IrInstSrcIdBinOp, | |
| 2490 | IrInstSrcIdMergeErrSets, | |
| 2491 | IrInstSrcIdLoadPtr, | |
| 2492 | IrInstSrcIdStorePtr, | |
| 2493 | IrInstSrcIdFieldPtr, | |
| 2494 | IrInstSrcIdElemPtr, | |
| 2495 | IrInstSrcIdVarPtr, | |
| 2496 | IrInstSrcIdCall, | |
| 2497 | IrInstSrcIdCallArgs, | |
| 2498 | IrInstSrcIdCallExtra, | |
| 2499 | IrInstSrcIdAsyncCallExtra, | |
| 2500 | IrInstSrcIdConst, | |
| 2501 | IrInstSrcIdReturn, | |
| 2502 | IrInstSrcIdContainerInitList, | |
| 2503 | IrInstSrcIdContainerInitFields, | |
| 2504 | IrInstSrcIdUnreachable, | |
| 2505 | IrInstSrcIdTypeOf, | |
| 2506 | IrInstSrcIdSetCold, | |
| 2507 | IrInstSrcIdSetRuntimeSafety, | |
| 2508 | IrInstSrcIdSetFloatMode, | |
| 2509 | IrInstSrcIdArrayType, | |
| 2510 | IrInstSrcIdAnyFrameType, | |
| 2511 | IrInstSrcIdSliceType, | |
| 2512 | IrInstSrcIdAsm, | |
| 2513 | IrInstSrcIdSizeOf, | |
| 2514 | IrInstSrcIdTestNonNull, | |
| 2515 | IrInstSrcIdOptionalUnwrapPtr, | |
| 2516 | IrInstSrcIdClz, | |
| 2517 | IrInstSrcIdCtz, | |
| 2518 | IrInstSrcIdPopCount, | |
| 2519 | IrInstSrcIdBswap, | |
| 2520 | IrInstSrcIdBitReverse, | |
| 2521 | IrInstSrcIdImport, | |
| 2522 | IrInstSrcIdCImport, | |
| 2523 | IrInstSrcIdCInclude, | |
| 2524 | IrInstSrcIdCDefine, | |
| 2525 | IrInstSrcIdCUndef, | |
| 2526 | IrInstSrcIdRef, | |
| 2527 | IrInstSrcIdCompileErr, | |
| 2528 | IrInstSrcIdCompileLog, | |
| 2529 | IrInstSrcIdErrName, | |
| 2530 | IrInstSrcIdEmbedFile, | |
| 2531 | IrInstSrcIdCmpxchg, | |
| 2532 | IrInstSrcIdFence, | |
| 2533 | IrInstSrcIdReduce, | |
| 2534 | IrInstSrcIdTruncate, | |
| 2535 | IrInstSrcIdIntCast, | |
| 2536 | IrInstSrcIdFloatCast, | |
| 2537 | IrInstSrcIdIntToFloat, | |
| 2538 | IrInstSrcIdFloatToInt, | |
| 2539 | IrInstSrcIdBoolToInt, | |
| 2540 | IrInstSrcIdVectorType, | |
| 2541 | IrInstSrcIdShuffleVector, | |
| 2542 | IrInstSrcIdSplat, | |
| 2543 | IrInstSrcIdBoolNot, | |
| 2544 | IrInstSrcIdMemset, | |
| 2545 | IrInstSrcIdMemcpy, | |
| 2546 | IrInstSrcIdSlice, | |
| 2547 | IrInstSrcIdBreakpoint, | |
| 2548 | IrInstSrcIdReturnAddress, | |
| 2549 | IrInstSrcIdFrameAddress, | |
| 2550 | IrInstSrcIdFrameHandle, | |
| 2551 | IrInstSrcIdFrameType, | |
| 2552 | IrInstSrcIdFrameSize, | |
| 2553 | IrInstSrcIdAlignOf, | |
| 2554 | IrInstSrcIdOverflowOp, | |
| 2555 | IrInstSrcIdTestErr, | |
| 2556 | IrInstSrcIdMulAdd, | |
| 2557 | IrInstSrcIdFloatOp, | |
| 2558 | IrInstSrcIdUnwrapErrCode, | |
| 2559 | IrInstSrcIdUnwrapErrPayload, | |
| 2560 | IrInstSrcIdFnProto, | |
| 2561 | IrInstSrcIdTestComptime, | |
| 2562 | IrInstSrcIdPtrCast, | |
| 2563 | IrInstSrcIdBitCast, | |
| 2564 | IrInstSrcIdIntToPtr, | |
| 2565 | IrInstSrcIdPtrToInt, | |
| 2566 | IrInstSrcIdIntToEnum, | |
| 2567 | IrInstSrcIdEnumToInt, | |
| 2568 | IrInstSrcIdIntToErr, | |
| 2569 | IrInstSrcIdErrToInt, | |
| 2570 | IrInstSrcIdCheckSwitchProngsUnderYes, | |
| 2571 | IrInstSrcIdCheckSwitchProngsUnderNo, | |
| 2572 | IrInstSrcIdCheckStatementIsVoid, | |
| 2573 | IrInstSrcIdTypeName, | |
| 2574 | IrInstSrcIdDeclRef, | |
| 2575 | IrInstSrcIdPanic, | |
| 2576 | IrInstSrcIdTagName, | |
| 2577 | IrInstSrcIdFieldParentPtr, | |
| 2578 | IrInstSrcIdOffsetOf, | |
| 2579 | IrInstSrcIdBitOffsetOf, | |
| 2580 | IrInstSrcIdTypeInfo, | |
| 2581 | IrInstSrcIdType, | |
| 2582 | IrInstSrcIdHasField, | |
| 2583 | IrInstSrcIdSetEvalBranchQuota, | |
| 2584 | IrInstSrcIdPtrType, | |
| 2585 | IrInstSrcIdPtrTypeSimple, | |
| 2586 | IrInstSrcIdPtrTypeSimpleConst, | |
| 2587 | IrInstSrcIdAlignCast, | |
| 2588 | IrInstSrcIdImplicitCast, | |
| 2589 | IrInstSrcIdResolveResult, | |
| 2590 | IrInstSrcIdResetResult, | |
| 2591 | IrInstSrcIdSetAlignStack, | |
| 2592 | IrInstSrcIdArgTypeAllowVarFalse, | |
| 2593 | IrInstSrcIdArgTypeAllowVarTrue, | |
| 2594 | IrInstSrcIdExport, | |
| 2595 | IrInstSrcIdExtern, | |
| 2596 | IrInstSrcIdErrorReturnTrace, | |
| 2597 | IrInstSrcIdErrorUnion, | |
| 2598 | IrInstSrcIdAtomicRmw, | |
| 2599 | IrInstSrcIdAtomicLoad, | |
| 2600 | IrInstSrcIdAtomicStore, | |
| 2601 | IrInstSrcIdSaveErrRetAddr, | |
| 2602 | IrInstSrcIdAddImplicitReturnType, | |
| 2603 | IrInstSrcIdErrSetCast, | |
| 2604 | IrInstSrcIdCheckRuntimeScope, | |
| 2605 | IrInstSrcIdHasDecl, | |
| 2606 | IrInstSrcIdUndeclaredIdent, | |
| 2607 | IrInstSrcIdAlloca, | |
| 2608 | IrInstSrcIdEndExpr, | |
| 2609 | IrInstSrcIdUnionInitNamedField, | |
| 2610 | IrInstSrcIdSuspendBegin, | |
| 2611 | IrInstSrcIdSuspendFinish, | |
| 2612 | IrInstSrcIdAwait, | |
| 2613 | IrInstSrcIdResume, | |
| 2614 | IrInstSrcIdSpillBegin, | |
| 2615 | IrInstSrcIdSpillEnd, | |
| 2616 | IrInstSrcIdWasmMemorySize, | |
| 2617 | IrInstSrcIdWasmMemoryGrow, | |
| 2618 | IrInstSrcIdSrc, | |
| 2478 | enum Stage1ZirInstId : uint8_t { | |
| 2479 | Stage1ZirInstIdInvalid, | |
| 2480 | Stage1ZirInstIdDeclVar, | |
| 2481 | Stage1ZirInstIdBr, | |
| 2482 | Stage1ZirInstIdCondBr, | |
| 2483 | Stage1ZirInstIdSwitchBr, | |
| 2484 | Stage1ZirInstIdSwitchVar, | |
| 2485 | Stage1ZirInstIdSwitchElseVar, | |
| 2486 | Stage1ZirInstIdSwitchTarget, | |
| 2487 | Stage1ZirInstIdPhi, | |
| 2488 | Stage1ZirInstIdUnOp, | |
| 2489 | Stage1ZirInstIdBinOp, | |
| 2490 | Stage1ZirInstIdMergeErrSets, | |
| 2491 | Stage1ZirInstIdLoadPtr, | |
| 2492 | Stage1ZirInstIdStorePtr, | |
| 2493 | Stage1ZirInstIdFieldPtr, | |
| 2494 | Stage1ZirInstIdElemPtr, | |
| 2495 | Stage1ZirInstIdVarPtr, | |
| 2496 | Stage1ZirInstIdCall, | |
| 2497 | Stage1ZirInstIdCallArgs, | |
| 2498 | Stage1ZirInstIdCallExtra, | |
| 2499 | Stage1ZirInstIdAsyncCallExtra, | |
| 2500 | Stage1ZirInstIdConst, | |
| 2501 | Stage1ZirInstIdReturn, | |
| 2502 | Stage1ZirInstIdContainerInitList, | |
| 2503 | Stage1ZirInstIdContainerInitFields, | |
| 2504 | Stage1ZirInstIdUnreachable, | |
| 2505 | Stage1ZirInstIdTypeOf, | |
| 2506 | Stage1ZirInstIdSetCold, | |
| 2507 | Stage1ZirInstIdSetRuntimeSafety, | |
| 2508 | Stage1ZirInstIdSetFloatMode, | |
| 2509 | Stage1ZirInstIdArrayType, | |
| 2510 | Stage1ZirInstIdAnyFrameType, | |
| 2511 | Stage1ZirInstIdSliceType, | |
| 2512 | Stage1ZirInstIdAsm, | |
| 2513 | Stage1ZirInstIdSizeOf, | |
| 2514 | Stage1ZirInstIdTestNonNull, | |
| 2515 | Stage1ZirInstIdOptionalUnwrapPtr, | |
| 2516 | Stage1ZirInstIdClz, | |
| 2517 | Stage1ZirInstIdCtz, | |
| 2518 | Stage1ZirInstIdPopCount, | |
| 2519 | Stage1ZirInstIdBswap, | |
| 2520 | Stage1ZirInstIdBitReverse, | |
| 2521 | Stage1ZirInstIdImport, | |
| 2522 | Stage1ZirInstIdCImport, | |
| 2523 | Stage1ZirInstIdCInclude, | |
| 2524 | Stage1ZirInstIdCDefine, | |
| 2525 | Stage1ZirInstIdCUndef, | |
| 2526 | Stage1ZirInstIdRef, | |
| 2527 | Stage1ZirInstIdCompileErr, | |
| 2528 | Stage1ZirInstIdCompileLog, | |
| 2529 | Stage1ZirInstIdErrName, | |
| 2530 | Stage1ZirInstIdEmbedFile, | |
| 2531 | Stage1ZirInstIdCmpxchg, | |
| 2532 | Stage1ZirInstIdFence, | |
| 2533 | Stage1ZirInstIdReduce, | |
| 2534 | Stage1ZirInstIdTruncate, | |
| 2535 | Stage1ZirInstIdIntCast, | |
| 2536 | Stage1ZirInstIdFloatCast, | |
| 2537 | Stage1ZirInstIdIntToFloat, | |
| 2538 | Stage1ZirInstIdFloatToInt, | |
| 2539 | Stage1ZirInstIdBoolToInt, | |
| 2540 | Stage1ZirInstIdVectorType, | |
| 2541 | Stage1ZirInstIdShuffleVector, | |
| 2542 | Stage1ZirInstIdSplat, | |
| 2543 | Stage1ZirInstIdBoolNot, | |
| 2544 | Stage1ZirInstIdMemset, | |
| 2545 | Stage1ZirInstIdMemcpy, | |
| 2546 | Stage1ZirInstIdSlice, | |
| 2547 | Stage1ZirInstIdBreakpoint, | |
| 2548 | Stage1ZirInstIdReturnAddress, | |
| 2549 | Stage1ZirInstIdFrameAddress, | |
| 2550 | Stage1ZirInstIdFrameHandle, | |
| 2551 | Stage1ZirInstIdFrameType, | |
| 2552 | Stage1ZirInstIdFrameSize, | |
| 2553 | Stage1ZirInstIdAlignOf, | |
| 2554 | Stage1ZirInstIdOverflowOp, | |
| 2555 | Stage1ZirInstIdTestErr, | |
| 2556 | Stage1ZirInstIdMulAdd, | |
| 2557 | Stage1ZirInstIdFloatOp, | |
| 2558 | Stage1ZirInstIdUnwrapErrCode, | |
| 2559 | Stage1ZirInstIdUnwrapErrPayload, | |
| 2560 | Stage1ZirInstIdFnProto, | |
| 2561 | Stage1ZirInstIdTestComptime, | |
| 2562 | Stage1ZirInstIdPtrCast, | |
| 2563 | Stage1ZirInstIdBitCast, | |
| 2564 | Stage1ZirInstIdIntToPtr, | |
| 2565 | Stage1ZirInstIdPtrToInt, | |
| 2566 | Stage1ZirInstIdIntToEnum, | |
| 2567 | Stage1ZirInstIdEnumToInt, | |
| 2568 | Stage1ZirInstIdIntToErr, | |
| 2569 | Stage1ZirInstIdErrToInt, | |
| 2570 | Stage1ZirInstIdCheckSwitchProngsUnderYes, | |
| 2571 | Stage1ZirInstIdCheckSwitchProngsUnderNo, | |
| 2572 | Stage1ZirInstIdCheckStatementIsVoid, | |
| 2573 | Stage1ZirInstIdTypeName, | |
| 2574 | Stage1ZirInstIdDeclRef, | |
| 2575 | Stage1ZirInstIdPanic, | |
| 2576 | Stage1ZirInstIdTagName, | |
| 2577 | Stage1ZirInstIdFieldParentPtr, | |
| 2578 | Stage1ZirInstIdOffsetOf, | |
| 2579 | Stage1ZirInstIdBitOffsetOf, | |
| 2580 | Stage1ZirInstIdTypeInfo, | |
| 2581 | Stage1ZirInstIdType, | |
| 2582 | Stage1ZirInstIdHasField, | |
| 2583 | Stage1ZirInstIdSetEvalBranchQuota, | |
| 2584 | Stage1ZirInstIdPtrType, | |
| 2585 | Stage1ZirInstIdPtrTypeSimple, | |
| 2586 | Stage1ZirInstIdPtrTypeSimpleConst, | |
| 2587 | Stage1ZirInstIdAlignCast, | |
| 2588 | Stage1ZirInstIdImplicitCast, | |
| 2589 | Stage1ZirInstIdResolveResult, | |
| 2590 | Stage1ZirInstIdResetResult, | |
| 2591 | Stage1ZirInstIdSetAlignStack, | |
| 2592 | Stage1ZirInstIdArgTypeAllowVarFalse, | |
| 2593 | Stage1ZirInstIdArgTypeAllowVarTrue, | |
| 2594 | Stage1ZirInstIdExport, | |
| 2595 | Stage1ZirInstIdExtern, | |
| 2596 | Stage1ZirInstIdErrorReturnTrace, | |
| 2597 | Stage1ZirInstIdErrorUnion, | |
| 2598 | Stage1ZirInstIdAtomicRmw, | |
| 2599 | Stage1ZirInstIdAtomicLoad, | |
| 2600 | Stage1ZirInstIdAtomicStore, | |
| 2601 | Stage1ZirInstIdSaveErrRetAddr, | |
| 2602 | Stage1ZirInstIdAddImplicitReturnType, | |
| 2603 | Stage1ZirInstIdErrSetCast, | |
| 2604 | Stage1ZirInstIdCheckRuntimeScope, | |
| 2605 | Stage1ZirInstIdHasDecl, | |
| 2606 | Stage1ZirInstIdUndeclaredIdent, | |
| 2607 | Stage1ZirInstIdAlloca, | |
| 2608 | Stage1ZirInstIdEndExpr, | |
| 2609 | Stage1ZirInstIdUnionInitNamedField, | |
| 2610 | Stage1ZirInstIdSuspendBegin, | |
| 2611 | Stage1ZirInstIdSuspendFinish, | |
| 2612 | Stage1ZirInstIdAwait, | |
| 2613 | Stage1ZirInstIdResume, | |
| 2614 | Stage1ZirInstIdSpillBegin, | |
| 2615 | Stage1ZirInstIdSpillEnd, | |
| 2616 | Stage1ZirInstIdWasmMemorySize, | |
| 2617 | Stage1ZirInstIdWasmMemoryGrow, | |
| 2618 | Stage1ZirInstIdSrc, | |
| 2619 | 2619 | }; |
| 2620 | 2620 | |
| 2621 | 2621 | // ir_render_* functions in codegen.cpp consume Gen instructions and produce LLVM IR. |
| 2622 | 2622 | // Src instructions do not have type information; Gen instructions do. |
| 2623 | enum IrInstGenId : uint8_t { | |
| 2624 | IrInstGenIdInvalid, | |
| 2625 | IrInstGenIdDeclVar, | |
| 2626 | IrInstGenIdBr, | |
| 2627 | IrInstGenIdCondBr, | |
| 2628 | IrInstGenIdSwitchBr, | |
| 2629 | IrInstGenIdPhi, | |
| 2630 | IrInstGenIdBinaryNot, | |
| 2631 | IrInstGenIdNegation, | |
| 2632 | IrInstGenIdBinOp, | |
| 2633 | IrInstGenIdLoadPtr, | |
| 2634 | IrInstGenIdStorePtr, | |
| 2635 | IrInstGenIdVectorStoreElem, | |
| 2636 | IrInstGenIdStructFieldPtr, | |
| 2637 | IrInstGenIdUnionFieldPtr, | |
| 2638 | IrInstGenIdElemPtr, | |
| 2639 | IrInstGenIdVarPtr, | |
| 2640 | IrInstGenIdReturnPtr, | |
| 2641 | IrInstGenIdCall, | |
| 2642 | IrInstGenIdReturn, | |
| 2643 | IrInstGenIdCast, | |
| 2644 | IrInstGenIdUnreachable, | |
| 2645 | IrInstGenIdAsm, | |
| 2646 | IrInstGenIdTestNonNull, | |
| 2647 | IrInstGenIdOptionalUnwrapPtr, | |
| 2648 | IrInstGenIdOptionalWrap, | |
| 2649 | IrInstGenIdUnionTag, | |
| 2650 | IrInstGenIdClz, | |
| 2651 | IrInstGenIdCtz, | |
| 2652 | IrInstGenIdPopCount, | |
| 2653 | IrInstGenIdBswap, | |
| 2654 | IrInstGenIdBitReverse, | |
| 2655 | IrInstGenIdRef, | |
| 2656 | IrInstGenIdErrName, | |
| 2657 | IrInstGenIdCmpxchg, | |
| 2658 | IrInstGenIdFence, | |
| 2659 | IrInstGenIdReduce, | |
| 2660 | IrInstGenIdTruncate, | |
| 2661 | IrInstGenIdShuffleVector, | |
| 2662 | IrInstGenIdSplat, | |
| 2663 | IrInstGenIdBoolNot, | |
| 2664 | IrInstGenIdMemset, | |
| 2665 | IrInstGenIdMemcpy, | |
| 2666 | IrInstGenIdSlice, | |
| 2667 | IrInstGenIdBreakpoint, | |
| 2668 | IrInstGenIdReturnAddress, | |
| 2669 | IrInstGenIdFrameAddress, | |
| 2670 | IrInstGenIdFrameHandle, | |
| 2671 | IrInstGenIdFrameSize, | |
| 2672 | IrInstGenIdOverflowOp, | |
| 2673 | IrInstGenIdTestErr, | |
| 2674 | IrInstGenIdMulAdd, | |
| 2675 | IrInstGenIdFloatOp, | |
| 2676 | IrInstGenIdUnwrapErrCode, | |
| 2677 | IrInstGenIdUnwrapErrPayload, | |
| 2678 | IrInstGenIdErrWrapCode, | |
| 2679 | IrInstGenIdErrWrapPayload, | |
| 2680 | IrInstGenIdPtrCast, | |
| 2681 | IrInstGenIdBitCast, | |
| 2682 | IrInstGenIdWidenOrShorten, | |
| 2683 | IrInstGenIdIntToPtr, | |
| 2684 | IrInstGenIdPtrToInt, | |
| 2685 | IrInstGenIdIntToEnum, | |
| 2686 | IrInstGenIdIntToErr, | |
| 2687 | IrInstGenIdErrToInt, | |
| 2688 | IrInstGenIdPanic, | |
| 2689 | IrInstGenIdTagName, | |
| 2690 | IrInstGenIdFieldParentPtr, | |
| 2691 | IrInstGenIdAlignCast, | |
| 2692 | IrInstGenIdErrorReturnTrace, | |
| 2693 | IrInstGenIdAtomicRmw, | |
| 2694 | IrInstGenIdAtomicLoad, | |
| 2695 | IrInstGenIdAtomicStore, | |
| 2696 | IrInstGenIdSaveErrRetAddr, | |
| 2697 | IrInstGenIdVectorToArray, | |
| 2698 | IrInstGenIdArrayToVector, | |
| 2699 | IrInstGenIdAssertZero, | |
| 2700 | IrInstGenIdAssertNonNull, | |
| 2701 | IrInstGenIdPtrOfArrayToSlice, | |
| 2702 | IrInstGenIdSuspendBegin, | |
| 2703 | IrInstGenIdSuspendFinish, | |
| 2704 | IrInstGenIdAwait, | |
| 2705 | IrInstGenIdResume, | |
| 2706 | IrInstGenIdSpillBegin, | |
| 2707 | IrInstGenIdSpillEnd, | |
| 2708 | IrInstGenIdVectorExtractElem, | |
| 2709 | IrInstGenIdAlloca, | |
| 2710 | IrInstGenIdConst, | |
| 2711 | IrInstGenIdWasmMemorySize, | |
| 2712 | IrInstGenIdWasmMemoryGrow, | |
| 2713 | IrInstGenIdExtern, | |
| 2714 | }; | |
| 2715 | ||
| 2716 | struct IrInstSrc { | |
| 2717 | IrInstSrcId id; | |
| 2623 | enum Stage1AirInstId : uint8_t { | |
| 2624 | Stage1AirInstIdInvalid, | |
| 2625 | Stage1AirInstIdDeclVar, | |
| 2626 | Stage1AirInstIdBr, | |
| 2627 | Stage1AirInstIdCondBr, | |
| 2628 | Stage1AirInstIdSwitchBr, | |
| 2629 | Stage1AirInstIdPhi, | |
| 2630 | Stage1AirInstIdBinaryNot, | |
| 2631 | Stage1AirInstIdNegation, | |
| 2632 | Stage1AirInstIdBinOp, | |
| 2633 | Stage1AirInstIdLoadPtr, | |
| 2634 | Stage1AirInstIdStorePtr, | |
| 2635 | Stage1AirInstIdVectorStoreElem, | |
| 2636 | Stage1AirInstIdStructFieldPtr, | |
| 2637 | Stage1AirInstIdUnionFieldPtr, | |
| 2638 | Stage1AirInstIdElemPtr, | |
| 2639 | Stage1AirInstIdVarPtr, | |
| 2640 | Stage1AirInstIdReturnPtr, | |
| 2641 | Stage1AirInstIdCall, | |
| 2642 | Stage1AirInstIdReturn, | |
| 2643 | Stage1AirInstIdCast, | |
| 2644 | Stage1AirInstIdUnreachable, | |
| 2645 | Stage1AirInstIdAsm, | |
| 2646 | Stage1AirInstIdTestNonNull, | |
| 2647 | Stage1AirInstIdOptionalUnwrapPtr, | |
| 2648 | Stage1AirInstIdOptionalWrap, | |
| 2649 | Stage1AirInstIdUnionTag, | |
| 2650 | Stage1AirInstIdClz, | |
| 2651 | Stage1AirInstIdCtz, | |
| 2652 | Stage1AirInstIdPopCount, | |
| 2653 | Stage1AirInstIdBswap, | |
| 2654 | Stage1AirInstIdBitReverse, | |
| 2655 | Stage1AirInstIdRef, | |
| 2656 | Stage1AirInstIdErrName, | |
| 2657 | Stage1AirInstIdCmpxchg, | |
| 2658 | Stage1AirInstIdFence, | |
| 2659 | Stage1AirInstIdReduce, | |
| 2660 | Stage1AirInstIdTruncate, | |
| 2661 | Stage1AirInstIdShuffleVector, | |
| 2662 | Stage1AirInstIdSplat, | |
| 2663 | Stage1AirInstIdBoolNot, | |
| 2664 | Stage1AirInstIdMemset, | |
| 2665 | Stage1AirInstIdMemcpy, | |
| 2666 | Stage1AirInstIdSlice, | |
| 2667 | Stage1AirInstIdBreakpoint, | |
| 2668 | Stage1AirInstIdReturnAddress, | |
| 2669 | Stage1AirInstIdFrameAddress, | |
| 2670 | Stage1AirInstIdFrameHandle, | |
| 2671 | Stage1AirInstIdFrameSize, | |
| 2672 | Stage1AirInstIdOverflowOp, | |
| 2673 | Stage1AirInstIdTestErr, | |
| 2674 | Stage1AirInstIdMulAdd, | |
| 2675 | Stage1AirInstIdFloatOp, | |
| 2676 | Stage1AirInstIdUnwrapErrCode, | |
| 2677 | Stage1AirInstIdUnwrapErrPayload, | |
| 2678 | Stage1AirInstIdErrWrapCode, | |
| 2679 | Stage1AirInstIdErrWrapPayload, | |
| 2680 | Stage1AirInstIdPtrCast, | |
| 2681 | Stage1AirInstIdBitCast, | |
| 2682 | Stage1AirInstIdWidenOrShorten, | |
| 2683 | Stage1AirInstIdIntToPtr, | |
| 2684 | Stage1AirInstIdPtrToInt, | |
| 2685 | Stage1AirInstIdIntToEnum, | |
| 2686 | Stage1AirInstIdIntToErr, | |
| 2687 | Stage1AirInstIdErrToInt, | |
| 2688 | Stage1AirInstIdPanic, | |
| 2689 | Stage1AirInstIdTagName, | |
| 2690 | Stage1AirInstIdFieldParentPtr, | |
| 2691 | Stage1AirInstIdAlignCast, | |
| 2692 | Stage1AirInstIdErrorReturnTrace, | |
| 2693 | Stage1AirInstIdAtomicRmw, | |
| 2694 | Stage1AirInstIdAtomicLoad, | |
| 2695 | Stage1AirInstIdAtomicStore, | |
| 2696 | Stage1AirInstIdSaveErrRetAddr, | |
| 2697 | Stage1AirInstIdVectorToArray, | |
| 2698 | Stage1AirInstIdArrayToVector, | |
| 2699 | Stage1AirInstIdAssertZero, | |
| 2700 | Stage1AirInstIdAssertNonNull, | |
| 2701 | Stage1AirInstIdPtrOfArrayToSlice, | |
| 2702 | Stage1AirInstIdSuspendBegin, | |
| 2703 | Stage1AirInstIdSuspendFinish, | |
| 2704 | Stage1AirInstIdAwait, | |
| 2705 | Stage1AirInstIdResume, | |
| 2706 | Stage1AirInstIdSpillBegin, | |
| 2707 | Stage1AirInstIdSpillEnd, | |
| 2708 | Stage1AirInstIdVectorExtractElem, | |
| 2709 | Stage1AirInstIdAlloca, | |
| 2710 | Stage1AirInstIdConst, | |
| 2711 | Stage1AirInstIdWasmMemorySize, | |
| 2712 | Stage1AirInstIdWasmMemoryGrow, | |
| 2713 | Stage1AirInstIdExtern, | |
| 2714 | }; | |
| 2715 | ||
| 2716 | struct Stage1ZirInst { | |
| 2717 | Stage1ZirInstId id; | |
| 2718 | 2718 | uint16_t ref_count; |
| 2719 | 2719 | uint32_t debug_id; |
| 2720 | 2720 | |
| ... | ... | @@ -2724,7 +2724,7 @@ struct IrInstSrc { |
| 2724 | 2724 | // When analyzing IR, instructions that point to this instruction in the "old ir" |
| 2725 | 2725 | // can find the instruction that corresponds to this value in the "new ir" |
| 2726 | 2726 | // with this child field. |
| 2727 | IrInstGen *child; | |
| 2727 | Stage1AirInst *child; | |
| 2728 | 2728 | Stage1ZirBasicBlock *owner_bb; |
| 2729 | 2729 | |
| 2730 | 2730 | // for debugging purposes, these are useful to call to inspect the instruction |
| ... | ... | @@ -2732,8 +2732,8 @@ struct IrInstSrc { |
| 2732 | 2732 | void src(); |
| 2733 | 2733 | }; |
| 2734 | 2734 | |
| 2735 | struct IrInstGen { | |
| 2736 | IrInstGenId id; | |
| 2735 | struct Stage1AirInst { | |
| 2736 | Stage1AirInstId id; | |
| 2737 | 2737 | // if ref_count is zero and the instruction has no side effects, |
| 2738 | 2738 | // the instruction can be omitted in codegen |
| 2739 | 2739 | uint16_t ref_count; |
| ... | ... | @@ -2744,130 +2744,130 @@ struct IrInstGen { |
| 2744 | 2744 | |
| 2745 | 2745 | LLVMValueRef llvm_value; |
| 2746 | 2746 | ZigValue *value; |
| 2747 | IrBasicBlockGen *owner_bb; | |
| 2747 | Stage1AirBasicBlock *owner_bb; | |
| 2748 | 2748 | // Nearly any instruction can have to be stored as a local variable before suspending |
| 2749 | 2749 | // and then loaded after resuming, in case there is an expression with a suspend point |
| 2750 | 2750 | // in it, such as: x + await y |
| 2751 | IrInstGen *spill; | |
| 2751 | Stage1AirInst *spill; | |
| 2752 | 2752 | |
| 2753 | 2753 | // for debugging purposes, these are useful to call to inspect the instruction |
| 2754 | 2754 | void dump(); |
| 2755 | 2755 | void src(); |
| 2756 | 2756 | }; |
| 2757 | 2757 | |
| 2758 | struct IrInstSrcDeclVar { | |
| 2759 | IrInstSrc base; | |
| 2758 | struct Stage1ZirInstDeclVar { | |
| 2759 | Stage1ZirInst base; | |
| 2760 | 2760 | |
| 2761 | 2761 | ZigVar *var; |
| 2762 | IrInstSrc *var_type; | |
| 2763 | IrInstSrc *align_value; | |
| 2764 | IrInstSrc *ptr; | |
| 2762 | Stage1ZirInst *var_type; | |
| 2763 | Stage1ZirInst *align_value; | |
| 2764 | Stage1ZirInst *ptr; | |
| 2765 | 2765 | }; |
| 2766 | 2766 | |
| 2767 | struct IrInstGenDeclVar { | |
| 2768 | IrInstGen base; | |
| 2767 | struct Stage1AirInstDeclVar { | |
| 2768 | Stage1AirInst base; | |
| 2769 | 2769 | |
| 2770 | 2770 | ZigVar *var; |
| 2771 | IrInstGen *var_ptr; | |
| 2771 | Stage1AirInst *var_ptr; | |
| 2772 | 2772 | }; |
| 2773 | 2773 | |
| 2774 | struct IrInstSrcCondBr { | |
| 2775 | IrInstSrc base; | |
| 2774 | struct Stage1ZirInstCondBr { | |
| 2775 | Stage1ZirInst base; | |
| 2776 | 2776 | |
| 2777 | IrInstSrc *condition; | |
| 2777 | Stage1ZirInst *condition; | |
| 2778 | 2778 | Stage1ZirBasicBlock *then_block; |
| 2779 | 2779 | Stage1ZirBasicBlock *else_block; |
| 2780 | IrInstSrc *is_comptime; | |
| 2780 | Stage1ZirInst *is_comptime; | |
| 2781 | 2781 | ResultLoc *result_loc; |
| 2782 | 2782 | }; |
| 2783 | 2783 | |
| 2784 | struct IrInstGenCondBr { | |
| 2785 | IrInstGen base; | |
| 2784 | struct Stage1AirInstCondBr { | |
| 2785 | Stage1AirInst base; | |
| 2786 | 2786 | |
| 2787 | IrInstGen *condition; | |
| 2788 | IrBasicBlockGen *then_block; | |
| 2789 | IrBasicBlockGen *else_block; | |
| 2787 | Stage1AirInst *condition; | |
| 2788 | Stage1AirBasicBlock *then_block; | |
| 2789 | Stage1AirBasicBlock *else_block; | |
| 2790 | 2790 | }; |
| 2791 | 2791 | |
| 2792 | struct IrInstSrcBr { | |
| 2793 | IrInstSrc base; | |
| 2792 | struct Stage1ZirInstBr { | |
| 2793 | Stage1ZirInst base; | |
| 2794 | 2794 | |
| 2795 | 2795 | Stage1ZirBasicBlock *dest_block; |
| 2796 | IrInstSrc *is_comptime; | |
| 2796 | Stage1ZirInst *is_comptime; | |
| 2797 | 2797 | }; |
| 2798 | 2798 | |
| 2799 | struct IrInstGenBr { | |
| 2800 | IrInstGen base; | |
| 2799 | struct Stage1AirInstBr { | |
| 2800 | Stage1AirInst base; | |
| 2801 | 2801 | |
| 2802 | IrBasicBlockGen *dest_block; | |
| 2802 | Stage1AirBasicBlock *dest_block; | |
| 2803 | 2803 | }; |
| 2804 | 2804 | |
| 2805 | struct IrInstSrcSwitchBrCase { | |
| 2806 | IrInstSrc *value; | |
| 2805 | struct Stage1ZirInstSwitchBrCase { | |
| 2806 | Stage1ZirInst *value; | |
| 2807 | 2807 | Stage1ZirBasicBlock *block; |
| 2808 | 2808 | }; |
| 2809 | 2809 | |
| 2810 | struct IrInstSrcSwitchBr { | |
| 2811 | IrInstSrc base; | |
| 2810 | struct Stage1ZirInstSwitchBr { | |
| 2811 | Stage1ZirInst base; | |
| 2812 | 2812 | |
| 2813 | IrInstSrc *target_value; | |
| 2813 | Stage1ZirInst *target_value; | |
| 2814 | 2814 | Stage1ZirBasicBlock *else_block; |
| 2815 | 2815 | size_t case_count; |
| 2816 | IrInstSrcSwitchBrCase *cases; | |
| 2817 | IrInstSrc *is_comptime; | |
| 2818 | IrInstSrc *switch_prongs_void; | |
| 2816 | Stage1ZirInstSwitchBrCase *cases; | |
| 2817 | Stage1ZirInst *is_comptime; | |
| 2818 | Stage1ZirInst *switch_prongs_void; | |
| 2819 | 2819 | }; |
| 2820 | 2820 | |
| 2821 | struct IrInstGenSwitchBrCase { | |
| 2822 | IrInstGen *value; | |
| 2823 | IrBasicBlockGen *block; | |
| 2821 | struct Stage1AirInstSwitchBrCase { | |
| 2822 | Stage1AirInst *value; | |
| 2823 | Stage1AirBasicBlock *block; | |
| 2824 | 2824 | }; |
| 2825 | 2825 | |
| 2826 | struct IrInstGenSwitchBr { | |
| 2827 | IrInstGen base; | |
| 2826 | struct Stage1AirInstSwitchBr { | |
| 2827 | Stage1AirInst base; | |
| 2828 | 2828 | |
| 2829 | IrInstGen *target_value; | |
| 2830 | IrBasicBlockGen *else_block; | |
| 2829 | Stage1AirInst *target_value; | |
| 2830 | Stage1AirBasicBlock *else_block; | |
| 2831 | 2831 | size_t case_count; |
| 2832 | IrInstGenSwitchBrCase *cases; | |
| 2832 | Stage1AirInstSwitchBrCase *cases; | |
| 2833 | 2833 | }; |
| 2834 | 2834 | |
| 2835 | struct IrInstSrcSwitchVar { | |
| 2836 | IrInstSrc base; | |
| 2835 | struct Stage1ZirInstSwitchVar { | |
| 2836 | Stage1ZirInst base; | |
| 2837 | 2837 | |
| 2838 | IrInstSrc *target_value_ptr; | |
| 2839 | IrInstSrc **prongs_ptr; | |
| 2838 | Stage1ZirInst *target_value_ptr; | |
| 2839 | Stage1ZirInst **prongs_ptr; | |
| 2840 | 2840 | size_t prongs_len; |
| 2841 | 2841 | }; |
| 2842 | 2842 | |
| 2843 | struct IrInstSrcSwitchElseVar { | |
| 2844 | IrInstSrc base; | |
| 2843 | struct Stage1ZirInstSwitchElseVar { | |
| 2844 | Stage1ZirInst base; | |
| 2845 | 2845 | |
| 2846 | IrInstSrc *target_value_ptr; | |
| 2847 | IrInstSrcSwitchBr *switch_br; | |
| 2846 | Stage1ZirInst *target_value_ptr; | |
| 2847 | Stage1ZirInstSwitchBr *switch_br; | |
| 2848 | 2848 | }; |
| 2849 | 2849 | |
| 2850 | struct IrInstSrcSwitchTarget { | |
| 2851 | IrInstSrc base; | |
| 2850 | struct Stage1ZirInstSwitchTarget { | |
| 2851 | Stage1ZirInst base; | |
| 2852 | 2852 | |
| 2853 | IrInstSrc *target_value_ptr; | |
| 2853 | Stage1ZirInst *target_value_ptr; | |
| 2854 | 2854 | }; |
| 2855 | 2855 | |
| 2856 | struct IrInstSrcPhi { | |
| 2857 | IrInstSrc base; | |
| 2856 | struct Stage1ZirInstPhi { | |
| 2857 | Stage1ZirInst base; | |
| 2858 | 2858 | |
| 2859 | 2859 | size_t incoming_count; |
| 2860 | 2860 | Stage1ZirBasicBlock **incoming_blocks; |
| 2861 | IrInstSrc **incoming_values; | |
| 2861 | Stage1ZirInst **incoming_values; | |
| 2862 | 2862 | ResultLocPeerParent *peer_parent; |
| 2863 | 2863 | }; |
| 2864 | 2864 | |
| 2865 | struct IrInstGenPhi { | |
| 2866 | IrInstGen base; | |
| 2865 | struct Stage1AirInstPhi { | |
| 2866 | Stage1AirInst base; | |
| 2867 | 2867 | |
| 2868 | 2868 | size_t incoming_count; |
| 2869 | IrBasicBlockGen **incoming_blocks; | |
| 2870 | IrInstGen **incoming_values; | |
| 2869 | Stage1AirBasicBlock **incoming_blocks; | |
| 2870 | Stage1AirInst **incoming_values; | |
| 2871 | 2871 | }; |
| 2872 | 2872 | |
| 2873 | 2873 | enum IrUnOp { |
| ... | ... | @@ -2879,23 +2879,23 @@ enum IrUnOp { |
| 2879 | 2879 | IrUnOpOptional, |
| 2880 | 2880 | }; |
| 2881 | 2881 | |
| 2882 | struct IrInstSrcUnOp { | |
| 2883 | IrInstSrc base; | |
| 2882 | struct Stage1ZirInstUnOp { | |
| 2883 | Stage1ZirInst base; | |
| 2884 | 2884 | |
| 2885 | 2885 | IrUnOp op_id; |
| 2886 | 2886 | LVal lval; |
| 2887 | IrInstSrc *value; | |
| 2887 | Stage1ZirInst *value; | |
| 2888 | 2888 | ResultLoc *result_loc; |
| 2889 | 2889 | }; |
| 2890 | 2890 | |
| 2891 | struct IrInstGenBinaryNot { | |
| 2892 | IrInstGen base; | |
| 2893 | IrInstGen *operand; | |
| 2891 | struct Stage1AirInstBinaryNot { | |
| 2892 | Stage1AirInst base; | |
| 2893 | Stage1AirInst *operand; | |
| 2894 | 2894 | }; |
| 2895 | 2895 | |
| 2896 | struct IrInstGenNegation { | |
| 2897 | IrInstGen base; | |
| 2898 | IrInstGen *operand; | |
| 2896 | struct Stage1AirInstNegation { | |
| 2897 | Stage1AirInst base; | |
| 2898 | Stage1AirInst *operand; | |
| 2899 | 2899 | bool wrapping; |
| 2900 | 2900 | }; |
| 2901 | 2901 | |
| ... | ... | @@ -2933,122 +2933,122 @@ enum IrBinOp { |
| 2933 | 2933 | IrBinOpArrayMult, |
| 2934 | 2934 | }; |
| 2935 | 2935 | |
| 2936 | struct IrInstSrcBinOp { | |
| 2937 | IrInstSrc base; | |
| 2936 | struct Stage1ZirInstBinOp { | |
| 2937 | Stage1ZirInst base; | |
| 2938 | 2938 | |
| 2939 | IrInstSrc *op1; | |
| 2940 | IrInstSrc *op2; | |
| 2939 | Stage1ZirInst *op1; | |
| 2940 | Stage1ZirInst *op2; | |
| 2941 | 2941 | IrBinOp op_id; |
| 2942 | 2942 | bool safety_check_on; |
| 2943 | 2943 | }; |
| 2944 | 2944 | |
| 2945 | struct IrInstGenBinOp { | |
| 2946 | IrInstGen base; | |
| 2945 | struct Stage1AirInstBinOp { | |
| 2946 | Stage1AirInst base; | |
| 2947 | 2947 | |
| 2948 | IrInstGen *op1; | |
| 2949 | IrInstGen *op2; | |
| 2948 | Stage1AirInst *op1; | |
| 2949 | Stage1AirInst *op2; | |
| 2950 | 2950 | IrBinOp op_id; |
| 2951 | 2951 | bool safety_check_on; |
| 2952 | 2952 | }; |
| 2953 | 2953 | |
| 2954 | struct IrInstSrcMergeErrSets { | |
| 2955 | IrInstSrc base; | |
| 2954 | struct Stage1ZirInstMergeErrSets { | |
| 2955 | Stage1ZirInst base; | |
| 2956 | 2956 | |
| 2957 | IrInstSrc *op1; | |
| 2958 | IrInstSrc *op2; | |
| 2957 | Stage1ZirInst *op1; | |
| 2958 | Stage1ZirInst *op2; | |
| 2959 | 2959 | Buf *type_name; |
| 2960 | 2960 | }; |
| 2961 | 2961 | |
| 2962 | struct IrInstSrcLoadPtr { | |
| 2963 | IrInstSrc base; | |
| 2962 | struct Stage1ZirInstLoadPtr { | |
| 2963 | Stage1ZirInst base; | |
| 2964 | 2964 | |
| 2965 | IrInstSrc *ptr; | |
| 2965 | Stage1ZirInst *ptr; | |
| 2966 | 2966 | }; |
| 2967 | 2967 | |
| 2968 | struct IrInstGenLoadPtr { | |
| 2969 | IrInstGen base; | |
| 2968 | struct Stage1AirInstLoadPtr { | |
| 2969 | Stage1AirInst base; | |
| 2970 | 2970 | |
| 2971 | IrInstGen *ptr; | |
| 2972 | IrInstGen *result_loc; | |
| 2971 | Stage1AirInst *ptr; | |
| 2972 | Stage1AirInst *result_loc; | |
| 2973 | 2973 | }; |
| 2974 | 2974 | |
| 2975 | struct IrInstSrcStorePtr { | |
| 2976 | IrInstSrc base; | |
| 2975 | struct Stage1ZirInstStorePtr { | |
| 2976 | Stage1ZirInst base; | |
| 2977 | 2977 | |
| 2978 | IrInstSrc *ptr; | |
| 2979 | IrInstSrc *value; | |
| 2978 | Stage1ZirInst *ptr; | |
| 2979 | Stage1ZirInst *value; | |
| 2980 | 2980 | |
| 2981 | 2981 | bool allow_write_through_const; |
| 2982 | 2982 | }; |
| 2983 | 2983 | |
| 2984 | struct IrInstGenStorePtr { | |
| 2985 | IrInstGen base; | |
| 2984 | struct Stage1AirInstStorePtr { | |
| 2985 | Stage1AirInst base; | |
| 2986 | 2986 | |
| 2987 | IrInstGen *ptr; | |
| 2988 | IrInstGen *value; | |
| 2987 | Stage1AirInst *ptr; | |
| 2988 | Stage1AirInst *value; | |
| 2989 | 2989 | }; |
| 2990 | 2990 | |
| 2991 | struct IrInstGenVectorStoreElem { | |
| 2992 | IrInstGen base; | |
| 2991 | struct Stage1AirInstVectorStoreElem { | |
| 2992 | Stage1AirInst base; | |
| 2993 | 2993 | |
| 2994 | IrInstGen *vector_ptr; | |
| 2995 | IrInstGen *index; | |
| 2996 | IrInstGen *value; | |
| 2994 | Stage1AirInst *vector_ptr; | |
| 2995 | Stage1AirInst *index; | |
| 2996 | Stage1AirInst *value; | |
| 2997 | 2997 | }; |
| 2998 | 2998 | |
| 2999 | struct IrInstSrcFieldPtr { | |
| 3000 | IrInstSrc base; | |
| 2999 | struct Stage1ZirInstFieldPtr { | |
| 3000 | Stage1ZirInst base; | |
| 3001 | 3001 | |
| 3002 | IrInstSrc *container_ptr; | |
| 3002 | Stage1ZirInst *container_ptr; | |
| 3003 | 3003 | Buf *field_name_buffer; |
| 3004 | IrInstSrc *field_name_expr; | |
| 3004 | Stage1ZirInst *field_name_expr; | |
| 3005 | 3005 | bool initializing; |
| 3006 | 3006 | }; |
| 3007 | 3007 | |
| 3008 | struct IrInstGenStructFieldPtr { | |
| 3009 | IrInstGen base; | |
| 3008 | struct Stage1AirInstStructFieldPtr { | |
| 3009 | Stage1AirInst base; | |
| 3010 | 3010 | |
| 3011 | IrInstGen *struct_ptr; | |
| 3011 | Stage1AirInst *struct_ptr; | |
| 3012 | 3012 | TypeStructField *field; |
| 3013 | 3013 | bool is_const; |
| 3014 | 3014 | }; |
| 3015 | 3015 | |
| 3016 | struct IrInstGenUnionFieldPtr { | |
| 3017 | IrInstGen base; | |
| 3016 | struct Stage1AirInstUnionFieldPtr { | |
| 3017 | Stage1AirInst base; | |
| 3018 | 3018 | |
| 3019 | IrInstGen *union_ptr; | |
| 3019 | Stage1AirInst *union_ptr; | |
| 3020 | 3020 | TypeUnionField *field; |
| 3021 | 3021 | bool safety_check_on; |
| 3022 | 3022 | bool initializing; |
| 3023 | 3023 | }; |
| 3024 | 3024 | |
| 3025 | struct IrInstSrcElemPtr { | |
| 3026 | IrInstSrc base; | |
| 3025 | struct Stage1ZirInstElemPtr { | |
| 3026 | Stage1ZirInst base; | |
| 3027 | 3027 | |
| 3028 | IrInstSrc *array_ptr; | |
| 3029 | IrInstSrc *elem_index; | |
| 3028 | Stage1ZirInst *array_ptr; | |
| 3029 | Stage1ZirInst *elem_index; | |
| 3030 | 3030 | AstNode *init_array_type_source_node; |
| 3031 | 3031 | PtrLen ptr_len; |
| 3032 | 3032 | bool safety_check_on; |
| 3033 | 3033 | }; |
| 3034 | 3034 | |
| 3035 | struct IrInstGenElemPtr { | |
| 3036 | IrInstGen base; | |
| 3035 | struct Stage1AirInstElemPtr { | |
| 3036 | Stage1AirInst base; | |
| 3037 | 3037 | |
| 3038 | IrInstGen *array_ptr; | |
| 3039 | IrInstGen *elem_index; | |
| 3038 | Stage1AirInst *array_ptr; | |
| 3039 | Stage1AirInst *elem_index; | |
| 3040 | 3040 | bool safety_check_on; |
| 3041 | 3041 | }; |
| 3042 | 3042 | |
| 3043 | struct IrInstSrcVarPtr { | |
| 3044 | IrInstSrc base; | |
| 3043 | struct Stage1ZirInstVarPtr { | |
| 3044 | Stage1ZirInst base; | |
| 3045 | 3045 | |
| 3046 | 3046 | ZigVar *var; |
| 3047 | 3047 | ScopeFnDef *crossed_fndef_scope; |
| 3048 | 3048 | }; |
| 3049 | 3049 | |
| 3050 | struct IrInstGenVarPtr { | |
| 3051 | IrInstGen base; | |
| 3050 | struct Stage1AirInstVarPtr { | |
| 3051 | Stage1AirInst base; | |
| 3052 | 3052 | |
| 3053 | 3053 | ZigVar *var; |
| 3054 | 3054 | }; |
| ... | ... | @@ -3056,21 +3056,21 @@ struct IrInstGenVarPtr { |
| 3056 | 3056 | // For functions that have a return type for which handle_is_ptr is true, a |
| 3057 | 3057 | // result location pointer is the secret first parameter ("sret"). This |
| 3058 | 3058 | // instruction returns that pointer. |
| 3059 | struct IrInstGenReturnPtr { | |
| 3060 | IrInstGen base; | |
| 3059 | struct Stage1AirInstReturnPtr { | |
| 3060 | Stage1AirInst base; | |
| 3061 | 3061 | }; |
| 3062 | 3062 | |
| 3063 | struct IrInstSrcCall { | |
| 3064 | IrInstSrc base; | |
| 3063 | struct Stage1ZirInstCall { | |
| 3064 | Stage1ZirInst base; | |
| 3065 | 3065 | |
| 3066 | IrInstSrc *fn_ref; | |
| 3066 | Stage1ZirInst *fn_ref; | |
| 3067 | 3067 | ZigFn *fn_entry; |
| 3068 | 3068 | size_t arg_count; |
| 3069 | IrInstSrc **args; | |
| 3070 | IrInstSrc *ret_ptr; | |
| 3069 | Stage1ZirInst **args; | |
| 3070 | Stage1ZirInst *ret_ptr; | |
| 3071 | 3071 | ResultLoc *result_loc; |
| 3072 | 3072 | |
| 3073 | IrInstSrc *new_stack; | |
| 3073 | Stage1ZirInst *new_stack; | |
| 3074 | 3074 | |
| 3075 | 3075 | CallModifier modifier; |
| 3076 | 3076 | bool is_async_call_builtin; |
| ... | ... | @@ -3078,12 +3078,12 @@ struct IrInstSrcCall { |
| 3078 | 3078 | |
| 3079 | 3079 | // This is a pass1 instruction, used by @call when the args node is |
| 3080 | 3080 | // a tuple or struct literal. |
| 3081 | struct IrInstSrcCallArgs { | |
| 3082 | IrInstSrc base; | |
| 3081 | struct Stage1ZirInstCallArgs { | |
| 3082 | Stage1ZirInst base; | |
| 3083 | 3083 | |
| 3084 | IrInstSrc *options; | |
| 3085 | IrInstSrc *fn_ref; | |
| 3086 | IrInstSrc **args_ptr; | |
| 3084 | Stage1ZirInst *options; | |
| 3085 | Stage1ZirInst *fn_ref; | |
| 3086 | Stage1ZirInst **args_ptr; | |
| 3087 | 3087 | size_t args_len; |
| 3088 | 3088 | ResultLoc *result_loc; |
| 3089 | 3089 | }; |
| ... | ... | @@ -3091,68 +3091,68 @@ struct IrInstSrcCallArgs { |
| 3091 | 3091 | // This is a pass1 instruction, used by @call, when the args node |
| 3092 | 3092 | // is not a literal. |
| 3093 | 3093 | // `args` is expected to be either a struct or a tuple. |
| 3094 | struct IrInstSrcCallExtra { | |
| 3095 | IrInstSrc base; | |
| 3094 | struct Stage1ZirInstCallExtra { | |
| 3095 | Stage1ZirInst base; | |
| 3096 | 3096 | |
| 3097 | IrInstSrc *options; | |
| 3098 | IrInstSrc *fn_ref; | |
| 3099 | IrInstSrc *args; | |
| 3097 | Stage1ZirInst *options; | |
| 3098 | Stage1ZirInst *fn_ref; | |
| 3099 | Stage1ZirInst *args; | |
| 3100 | 3100 | ResultLoc *result_loc; |
| 3101 | 3101 | }; |
| 3102 | 3102 | |
| 3103 | 3103 | // This is a pass1 instruction, used by @asyncCall, when the args node |
| 3104 | 3104 | // is not a literal. |
| 3105 | 3105 | // `args` is expected to be either a struct or a tuple. |
| 3106 | struct IrInstSrcAsyncCallExtra { | |
| 3107 | IrInstSrc base; | |
| 3106 | struct Stage1ZirInstAsyncCallExtra { | |
| 3107 | Stage1ZirInst base; | |
| 3108 | 3108 | |
| 3109 | 3109 | CallModifier modifier; |
| 3110 | IrInstSrc *fn_ref; | |
| 3111 | IrInstSrc *ret_ptr; | |
| 3112 | IrInstSrc *new_stack; | |
| 3113 | IrInstSrc *args; | |
| 3110 | Stage1ZirInst *fn_ref; | |
| 3111 | Stage1ZirInst *ret_ptr; | |
| 3112 | Stage1ZirInst *new_stack; | |
| 3113 | Stage1ZirInst *args; | |
| 3114 | 3114 | ResultLoc *result_loc; |
| 3115 | 3115 | }; |
| 3116 | 3116 | |
| 3117 | struct IrInstGenCall { | |
| 3118 | IrInstGen base; | |
| 3117 | struct Stage1AirInstCall { | |
| 3118 | Stage1AirInst base; | |
| 3119 | 3119 | |
| 3120 | IrInstGen *fn_ref; | |
| 3120 | Stage1AirInst *fn_ref; | |
| 3121 | 3121 | ZigFn *fn_entry; |
| 3122 | 3122 | size_t arg_count; |
| 3123 | IrInstGen **args; | |
| 3124 | IrInstGen *result_loc; | |
| 3125 | IrInstGen *frame_result_loc; | |
| 3126 | IrInstGen *new_stack; | |
| 3123 | Stage1AirInst **args; | |
| 3124 | Stage1AirInst *result_loc; | |
| 3125 | Stage1AirInst *frame_result_loc; | |
| 3126 | Stage1AirInst *new_stack; | |
| 3127 | 3127 | |
| 3128 | 3128 | CallModifier modifier; |
| 3129 | 3129 | |
| 3130 | 3130 | bool is_async_call_builtin; |
| 3131 | 3131 | }; |
| 3132 | 3132 | |
| 3133 | struct IrInstSrcConst { | |
| 3134 | IrInstSrc base; | |
| 3133 | struct Stage1ZirInstConst { | |
| 3134 | Stage1ZirInst base; | |
| 3135 | 3135 | |
| 3136 | 3136 | ZigValue *value; |
| 3137 | 3137 | }; |
| 3138 | 3138 | |
| 3139 | struct IrInstGenConst { | |
| 3140 | IrInstGen base; | |
| 3139 | struct Stage1AirInstConst { | |
| 3140 | Stage1AirInst base; | |
| 3141 | 3141 | }; |
| 3142 | 3142 | |
| 3143 | struct IrInstSrcReturn { | |
| 3144 | IrInstSrc base; | |
| 3143 | struct Stage1ZirInstReturn { | |
| 3144 | Stage1ZirInst base; | |
| 3145 | 3145 | |
| 3146 | IrInstSrc *operand; | |
| 3146 | Stage1ZirInst *operand; | |
| 3147 | 3147 | }; |
| 3148 | 3148 | |
| 3149 | 3149 | // When an IrExecutable is not in a function, a return instruction means that |
| 3150 | 3150 | // the expression returns with that value, even though a return statement from |
| 3151 | 3151 | // an AST perspective is invalid. |
| 3152 | struct IrInstGenReturn { | |
| 3153 | IrInstGen base; | |
| 3152 | struct Stage1AirInstReturn { | |
| 3153 | Stage1AirInst base; | |
| 3154 | 3154 | |
| 3155 | IrInstGen *operand; | |
| 3155 | Stage1AirInst *operand; | |
| 3156 | 3156 | }; |
| 3157 | 3157 | |
| 3158 | 3158 | enum CastOp { |
| ... | ... | @@ -3167,94 +3167,94 @@ enum CastOp { |
| 3167 | 3167 | }; |
| 3168 | 3168 | |
| 3169 | 3169 | // TODO get rid of this instruction, replace with instructions for each op code |
| 3170 | struct IrInstGenCast { | |
| 3171 | IrInstGen base; | |
| 3170 | struct Stage1AirInstCast { | |
| 3171 | Stage1AirInst base; | |
| 3172 | 3172 | |
| 3173 | IrInstGen *value; | |
| 3173 | Stage1AirInst *value; | |
| 3174 | 3174 | CastOp cast_op; |
| 3175 | 3175 | }; |
| 3176 | 3176 | |
| 3177 | struct IrInstSrcContainerInitList { | |
| 3178 | IrInstSrc base; | |
| 3177 | struct Stage1ZirInstContainerInitList { | |
| 3178 | Stage1ZirInst base; | |
| 3179 | 3179 | |
| 3180 | IrInstSrc *elem_type; | |
| 3180 | Stage1ZirInst *elem_type; | |
| 3181 | 3181 | size_t item_count; |
| 3182 | IrInstSrc **elem_result_loc_list; | |
| 3183 | IrInstSrc *result_loc; | |
| 3182 | Stage1ZirInst **elem_result_loc_list; | |
| 3183 | Stage1ZirInst *result_loc; | |
| 3184 | 3184 | AstNode *init_array_type_source_node; |
| 3185 | 3185 | }; |
| 3186 | 3186 | |
| 3187 | struct IrInstSrcContainerInitFieldsField { | |
| 3187 | struct Stage1ZirInstContainerInitFieldsField { | |
| 3188 | 3188 | Buf *name; |
| 3189 | 3189 | AstNode *source_node; |
| 3190 | IrInstSrc *result_loc; | |
| 3190 | Stage1ZirInst *result_loc; | |
| 3191 | 3191 | }; |
| 3192 | 3192 | |
| 3193 | struct IrInstSrcContainerInitFields { | |
| 3194 | IrInstSrc base; | |
| 3193 | struct Stage1ZirInstContainerInitFields { | |
| 3194 | Stage1ZirInst base; | |
| 3195 | 3195 | |
| 3196 | 3196 | size_t field_count; |
| 3197 | IrInstSrcContainerInitFieldsField *fields; | |
| 3198 | IrInstSrc *result_loc; | |
| 3197 | Stage1ZirInstContainerInitFieldsField *fields; | |
| 3198 | Stage1ZirInst *result_loc; | |
| 3199 | 3199 | }; |
| 3200 | 3200 | |
| 3201 | struct IrInstSrcUnreachable { | |
| 3202 | IrInstSrc base; | |
| 3201 | struct Stage1ZirInstUnreachable { | |
| 3202 | Stage1ZirInst base; | |
| 3203 | 3203 | }; |
| 3204 | 3204 | |
| 3205 | struct IrInstGenUnreachable { | |
| 3206 | IrInstGen base; | |
| 3205 | struct Stage1AirInstUnreachable { | |
| 3206 | Stage1AirInst base; | |
| 3207 | 3207 | }; |
| 3208 | 3208 | |
| 3209 | struct IrInstSrcTypeOf { | |
| 3210 | IrInstSrc base; | |
| 3209 | struct Stage1ZirInstTypeOf { | |
| 3210 | Stage1ZirInst base; | |
| 3211 | 3211 | |
| 3212 | 3212 | union { |
| 3213 | IrInstSrc *scalar; // value_count == 1 | |
| 3214 | IrInstSrc **list; // value_count > 1 | |
| 3213 | Stage1ZirInst *scalar; // value_count == 1 | |
| 3214 | Stage1ZirInst **list; // value_count > 1 | |
| 3215 | 3215 | } value; |
| 3216 | 3216 | size_t value_count; |
| 3217 | 3217 | }; |
| 3218 | 3218 | |
| 3219 | struct IrInstSrcSetCold { | |
| 3220 | IrInstSrc base; | |
| 3219 | struct Stage1ZirInstSetCold { | |
| 3220 | Stage1ZirInst base; | |
| 3221 | 3221 | |
| 3222 | IrInstSrc *is_cold; | |
| 3222 | Stage1ZirInst *is_cold; | |
| 3223 | 3223 | }; |
| 3224 | 3224 | |
| 3225 | struct IrInstSrcSetRuntimeSafety { | |
| 3226 | IrInstSrc base; | |
| 3225 | struct Stage1ZirInstSetRuntimeSafety { | |
| 3226 | Stage1ZirInst base; | |
| 3227 | 3227 | |
| 3228 | IrInstSrc *safety_on; | |
| 3228 | Stage1ZirInst *safety_on; | |
| 3229 | 3229 | }; |
| 3230 | 3230 | |
| 3231 | struct IrInstSrcSetFloatMode { | |
| 3232 | IrInstSrc base; | |
| 3231 | struct Stage1ZirInstSetFloatMode { | |
| 3232 | Stage1ZirInst base; | |
| 3233 | 3233 | |
| 3234 | IrInstSrc *scope_value; | |
| 3235 | IrInstSrc *mode_value; | |
| 3234 | Stage1ZirInst *scope_value; | |
| 3235 | Stage1ZirInst *mode_value; | |
| 3236 | 3236 | }; |
| 3237 | 3237 | |
| 3238 | struct IrInstSrcArrayType { | |
| 3239 | IrInstSrc base; | |
| 3238 | struct Stage1ZirInstArrayType { | |
| 3239 | Stage1ZirInst base; | |
| 3240 | 3240 | |
| 3241 | IrInstSrc *size; | |
| 3242 | IrInstSrc *sentinel; | |
| 3243 | IrInstSrc *child_type; | |
| 3241 | Stage1ZirInst *size; | |
| 3242 | Stage1ZirInst *sentinel; | |
| 3243 | Stage1ZirInst *child_type; | |
| 3244 | 3244 | }; |
| 3245 | 3245 | |
| 3246 | struct IrInstSrcPtrTypeSimple { | |
| 3247 | IrInstSrc base; | |
| 3246 | struct Stage1ZirInstPtrTypeSimple { | |
| 3247 | Stage1ZirInst base; | |
| 3248 | 3248 | |
| 3249 | IrInstSrc *child_type; | |
| 3249 | Stage1ZirInst *child_type; | |
| 3250 | 3250 | }; |
| 3251 | 3251 | |
| 3252 | struct IrInstSrcPtrType { | |
| 3253 | IrInstSrc base; | |
| 3252 | struct Stage1ZirInstPtrType { | |
| 3253 | Stage1ZirInst base; | |
| 3254 | 3254 | |
| 3255 | IrInstSrc *sentinel; | |
| 3256 | IrInstSrc *align_value; | |
| 3257 | IrInstSrc *child_type; | |
| 3255 | Stage1ZirInst *sentinel; | |
| 3256 | Stage1ZirInst *align_value; | |
| 3257 | Stage1ZirInst *child_type; | |
| 3258 | 3258 | uint32_t bit_offset_start; |
| 3259 | 3259 | uint32_t host_int_bytes; |
| 3260 | 3260 | PtrLen ptr_len; |
| ... | ... | @@ -3263,459 +3263,459 @@ struct IrInstSrcPtrType { |
| 3263 | 3263 | bool is_allow_zero; |
| 3264 | 3264 | }; |
| 3265 | 3265 | |
| 3266 | struct IrInstSrcAnyFrameType { | |
| 3267 | IrInstSrc base; | |
| 3266 | struct Stage1ZirInstAnyFrameType { | |
| 3267 | Stage1ZirInst base; | |
| 3268 | 3268 | |
| 3269 | IrInstSrc *payload_type; | |
| 3269 | Stage1ZirInst *payload_type; | |
| 3270 | 3270 | }; |
| 3271 | 3271 | |
| 3272 | struct IrInstSrcSliceType { | |
| 3273 | IrInstSrc base; | |
| 3272 | struct Stage1ZirInstSliceType { | |
| 3273 | Stage1ZirInst base; | |
| 3274 | 3274 | |
| 3275 | IrInstSrc *sentinel; | |
| 3276 | IrInstSrc *align_value; | |
| 3277 | IrInstSrc *child_type; | |
| 3275 | Stage1ZirInst *sentinel; | |
| 3276 | Stage1ZirInst *align_value; | |
| 3277 | Stage1ZirInst *child_type; | |
| 3278 | 3278 | bool is_const; |
| 3279 | 3279 | bool is_volatile; |
| 3280 | 3280 | bool is_allow_zero; |
| 3281 | 3281 | }; |
| 3282 | 3282 | |
| 3283 | struct IrInstSrcAsm { | |
| 3284 | IrInstSrc base; | |
| 3283 | struct Stage1ZirInstAsm { | |
| 3284 | Stage1ZirInst base; | |
| 3285 | 3285 | |
| 3286 | IrInstSrc *asm_template; | |
| 3287 | IrInstSrc **input_list; | |
| 3288 | IrInstSrc **output_types; | |
| 3286 | Stage1ZirInst *asm_template; | |
| 3287 | Stage1ZirInst **input_list; | |
| 3288 | Stage1ZirInst **output_types; | |
| 3289 | 3289 | ZigVar **output_vars; |
| 3290 | 3290 | size_t return_count; |
| 3291 | 3291 | bool has_side_effects; |
| 3292 | 3292 | bool is_global; |
| 3293 | 3293 | }; |
| 3294 | 3294 | |
| 3295 | struct IrInstGenAsm { | |
| 3296 | IrInstGen base; | |
| 3295 | struct Stage1AirInstAsm { | |
| 3296 | Stage1AirInst base; | |
| 3297 | 3297 | |
| 3298 | 3298 | Buf *asm_template; |
| 3299 | 3299 | AsmToken *token_list; |
| 3300 | 3300 | size_t token_list_len; |
| 3301 | IrInstGen **input_list; | |
| 3302 | IrInstGen **output_types; | |
| 3301 | Stage1AirInst **input_list; | |
| 3302 | Stage1AirInst **output_types; | |
| 3303 | 3303 | ZigVar **output_vars; |
| 3304 | 3304 | size_t return_count; |
| 3305 | 3305 | bool has_side_effects; |
| 3306 | 3306 | }; |
| 3307 | 3307 | |
| 3308 | struct IrInstSrcSizeOf { | |
| 3309 | IrInstSrc base; | |
| 3308 | struct Stage1ZirInstSizeOf { | |
| 3309 | Stage1ZirInst base; | |
| 3310 | 3310 | |
| 3311 | IrInstSrc *type_value; | |
| 3311 | Stage1ZirInst *type_value; | |
| 3312 | 3312 | bool bit_size; |
| 3313 | 3313 | }; |
| 3314 | 3314 | |
| 3315 | 3315 | // returns true if nonnull, returns false if null |
| 3316 | struct IrInstSrcTestNonNull { | |
| 3317 | IrInstSrc base; | |
| 3316 | struct Stage1ZirInstTestNonNull { | |
| 3317 | Stage1ZirInst base; | |
| 3318 | 3318 | |
| 3319 | IrInstSrc *value; | |
| 3319 | Stage1ZirInst *value; | |
| 3320 | 3320 | }; |
| 3321 | 3321 | |
| 3322 | struct IrInstGenTestNonNull { | |
| 3323 | IrInstGen base; | |
| 3322 | struct Stage1AirInstTestNonNull { | |
| 3323 | Stage1AirInst base; | |
| 3324 | 3324 | |
| 3325 | IrInstGen *value; | |
| 3325 | Stage1AirInst *value; | |
| 3326 | 3326 | }; |
| 3327 | 3327 | |
| 3328 | 3328 | // Takes a pointer to an optional value, returns a pointer |
| 3329 | 3329 | // to the payload. |
| 3330 | struct IrInstSrcOptionalUnwrapPtr { | |
| 3331 | IrInstSrc base; | |
| 3330 | struct Stage1ZirInstOptionalUnwrapPtr { | |
| 3331 | Stage1ZirInst base; | |
| 3332 | 3332 | |
| 3333 | IrInstSrc *base_ptr; | |
| 3333 | Stage1ZirInst *base_ptr; | |
| 3334 | 3334 | bool safety_check_on; |
| 3335 | 3335 | }; |
| 3336 | 3336 | |
| 3337 | struct IrInstGenOptionalUnwrapPtr { | |
| 3338 | IrInstGen base; | |
| 3337 | struct Stage1AirInstOptionalUnwrapPtr { | |
| 3338 | Stage1AirInst base; | |
| 3339 | 3339 | |
| 3340 | IrInstGen *base_ptr; | |
| 3340 | Stage1AirInst *base_ptr; | |
| 3341 | 3341 | bool safety_check_on; |
| 3342 | 3342 | bool initializing; |
| 3343 | 3343 | }; |
| 3344 | 3344 | |
| 3345 | struct IrInstSrcCtz { | |
| 3346 | IrInstSrc base; | |
| 3345 | struct Stage1ZirInstCtz { | |
| 3346 | Stage1ZirInst base; | |
| 3347 | 3347 | |
| 3348 | IrInstSrc *type; | |
| 3349 | IrInstSrc *op; | |
| 3348 | Stage1ZirInst *type; | |
| 3349 | Stage1ZirInst *op; | |
| 3350 | 3350 | }; |
| 3351 | 3351 | |
| 3352 | struct IrInstGenCtz { | |
| 3353 | IrInstGen base; | |
| 3352 | struct Stage1AirInstCtz { | |
| 3353 | Stage1AirInst base; | |
| 3354 | 3354 | |
| 3355 | IrInstGen *op; | |
| 3355 | Stage1AirInst *op; | |
| 3356 | 3356 | }; |
| 3357 | 3357 | |
| 3358 | struct IrInstSrcClz { | |
| 3359 | IrInstSrc base; | |
| 3358 | struct Stage1ZirInstClz { | |
| 3359 | Stage1ZirInst base; | |
| 3360 | 3360 | |
| 3361 | IrInstSrc *type; | |
| 3362 | IrInstSrc *op; | |
| 3361 | Stage1ZirInst *type; | |
| 3362 | Stage1ZirInst *op; | |
| 3363 | 3363 | }; |
| 3364 | 3364 | |
| 3365 | struct IrInstGenClz { | |
| 3366 | IrInstGen base; | |
| 3365 | struct Stage1AirInstClz { | |
| 3366 | Stage1AirInst base; | |
| 3367 | 3367 | |
| 3368 | IrInstGen *op; | |
| 3368 | Stage1AirInst *op; | |
| 3369 | 3369 | }; |
| 3370 | 3370 | |
| 3371 | struct IrInstSrcPopCount { | |
| 3372 | IrInstSrc base; | |
| 3371 | struct Stage1ZirInstPopCount { | |
| 3372 | Stage1ZirInst base; | |
| 3373 | 3373 | |
| 3374 | IrInstSrc *type; | |
| 3375 | IrInstSrc *op; | |
| 3374 | Stage1ZirInst *type; | |
| 3375 | Stage1ZirInst *op; | |
| 3376 | 3376 | }; |
| 3377 | 3377 | |
| 3378 | struct IrInstGenPopCount { | |
| 3379 | IrInstGen base; | |
| 3378 | struct Stage1AirInstPopCount { | |
| 3379 | Stage1AirInst base; | |
| 3380 | 3380 | |
| 3381 | IrInstGen *op; | |
| 3381 | Stage1AirInst *op; | |
| 3382 | 3382 | }; |
| 3383 | 3383 | |
| 3384 | struct IrInstGenUnionTag { | |
| 3385 | IrInstGen base; | |
| 3384 | struct Stage1AirInstUnionTag { | |
| 3385 | Stage1AirInst base; | |
| 3386 | 3386 | |
| 3387 | IrInstGen *value; | |
| 3387 | Stage1AirInst *value; | |
| 3388 | 3388 | }; |
| 3389 | 3389 | |
| 3390 | struct IrInstSrcImport { | |
| 3391 | IrInstSrc base; | |
| 3390 | struct Stage1ZirInstImport { | |
| 3391 | Stage1ZirInst base; | |
| 3392 | 3392 | |
| 3393 | IrInstSrc *name; | |
| 3393 | Stage1ZirInst *name; | |
| 3394 | 3394 | }; |
| 3395 | 3395 | |
| 3396 | struct IrInstSrcRef { | |
| 3397 | IrInstSrc base; | |
| 3396 | struct Stage1ZirInstRef { | |
| 3397 | Stage1ZirInst base; | |
| 3398 | 3398 | |
| 3399 | IrInstSrc *value; | |
| 3399 | Stage1ZirInst *value; | |
| 3400 | 3400 | }; |
| 3401 | 3401 | |
| 3402 | struct IrInstGenRef { | |
| 3403 | IrInstGen base; | |
| 3402 | struct Stage1AirInstRef { | |
| 3403 | Stage1AirInst base; | |
| 3404 | 3404 | |
| 3405 | IrInstGen *operand; | |
| 3406 | IrInstGen *result_loc; | |
| 3405 | Stage1AirInst *operand; | |
| 3406 | Stage1AirInst *result_loc; | |
| 3407 | 3407 | }; |
| 3408 | 3408 | |
| 3409 | struct IrInstSrcCompileErr { | |
| 3410 | IrInstSrc base; | |
| 3409 | struct Stage1ZirInstCompileErr { | |
| 3410 | Stage1ZirInst base; | |
| 3411 | 3411 | |
| 3412 | IrInstSrc *msg; | |
| 3412 | Stage1ZirInst *msg; | |
| 3413 | 3413 | }; |
| 3414 | 3414 | |
| 3415 | struct IrInstSrcCompileLog { | |
| 3416 | IrInstSrc base; | |
| 3415 | struct Stage1ZirInstCompileLog { | |
| 3416 | Stage1ZirInst base; | |
| 3417 | 3417 | |
| 3418 | 3418 | size_t msg_count; |
| 3419 | IrInstSrc **msg_list; | |
| 3419 | Stage1ZirInst **msg_list; | |
| 3420 | 3420 | }; |
| 3421 | 3421 | |
| 3422 | struct IrInstSrcErrName { | |
| 3423 | IrInstSrc base; | |
| 3422 | struct Stage1ZirInstErrName { | |
| 3423 | Stage1ZirInst base; | |
| 3424 | 3424 | |
| 3425 | IrInstSrc *value; | |
| 3425 | Stage1ZirInst *value; | |
| 3426 | 3426 | }; |
| 3427 | 3427 | |
| 3428 | struct IrInstGenErrName { | |
| 3429 | IrInstGen base; | |
| 3428 | struct Stage1AirInstErrName { | |
| 3429 | Stage1AirInst base; | |
| 3430 | 3430 | |
| 3431 | IrInstGen *value; | |
| 3431 | Stage1AirInst *value; | |
| 3432 | 3432 | }; |
| 3433 | 3433 | |
| 3434 | struct IrInstSrcCImport { | |
| 3435 | IrInstSrc base; | |
| 3434 | struct Stage1ZirInstCImport { | |
| 3435 | Stage1ZirInst base; | |
| 3436 | 3436 | }; |
| 3437 | 3437 | |
| 3438 | struct IrInstSrcCInclude { | |
| 3439 | IrInstSrc base; | |
| 3438 | struct Stage1ZirInstCInclude { | |
| 3439 | Stage1ZirInst base; | |
| 3440 | 3440 | |
| 3441 | IrInstSrc *name; | |
| 3441 | Stage1ZirInst *name; | |
| 3442 | 3442 | }; |
| 3443 | 3443 | |
| 3444 | struct IrInstSrcCDefine { | |
| 3445 | IrInstSrc base; | |
| 3444 | struct Stage1ZirInstCDefine { | |
| 3445 | Stage1ZirInst base; | |
| 3446 | 3446 | |
| 3447 | IrInstSrc *name; | |
| 3448 | IrInstSrc *value; | |
| 3447 | Stage1ZirInst *name; | |
| 3448 | Stage1ZirInst *value; | |
| 3449 | 3449 | }; |
| 3450 | 3450 | |
| 3451 | struct IrInstSrcCUndef { | |
| 3452 | IrInstSrc base; | |
| 3451 | struct Stage1ZirInstCUndef { | |
| 3452 | Stage1ZirInst base; | |
| 3453 | 3453 | |
| 3454 | IrInstSrc *name; | |
| 3454 | Stage1ZirInst *name; | |
| 3455 | 3455 | }; |
| 3456 | 3456 | |
| 3457 | struct IrInstSrcEmbedFile { | |
| 3458 | IrInstSrc base; | |
| 3457 | struct Stage1ZirInstEmbedFile { | |
| 3458 | Stage1ZirInst base; | |
| 3459 | 3459 | |
| 3460 | IrInstSrc *name; | |
| 3460 | Stage1ZirInst *name; | |
| 3461 | 3461 | }; |
| 3462 | 3462 | |
| 3463 | struct IrInstSrcCmpxchg { | |
| 3464 | IrInstSrc base; | |
| 3463 | struct Stage1ZirInstCmpxchg { | |
| 3464 | Stage1ZirInst base; | |
| 3465 | 3465 | |
| 3466 | 3466 | bool is_weak; |
| 3467 | IrInstSrc *type_value; | |
| 3468 | IrInstSrc *ptr; | |
| 3469 | IrInstSrc *cmp_value; | |
| 3470 | IrInstSrc *new_value; | |
| 3471 | IrInstSrc *success_order_value; | |
| 3472 | IrInstSrc *failure_order_value; | |
| 3467 | Stage1ZirInst *type_value; | |
| 3468 | Stage1ZirInst *ptr; | |
| 3469 | Stage1ZirInst *cmp_value; | |
| 3470 | Stage1ZirInst *new_value; | |
| 3471 | Stage1ZirInst *success_order_value; | |
| 3472 | Stage1ZirInst *failure_order_value; | |
| 3473 | 3473 | ResultLoc *result_loc; |
| 3474 | 3474 | }; |
| 3475 | 3475 | |
| 3476 | struct IrInstGenCmpxchg { | |
| 3477 | IrInstGen base; | |
| 3476 | struct Stage1AirInstCmpxchg { | |
| 3477 | Stage1AirInst base; | |
| 3478 | 3478 | |
| 3479 | 3479 | AtomicOrder success_order; |
| 3480 | 3480 | AtomicOrder failure_order; |
| 3481 | IrInstGen *ptr; | |
| 3482 | IrInstGen *cmp_value; | |
| 3483 | IrInstGen *new_value; | |
| 3484 | IrInstGen *result_loc; | |
| 3481 | Stage1AirInst *ptr; | |
| 3482 | Stage1AirInst *cmp_value; | |
| 3483 | Stage1AirInst *new_value; | |
| 3484 | Stage1AirInst *result_loc; | |
| 3485 | 3485 | bool is_weak; |
| 3486 | 3486 | }; |
| 3487 | 3487 | |
| 3488 | struct IrInstSrcFence { | |
| 3489 | IrInstSrc base; | |
| 3488 | struct Stage1ZirInstFence { | |
| 3489 | Stage1ZirInst base; | |
| 3490 | 3490 | |
| 3491 | IrInstSrc *order; | |
| 3491 | Stage1ZirInst *order; | |
| 3492 | 3492 | }; |
| 3493 | 3493 | |
| 3494 | struct IrInstGenFence { | |
| 3495 | IrInstGen base; | |
| 3494 | struct Stage1AirInstFence { | |
| 3495 | Stage1AirInst base; | |
| 3496 | 3496 | |
| 3497 | 3497 | AtomicOrder order; |
| 3498 | 3498 | }; |
| 3499 | 3499 | |
| 3500 | struct IrInstSrcReduce { | |
| 3501 | IrInstSrc base; | |
| 3500 | struct Stage1ZirInstReduce { | |
| 3501 | Stage1ZirInst base; | |
| 3502 | 3502 | |
| 3503 | IrInstSrc *op; | |
| 3504 | IrInstSrc *value; | |
| 3503 | Stage1ZirInst *op; | |
| 3504 | Stage1ZirInst *value; | |
| 3505 | 3505 | }; |
| 3506 | 3506 | |
| 3507 | struct IrInstGenReduce { | |
| 3508 | IrInstGen base; | |
| 3507 | struct Stage1AirInstReduce { | |
| 3508 | Stage1AirInst base; | |
| 3509 | 3509 | |
| 3510 | 3510 | ReduceOp op; |
| 3511 | IrInstGen *value; | |
| 3511 | Stage1AirInst *value; | |
| 3512 | 3512 | }; |
| 3513 | 3513 | |
| 3514 | struct IrInstSrcTruncate { | |
| 3515 | IrInstSrc base; | |
| 3514 | struct Stage1ZirInstTruncate { | |
| 3515 | Stage1ZirInst base; | |
| 3516 | 3516 | |
| 3517 | IrInstSrc *dest_type; | |
| 3518 | IrInstSrc *target; | |
| 3517 | Stage1ZirInst *dest_type; | |
| 3518 | Stage1ZirInst *target; | |
| 3519 | 3519 | }; |
| 3520 | 3520 | |
| 3521 | struct IrInstGenTruncate { | |
| 3522 | IrInstGen base; | |
| 3521 | struct Stage1AirInstTruncate { | |
| 3522 | Stage1AirInst base; | |
| 3523 | 3523 | |
| 3524 | IrInstGen *target; | |
| 3524 | Stage1AirInst *target; | |
| 3525 | 3525 | }; |
| 3526 | 3526 | |
| 3527 | struct IrInstSrcIntCast { | |
| 3528 | IrInstSrc base; | |
| 3527 | struct Stage1ZirInstIntCast { | |
| 3528 | Stage1ZirInst base; | |
| 3529 | 3529 | |
| 3530 | IrInstSrc *dest_type; | |
| 3531 | IrInstSrc *target; | |
| 3530 | Stage1ZirInst *dest_type; | |
| 3531 | Stage1ZirInst *target; | |
| 3532 | 3532 | }; |
| 3533 | 3533 | |
| 3534 | struct IrInstSrcFloatCast { | |
| 3535 | IrInstSrc base; | |
| 3534 | struct Stage1ZirInstFloatCast { | |
| 3535 | Stage1ZirInst base; | |
| 3536 | 3536 | |
| 3537 | IrInstSrc *dest_type; | |
| 3538 | IrInstSrc *target; | |
| 3537 | Stage1ZirInst *dest_type; | |
| 3538 | Stage1ZirInst *target; | |
| 3539 | 3539 | }; |
| 3540 | 3540 | |
| 3541 | struct IrInstSrcErrSetCast { | |
| 3542 | IrInstSrc base; | |
| 3541 | struct Stage1ZirInstErrSetCast { | |
| 3542 | Stage1ZirInst base; | |
| 3543 | 3543 | |
| 3544 | IrInstSrc *dest_type; | |
| 3545 | IrInstSrc *target; | |
| 3544 | Stage1ZirInst *dest_type; | |
| 3545 | Stage1ZirInst *target; | |
| 3546 | 3546 | }; |
| 3547 | 3547 | |
| 3548 | struct IrInstSrcIntToFloat { | |
| 3549 | IrInstSrc base; | |
| 3548 | struct Stage1ZirInstIntToFloat { | |
| 3549 | Stage1ZirInst base; | |
| 3550 | 3550 | |
| 3551 | IrInstSrc *dest_type; | |
| 3552 | IrInstSrc *target; | |
| 3551 | Stage1ZirInst *dest_type; | |
| 3552 | Stage1ZirInst *target; | |
| 3553 | 3553 | }; |
| 3554 | 3554 | |
| 3555 | struct IrInstSrcFloatToInt { | |
| 3556 | IrInstSrc base; | |
| 3555 | struct Stage1ZirInstFloatToInt { | |
| 3556 | Stage1ZirInst base; | |
| 3557 | 3557 | |
| 3558 | IrInstSrc *dest_type; | |
| 3559 | IrInstSrc *target; | |
| 3558 | Stage1ZirInst *dest_type; | |
| 3559 | Stage1ZirInst *target; | |
| 3560 | 3560 | }; |
| 3561 | 3561 | |
| 3562 | struct IrInstSrcBoolToInt { | |
| 3563 | IrInstSrc base; | |
| 3562 | struct Stage1ZirInstBoolToInt { | |
| 3563 | Stage1ZirInst base; | |
| 3564 | 3564 | |
| 3565 | IrInstSrc *target; | |
| 3565 | Stage1ZirInst *target; | |
| 3566 | 3566 | }; |
| 3567 | 3567 | |
| 3568 | struct IrInstSrcVectorType { | |
| 3569 | IrInstSrc base; | |
| 3568 | struct Stage1ZirInstVectorType { | |
| 3569 | Stage1ZirInst base; | |
| 3570 | 3570 | |
| 3571 | IrInstSrc *len; | |
| 3572 | IrInstSrc *elem_type; | |
| 3571 | Stage1ZirInst *len; | |
| 3572 | Stage1ZirInst *elem_type; | |
| 3573 | 3573 | }; |
| 3574 | 3574 | |
| 3575 | struct IrInstSrcBoolNot { | |
| 3576 | IrInstSrc base; | |
| 3575 | struct Stage1ZirInstBoolNot { | |
| 3576 | Stage1ZirInst base; | |
| 3577 | 3577 | |
| 3578 | IrInstSrc *value; | |
| 3578 | Stage1ZirInst *value; | |
| 3579 | 3579 | }; |
| 3580 | 3580 | |
| 3581 | struct IrInstGenBoolNot { | |
| 3582 | IrInstGen base; | |
| 3581 | struct Stage1AirInstBoolNot { | |
| 3582 | Stage1AirInst base; | |
| 3583 | 3583 | |
| 3584 | IrInstGen *value; | |
| 3584 | Stage1AirInst *value; | |
| 3585 | 3585 | }; |
| 3586 | 3586 | |
| 3587 | struct IrInstSrcMemset { | |
| 3588 | IrInstSrc base; | |
| 3587 | struct Stage1ZirInstMemset { | |
| 3588 | Stage1ZirInst base; | |
| 3589 | 3589 | |
| 3590 | IrInstSrc *dest_ptr; | |
| 3591 | IrInstSrc *byte; | |
| 3592 | IrInstSrc *count; | |
| 3590 | Stage1ZirInst *dest_ptr; | |
| 3591 | Stage1ZirInst *byte; | |
| 3592 | Stage1ZirInst *count; | |
| 3593 | 3593 | }; |
| 3594 | 3594 | |
| 3595 | struct IrInstGenMemset { | |
| 3596 | IrInstGen base; | |
| 3595 | struct Stage1AirInstMemset { | |
| 3596 | Stage1AirInst base; | |
| 3597 | 3597 | |
| 3598 | IrInstGen *dest_ptr; | |
| 3599 | IrInstGen *byte; | |
| 3600 | IrInstGen *count; | |
| 3598 | Stage1AirInst *dest_ptr; | |
| 3599 | Stage1AirInst *byte; | |
| 3600 | Stage1AirInst *count; | |
| 3601 | 3601 | }; |
| 3602 | 3602 | |
| 3603 | struct IrInstSrcMemcpy { | |
| 3604 | IrInstSrc base; | |
| 3603 | struct Stage1ZirInstMemcpy { | |
| 3604 | Stage1ZirInst base; | |
| 3605 | 3605 | |
| 3606 | IrInstSrc *dest_ptr; | |
| 3607 | IrInstSrc *src_ptr; | |
| 3608 | IrInstSrc *count; | |
| 3606 | Stage1ZirInst *dest_ptr; | |
| 3607 | Stage1ZirInst *src_ptr; | |
| 3608 | Stage1ZirInst *count; | |
| 3609 | 3609 | }; |
| 3610 | 3610 | |
| 3611 | struct IrInstGenMemcpy { | |
| 3612 | IrInstGen base; | |
| 3611 | struct Stage1AirInstMemcpy { | |
| 3612 | Stage1AirInst base; | |
| 3613 | 3613 | |
| 3614 | IrInstGen *dest_ptr; | |
| 3615 | IrInstGen *src_ptr; | |
| 3616 | IrInstGen *count; | |
| 3614 | Stage1AirInst *dest_ptr; | |
| 3615 | Stage1AirInst *src_ptr; | |
| 3616 | Stage1AirInst *count; | |
| 3617 | 3617 | }; |
| 3618 | 3618 | |
| 3619 | struct IrInstSrcWasmMemorySize { | |
| 3620 | IrInstSrc base; | |
| 3619 | struct Stage1ZirInstWasmMemorySize { | |
| 3620 | Stage1ZirInst base; | |
| 3621 | 3621 | |
| 3622 | IrInstSrc *index; | |
| 3622 | Stage1ZirInst *index; | |
| 3623 | 3623 | }; |
| 3624 | 3624 | |
| 3625 | struct IrInstGenWasmMemorySize { | |
| 3626 | IrInstGen base; | |
| 3625 | struct Stage1AirInstWasmMemorySize { | |
| 3626 | Stage1AirInst base; | |
| 3627 | 3627 | |
| 3628 | IrInstGen *index; | |
| 3628 | Stage1AirInst *index; | |
| 3629 | 3629 | }; |
| 3630 | 3630 | |
| 3631 | struct IrInstSrcWasmMemoryGrow { | |
| 3632 | IrInstSrc base; | |
| 3631 | struct Stage1ZirInstWasmMemoryGrow { | |
| 3632 | Stage1ZirInst base; | |
| 3633 | 3633 | |
| 3634 | IrInstSrc *index; | |
| 3635 | IrInstSrc *delta; | |
| 3634 | Stage1ZirInst *index; | |
| 3635 | Stage1ZirInst *delta; | |
| 3636 | 3636 | }; |
| 3637 | 3637 | |
| 3638 | struct IrInstGenWasmMemoryGrow { | |
| 3639 | IrInstGen base; | |
| 3638 | struct Stage1AirInstWasmMemoryGrow { | |
| 3639 | Stage1AirInst base; | |
| 3640 | 3640 | |
| 3641 | IrInstGen *index; | |
| 3642 | IrInstGen *delta; | |
| 3641 | Stage1AirInst *index; | |
| 3642 | Stage1AirInst *delta; | |
| 3643 | 3643 | }; |
| 3644 | 3644 | |
| 3645 | struct IrInstSrcSrc { | |
| 3646 | IrInstSrc base; | |
| 3645 | struct Stage1ZirInstSrc { | |
| 3646 | Stage1ZirInst base; | |
| 3647 | 3647 | }; |
| 3648 | 3648 | |
| 3649 | struct IrInstSrcSlice { | |
| 3650 | IrInstSrc base; | |
| 3649 | struct Stage1ZirInstSlice { | |
| 3650 | Stage1ZirInst base; | |
| 3651 | 3651 | |
| 3652 | IrInstSrc *ptr; | |
| 3653 | IrInstSrc *start; | |
| 3654 | IrInstSrc *end; | |
| 3655 | IrInstSrc *sentinel; | |
| 3652 | Stage1ZirInst *ptr; | |
| 3653 | Stage1ZirInst *start; | |
| 3654 | Stage1ZirInst *end; | |
| 3655 | Stage1ZirInst *sentinel; | |
| 3656 | 3656 | ResultLoc *result_loc; |
| 3657 | 3657 | bool safety_check_on; |
| 3658 | 3658 | }; |
| 3659 | 3659 | |
| 3660 | struct IrInstGenSlice { | |
| 3661 | IrInstGen base; | |
| 3660 | struct Stage1AirInstSlice { | |
| 3661 | Stage1AirInst base; | |
| 3662 | 3662 | |
| 3663 | IrInstGen *ptr; | |
| 3664 | IrInstGen *start; | |
| 3665 | IrInstGen *end; | |
| 3666 | IrInstGen *result_loc; | |
| 3663 | Stage1AirInst *ptr; | |
| 3664 | Stage1AirInst *start; | |
| 3665 | Stage1AirInst *end; | |
| 3666 | Stage1AirInst *result_loc; | |
| 3667 | 3667 | ZigValue *sentinel; |
| 3668 | 3668 | bool safety_check_on; |
| 3669 | 3669 | }; |
| 3670 | 3670 | |
| 3671 | struct IrInstSrcBreakpoint { | |
| 3672 | IrInstSrc base; | |
| 3671 | struct Stage1ZirInstBreakpoint { | |
| 3672 | Stage1ZirInst base; | |
| 3673 | 3673 | }; |
| 3674 | 3674 | |
| 3675 | struct IrInstGenBreakpoint { | |
| 3676 | IrInstGen base; | |
| 3675 | struct Stage1AirInstBreakpoint { | |
| 3676 | Stage1AirInst base; | |
| 3677 | 3677 | }; |
| 3678 | 3678 | |
| 3679 | struct IrInstSrcReturnAddress { | |
| 3680 | IrInstSrc base; | |
| 3679 | struct Stage1ZirInstReturnAddress { | |
| 3680 | Stage1ZirInst base; | |
| 3681 | 3681 | }; |
| 3682 | 3682 | |
| 3683 | struct IrInstGenReturnAddress { | |
| 3684 | IrInstGen base; | |
| 3683 | struct Stage1AirInstReturnAddress { | |
| 3684 | Stage1AirInst base; | |
| 3685 | 3685 | }; |
| 3686 | 3686 | |
| 3687 | struct IrInstSrcFrameAddress { | |
| 3688 | IrInstSrc base; | |
| 3687 | struct Stage1ZirInstFrameAddress { | |
| 3688 | Stage1ZirInst base; | |
| 3689 | 3689 | }; |
| 3690 | 3690 | |
| 3691 | struct IrInstGenFrameAddress { | |
| 3692 | IrInstGen base; | |
| 3691 | struct Stage1AirInstFrameAddress { | |
| 3692 | Stage1AirInst base; | |
| 3693 | 3693 | }; |
| 3694 | 3694 | |
| 3695 | struct IrInstSrcFrameHandle { | |
| 3696 | IrInstSrc base; | |
| 3695 | struct Stage1ZirInstFrameHandle { | |
| 3696 | Stage1ZirInst base; | |
| 3697 | 3697 | }; |
| 3698 | 3698 | |
| 3699 | struct IrInstGenFrameHandle { | |
| 3700 | IrInstGen base; | |
| 3699 | struct Stage1AirInstFrameHandle { | |
| 3700 | Stage1AirInst base; | |
| 3701 | 3701 | }; |
| 3702 | 3702 | |
| 3703 | struct IrInstSrcFrameType { | |
| 3704 | IrInstSrc base; | |
| 3703 | struct Stage1ZirInstFrameType { | |
| 3704 | Stage1ZirInst base; | |
| 3705 | 3705 | |
| 3706 | IrInstSrc *fn; | |
| 3706 | Stage1ZirInst *fn; | |
| 3707 | 3707 | }; |
| 3708 | 3708 | |
| 3709 | struct IrInstSrcFrameSize { | |
| 3710 | IrInstSrc base; | |
| 3709 | struct Stage1ZirInstFrameSize { | |
| 3710 | Stage1ZirInst base; | |
| 3711 | 3711 | |
| 3712 | IrInstSrc *fn; | |
| 3712 | Stage1ZirInst *fn; | |
| 3713 | 3713 | }; |
| 3714 | 3714 | |
| 3715 | struct IrInstGenFrameSize { | |
| 3716 | IrInstGen base; | |
| 3715 | struct Stage1AirInstFrameSize { | |
| 3716 | Stage1AirInst base; | |
| 3717 | 3717 | |
| 3718 | IrInstGen *fn; | |
| 3718 | Stage1AirInst *fn; | |
| 3719 | 3719 | }; |
| 3720 | 3720 | |
| 3721 | 3721 | enum IrOverflowOp { |
| ... | ... | @@ -3725,397 +3725,397 @@ enum IrOverflowOp { |
| 3725 | 3725 | IrOverflowOpShl, |
| 3726 | 3726 | }; |
| 3727 | 3727 | |
| 3728 | struct IrInstSrcOverflowOp { | |
| 3729 | IrInstSrc base; | |
| 3728 | struct Stage1ZirInstOverflowOp { | |
| 3729 | Stage1ZirInst base; | |
| 3730 | 3730 | |
| 3731 | 3731 | IrOverflowOp op; |
| 3732 | IrInstSrc *type_value; | |
| 3733 | IrInstSrc *op1; | |
| 3734 | IrInstSrc *op2; | |
| 3735 | IrInstSrc *result_ptr; | |
| 3732 | Stage1ZirInst *type_value; | |
| 3733 | Stage1ZirInst *op1; | |
| 3734 | Stage1ZirInst *op2; | |
| 3735 | Stage1ZirInst *result_ptr; | |
| 3736 | 3736 | }; |
| 3737 | 3737 | |
| 3738 | struct IrInstGenOverflowOp { | |
| 3739 | IrInstGen base; | |
| 3738 | struct Stage1AirInstOverflowOp { | |
| 3739 | Stage1AirInst base; | |
| 3740 | 3740 | |
| 3741 | 3741 | IrOverflowOp op; |
| 3742 | IrInstGen *op1; | |
| 3743 | IrInstGen *op2; | |
| 3744 | IrInstGen *result_ptr; | |
| 3742 | Stage1AirInst *op1; | |
| 3743 | Stage1AirInst *op2; | |
| 3744 | Stage1AirInst *result_ptr; | |
| 3745 | 3745 | |
| 3746 | 3746 | // TODO can this field be removed? |
| 3747 | 3747 | ZigType *result_ptr_type; |
| 3748 | 3748 | }; |
| 3749 | 3749 | |
| 3750 | struct IrInstSrcMulAdd { | |
| 3751 | IrInstSrc base; | |
| 3750 | struct Stage1ZirInstMulAdd { | |
| 3751 | Stage1ZirInst base; | |
| 3752 | 3752 | |
| 3753 | IrInstSrc *type_value; | |
| 3754 | IrInstSrc *op1; | |
| 3755 | IrInstSrc *op2; | |
| 3756 | IrInstSrc *op3; | |
| 3753 | Stage1ZirInst *type_value; | |
| 3754 | Stage1ZirInst *op1; | |
| 3755 | Stage1ZirInst *op2; | |
| 3756 | Stage1ZirInst *op3; | |
| 3757 | 3757 | }; |
| 3758 | 3758 | |
| 3759 | struct IrInstGenMulAdd { | |
| 3760 | IrInstGen base; | |
| 3759 | struct Stage1AirInstMulAdd { | |
| 3760 | Stage1AirInst base; | |
| 3761 | 3761 | |
| 3762 | IrInstGen *op1; | |
| 3763 | IrInstGen *op2; | |
| 3764 | IrInstGen *op3; | |
| 3762 | Stage1AirInst *op1; | |
| 3763 | Stage1AirInst *op2; | |
| 3764 | Stage1AirInst *op3; | |
| 3765 | 3765 | }; |
| 3766 | 3766 | |
| 3767 | struct IrInstSrcAlignOf { | |
| 3768 | IrInstSrc base; | |
| 3767 | struct Stage1ZirInstAlignOf { | |
| 3768 | Stage1ZirInst base; | |
| 3769 | 3769 | |
| 3770 | IrInstSrc *type_value; | |
| 3770 | Stage1ZirInst *type_value; | |
| 3771 | 3771 | }; |
| 3772 | 3772 | |
| 3773 | 3773 | // returns true if error, returns false if not error |
| 3774 | struct IrInstSrcTestErr { | |
| 3775 | IrInstSrc base; | |
| 3774 | struct Stage1ZirInstTestErr { | |
| 3775 | Stage1ZirInst base; | |
| 3776 | 3776 | |
| 3777 | IrInstSrc *base_ptr; | |
| 3777 | Stage1ZirInst *base_ptr; | |
| 3778 | 3778 | bool resolve_err_set; |
| 3779 | 3779 | bool base_ptr_is_payload; |
| 3780 | 3780 | }; |
| 3781 | 3781 | |
| 3782 | struct IrInstGenTestErr { | |
| 3783 | IrInstGen base; | |
| 3782 | struct Stage1AirInstTestErr { | |
| 3783 | Stage1AirInst base; | |
| 3784 | 3784 | |
| 3785 | IrInstGen *err_union; | |
| 3785 | Stage1AirInst *err_union; | |
| 3786 | 3786 | }; |
| 3787 | 3787 | |
| 3788 | 3788 | // Takes an error union pointer, returns a pointer to the error code. |
| 3789 | struct IrInstSrcUnwrapErrCode { | |
| 3790 | IrInstSrc base; | |
| 3789 | struct Stage1ZirInstUnwrapErrCode { | |
| 3790 | Stage1ZirInst base; | |
| 3791 | 3791 | |
| 3792 | IrInstSrc *err_union_ptr; | |
| 3792 | Stage1ZirInst *err_union_ptr; | |
| 3793 | 3793 | bool initializing; |
| 3794 | 3794 | }; |
| 3795 | 3795 | |
| 3796 | struct IrInstGenUnwrapErrCode { | |
| 3797 | IrInstGen base; | |
| 3796 | struct Stage1AirInstUnwrapErrCode { | |
| 3797 | Stage1AirInst base; | |
| 3798 | 3798 | |
| 3799 | IrInstGen *err_union_ptr; | |
| 3799 | Stage1AirInst *err_union_ptr; | |
| 3800 | 3800 | bool initializing; |
| 3801 | 3801 | }; |
| 3802 | 3802 | |
| 3803 | struct IrInstSrcUnwrapErrPayload { | |
| 3804 | IrInstSrc base; | |
| 3803 | struct Stage1ZirInstUnwrapErrPayload { | |
| 3804 | Stage1ZirInst base; | |
| 3805 | 3805 | |
| 3806 | IrInstSrc *value; | |
| 3806 | Stage1ZirInst *value; | |
| 3807 | 3807 | bool safety_check_on; |
| 3808 | 3808 | bool initializing; |
| 3809 | 3809 | }; |
| 3810 | 3810 | |
| 3811 | struct IrInstGenUnwrapErrPayload { | |
| 3812 | IrInstGen base; | |
| 3811 | struct Stage1AirInstUnwrapErrPayload { | |
| 3812 | Stage1AirInst base; | |
| 3813 | 3813 | |
| 3814 | IrInstGen *value; | |
| 3814 | Stage1AirInst *value; | |
| 3815 | 3815 | bool safety_check_on; |
| 3816 | 3816 | bool initializing; |
| 3817 | 3817 | }; |
| 3818 | 3818 | |
| 3819 | struct IrInstGenOptionalWrap { | |
| 3820 | IrInstGen base; | |
| 3819 | struct Stage1AirInstOptionalWrap { | |
| 3820 | Stage1AirInst base; | |
| 3821 | 3821 | |
| 3822 | IrInstGen *operand; | |
| 3823 | IrInstGen *result_loc; | |
| 3822 | Stage1AirInst *operand; | |
| 3823 | Stage1AirInst *result_loc; | |
| 3824 | 3824 | }; |
| 3825 | 3825 | |
| 3826 | struct IrInstGenErrWrapPayload { | |
| 3827 | IrInstGen base; | |
| 3826 | struct Stage1AirInstErrWrapPayload { | |
| 3827 | Stage1AirInst base; | |
| 3828 | 3828 | |
| 3829 | IrInstGen *operand; | |
| 3830 | IrInstGen *result_loc; | |
| 3829 | Stage1AirInst *operand; | |
| 3830 | Stage1AirInst *result_loc; | |
| 3831 | 3831 | }; |
| 3832 | 3832 | |
| 3833 | struct IrInstGenErrWrapCode { | |
| 3834 | IrInstGen base; | |
| 3833 | struct Stage1AirInstErrWrapCode { | |
| 3834 | Stage1AirInst base; | |
| 3835 | 3835 | |
| 3836 | IrInstGen *operand; | |
| 3837 | IrInstGen *result_loc; | |
| 3836 | Stage1AirInst *operand; | |
| 3837 | Stage1AirInst *result_loc; | |
| 3838 | 3838 | }; |
| 3839 | 3839 | |
| 3840 | struct IrInstSrcFnProto { | |
| 3841 | IrInstSrc base; | |
| 3840 | struct Stage1ZirInstFnProto { | |
| 3841 | Stage1ZirInst base; | |
| 3842 | 3842 | |
| 3843 | IrInstSrc **param_types; | |
| 3844 | IrInstSrc *align_value; | |
| 3845 | IrInstSrc *callconv_value; | |
| 3846 | IrInstSrc *return_type; | |
| 3843 | Stage1ZirInst **param_types; | |
| 3844 | Stage1ZirInst *align_value; | |
| 3845 | Stage1ZirInst *callconv_value; | |
| 3846 | Stage1ZirInst *return_type; | |
| 3847 | 3847 | bool is_var_args; |
| 3848 | 3848 | }; |
| 3849 | 3849 | |
| 3850 | 3850 | // true if the target value is compile time known, false otherwise |
| 3851 | struct IrInstSrcTestComptime { | |
| 3852 | IrInstSrc base; | |
| 3851 | struct Stage1ZirInstTestComptime { | |
| 3852 | Stage1ZirInst base; | |
| 3853 | 3853 | |
| 3854 | IrInstSrc *value; | |
| 3854 | Stage1ZirInst *value; | |
| 3855 | 3855 | }; |
| 3856 | 3856 | |
| 3857 | struct IrInstSrcPtrCast { | |
| 3858 | IrInstSrc base; | |
| 3857 | struct Stage1ZirInstPtrCast { | |
| 3858 | Stage1ZirInst base; | |
| 3859 | 3859 | |
| 3860 | IrInstSrc *dest_type; | |
| 3861 | IrInstSrc *ptr; | |
| 3860 | Stage1ZirInst *dest_type; | |
| 3861 | Stage1ZirInst *ptr; | |
| 3862 | 3862 | bool safety_check_on; |
| 3863 | 3863 | }; |
| 3864 | 3864 | |
| 3865 | struct IrInstGenPtrCast { | |
| 3866 | IrInstGen base; | |
| 3865 | struct Stage1AirInstPtrCast { | |
| 3866 | Stage1AirInst base; | |
| 3867 | 3867 | |
| 3868 | IrInstGen *ptr; | |
| 3868 | Stage1AirInst *ptr; | |
| 3869 | 3869 | bool safety_check_on; |
| 3870 | 3870 | }; |
| 3871 | 3871 | |
| 3872 | struct IrInstSrcImplicitCast { | |
| 3873 | IrInstSrc base; | |
| 3872 | struct Stage1ZirInstImplicitCast { | |
| 3873 | Stage1ZirInst base; | |
| 3874 | 3874 | |
| 3875 | IrInstSrc *operand; | |
| 3875 | Stage1ZirInst *operand; | |
| 3876 | 3876 | ResultLocCast *result_loc_cast; |
| 3877 | 3877 | }; |
| 3878 | 3878 | |
| 3879 | struct IrInstSrcBitCast { | |
| 3880 | IrInstSrc base; | |
| 3879 | struct Stage1ZirInstBitCast { | |
| 3880 | Stage1ZirInst base; | |
| 3881 | 3881 | |
| 3882 | IrInstSrc *operand; | |
| 3882 | Stage1ZirInst *operand; | |
| 3883 | 3883 | ResultLocBitCast *result_loc_bit_cast; |
| 3884 | 3884 | }; |
| 3885 | 3885 | |
| 3886 | struct IrInstGenBitCast { | |
| 3887 | IrInstGen base; | |
| 3886 | struct Stage1AirInstBitCast { | |
| 3887 | Stage1AirInst base; | |
| 3888 | 3888 | |
| 3889 | IrInstGen *operand; | |
| 3889 | Stage1AirInst *operand; | |
| 3890 | 3890 | }; |
| 3891 | 3891 | |
| 3892 | struct IrInstGenWidenOrShorten { | |
| 3893 | IrInstGen base; | |
| 3892 | struct Stage1AirInstWidenOrShorten { | |
| 3893 | Stage1AirInst base; | |
| 3894 | 3894 | |
| 3895 | IrInstGen *target; | |
| 3895 | Stage1AirInst *target; | |
| 3896 | 3896 | }; |
| 3897 | 3897 | |
| 3898 | struct IrInstSrcPtrToInt { | |
| 3899 | IrInstSrc base; | |
| 3898 | struct Stage1ZirInstPtrToInt { | |
| 3899 | Stage1ZirInst base; | |
| 3900 | 3900 | |
| 3901 | IrInstSrc *target; | |
| 3901 | Stage1ZirInst *target; | |
| 3902 | 3902 | }; |
| 3903 | 3903 | |
| 3904 | struct IrInstGenPtrToInt { | |
| 3905 | IrInstGen base; | |
| 3904 | struct Stage1AirInstPtrToInt { | |
| 3905 | Stage1AirInst base; | |
| 3906 | 3906 | |
| 3907 | IrInstGen *target; | |
| 3907 | Stage1AirInst *target; | |
| 3908 | 3908 | }; |
| 3909 | 3909 | |
| 3910 | struct IrInstSrcIntToPtr { | |
| 3911 | IrInstSrc base; | |
| 3910 | struct Stage1ZirInstIntToPtr { | |
| 3911 | Stage1ZirInst base; | |
| 3912 | 3912 | |
| 3913 | IrInstSrc *dest_type; | |
| 3914 | IrInstSrc *target; | |
| 3913 | Stage1ZirInst *dest_type; | |
| 3914 | Stage1ZirInst *target; | |
| 3915 | 3915 | }; |
| 3916 | 3916 | |
| 3917 | struct IrInstGenIntToPtr { | |
| 3918 | IrInstGen base; | |
| 3917 | struct Stage1AirInstIntToPtr { | |
| 3918 | Stage1AirInst base; | |
| 3919 | 3919 | |
| 3920 | IrInstGen *target; | |
| 3920 | Stage1AirInst *target; | |
| 3921 | 3921 | }; |
| 3922 | 3922 | |
| 3923 | struct IrInstSrcIntToEnum { | |
| 3924 | IrInstSrc base; | |
| 3923 | struct Stage1ZirInstIntToEnum { | |
| 3924 | Stage1ZirInst base; | |
| 3925 | 3925 | |
| 3926 | IrInstSrc *dest_type; | |
| 3927 | IrInstSrc *target; | |
| 3926 | Stage1ZirInst *dest_type; | |
| 3927 | Stage1ZirInst *target; | |
| 3928 | 3928 | }; |
| 3929 | 3929 | |
| 3930 | struct IrInstGenIntToEnum { | |
| 3931 | IrInstGen base; | |
| 3930 | struct Stage1AirInstIntToEnum { | |
| 3931 | Stage1AirInst base; | |
| 3932 | 3932 | |
| 3933 | IrInstGen *target; | |
| 3933 | Stage1AirInst *target; | |
| 3934 | 3934 | }; |
| 3935 | 3935 | |
| 3936 | struct IrInstSrcEnumToInt { | |
| 3937 | IrInstSrc base; | |
| 3936 | struct Stage1ZirInstEnumToInt { | |
| 3937 | Stage1ZirInst base; | |
| 3938 | 3938 | |
| 3939 | IrInstSrc *target; | |
| 3939 | Stage1ZirInst *target; | |
| 3940 | 3940 | }; |
| 3941 | 3941 | |
| 3942 | struct IrInstSrcIntToErr { | |
| 3943 | IrInstSrc base; | |
| 3942 | struct Stage1ZirInstIntToErr { | |
| 3943 | Stage1ZirInst base; | |
| 3944 | 3944 | |
| 3945 | IrInstSrc *target; | |
| 3945 | Stage1ZirInst *target; | |
| 3946 | 3946 | }; |
| 3947 | 3947 | |
| 3948 | struct IrInstGenIntToErr { | |
| 3949 | IrInstGen base; | |
| 3948 | struct Stage1AirInstIntToErr { | |
| 3949 | Stage1AirInst base; | |
| 3950 | 3950 | |
| 3951 | IrInstGen *target; | |
| 3951 | Stage1AirInst *target; | |
| 3952 | 3952 | }; |
| 3953 | 3953 | |
| 3954 | struct IrInstSrcErrToInt { | |
| 3955 | IrInstSrc base; | |
| 3954 | struct Stage1ZirInstErrToInt { | |
| 3955 | Stage1ZirInst base; | |
| 3956 | 3956 | |
| 3957 | IrInstSrc *target; | |
| 3957 | Stage1ZirInst *target; | |
| 3958 | 3958 | }; |
| 3959 | 3959 | |
| 3960 | struct IrInstGenErrToInt { | |
| 3961 | IrInstGen base; | |
| 3960 | struct Stage1AirInstErrToInt { | |
| 3961 | Stage1AirInst base; | |
| 3962 | 3962 | |
| 3963 | IrInstGen *target; | |
| 3963 | Stage1AirInst *target; | |
| 3964 | 3964 | }; |
| 3965 | 3965 | |
| 3966 | struct IrInstSrcCheckSwitchProngsRange { | |
| 3967 | IrInstSrc *start; | |
| 3968 | IrInstSrc *end; | |
| 3966 | struct Stage1ZirInstCheckSwitchProngsRange { | |
| 3967 | Stage1ZirInst *start; | |
| 3968 | Stage1ZirInst *end; | |
| 3969 | 3969 | }; |
| 3970 | 3970 | |
| 3971 | struct IrInstSrcCheckSwitchProngs { | |
| 3972 | IrInstSrc base; | |
| 3971 | struct Stage1ZirInstCheckSwitchProngs { | |
| 3972 | Stage1ZirInst base; | |
| 3973 | 3973 | |
| 3974 | IrInstSrc *target_value; | |
| 3975 | IrInstSrcCheckSwitchProngsRange *ranges; | |
| 3974 | Stage1ZirInst *target_value; | |
| 3975 | Stage1ZirInstCheckSwitchProngsRange *ranges; | |
| 3976 | 3976 | size_t range_count; |
| 3977 | 3977 | AstNode* else_prong; |
| 3978 | 3978 | }; |
| 3979 | 3979 | |
| 3980 | struct IrInstSrcCheckStatementIsVoid { | |
| 3981 | IrInstSrc base; | |
| 3980 | struct Stage1ZirInstCheckStatementIsVoid { | |
| 3981 | Stage1ZirInst base; | |
| 3982 | 3982 | |
| 3983 | IrInstSrc *statement_value; | |
| 3983 | Stage1ZirInst *statement_value; | |
| 3984 | 3984 | }; |
| 3985 | 3985 | |
| 3986 | struct IrInstSrcTypeName { | |
| 3987 | IrInstSrc base; | |
| 3986 | struct Stage1ZirInstTypeName { | |
| 3987 | Stage1ZirInst base; | |
| 3988 | 3988 | |
| 3989 | IrInstSrc *type_value; | |
| 3989 | Stage1ZirInst *type_value; | |
| 3990 | 3990 | }; |
| 3991 | 3991 | |
| 3992 | struct IrInstSrcDeclRef { | |
| 3993 | IrInstSrc base; | |
| 3992 | struct Stage1ZirInstDeclRef { | |
| 3993 | Stage1ZirInst base; | |
| 3994 | 3994 | |
| 3995 | 3995 | LVal lval; |
| 3996 | 3996 | Tld *tld; |
| 3997 | 3997 | }; |
| 3998 | 3998 | |
| 3999 | struct IrInstSrcPanic { | |
| 4000 | IrInstSrc base; | |
| 3999 | struct Stage1ZirInstPanic { | |
| 4000 | Stage1ZirInst base; | |
| 4001 | 4001 | |
| 4002 | IrInstSrc *msg; | |
| 4002 | Stage1ZirInst *msg; | |
| 4003 | 4003 | }; |
| 4004 | 4004 | |
| 4005 | struct IrInstGenPanic { | |
| 4006 | IrInstGen base; | |
| 4005 | struct Stage1AirInstPanic { | |
| 4006 | Stage1AirInst base; | |
| 4007 | 4007 | |
| 4008 | IrInstGen *msg; | |
| 4008 | Stage1AirInst *msg; | |
| 4009 | 4009 | }; |
| 4010 | 4010 | |
| 4011 | struct IrInstSrcTagName { | |
| 4012 | IrInstSrc base; | |
| 4011 | struct Stage1ZirInstTagName { | |
| 4012 | Stage1ZirInst base; | |
| 4013 | 4013 | |
| 4014 | IrInstSrc *target; | |
| 4014 | Stage1ZirInst *target; | |
| 4015 | 4015 | }; |
| 4016 | 4016 | |
| 4017 | struct IrInstGenTagName { | |
| 4018 | IrInstGen base; | |
| 4017 | struct Stage1AirInstTagName { | |
| 4018 | Stage1AirInst base; | |
| 4019 | 4019 | |
| 4020 | IrInstGen *target; | |
| 4020 | Stage1AirInst *target; | |
| 4021 | 4021 | }; |
| 4022 | 4022 | |
| 4023 | struct IrInstSrcFieldParentPtr { | |
| 4024 | IrInstSrc base; | |
| 4023 | struct Stage1ZirInstFieldParentPtr { | |
| 4024 | Stage1ZirInst base; | |
| 4025 | 4025 | |
| 4026 | IrInstSrc *type_value; | |
| 4027 | IrInstSrc *field_name; | |
| 4028 | IrInstSrc *field_ptr; | |
| 4026 | Stage1ZirInst *type_value; | |
| 4027 | Stage1ZirInst *field_name; | |
| 4028 | Stage1ZirInst *field_ptr; | |
| 4029 | 4029 | }; |
| 4030 | 4030 | |
| 4031 | struct IrInstGenFieldParentPtr { | |
| 4032 | IrInstGen base; | |
| 4031 | struct Stage1AirInstFieldParentPtr { | |
| 4032 | Stage1AirInst base; | |
| 4033 | 4033 | |
| 4034 | IrInstGen *field_ptr; | |
| 4034 | Stage1AirInst *field_ptr; | |
| 4035 | 4035 | TypeStructField *field; |
| 4036 | 4036 | }; |
| 4037 | 4037 | |
| 4038 | struct IrInstSrcOffsetOf { | |
| 4039 | IrInstSrc base; | |
| 4038 | struct Stage1ZirInstOffsetOf { | |
| 4039 | Stage1ZirInst base; | |
| 4040 | 4040 | |
| 4041 | IrInstSrc *type_value; | |
| 4042 | IrInstSrc *field_name; | |
| 4041 | Stage1ZirInst *type_value; | |
| 4042 | Stage1ZirInst *field_name; | |
| 4043 | 4043 | }; |
| 4044 | 4044 | |
| 4045 | struct IrInstSrcBitOffsetOf { | |
| 4046 | IrInstSrc base; | |
| 4045 | struct Stage1ZirInstBitOffsetOf { | |
| 4046 | Stage1ZirInst base; | |
| 4047 | 4047 | |
| 4048 | IrInstSrc *type_value; | |
| 4049 | IrInstSrc *field_name; | |
| 4048 | Stage1ZirInst *type_value; | |
| 4049 | Stage1ZirInst *field_name; | |
| 4050 | 4050 | }; |
| 4051 | 4051 | |
| 4052 | struct IrInstSrcTypeInfo { | |
| 4053 | IrInstSrc base; | |
| 4052 | struct Stage1ZirInstTypeInfo { | |
| 4053 | Stage1ZirInst base; | |
| 4054 | 4054 | |
| 4055 | IrInstSrc *type_value; | |
| 4055 | Stage1ZirInst *type_value; | |
| 4056 | 4056 | }; |
| 4057 | 4057 | |
| 4058 | struct IrInstSrcType { | |
| 4059 | IrInstSrc base; | |
| 4058 | struct Stage1ZirInstType { | |
| 4059 | Stage1ZirInst base; | |
| 4060 | 4060 | |
| 4061 | IrInstSrc *type_info; | |
| 4061 | Stage1ZirInst *type_info; | |
| 4062 | 4062 | }; |
| 4063 | 4063 | |
| 4064 | struct IrInstSrcHasField { | |
| 4065 | IrInstSrc base; | |
| 4064 | struct Stage1ZirInstHasField { | |
| 4065 | Stage1ZirInst base; | |
| 4066 | 4066 | |
| 4067 | IrInstSrc *container_type; | |
| 4068 | IrInstSrc *field_name; | |
| 4067 | Stage1ZirInst *container_type; | |
| 4068 | Stage1ZirInst *field_name; | |
| 4069 | 4069 | }; |
| 4070 | 4070 | |
| 4071 | struct IrInstSrcSetEvalBranchQuota { | |
| 4072 | IrInstSrc base; | |
| 4071 | struct Stage1ZirInstSetEvalBranchQuota { | |
| 4072 | Stage1ZirInst base; | |
| 4073 | 4073 | |
| 4074 | IrInstSrc *new_quota; | |
| 4074 | Stage1ZirInst *new_quota; | |
| 4075 | 4075 | }; |
| 4076 | 4076 | |
| 4077 | struct IrInstSrcAlignCast { | |
| 4078 | IrInstSrc base; | |
| 4077 | struct Stage1ZirInstAlignCast { | |
| 4078 | Stage1ZirInst base; | |
| 4079 | 4079 | |
| 4080 | IrInstSrc *align_bytes; | |
| 4081 | IrInstSrc *target; | |
| 4080 | Stage1ZirInst *align_bytes; | |
| 4081 | Stage1ZirInst *target; | |
| 4082 | 4082 | }; |
| 4083 | 4083 | |
| 4084 | struct IrInstGenAlignCast { | |
| 4085 | IrInstGen base; | |
| 4084 | struct Stage1AirInstAlignCast { | |
| 4085 | Stage1AirInst base; | |
| 4086 | 4086 | |
| 4087 | IrInstGen *target; | |
| 4087 | Stage1AirInst *target; | |
| 4088 | 4088 | }; |
| 4089 | 4089 | |
| 4090 | struct IrInstSrcSetAlignStack { | |
| 4091 | IrInstSrc base; | |
| 4090 | struct Stage1ZirInstSetAlignStack { | |
| 4091 | Stage1ZirInst base; | |
| 4092 | 4092 | |
| 4093 | IrInstSrc *align_bytes; | |
| 4093 | Stage1ZirInst *align_bytes; | |
| 4094 | 4094 | }; |
| 4095 | 4095 | |
| 4096 | struct IrInstSrcArgType { | |
| 4097 | IrInstSrc base; | |
| 4096 | struct Stage1ZirInstArgType { | |
| 4097 | Stage1ZirInst base; | |
| 4098 | 4098 | |
| 4099 | IrInstSrc *fn_type; | |
| 4100 | IrInstSrc *arg_index; | |
| 4099 | Stage1ZirInst *fn_type; | |
| 4100 | Stage1ZirInst *arg_index; | |
| 4101 | 4101 | }; |
| 4102 | 4102 | |
| 4103 | struct IrInstSrcExport { | |
| 4104 | IrInstSrc base; | |
| 4103 | struct Stage1ZirInstExport { | |
| 4104 | Stage1ZirInst base; | |
| 4105 | 4105 | |
| 4106 | IrInstSrc *target; | |
| 4107 | IrInstSrc *options; | |
| 4106 | Stage1ZirInst *target; | |
| 4107 | Stage1ZirInst *options; | |
| 4108 | 4108 | }; |
| 4109 | 4109 | |
| 4110 | struct IrInstSrcExtern { | |
| 4111 | IrInstSrc base; | |
| 4110 | struct Stage1ZirInstExtern { | |
| 4111 | Stage1ZirInst base; | |
| 4112 | 4112 | |
| 4113 | IrInstSrc *type; | |
| 4114 | IrInstSrc *options; | |
| 4113 | Stage1ZirInst *type; | |
| 4114 | Stage1ZirInst *options; | |
| 4115 | 4115 | }; |
| 4116 | 4116 | |
| 4117 | struct IrInstGenExtern { | |
| 4118 | IrInstGen base; | |
| 4117 | struct Stage1AirInstExtern { | |
| 4118 | Stage1AirInst base; | |
| 4119 | 4119 | |
| 4120 | 4120 | Buf *name; |
| 4121 | 4121 | GlobalLinkageId linkage; |
| ... | ... | @@ -4127,310 +4127,310 @@ enum IrInstErrorReturnTraceOptional { |
| 4127 | 4127 | IrInstErrorReturnTraceNonNull, |
| 4128 | 4128 | }; |
| 4129 | 4129 | |
| 4130 | struct IrInstSrcErrorReturnTrace { | |
| 4131 | IrInstSrc base; | |
| 4130 | struct Stage1ZirInstErrorReturnTrace { | |
| 4131 | Stage1ZirInst base; | |
| 4132 | 4132 | |
| 4133 | 4133 | IrInstErrorReturnTraceOptional optional; |
| 4134 | 4134 | }; |
| 4135 | 4135 | |
| 4136 | struct IrInstGenErrorReturnTrace { | |
| 4137 | IrInstGen base; | |
| 4136 | struct Stage1AirInstErrorReturnTrace { | |
| 4137 | Stage1AirInst base; | |
| 4138 | 4138 | |
| 4139 | 4139 | IrInstErrorReturnTraceOptional optional; |
| 4140 | 4140 | }; |
| 4141 | 4141 | |
| 4142 | struct IrInstSrcErrorUnion { | |
| 4143 | IrInstSrc base; | |
| 4142 | struct Stage1ZirInstErrorUnion { | |
| 4143 | Stage1ZirInst base; | |
| 4144 | 4144 | |
| 4145 | IrInstSrc *err_set; | |
| 4146 | IrInstSrc *payload; | |
| 4145 | Stage1ZirInst *err_set; | |
| 4146 | Stage1ZirInst *payload; | |
| 4147 | 4147 | Buf *type_name; |
| 4148 | 4148 | }; |
| 4149 | 4149 | |
| 4150 | struct IrInstSrcAtomicRmw { | |
| 4151 | IrInstSrc base; | |
| 4150 | struct Stage1ZirInstAtomicRmw { | |
| 4151 | Stage1ZirInst base; | |
| 4152 | 4152 | |
| 4153 | IrInstSrc *operand_type; | |
| 4154 | IrInstSrc *ptr; | |
| 4155 | IrInstSrc *op; | |
| 4156 | IrInstSrc *operand; | |
| 4157 | IrInstSrc *ordering; | |
| 4153 | Stage1ZirInst *operand_type; | |
| 4154 | Stage1ZirInst *ptr; | |
| 4155 | Stage1ZirInst *op; | |
| 4156 | Stage1ZirInst *operand; | |
| 4157 | Stage1ZirInst *ordering; | |
| 4158 | 4158 | }; |
| 4159 | 4159 | |
| 4160 | struct IrInstGenAtomicRmw { | |
| 4161 | IrInstGen base; | |
| 4160 | struct Stage1AirInstAtomicRmw { | |
| 4161 | Stage1AirInst base; | |
| 4162 | 4162 | |
| 4163 | IrInstGen *ptr; | |
| 4164 | IrInstGen *operand; | |
| 4163 | Stage1AirInst *ptr; | |
| 4164 | Stage1AirInst *operand; | |
| 4165 | 4165 | AtomicRmwOp op; |
| 4166 | 4166 | AtomicOrder ordering; |
| 4167 | 4167 | }; |
| 4168 | 4168 | |
| 4169 | struct IrInstSrcAtomicLoad { | |
| 4170 | IrInstSrc base; | |
| 4169 | struct Stage1ZirInstAtomicLoad { | |
| 4170 | Stage1ZirInst base; | |
| 4171 | 4171 | |
| 4172 | IrInstSrc *operand_type; | |
| 4173 | IrInstSrc *ptr; | |
| 4174 | IrInstSrc *ordering; | |
| 4172 | Stage1ZirInst *operand_type; | |
| 4173 | Stage1ZirInst *ptr; | |
| 4174 | Stage1ZirInst *ordering; | |
| 4175 | 4175 | }; |
| 4176 | 4176 | |
| 4177 | struct IrInstGenAtomicLoad { | |
| 4178 | IrInstGen base; | |
| 4177 | struct Stage1AirInstAtomicLoad { | |
| 4178 | Stage1AirInst base; | |
| 4179 | 4179 | |
| 4180 | IrInstGen *ptr; | |
| 4180 | Stage1AirInst *ptr; | |
| 4181 | 4181 | AtomicOrder ordering; |
| 4182 | 4182 | }; |
| 4183 | 4183 | |
| 4184 | struct IrInstSrcAtomicStore { | |
| 4185 | IrInstSrc base; | |
| 4184 | struct Stage1ZirInstAtomicStore { | |
| 4185 | Stage1ZirInst base; | |
| 4186 | 4186 | |
| 4187 | IrInstSrc *operand_type; | |
| 4188 | IrInstSrc *ptr; | |
| 4189 | IrInstSrc *value; | |
| 4190 | IrInstSrc *ordering; | |
| 4187 | Stage1ZirInst *operand_type; | |
| 4188 | Stage1ZirInst *ptr; | |
| 4189 | Stage1ZirInst *value; | |
| 4190 | Stage1ZirInst *ordering; | |
| 4191 | 4191 | }; |
| 4192 | 4192 | |
| 4193 | struct IrInstGenAtomicStore { | |
| 4194 | IrInstGen base; | |
| 4193 | struct Stage1AirInstAtomicStore { | |
| 4194 | Stage1AirInst base; | |
| 4195 | 4195 | |
| 4196 | IrInstGen *ptr; | |
| 4197 | IrInstGen *value; | |
| 4196 | Stage1AirInst *ptr; | |
| 4197 | Stage1AirInst *value; | |
| 4198 | 4198 | AtomicOrder ordering; |
| 4199 | 4199 | }; |
| 4200 | 4200 | |
| 4201 | struct IrInstSrcSaveErrRetAddr { | |
| 4202 | IrInstSrc base; | |
| 4201 | struct Stage1ZirInstSaveErrRetAddr { | |
| 4202 | Stage1ZirInst base; | |
| 4203 | 4203 | }; |
| 4204 | 4204 | |
| 4205 | struct IrInstGenSaveErrRetAddr { | |
| 4206 | IrInstGen base; | |
| 4205 | struct Stage1AirInstSaveErrRetAddr { | |
| 4206 | Stage1AirInst base; | |
| 4207 | 4207 | }; |
| 4208 | 4208 | |
| 4209 | struct IrInstSrcAddImplicitReturnType { | |
| 4210 | IrInstSrc base; | |
| 4209 | struct Stage1ZirInstAddImplicitReturnType { | |
| 4210 | Stage1ZirInst base; | |
| 4211 | 4211 | |
| 4212 | IrInstSrc *value; | |
| 4212 | Stage1ZirInst *value; | |
| 4213 | 4213 | ResultLocReturn *result_loc_ret; |
| 4214 | 4214 | }; |
| 4215 | 4215 | |
| 4216 | 4216 | // For float ops that take a single argument |
| 4217 | struct IrInstSrcFloatOp { | |
| 4218 | IrInstSrc base; | |
| 4217 | struct Stage1ZirInstFloatOp { | |
| 4218 | Stage1ZirInst base; | |
| 4219 | 4219 | |
| 4220 | IrInstSrc *operand; | |
| 4220 | Stage1ZirInst *operand; | |
| 4221 | 4221 | BuiltinFnId fn_id; |
| 4222 | 4222 | }; |
| 4223 | 4223 | |
| 4224 | struct IrInstGenFloatOp { | |
| 4225 | IrInstGen base; | |
| 4224 | struct Stage1AirInstFloatOp { | |
| 4225 | Stage1AirInst base; | |
| 4226 | 4226 | |
| 4227 | IrInstGen *operand; | |
| 4227 | Stage1AirInst *operand; | |
| 4228 | 4228 | BuiltinFnId fn_id; |
| 4229 | 4229 | }; |
| 4230 | 4230 | |
| 4231 | struct IrInstSrcCheckRuntimeScope { | |
| 4232 | IrInstSrc base; | |
| 4231 | struct Stage1ZirInstCheckRuntimeScope { | |
| 4232 | Stage1ZirInst base; | |
| 4233 | 4233 | |
| 4234 | IrInstSrc *scope_is_comptime; | |
| 4235 | IrInstSrc *is_comptime; | |
| 4234 | Stage1ZirInst *scope_is_comptime; | |
| 4235 | Stage1ZirInst *is_comptime; | |
| 4236 | 4236 | }; |
| 4237 | 4237 | |
| 4238 | struct IrInstSrcBswap { | |
| 4239 | IrInstSrc base; | |
| 4238 | struct Stage1ZirInstBswap { | |
| 4239 | Stage1ZirInst base; | |
| 4240 | 4240 | |
| 4241 | IrInstSrc *type; | |
| 4242 | IrInstSrc *op; | |
| 4241 | Stage1ZirInst *type; | |
| 4242 | Stage1ZirInst *op; | |
| 4243 | 4243 | }; |
| 4244 | 4244 | |
| 4245 | struct IrInstGenBswap { | |
| 4246 | IrInstGen base; | |
| 4245 | struct Stage1AirInstBswap { | |
| 4246 | Stage1AirInst base; | |
| 4247 | 4247 | |
| 4248 | IrInstGen *op; | |
| 4248 | Stage1AirInst *op; | |
| 4249 | 4249 | }; |
| 4250 | 4250 | |
| 4251 | struct IrInstSrcBitReverse { | |
| 4252 | IrInstSrc base; | |
| 4251 | struct Stage1ZirInstBitReverse { | |
| 4252 | Stage1ZirInst base; | |
| 4253 | 4253 | |
| 4254 | IrInstSrc *type; | |
| 4255 | IrInstSrc *op; | |
| 4254 | Stage1ZirInst *type; | |
| 4255 | Stage1ZirInst *op; | |
| 4256 | 4256 | }; |
| 4257 | 4257 | |
| 4258 | struct IrInstGenBitReverse { | |
| 4259 | IrInstGen base; | |
| 4258 | struct Stage1AirInstBitReverse { | |
| 4259 | Stage1AirInst base; | |
| 4260 | 4260 | |
| 4261 | IrInstGen *op; | |
| 4261 | Stage1AirInst *op; | |
| 4262 | 4262 | }; |
| 4263 | 4263 | |
| 4264 | struct IrInstGenArrayToVector { | |
| 4265 | IrInstGen base; | |
| 4264 | struct Stage1AirInstArrayToVector { | |
| 4265 | Stage1AirInst base; | |
| 4266 | 4266 | |
| 4267 | IrInstGen *array; | |
| 4267 | Stage1AirInst *array; | |
| 4268 | 4268 | }; |
| 4269 | 4269 | |
| 4270 | struct IrInstGenVectorToArray { | |
| 4271 | IrInstGen base; | |
| 4270 | struct Stage1AirInstVectorToArray { | |
| 4271 | Stage1AirInst base; | |
| 4272 | 4272 | |
| 4273 | IrInstGen *vector; | |
| 4274 | IrInstGen *result_loc; | |
| 4273 | Stage1AirInst *vector; | |
| 4274 | Stage1AirInst *result_loc; | |
| 4275 | 4275 | }; |
| 4276 | 4276 | |
| 4277 | struct IrInstSrcShuffleVector { | |
| 4278 | IrInstSrc base; | |
| 4277 | struct Stage1ZirInstShuffleVector { | |
| 4278 | Stage1ZirInst base; | |
| 4279 | 4279 | |
| 4280 | IrInstSrc *scalar_type; | |
| 4281 | IrInstSrc *a; | |
| 4282 | IrInstSrc *b; | |
| 4283 | IrInstSrc *mask; // This is in zig-format, not llvm format | |
| 4280 | Stage1ZirInst *scalar_type; | |
| 4281 | Stage1ZirInst *a; | |
| 4282 | Stage1ZirInst *b; | |
| 4283 | Stage1ZirInst *mask; // This is in zig-format, not llvm format | |
| 4284 | 4284 | }; |
| 4285 | 4285 | |
| 4286 | struct IrInstGenShuffleVector { | |
| 4287 | IrInstGen base; | |
| 4286 | struct Stage1AirInstShuffleVector { | |
| 4287 | Stage1AirInst base; | |
| 4288 | 4288 | |
| 4289 | IrInstGen *a; | |
| 4290 | IrInstGen *b; | |
| 4291 | IrInstGen *mask; // This is in zig-format, not llvm format | |
| 4289 | Stage1AirInst *a; | |
| 4290 | Stage1AirInst *b; | |
| 4291 | Stage1AirInst *mask; // This is in zig-format, not llvm format | |
| 4292 | 4292 | }; |
| 4293 | 4293 | |
| 4294 | struct IrInstSrcSplat { | |
| 4295 | IrInstSrc base; | |
| 4294 | struct Stage1ZirInstSplat { | |
| 4295 | Stage1ZirInst base; | |
| 4296 | 4296 | |
| 4297 | IrInstSrc *len; | |
| 4298 | IrInstSrc *scalar; | |
| 4297 | Stage1ZirInst *len; | |
| 4298 | Stage1ZirInst *scalar; | |
| 4299 | 4299 | }; |
| 4300 | 4300 | |
| 4301 | struct IrInstGenSplat { | |
| 4302 | IrInstGen base; | |
| 4301 | struct Stage1AirInstSplat { | |
| 4302 | Stage1AirInst base; | |
| 4303 | 4303 | |
| 4304 | IrInstGen *scalar; | |
| 4304 | Stage1AirInst *scalar; | |
| 4305 | 4305 | }; |
| 4306 | 4306 | |
| 4307 | struct IrInstGenAssertZero { | |
| 4308 | IrInstGen base; | |
| 4307 | struct Stage1AirInstAssertZero { | |
| 4308 | Stage1AirInst base; | |
| 4309 | 4309 | |
| 4310 | IrInstGen *target; | |
| 4310 | Stage1AirInst *target; | |
| 4311 | 4311 | }; |
| 4312 | 4312 | |
| 4313 | struct IrInstGenAssertNonNull { | |
| 4314 | IrInstGen base; | |
| 4313 | struct Stage1AirInstAssertNonNull { | |
| 4314 | Stage1AirInst base; | |
| 4315 | 4315 | |
| 4316 | IrInstGen *target; | |
| 4316 | Stage1AirInst *target; | |
| 4317 | 4317 | }; |
| 4318 | 4318 | |
| 4319 | struct IrInstSrcUnionInitNamedField { | |
| 4320 | IrInstSrc base; | |
| 4319 | struct Stage1ZirInstUnionInitNamedField { | |
| 4320 | Stage1ZirInst base; | |
| 4321 | 4321 | |
| 4322 | IrInstSrc *union_type; | |
| 4323 | IrInstSrc *field_name; | |
| 4324 | IrInstSrc *field_result_loc; | |
| 4325 | IrInstSrc *result_loc; | |
| 4322 | Stage1ZirInst *union_type; | |
| 4323 | Stage1ZirInst *field_name; | |
| 4324 | Stage1ZirInst *field_result_loc; | |
| 4325 | Stage1ZirInst *result_loc; | |
| 4326 | 4326 | }; |
| 4327 | 4327 | |
| 4328 | struct IrInstSrcHasDecl { | |
| 4329 | IrInstSrc base; | |
| 4328 | struct Stage1ZirInstHasDecl { | |
| 4329 | Stage1ZirInst base; | |
| 4330 | 4330 | |
| 4331 | IrInstSrc *container; | |
| 4332 | IrInstSrc *name; | |
| 4331 | Stage1ZirInst *container; | |
| 4332 | Stage1ZirInst *name; | |
| 4333 | 4333 | }; |
| 4334 | 4334 | |
| 4335 | struct IrInstSrcUndeclaredIdent { | |
| 4336 | IrInstSrc base; | |
| 4335 | struct Stage1ZirInstUndeclaredIdent { | |
| 4336 | Stage1ZirInst base; | |
| 4337 | 4337 | |
| 4338 | 4338 | Buf *name; |
| 4339 | 4339 | }; |
| 4340 | 4340 | |
| 4341 | struct IrInstSrcAlloca { | |
| 4342 | IrInstSrc base; | |
| 4341 | struct Stage1ZirInstAlloca { | |
| 4342 | Stage1ZirInst base; | |
| 4343 | 4343 | |
| 4344 | IrInstSrc *align; | |
| 4345 | IrInstSrc *is_comptime; | |
| 4344 | Stage1ZirInst *align; | |
| 4345 | Stage1ZirInst *is_comptime; | |
| 4346 | 4346 | const char *name_hint; |
| 4347 | 4347 | }; |
| 4348 | 4348 | |
| 4349 | struct IrInstGenAlloca { | |
| 4350 | IrInstGen base; | |
| 4349 | struct Stage1AirInstAlloca { | |
| 4350 | Stage1AirInst base; | |
| 4351 | 4351 | |
| 4352 | 4352 | uint32_t align; |
| 4353 | 4353 | const char *name_hint; |
| 4354 | 4354 | size_t field_index; |
| 4355 | 4355 | }; |
| 4356 | 4356 | |
| 4357 | struct IrInstSrcEndExpr { | |
| 4358 | IrInstSrc base; | |
| 4357 | struct Stage1ZirInstEndExpr { | |
| 4358 | Stage1ZirInst base; | |
| 4359 | 4359 | |
| 4360 | IrInstSrc *value; | |
| 4360 | Stage1ZirInst *value; | |
| 4361 | 4361 | ResultLoc *result_loc; |
| 4362 | 4362 | }; |
| 4363 | 4363 | |
| 4364 | 4364 | // This one is for writing through the result pointer. |
| 4365 | struct IrInstSrcResolveResult { | |
| 4366 | IrInstSrc base; | |
| 4365 | struct Stage1ZirInstResolveResult { | |
| 4366 | Stage1ZirInst base; | |
| 4367 | 4367 | |
| 4368 | 4368 | ResultLoc *result_loc; |
| 4369 | IrInstSrc *ty; | |
| 4369 | Stage1ZirInst *ty; | |
| 4370 | 4370 | }; |
| 4371 | 4371 | |
| 4372 | struct IrInstSrcResetResult { | |
| 4373 | IrInstSrc base; | |
| 4372 | struct Stage1ZirInstResetResult { | |
| 4373 | Stage1ZirInst base; | |
| 4374 | 4374 | |
| 4375 | 4375 | ResultLoc *result_loc; |
| 4376 | 4376 | }; |
| 4377 | 4377 | |
| 4378 | struct IrInstGenPtrOfArrayToSlice { | |
| 4379 | IrInstGen base; | |
| 4378 | struct Stage1AirInstPtrOfArrayToSlice { | |
| 4379 | Stage1AirInst base; | |
| 4380 | 4380 | |
| 4381 | IrInstGen *operand; | |
| 4382 | IrInstGen *result_loc; | |
| 4381 | Stage1AirInst *operand; | |
| 4382 | Stage1AirInst *result_loc; | |
| 4383 | 4383 | }; |
| 4384 | 4384 | |
| 4385 | struct IrInstSrcSuspendBegin { | |
| 4386 | IrInstSrc base; | |
| 4385 | struct Stage1ZirInstSuspendBegin { | |
| 4386 | Stage1ZirInst base; | |
| 4387 | 4387 | }; |
| 4388 | 4388 | |
| 4389 | struct IrInstGenSuspendBegin { | |
| 4390 | IrInstGen base; | |
| 4389 | struct Stage1AirInstSuspendBegin { | |
| 4390 | Stage1AirInst base; | |
| 4391 | 4391 | |
| 4392 | 4392 | LLVMBasicBlockRef resume_bb; |
| 4393 | 4393 | }; |
| 4394 | 4394 | |
| 4395 | struct IrInstSrcSuspendFinish { | |
| 4396 | IrInstSrc base; | |
| 4395 | struct Stage1ZirInstSuspendFinish { | |
| 4396 | Stage1ZirInst base; | |
| 4397 | 4397 | |
| 4398 | IrInstSrcSuspendBegin *begin; | |
| 4398 | Stage1ZirInstSuspendBegin *begin; | |
| 4399 | 4399 | }; |
| 4400 | 4400 | |
| 4401 | struct IrInstGenSuspendFinish { | |
| 4402 | IrInstGen base; | |
| 4401 | struct Stage1AirInstSuspendFinish { | |
| 4402 | Stage1AirInst base; | |
| 4403 | 4403 | |
| 4404 | IrInstGenSuspendBegin *begin; | |
| 4404 | Stage1AirInstSuspendBegin *begin; | |
| 4405 | 4405 | }; |
| 4406 | 4406 | |
| 4407 | struct IrInstSrcAwait { | |
| 4408 | IrInstSrc base; | |
| 4407 | struct Stage1ZirInstAwait { | |
| 4408 | Stage1ZirInst base; | |
| 4409 | 4409 | |
| 4410 | IrInstSrc *frame; | |
| 4410 | Stage1ZirInst *frame; | |
| 4411 | 4411 | ResultLoc *result_loc; |
| 4412 | 4412 | bool is_nosuspend; |
| 4413 | 4413 | }; |
| 4414 | 4414 | |
| 4415 | struct IrInstGenAwait { | |
| 4416 | IrInstGen base; | |
| 4415 | struct Stage1AirInstAwait { | |
| 4416 | Stage1AirInst base; | |
| 4417 | 4417 | |
| 4418 | IrInstGen *frame; | |
| 4419 | IrInstGen *result_loc; | |
| 4418 | Stage1AirInst *frame; | |
| 4419 | Stage1AirInst *result_loc; | |
| 4420 | 4420 | ZigFn *target_fn; |
| 4421 | 4421 | bool is_nosuspend; |
| 4422 | 4422 | }; |
| 4423 | 4423 | |
| 4424 | struct IrInstSrcResume { | |
| 4425 | IrInstSrc base; | |
| 4424 | struct Stage1ZirInstResume { | |
| 4425 | Stage1ZirInst base; | |
| 4426 | 4426 | |
| 4427 | IrInstSrc *frame; | |
| 4427 | Stage1ZirInst *frame; | |
| 4428 | 4428 | }; |
| 4429 | 4429 | |
| 4430 | struct IrInstGenResume { | |
| 4431 | IrInstGen base; | |
| 4430 | struct Stage1AirInstResume { | |
| 4431 | Stage1AirInst base; | |
| 4432 | 4432 | |
| 4433 | IrInstGen *frame; | |
| 4433 | Stage1AirInst *frame; | |
| 4434 | 4434 | }; |
| 4435 | 4435 | |
| 4436 | 4436 | enum SpillId { |
| ... | ... | @@ -4438,37 +4438,37 @@ enum SpillId { |
| 4438 | 4438 | SpillIdRetErrCode, |
| 4439 | 4439 | }; |
| 4440 | 4440 | |
| 4441 | struct IrInstSrcSpillBegin { | |
| 4442 | IrInstSrc base; | |
| 4441 | struct Stage1ZirInstSpillBegin { | |
| 4442 | Stage1ZirInst base; | |
| 4443 | 4443 | |
| 4444 | IrInstSrc *operand; | |
| 4444 | Stage1ZirInst *operand; | |
| 4445 | 4445 | SpillId spill_id; |
| 4446 | 4446 | }; |
| 4447 | 4447 | |
| 4448 | struct IrInstGenSpillBegin { | |
| 4449 | IrInstGen base; | |
| 4448 | struct Stage1AirInstSpillBegin { | |
| 4449 | Stage1AirInst base; | |
| 4450 | 4450 | |
| 4451 | 4451 | SpillId spill_id; |
| 4452 | IrInstGen *operand; | |
| 4452 | Stage1AirInst *operand; | |
| 4453 | 4453 | }; |
| 4454 | 4454 | |
| 4455 | struct IrInstSrcSpillEnd { | |
| 4456 | IrInstSrc base; | |
| 4455 | struct Stage1ZirInstSpillEnd { | |
| 4456 | Stage1ZirInst base; | |
| 4457 | 4457 | |
| 4458 | IrInstSrcSpillBegin *begin; | |
| 4458 | Stage1ZirInstSpillBegin *begin; | |
| 4459 | 4459 | }; |
| 4460 | 4460 | |
| 4461 | struct IrInstGenSpillEnd { | |
| 4462 | IrInstGen base; | |
| 4461 | struct Stage1AirInstSpillEnd { | |
| 4462 | Stage1AirInst base; | |
| 4463 | 4463 | |
| 4464 | IrInstGenSpillBegin *begin; | |
| 4464 | Stage1AirInstSpillBegin *begin; | |
| 4465 | 4465 | }; |
| 4466 | 4466 | |
| 4467 | struct IrInstGenVectorExtractElem { | |
| 4468 | IrInstGen base; | |
| 4467 | struct Stage1AirInstVectorExtractElem { | |
| 4468 | Stage1AirInst base; | |
| 4469 | 4469 | |
| 4470 | IrInstGen *vector; | |
| 4471 | IrInstGen *index; | |
| 4470 | Stage1AirInst *vector; | |
| 4471 | Stage1AirInst *index; | |
| 4472 | 4472 | }; |
| 4473 | 4473 | |
| 4474 | 4474 | enum ResultLocId { |
| ... | ... | @@ -4489,9 +4489,9 @@ struct ResultLoc { |
| 4489 | 4489 | ResultLocId id; |
| 4490 | 4490 | bool written; |
| 4491 | 4491 | bool allow_write_through_const; |
| 4492 | IrInstGen *resolved_loc; // result ptr | |
| 4493 | IrInstSrc *source_instruction; | |
| 4494 | IrInstGen *gen_instruction; // value to store to the result loc | |
| 4492 | Stage1AirInst *resolved_loc; // result ptr | |
| 4493 | Stage1ZirInst *source_instruction; | |
| 4494 | Stage1AirInst *gen_instruction; // value to store to the result loc | |
| 4495 | 4495 | ZigType *implicit_elem_type; |
| 4496 | 4496 | }; |
| 4497 | 4497 | |
| ... | ... | @@ -4525,7 +4525,7 @@ struct ResultLocPeerParent { |
| 4525 | 4525 | ResultLoc *parent; |
| 4526 | 4526 | ZigList<ResultLocPeer *> peers; |
| 4527 | 4527 | ZigType *resolved_type; |
| 4528 | IrInstSrc *is_comptime; | |
| 4528 | Stage1ZirInst *is_comptime; | |
| 4529 | 4529 | }; |
| 4530 | 4530 | |
| 4531 | 4531 | struct ResultLocPeer { |
| ... | ... | @@ -4603,7 +4603,7 @@ struct FnWalkAttrs { |
| 4603 | 4603 | struct FnWalkCall { |
| 4604 | 4604 | ZigList<LLVMValueRef> *gen_param_values; |
| 4605 | 4605 | ZigList<ZigType *> *gen_param_types; |
| 4606 | IrInstGenCall *inst; | |
| 4606 | Stage1AirInstCall *inst; | |
| 4607 | 4607 | bool is_var_args; |
| 4608 | 4608 | }; |
| 4609 | 4609 |
src/stage1/analyze.cpp+23-23| ... | ... | @@ -206,7 +206,7 @@ ScopeLoop *create_loop_scope(CodeGen *g, AstNode *node, Scope *parent) { |
| 206 | 206 | return scope; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | Scope *create_runtime_scope(CodeGen *g, AstNode *node, Scope *parent, IrInstSrc *is_comptime) { | |
| 209 | Scope *create_runtime_scope(CodeGen *g, AstNode *node, Scope *parent, Stage1ZirInst *is_comptime) { | |
| 210 | 210 | ScopeRuntime *scope = heap::c_allocator.create<ScopeRuntime>(); |
| 211 | 211 | scope->is_comptime = is_comptime; |
| 212 | 212 | init_scope(g, &scope->base, ScopeIdRuntime, node, parent); |
| ... | ... | @@ -5071,7 +5071,7 @@ static void analyze_fn_async(CodeGen *g, ZigFn *fn, bool resolve_frame) { |
| 5071 | 5071 | } |
| 5072 | 5072 | |
| 5073 | 5073 | for (size_t i = 0; i < fn->call_list.length; i += 1) { |
| 5074 | IrInstGenCall *call = fn->call_list.at(i); | |
| 5074 | Stage1AirInstCall *call = fn->call_list.at(i); | |
| 5075 | 5075 | if (call->fn_entry == nullptr) { |
| 5076 | 5076 | // TODO function pointer call here, could be anything |
| 5077 | 5077 | continue; |
| ... | ... | @@ -5094,7 +5094,7 @@ static void analyze_fn_async(CodeGen *g, ZigFn *fn, bool resolve_frame) { |
| 5094 | 5094 | } |
| 5095 | 5095 | } |
| 5096 | 5096 | for (size_t i = 0; i < fn->await_list.length; i += 1) { |
| 5097 | IrInstGenAwait *await = fn->await_list.at(i); | |
| 5097 | Stage1AirInstAwait *await = fn->await_list.at(i); | |
| 5098 | 5098 | if (await->is_nosuspend) continue; |
| 5099 | 5099 | switch (analyze_callee_async(g, fn, await->target_fn, await->base.source_node, must_not_be_async, |
| 5100 | 5100 | CallModifierNone)) |
| ... | ... | @@ -6755,8 +6755,8 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) { |
| 6755 | 6755 | ZigType *fn_type = get_async_fn_type(g, fn->type_entry); |
| 6756 | 6756 | |
| 6757 | 6757 | if (fn->analyzed_executable.need_err_code_spill) { |
| 6758 | IrInstGenAlloca *alloca_gen = heap::c_allocator.create<IrInstGenAlloca>(); | |
| 6759 | alloca_gen->base.id = IrInstGenIdAlloca; | |
| 6758 | Stage1AirInstAlloca *alloca_gen = heap::c_allocator.create<Stage1AirInstAlloca>(); | |
| 6759 | alloca_gen->base.id = Stage1AirInstIdAlloca; | |
| 6760 | 6760 | alloca_gen->base.source_node = fn->proto_node; |
| 6761 | 6761 | alloca_gen->base.scope = fn->child_scope; |
| 6762 | 6762 | alloca_gen->base.value = g->pass1_arena->create<ZigValue>(); |
| ... | ... | @@ -6769,11 +6769,11 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) { |
| 6769 | 6769 | |
| 6770 | 6770 | ZigType *largest_call_frame_type = nullptr; |
| 6771 | 6771 | // Later we'll change this to be largest_call_frame_type instead of void. |
| 6772 | IrInstGen *all_calls_alloca = ir_create_alloca(g, &fn->fndef_scope->base, fn->body_node, | |
| 6772 | Stage1AirInst *all_calls_alloca = ir_create_alloca(g, &fn->fndef_scope->base, fn->body_node, | |
| 6773 | 6773 | fn, g->builtin_types.entry_void, "@async_call_frame"); |
| 6774 | 6774 | |
| 6775 | 6775 | for (size_t i = 0; i < fn->call_list.length; i += 1) { |
| 6776 | IrInstGenCall *call = fn->call_list.at(i); | |
| 6776 | Stage1AirInstCall *call = fn->call_list.at(i); | |
| 6777 | 6777 | if (call->new_stack != nullptr) { |
| 6778 | 6778 | // don't need to allocate a frame for this |
| 6779 | 6779 | continue; |
| ... | ... | @@ -6838,7 +6838,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) { |
| 6838 | 6838 | // For example: foo() + await z |
| 6839 | 6839 | // The funtion call result of foo() must be spilled. |
| 6840 | 6840 | for (size_t i = 0; i < fn->await_list.length; i += 1) { |
| 6841 | IrInstGenAwait *await = fn->await_list.at(i); | |
| 6841 | Stage1AirInstAwait *await = fn->await_list.at(i); | |
| 6842 | 6842 | if (await->is_nosuspend) { |
| 6843 | 6843 | continue; |
| 6844 | 6844 | } |
| ... | ... | @@ -6875,10 +6875,10 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) { |
| 6875 | 6875 | await->base.value->type, ""); |
| 6876 | 6876 | } |
| 6877 | 6877 | for (size_t block_i = 0; block_i < fn->analyzed_executable.basic_block_list.length; block_i += 1) { |
| 6878 | IrBasicBlockGen *block = fn->analyzed_executable.basic_block_list.at(block_i); | |
| 6878 | Stage1AirBasicBlock *block = fn->analyzed_executable.basic_block_list.at(block_i); | |
| 6879 | 6879 | for (size_t instr_i = 0; instr_i < block->instruction_list.length; instr_i += 1) { |
| 6880 | IrInstGen *instruction = block->instruction_list.at(instr_i); | |
| 6881 | if (instruction->id == IrInstGenIdSuspendFinish) { | |
| 6880 | Stage1AirInst *instruction = block->instruction_list.at(instr_i); | |
| 6881 | if (instruction->id == Stage1AirInstIdSuspendFinish) { | |
| 6882 | 6882 | mark_suspension_point(instruction->scope); |
| 6883 | 6883 | } |
| 6884 | 6884 | } |
| ... | ... | @@ -6886,20 +6886,20 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) { |
| 6886 | 6886 | // Now that we've marked all the expr scopes that have to spill, we go over the instructions |
| 6887 | 6887 | // and spill the relevant ones. |
| 6888 | 6888 | for (size_t block_i = 0; block_i < fn->analyzed_executable.basic_block_list.length; block_i += 1) { |
| 6889 | IrBasicBlockGen *block = fn->analyzed_executable.basic_block_list.at(block_i); | |
| 6889 | Stage1AirBasicBlock *block = fn->analyzed_executable.basic_block_list.at(block_i); | |
| 6890 | 6890 | for (size_t instr_i = 0; instr_i < block->instruction_list.length; instr_i += 1) { |
| 6891 | IrInstGen *instruction = block->instruction_list.at(instr_i); | |
| 6892 | if (instruction->id == IrInstGenIdAwait || | |
| 6893 | instruction->id == IrInstGenIdVarPtr || | |
| 6894 | instruction->id == IrInstGenIdAlloca || | |
| 6895 | instruction->id == IrInstGenIdSpillBegin || | |
| 6896 | instruction->id == IrInstGenIdSpillEnd) | |
| 6891 | Stage1AirInst *instruction = block->instruction_list.at(instr_i); | |
| 6892 | if (instruction->id == Stage1AirInstIdAwait || | |
| 6893 | instruction->id == Stage1AirInstIdVarPtr || | |
| 6894 | instruction->id == Stage1AirInstIdAlloca || | |
| 6895 | instruction->id == Stage1AirInstIdSpillBegin || | |
| 6896 | instruction->id == Stage1AirInstIdSpillEnd) | |
| 6897 | 6897 | { |
| 6898 | 6898 | // This instruction does its own spilling specially, or otherwise doesn't need it. |
| 6899 | 6899 | continue; |
| 6900 | 6900 | } |
| 6901 | if (instruction->id == IrInstGenIdCast && | |
| 6902 | reinterpret_cast<IrInstGenCast *>(instruction)->cast_op == CastOpNoop) | |
| 6901 | if (instruction->id == Stage1AirInstIdCast && | |
| 6902 | reinterpret_cast<Stage1AirInstCast *>(instruction)->cast_op == CastOpNoop) | |
| 6903 | 6903 | { |
| 6904 | 6904 | // The IR instruction exists only to change the type according to Zig. No spill needed. |
| 6905 | 6905 | continue; |
| ... | ... | @@ -6964,7 +6964,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) { |
| 6964 | 6964 | } |
| 6965 | 6965 | |
| 6966 | 6966 | for (size_t alloca_i = 0; alloca_i < fn->alloca_gen_list.length; alloca_i += 1) { |
| 6967 | IrInstGenAlloca *instruction = fn->alloca_gen_list.at(alloca_i); | |
| 6967 | Stage1AirInstAlloca *instruction = fn->alloca_gen_list.at(alloca_i); | |
| 6968 | 6968 | instruction->field_index = SIZE_MAX; |
| 6969 | 6969 | ZigType *ptr_type = instruction->base.value->type; |
| 6970 | 6970 | assert(ptr_type->id == ZigTypeIdPointer); |
| ... | ... | @@ -7146,8 +7146,8 @@ bool ir_get_var_is_comptime(ZigVar *var) { |
| 7146 | 7146 | // As an optimization, is_comptime values which are constant are allowed |
| 7147 | 7147 | // to be omitted from analysis. In this case, there is no child instruction |
| 7148 | 7148 | // and we simply look at the unanalyzed const parent instruction. |
| 7149 | assert(var->is_comptime->id == IrInstSrcIdConst); | |
| 7150 | IrInstSrcConst *const_inst = reinterpret_cast<IrInstSrcConst *>(var->is_comptime); | |
| 7149 | assert(var->is_comptime->id == Stage1ZirInstIdConst); | |
| 7150 | Stage1ZirInstConst *const_inst = reinterpret_cast<Stage1ZirInstConst *>(var->is_comptime); | |
| 7151 | 7151 | assert(const_inst->value->type->id == ZigTypeIdBool); |
| 7152 | 7152 | var->is_comptime_memoized_value = const_inst->value->data.x_bool; |
| 7153 | 7153 | var->is_comptime = nullptr; |
src/stage1/analyze.hpp+1-1| ... | ... | @@ -138,7 +138,7 @@ ScopeSuspend *create_suspend_scope(CodeGen *g, AstNode *node, Scope *parent); |
| 138 | 138 | ScopeFnDef *create_fndef_scope(CodeGen *g, AstNode *node, Scope *parent, ZigFn *fn_entry); |
| 139 | 139 | Scope *create_comptime_scope(CodeGen *g, AstNode *node, Scope *parent); |
| 140 | 140 | Scope *create_nosuspend_scope(CodeGen *g, AstNode *node, Scope *parent); |
| 141 | Scope *create_runtime_scope(CodeGen *g, AstNode *node, Scope *parent, IrInstSrc *is_comptime); | |
| 141 | Scope *create_runtime_scope(CodeGen *g, AstNode *node, Scope *parent, Stage1ZirInst *is_comptime); | |
| 142 | 142 | Scope *create_typeof_scope(CodeGen *g, AstNode *node, Scope *parent); |
| 143 | 143 | ScopeExpr *create_expr_scope(CodeGen *g, AstNode *node, Scope *parent); |
| 144 | 144 |
src/stage1/astgen.cpp+1569-1569| ... | ... | @@ -21,25 +21,25 @@ struct Stage1AstGen { |
| 21 | 21 | bool in_c_import_scope; |
| 22 | 22 | }; |
| 23 | 23 | |
| 24 | static IrInstSrc *astgen_node(Stage1AstGen *ag, AstNode *node, Scope *scope); | |
| 25 | static IrInstSrc *astgen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval, | |
| 24 | static Stage1ZirInst *astgen_node(Stage1AstGen *ag, AstNode *node, Scope *scope); | |
| 25 | static Stage1ZirInst *astgen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval, | |
| 26 | 26 | ResultLoc *result_loc); |
| 27 | 27 | |
| 28 | static IrInstSrc *ir_lval_wrap(Stage1AstGen *ag, Scope *scope, IrInstSrc *value, LVal lval, | |
| 28 | static Stage1ZirInst *ir_lval_wrap(Stage1AstGen *ag, Scope *scope, Stage1ZirInst *value, LVal lval, | |
| 29 | 29 | ResultLoc *result_loc); |
| 30 | static IrInstSrc *ir_expr_wrap(Stage1AstGen *ag, Scope *scope, IrInstSrc *inst, | |
| 30 | static Stage1ZirInst *ir_expr_wrap(Stage1AstGen *ag, Scope *scope, Stage1ZirInst *inst, | |
| 31 | 31 | ResultLoc *result_loc); |
| 32 | static IrInstSrc *astgen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 33 | IrInstSrc *union_type, IrInstSrc *field_name, AstNode *expr_node, | |
| 32 | static Stage1ZirInst *astgen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 33 | Stage1ZirInst *union_type, Stage1ZirInst *field_name, AstNode *expr_node, | |
| 34 | 34 | LVal lval, ResultLoc *parent_result_loc); |
| 35 | static ResultLocCast *ir_build_cast_result_loc(Stage1AstGen *ag, IrInstSrc *dest_type, | |
| 35 | static ResultLocCast *ir_build_cast_result_loc(Stage1AstGen *ag, Stage1ZirInst *dest_type, | |
| 36 | 36 | ResultLoc *parent_result_loc); |
| 37 | 37 | static ZigVar *ir_create_var(Stage1AstGen *ag, AstNode *node, Scope *scope, Buf *name, |
| 38 | bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstSrc *is_comptime); | |
| 38 | bool src_is_const, bool gen_is_const, bool is_shadowable, Stage1ZirInst *is_comptime); | |
| 39 | 39 | static void build_decl_var_and_init(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 40 | ZigVar *var, IrInstSrc *init, const char *name_hint, IrInstSrc *is_comptime); | |
| 40 | ZigVar *var, Stage1ZirInst *init, const char *name_hint, Stage1ZirInst *is_comptime); | |
| 41 | 41 | |
| 42 | static void ir_assert_impl(bool ok, IrInstSrc *source_instruction, char const *file, unsigned int line) { | |
| 42 | static void ir_assert_impl(bool ok, Stage1ZirInst *source_instruction, char const *file, unsigned int line) { | |
| 43 | 43 | if (ok) return; |
| 44 | 44 | src_assert_impl(ok, source_instruction->source_node, file, line); |
| 45 | 45 | } |
| ... | ... | @@ -54,299 +54,299 @@ static ErrorMsg *exec_add_error_node(CodeGen *codegen, Stage1Zir *exec, AstNode |
| 54 | 54 | #define ir_assert(OK, SOURCE_INSTRUCTION) ir_assert_impl((OK), (SOURCE_INSTRUCTION), __FILE__, __LINE__) |
| 55 | 55 | |
| 56 | 56 | |
| 57 | static bool instr_is_unreachable(IrInstSrc *instruction) { | |
| 57 | static bool instr_is_unreachable(Stage1ZirInst *instruction) { | |
| 58 | 58 | switch (instruction->id) { |
| 59 | case IrInstSrcIdCondBr: | |
| 60 | case IrInstSrcIdReturn: | |
| 61 | case IrInstSrcIdBr: | |
| 62 | case IrInstSrcIdUnreachable: | |
| 63 | case IrInstSrcIdSwitchBr: | |
| 64 | case IrInstSrcIdPanic: | |
| 59 | case Stage1ZirInstIdCondBr: | |
| 60 | case Stage1ZirInstIdReturn: | |
| 61 | case Stage1ZirInstIdBr: | |
| 62 | case Stage1ZirInstIdUnreachable: | |
| 63 | case Stage1ZirInstIdSwitchBr: | |
| 64 | case Stage1ZirInstIdPanic: | |
| 65 | 65 | return true; |
| 66 | 66 | default: |
| 67 | 67 | return false; |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | void destroy_instruction_src(IrInstSrc *inst) { | |
| 71 | void destroy_instruction_src(Stage1ZirInst *inst) { | |
| 72 | 72 | switch (inst->id) { |
| 73 | case IrInstSrcIdInvalid: | |
| 73 | case Stage1ZirInstIdInvalid: | |
| 74 | 74 | zig_unreachable(); |
| 75 | case IrInstSrcIdReturn: | |
| 76 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcReturn *>(inst)); | |
| 77 | case IrInstSrcIdConst: | |
| 78 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcConst *>(inst)); | |
| 79 | case IrInstSrcIdBinOp: | |
| 80 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBinOp *>(inst)); | |
| 81 | case IrInstSrcIdMergeErrSets: | |
| 82 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcMergeErrSets *>(inst)); | |
| 83 | case IrInstSrcIdDeclVar: | |
| 84 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcDeclVar *>(inst)); | |
| 85 | case IrInstSrcIdCall: | |
| 86 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCall *>(inst)); | |
| 87 | case IrInstSrcIdCallExtra: | |
| 88 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCallExtra *>(inst)); | |
| 89 | case IrInstSrcIdAsyncCallExtra: | |
| 90 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAsyncCallExtra *>(inst)); | |
| 91 | case IrInstSrcIdUnOp: | |
| 92 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUnOp *>(inst)); | |
| 93 | case IrInstSrcIdCondBr: | |
| 94 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCondBr *>(inst)); | |
| 95 | case IrInstSrcIdBr: | |
| 96 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBr *>(inst)); | |
| 97 | case IrInstSrcIdPhi: | |
| 98 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPhi *>(inst)); | |
| 99 | case IrInstSrcIdContainerInitList: | |
| 100 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcContainerInitList *>(inst)); | |
| 101 | case IrInstSrcIdContainerInitFields: | |
| 102 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcContainerInitFields *>(inst)); | |
| 103 | case IrInstSrcIdUnreachable: | |
| 104 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUnreachable *>(inst)); | |
| 105 | case IrInstSrcIdElemPtr: | |
| 106 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcElemPtr *>(inst)); | |
| 107 | case IrInstSrcIdVarPtr: | |
| 108 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcVarPtr *>(inst)); | |
| 109 | case IrInstSrcIdLoadPtr: | |
| 110 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcLoadPtr *>(inst)); | |
| 111 | case IrInstSrcIdStorePtr: | |
| 112 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcStorePtr *>(inst)); | |
| 113 | case IrInstSrcIdTypeOf: | |
| 114 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTypeOf *>(inst)); | |
| 115 | case IrInstSrcIdFieldPtr: | |
| 116 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFieldPtr *>(inst)); | |
| 117 | case IrInstSrcIdSetCold: | |
| 118 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetCold *>(inst)); | |
| 119 | case IrInstSrcIdSetRuntimeSafety: | |
| 120 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetRuntimeSafety *>(inst)); | |
| 121 | case IrInstSrcIdSetFloatMode: | |
| 122 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetFloatMode *>(inst)); | |
| 123 | case IrInstSrcIdArrayType: | |
| 124 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcArrayType *>(inst)); | |
| 125 | case IrInstSrcIdSliceType: | |
| 126 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSliceType *>(inst)); | |
| 127 | case IrInstSrcIdAnyFrameType: | |
| 128 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAnyFrameType *>(inst)); | |
| 129 | case IrInstSrcIdAsm: | |
| 130 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAsm *>(inst)); | |
| 131 | case IrInstSrcIdSizeOf: | |
| 132 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSizeOf *>(inst)); | |
| 133 | case IrInstSrcIdTestNonNull: | |
| 134 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTestNonNull *>(inst)); | |
| 135 | case IrInstSrcIdOptionalUnwrapPtr: | |
| 136 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcOptionalUnwrapPtr *>(inst)); | |
| 137 | case IrInstSrcIdPopCount: | |
| 138 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPopCount *>(inst)); | |
| 139 | case IrInstSrcIdClz: | |
| 140 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcClz *>(inst)); | |
| 141 | case IrInstSrcIdCtz: | |
| 142 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCtz *>(inst)); | |
| 143 | case IrInstSrcIdBswap: | |
| 144 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBswap *>(inst)); | |
| 145 | case IrInstSrcIdBitReverse: | |
| 146 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBitReverse *>(inst)); | |
| 147 | case IrInstSrcIdSwitchBr: | |
| 148 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSwitchBr *>(inst)); | |
| 149 | case IrInstSrcIdSwitchVar: | |
| 150 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSwitchVar *>(inst)); | |
| 151 | case IrInstSrcIdSwitchElseVar: | |
| 152 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSwitchElseVar *>(inst)); | |
| 153 | case IrInstSrcIdSwitchTarget: | |
| 154 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSwitchTarget *>(inst)); | |
| 155 | case IrInstSrcIdImport: | |
| 156 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcImport *>(inst)); | |
| 157 | case IrInstSrcIdRef: | |
| 158 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcRef *>(inst)); | |
| 159 | case IrInstSrcIdCompileErr: | |
| 160 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCompileErr *>(inst)); | |
| 161 | case IrInstSrcIdCompileLog: | |
| 162 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCompileLog *>(inst)); | |
| 163 | case IrInstSrcIdErrName: | |
| 164 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrName *>(inst)); | |
| 165 | case IrInstSrcIdCImport: | |
| 166 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCImport *>(inst)); | |
| 167 | case IrInstSrcIdCInclude: | |
| 168 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCInclude *>(inst)); | |
| 169 | case IrInstSrcIdCDefine: | |
| 170 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCDefine *>(inst)); | |
| 171 | case IrInstSrcIdCUndef: | |
| 172 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCUndef *>(inst)); | |
| 173 | case IrInstSrcIdEmbedFile: | |
| 174 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcEmbedFile *>(inst)); | |
| 175 | case IrInstSrcIdCmpxchg: | |
| 176 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCmpxchg *>(inst)); | |
| 177 | case IrInstSrcIdFence: | |
| 178 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFence *>(inst)); | |
| 179 | case IrInstSrcIdReduce: | |
| 180 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcReduce *>(inst)); | |
| 181 | case IrInstSrcIdTruncate: | |
| 182 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTruncate *>(inst)); | |
| 183 | case IrInstSrcIdIntCast: | |
| 184 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntCast *>(inst)); | |
| 185 | case IrInstSrcIdFloatCast: | |
| 186 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFloatCast *>(inst)); | |
| 187 | case IrInstSrcIdErrSetCast: | |
| 188 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrSetCast *>(inst)); | |
| 189 | case IrInstSrcIdIntToFloat: | |
| 190 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntToFloat *>(inst)); | |
| 191 | case IrInstSrcIdFloatToInt: | |
| 192 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFloatToInt *>(inst)); | |
| 193 | case IrInstSrcIdBoolToInt: | |
| 194 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBoolToInt *>(inst)); | |
| 195 | case IrInstSrcIdVectorType: | |
| 196 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcVectorType *>(inst)); | |
| 197 | case IrInstSrcIdShuffleVector: | |
| 198 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcShuffleVector *>(inst)); | |
| 199 | case IrInstSrcIdSplat: | |
| 200 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSplat *>(inst)); | |
| 201 | case IrInstSrcIdBoolNot: | |
| 202 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBoolNot *>(inst)); | |
| 203 | case IrInstSrcIdMemset: | |
| 204 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcMemset *>(inst)); | |
| 205 | case IrInstSrcIdMemcpy: | |
| 206 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcMemcpy *>(inst)); | |
| 207 | case IrInstSrcIdSlice: | |
| 208 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSlice *>(inst)); | |
| 209 | case IrInstSrcIdBreakpoint: | |
| 210 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBreakpoint *>(inst)); | |
| 211 | case IrInstSrcIdReturnAddress: | |
| 212 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcReturnAddress *>(inst)); | |
| 213 | case IrInstSrcIdFrameAddress: | |
| 214 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFrameAddress *>(inst)); | |
| 215 | case IrInstSrcIdFrameHandle: | |
| 216 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFrameHandle *>(inst)); | |
| 217 | case IrInstSrcIdFrameType: | |
| 218 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFrameType *>(inst)); | |
| 219 | case IrInstSrcIdFrameSize: | |
| 220 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFrameSize *>(inst)); | |
| 221 | case IrInstSrcIdAlignOf: | |
| 222 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAlignOf *>(inst)); | |
| 223 | case IrInstSrcIdOverflowOp: | |
| 224 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcOverflowOp *>(inst)); | |
| 225 | case IrInstSrcIdTestErr: | |
| 226 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTestErr *>(inst)); | |
| 227 | case IrInstSrcIdUnwrapErrCode: | |
| 228 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUnwrapErrCode *>(inst)); | |
| 229 | case IrInstSrcIdUnwrapErrPayload: | |
| 230 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUnwrapErrPayload *>(inst)); | |
| 231 | case IrInstSrcIdFnProto: | |
| 232 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFnProto *>(inst)); | |
| 233 | case IrInstSrcIdTestComptime: | |
| 234 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTestComptime *>(inst)); | |
| 235 | case IrInstSrcIdPtrCast: | |
| 236 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPtrCast *>(inst)); | |
| 237 | case IrInstSrcIdBitCast: | |
| 238 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBitCast *>(inst)); | |
| 239 | case IrInstSrcIdPtrToInt: | |
| 240 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPtrToInt *>(inst)); | |
| 241 | case IrInstSrcIdIntToPtr: | |
| 242 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntToPtr *>(inst)); | |
| 243 | case IrInstSrcIdIntToEnum: | |
| 244 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntToEnum *>(inst)); | |
| 245 | case IrInstSrcIdIntToErr: | |
| 246 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntToErr *>(inst)); | |
| 247 | case IrInstSrcIdErrToInt: | |
| 248 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrToInt *>(inst)); | |
| 249 | case IrInstSrcIdCheckSwitchProngsUnderNo: | |
| 250 | case IrInstSrcIdCheckSwitchProngsUnderYes: | |
| 251 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCheckSwitchProngs *>(inst)); | |
| 252 | case IrInstSrcIdCheckStatementIsVoid: | |
| 253 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCheckStatementIsVoid *>(inst)); | |
| 254 | case IrInstSrcIdTypeName: | |
| 255 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTypeName *>(inst)); | |
| 256 | case IrInstSrcIdTagName: | |
| 257 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTagName *>(inst)); | |
| 258 | case IrInstSrcIdPtrType: | |
| 259 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPtrType *>(inst)); | |
| 260 | case IrInstSrcIdPtrTypeSimple: | |
| 261 | case IrInstSrcIdPtrTypeSimpleConst: | |
| 262 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPtrTypeSimple *>(inst)); | |
| 263 | case IrInstSrcIdDeclRef: | |
| 264 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcDeclRef *>(inst)); | |
| 265 | case IrInstSrcIdPanic: | |
| 266 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPanic *>(inst)); | |
| 267 | case IrInstSrcIdFieldParentPtr: | |
| 268 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFieldParentPtr *>(inst)); | |
| 269 | case IrInstSrcIdOffsetOf: | |
| 270 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcOffsetOf *>(inst)); | |
| 271 | case IrInstSrcIdBitOffsetOf: | |
| 272 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBitOffsetOf *>(inst)); | |
| 273 | case IrInstSrcIdTypeInfo: | |
| 274 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcTypeInfo *>(inst)); | |
| 275 | case IrInstSrcIdType: | |
| 276 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcType *>(inst)); | |
| 277 | case IrInstSrcIdHasField: | |
| 278 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcHasField *>(inst)); | |
| 279 | case IrInstSrcIdSetEvalBranchQuota: | |
| 280 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetEvalBranchQuota *>(inst)); | |
| 281 | case IrInstSrcIdAlignCast: | |
| 282 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAlignCast *>(inst)); | |
| 283 | case IrInstSrcIdImplicitCast: | |
| 284 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcImplicitCast *>(inst)); | |
| 285 | case IrInstSrcIdResolveResult: | |
| 286 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcResolveResult *>(inst)); | |
| 287 | case IrInstSrcIdResetResult: | |
| 288 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcResetResult *>(inst)); | |
| 289 | case IrInstSrcIdSetAlignStack: | |
| 290 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetAlignStack *>(inst)); | |
| 291 | case IrInstSrcIdArgTypeAllowVarFalse: | |
| 292 | case IrInstSrcIdArgTypeAllowVarTrue: | |
| 293 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcArgType *>(inst)); | |
| 294 | case IrInstSrcIdExport: | |
| 295 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcExport *>(inst)); | |
| 296 | case IrInstSrcIdExtern: | |
| 297 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcExtern *>(inst)); | |
| 298 | case IrInstSrcIdErrorReturnTrace: | |
| 299 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrorReturnTrace *>(inst)); | |
| 300 | case IrInstSrcIdErrorUnion: | |
| 301 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrorUnion *>(inst)); | |
| 302 | case IrInstSrcIdAtomicRmw: | |
| 303 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAtomicRmw *>(inst)); | |
| 304 | case IrInstSrcIdSaveErrRetAddr: | |
| 305 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSaveErrRetAddr *>(inst)); | |
| 306 | case IrInstSrcIdAddImplicitReturnType: | |
| 307 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAddImplicitReturnType *>(inst)); | |
| 308 | case IrInstSrcIdFloatOp: | |
| 309 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFloatOp *>(inst)); | |
| 310 | case IrInstSrcIdMulAdd: | |
| 311 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcMulAdd *>(inst)); | |
| 312 | case IrInstSrcIdAtomicLoad: | |
| 313 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAtomicLoad *>(inst)); | |
| 314 | case IrInstSrcIdAtomicStore: | |
| 315 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAtomicStore *>(inst)); | |
| 316 | case IrInstSrcIdEnumToInt: | |
| 317 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcEnumToInt *>(inst)); | |
| 318 | case IrInstSrcIdCheckRuntimeScope: | |
| 319 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCheckRuntimeScope *>(inst)); | |
| 320 | case IrInstSrcIdHasDecl: | |
| 321 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcHasDecl *>(inst)); | |
| 322 | case IrInstSrcIdUndeclaredIdent: | |
| 323 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUndeclaredIdent *>(inst)); | |
| 324 | case IrInstSrcIdAlloca: | |
| 325 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAlloca *>(inst)); | |
| 326 | case IrInstSrcIdEndExpr: | |
| 327 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcEndExpr *>(inst)); | |
| 328 | case IrInstSrcIdUnionInitNamedField: | |
| 329 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcUnionInitNamedField *>(inst)); | |
| 330 | case IrInstSrcIdSuspendBegin: | |
| 331 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSuspendBegin *>(inst)); | |
| 332 | case IrInstSrcIdSuspendFinish: | |
| 333 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSuspendFinish *>(inst)); | |
| 334 | case IrInstSrcIdResume: | |
| 335 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcResume *>(inst)); | |
| 336 | case IrInstSrcIdAwait: | |
| 337 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcAwait *>(inst)); | |
| 338 | case IrInstSrcIdSpillBegin: | |
| 339 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSpillBegin *>(inst)); | |
| 340 | case IrInstSrcIdSpillEnd: | |
| 341 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSpillEnd *>(inst)); | |
| 342 | case IrInstSrcIdCallArgs: | |
| 343 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCallArgs *>(inst)); | |
| 344 | case IrInstSrcIdWasmMemorySize: | |
| 345 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcWasmMemorySize *>(inst)); | |
| 346 | case IrInstSrcIdWasmMemoryGrow: | |
| 347 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcWasmMemoryGrow *>(inst)); | |
| 348 | case IrInstSrcIdSrc: | |
| 349 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSrc *>(inst)); | |
| 75 | case Stage1ZirInstIdReturn: | |
| 76 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstReturn *>(inst)); | |
| 77 | case Stage1ZirInstIdConst: | |
| 78 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstConst *>(inst)); | |
| 79 | case Stage1ZirInstIdBinOp: | |
| 80 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstBinOp *>(inst)); | |
| 81 | case Stage1ZirInstIdMergeErrSets: | |
| 82 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstMergeErrSets *>(inst)); | |
| 83 | case Stage1ZirInstIdDeclVar: | |
| 84 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstDeclVar *>(inst)); | |
| 85 | case Stage1ZirInstIdCall: | |
| 86 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCall *>(inst)); | |
| 87 | case Stage1ZirInstIdCallExtra: | |
| 88 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCallExtra *>(inst)); | |
| 89 | case Stage1ZirInstIdAsyncCallExtra: | |
| 90 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstAsyncCallExtra *>(inst)); | |
| 91 | case Stage1ZirInstIdUnOp: | |
| 92 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstUnOp *>(inst)); | |
| 93 | case Stage1ZirInstIdCondBr: | |
| 94 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCondBr *>(inst)); | |
| 95 | case Stage1ZirInstIdBr: | |
| 96 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstBr *>(inst)); | |
| 97 | case Stage1ZirInstIdPhi: | |
| 98 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstPhi *>(inst)); | |
| 99 | case Stage1ZirInstIdContainerInitList: | |
| 100 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstContainerInitList *>(inst)); | |
| 101 | case Stage1ZirInstIdContainerInitFields: | |
| 102 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstContainerInitFields *>(inst)); | |
| 103 | case Stage1ZirInstIdUnreachable: | |
| 104 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstUnreachable *>(inst)); | |
| 105 | case Stage1ZirInstIdElemPtr: | |
| 106 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstElemPtr *>(inst)); | |
| 107 | case Stage1ZirInstIdVarPtr: | |
| 108 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstVarPtr *>(inst)); | |
| 109 | case Stage1ZirInstIdLoadPtr: | |
| 110 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstLoadPtr *>(inst)); | |
| 111 | case Stage1ZirInstIdStorePtr: | |
| 112 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstStorePtr *>(inst)); | |
| 113 | case Stage1ZirInstIdTypeOf: | |
| 114 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstTypeOf *>(inst)); | |
| 115 | case Stage1ZirInstIdFieldPtr: | |
| 116 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstFieldPtr *>(inst)); | |
| 117 | case Stage1ZirInstIdSetCold: | |
| 118 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSetCold *>(inst)); | |
| 119 | case Stage1ZirInstIdSetRuntimeSafety: | |
| 120 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSetRuntimeSafety *>(inst)); | |
| 121 | case Stage1ZirInstIdSetFloatMode: | |
| 122 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSetFloatMode *>(inst)); | |
| 123 | case Stage1ZirInstIdArrayType: | |
| 124 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstArrayType *>(inst)); | |
| 125 | case Stage1ZirInstIdSliceType: | |
| 126 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSliceType *>(inst)); | |
| 127 | case Stage1ZirInstIdAnyFrameType: | |
| 128 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstAnyFrameType *>(inst)); | |
| 129 | case Stage1ZirInstIdAsm: | |
| 130 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstAsm *>(inst)); | |
| 131 | case Stage1ZirInstIdSizeOf: | |
| 132 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSizeOf *>(inst)); | |
| 133 | case Stage1ZirInstIdTestNonNull: | |
| 134 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstTestNonNull *>(inst)); | |
| 135 | case Stage1ZirInstIdOptionalUnwrapPtr: | |
| 136 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstOptionalUnwrapPtr *>(inst)); | |
| 137 | case Stage1ZirInstIdPopCount: | |
| 138 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstPopCount *>(inst)); | |
| 139 | case Stage1ZirInstIdClz: | |
| 140 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstClz *>(inst)); | |
| 141 | case Stage1ZirInstIdCtz: | |
| 142 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCtz *>(inst)); | |
| 143 | case Stage1ZirInstIdBswap: | |
| 144 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstBswap *>(inst)); | |
| 145 | case Stage1ZirInstIdBitReverse: | |
| 146 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstBitReverse *>(inst)); | |
| 147 | case Stage1ZirInstIdSwitchBr: | |
| 148 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSwitchBr *>(inst)); | |
| 149 | case Stage1ZirInstIdSwitchVar: | |
| 150 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSwitchVar *>(inst)); | |
| 151 | case Stage1ZirInstIdSwitchElseVar: | |
| 152 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSwitchElseVar *>(inst)); | |
| 153 | case Stage1ZirInstIdSwitchTarget: | |
| 154 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSwitchTarget *>(inst)); | |
| 155 | case Stage1ZirInstIdImport: | |
| 156 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstImport *>(inst)); | |
| 157 | case Stage1ZirInstIdRef: | |
| 158 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstRef *>(inst)); | |
| 159 | case Stage1ZirInstIdCompileErr: | |
| 160 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCompileErr *>(inst)); | |
| 161 | case Stage1ZirInstIdCompileLog: | |
| 162 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCompileLog *>(inst)); | |
| 163 | case Stage1ZirInstIdErrName: | |
| 164 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstErrName *>(inst)); | |
| 165 | case Stage1ZirInstIdCImport: | |
| 166 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCImport *>(inst)); | |
| 167 | case Stage1ZirInstIdCInclude: | |
| 168 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCInclude *>(inst)); | |
| 169 | case Stage1ZirInstIdCDefine: | |
| 170 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCDefine *>(inst)); | |
| 171 | case Stage1ZirInstIdCUndef: | |
| 172 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCUndef *>(inst)); | |
| 173 | case Stage1ZirInstIdEmbedFile: | |
| 174 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstEmbedFile *>(inst)); | |
| 175 | case Stage1ZirInstIdCmpxchg: | |
| 176 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCmpxchg *>(inst)); | |
| 177 | case Stage1ZirInstIdFence: | |
| 178 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstFence *>(inst)); | |
| 179 | case Stage1ZirInstIdReduce: | |
| 180 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstReduce *>(inst)); | |
| 181 | case Stage1ZirInstIdTruncate: | |
| 182 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstTruncate *>(inst)); | |
| 183 | case Stage1ZirInstIdIntCast: | |
| 184 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstIntCast *>(inst)); | |
| 185 | case Stage1ZirInstIdFloatCast: | |
| 186 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstFloatCast *>(inst)); | |
| 187 | case Stage1ZirInstIdErrSetCast: | |
| 188 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstErrSetCast *>(inst)); | |
| 189 | case Stage1ZirInstIdIntToFloat: | |
| 190 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstIntToFloat *>(inst)); | |
| 191 | case Stage1ZirInstIdFloatToInt: | |
| 192 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstFloatToInt *>(inst)); | |
| 193 | case Stage1ZirInstIdBoolToInt: | |
| 194 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstBoolToInt *>(inst)); | |
| 195 | case Stage1ZirInstIdVectorType: | |
| 196 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstVectorType *>(inst)); | |
| 197 | case Stage1ZirInstIdShuffleVector: | |
| 198 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstShuffleVector *>(inst)); | |
| 199 | case Stage1ZirInstIdSplat: | |
| 200 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSplat *>(inst)); | |
| 201 | case Stage1ZirInstIdBoolNot: | |
| 202 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstBoolNot *>(inst)); | |
| 203 | case Stage1ZirInstIdMemset: | |
| 204 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstMemset *>(inst)); | |
| 205 | case Stage1ZirInstIdMemcpy: | |
| 206 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstMemcpy *>(inst)); | |
| 207 | case Stage1ZirInstIdSlice: | |
| 208 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSlice *>(inst)); | |
| 209 | case Stage1ZirInstIdBreakpoint: | |
| 210 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstBreakpoint *>(inst)); | |
| 211 | case Stage1ZirInstIdReturnAddress: | |
| 212 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstReturnAddress *>(inst)); | |
| 213 | case Stage1ZirInstIdFrameAddress: | |
| 214 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstFrameAddress *>(inst)); | |
| 215 | case Stage1ZirInstIdFrameHandle: | |
| 216 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstFrameHandle *>(inst)); | |
| 217 | case Stage1ZirInstIdFrameType: | |
| 218 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstFrameType *>(inst)); | |
| 219 | case Stage1ZirInstIdFrameSize: | |
| 220 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstFrameSize *>(inst)); | |
| 221 | case Stage1ZirInstIdAlignOf: | |
| 222 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstAlignOf *>(inst)); | |
| 223 | case Stage1ZirInstIdOverflowOp: | |
| 224 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstOverflowOp *>(inst)); | |
| 225 | case Stage1ZirInstIdTestErr: | |
| 226 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstTestErr *>(inst)); | |
| 227 | case Stage1ZirInstIdUnwrapErrCode: | |
| 228 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstUnwrapErrCode *>(inst)); | |
| 229 | case Stage1ZirInstIdUnwrapErrPayload: | |
| 230 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstUnwrapErrPayload *>(inst)); | |
| 231 | case Stage1ZirInstIdFnProto: | |
| 232 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstFnProto *>(inst)); | |
| 233 | case Stage1ZirInstIdTestComptime: | |
| 234 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstTestComptime *>(inst)); | |
| 235 | case Stage1ZirInstIdPtrCast: | |
| 236 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstPtrCast *>(inst)); | |
| 237 | case Stage1ZirInstIdBitCast: | |
| 238 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstBitCast *>(inst)); | |
| 239 | case Stage1ZirInstIdPtrToInt: | |
| 240 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstPtrToInt *>(inst)); | |
| 241 | case Stage1ZirInstIdIntToPtr: | |
| 242 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstIntToPtr *>(inst)); | |
| 243 | case Stage1ZirInstIdIntToEnum: | |
| 244 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstIntToEnum *>(inst)); | |
| 245 | case Stage1ZirInstIdIntToErr: | |
| 246 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstIntToErr *>(inst)); | |
| 247 | case Stage1ZirInstIdErrToInt: | |
| 248 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstErrToInt *>(inst)); | |
| 249 | case Stage1ZirInstIdCheckSwitchProngsUnderNo: | |
| 250 | case Stage1ZirInstIdCheckSwitchProngsUnderYes: | |
| 251 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCheckSwitchProngs *>(inst)); | |
| 252 | case Stage1ZirInstIdCheckStatementIsVoid: | |
| 253 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCheckStatementIsVoid *>(inst)); | |
| 254 | case Stage1ZirInstIdTypeName: | |
| 255 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstTypeName *>(inst)); | |
| 256 | case Stage1ZirInstIdTagName: | |
| 257 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstTagName *>(inst)); | |
| 258 | case Stage1ZirInstIdPtrType: | |
| 259 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstPtrType *>(inst)); | |
| 260 | case Stage1ZirInstIdPtrTypeSimple: | |
| 261 | case Stage1ZirInstIdPtrTypeSimpleConst: | |
| 262 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstPtrTypeSimple *>(inst)); | |
| 263 | case Stage1ZirInstIdDeclRef: | |
| 264 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstDeclRef *>(inst)); | |
| 265 | case Stage1ZirInstIdPanic: | |
| 266 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstPanic *>(inst)); | |
| 267 | case Stage1ZirInstIdFieldParentPtr: | |
| 268 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstFieldParentPtr *>(inst)); | |
| 269 | case Stage1ZirInstIdOffsetOf: | |
| 270 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstOffsetOf *>(inst)); | |
| 271 | case Stage1ZirInstIdBitOffsetOf: | |
| 272 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstBitOffsetOf *>(inst)); | |
| 273 | case Stage1ZirInstIdTypeInfo: | |
| 274 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstTypeInfo *>(inst)); | |
| 275 | case Stage1ZirInstIdType: | |
| 276 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstType *>(inst)); | |
| 277 | case Stage1ZirInstIdHasField: | |
| 278 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstHasField *>(inst)); | |
| 279 | case Stage1ZirInstIdSetEvalBranchQuota: | |
| 280 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSetEvalBranchQuota *>(inst)); | |
| 281 | case Stage1ZirInstIdAlignCast: | |
| 282 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstAlignCast *>(inst)); | |
| 283 | case Stage1ZirInstIdImplicitCast: | |
| 284 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstImplicitCast *>(inst)); | |
| 285 | case Stage1ZirInstIdResolveResult: | |
| 286 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstResolveResult *>(inst)); | |
| 287 | case Stage1ZirInstIdResetResult: | |
| 288 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstResetResult *>(inst)); | |
| 289 | case Stage1ZirInstIdSetAlignStack: | |
| 290 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSetAlignStack *>(inst)); | |
| 291 | case Stage1ZirInstIdArgTypeAllowVarFalse: | |
| 292 | case Stage1ZirInstIdArgTypeAllowVarTrue: | |
| 293 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstArgType *>(inst)); | |
| 294 | case Stage1ZirInstIdExport: | |
| 295 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstExport *>(inst)); | |
| 296 | case Stage1ZirInstIdExtern: | |
| 297 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstExtern *>(inst)); | |
| 298 | case Stage1ZirInstIdErrorReturnTrace: | |
| 299 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstErrorReturnTrace *>(inst)); | |
| 300 | case Stage1ZirInstIdErrorUnion: | |
| 301 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstErrorUnion *>(inst)); | |
| 302 | case Stage1ZirInstIdAtomicRmw: | |
| 303 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstAtomicRmw *>(inst)); | |
| 304 | case Stage1ZirInstIdSaveErrRetAddr: | |
| 305 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSaveErrRetAddr *>(inst)); | |
| 306 | case Stage1ZirInstIdAddImplicitReturnType: | |
| 307 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstAddImplicitReturnType *>(inst)); | |
| 308 | case Stage1ZirInstIdFloatOp: | |
| 309 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstFloatOp *>(inst)); | |
| 310 | case Stage1ZirInstIdMulAdd: | |
| 311 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstMulAdd *>(inst)); | |
| 312 | case Stage1ZirInstIdAtomicLoad: | |
| 313 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstAtomicLoad *>(inst)); | |
| 314 | case Stage1ZirInstIdAtomicStore: | |
| 315 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstAtomicStore *>(inst)); | |
| 316 | case Stage1ZirInstIdEnumToInt: | |
| 317 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstEnumToInt *>(inst)); | |
| 318 | case Stage1ZirInstIdCheckRuntimeScope: | |
| 319 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCheckRuntimeScope *>(inst)); | |
| 320 | case Stage1ZirInstIdHasDecl: | |
| 321 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstHasDecl *>(inst)); | |
| 322 | case Stage1ZirInstIdUndeclaredIdent: | |
| 323 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstUndeclaredIdent *>(inst)); | |
| 324 | case Stage1ZirInstIdAlloca: | |
| 325 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstAlloca *>(inst)); | |
| 326 | case Stage1ZirInstIdEndExpr: | |
| 327 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstEndExpr *>(inst)); | |
| 328 | case Stage1ZirInstIdUnionInitNamedField: | |
| 329 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstUnionInitNamedField *>(inst)); | |
| 330 | case Stage1ZirInstIdSuspendBegin: | |
| 331 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSuspendBegin *>(inst)); | |
| 332 | case Stage1ZirInstIdSuspendFinish: | |
| 333 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSuspendFinish *>(inst)); | |
| 334 | case Stage1ZirInstIdResume: | |
| 335 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstResume *>(inst)); | |
| 336 | case Stage1ZirInstIdAwait: | |
| 337 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstAwait *>(inst)); | |
| 338 | case Stage1ZirInstIdSpillBegin: | |
| 339 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSpillBegin *>(inst)); | |
| 340 | case Stage1ZirInstIdSpillEnd: | |
| 341 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSpillEnd *>(inst)); | |
| 342 | case Stage1ZirInstIdCallArgs: | |
| 343 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstCallArgs *>(inst)); | |
| 344 | case Stage1ZirInstIdWasmMemorySize: | |
| 345 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstWasmMemorySize *>(inst)); | |
| 346 | case Stage1ZirInstIdWasmMemoryGrow: | |
| 347 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstWasmMemoryGrow *>(inst)); | |
| 348 | case Stage1ZirInstIdSrc: | |
| 349 | return heap::c_allocator.destroy(reinterpret_cast<Stage1ZirInstSrc *>(inst)); | |
| 350 | 350 | } |
| 351 | 351 | zig_unreachable(); |
| 352 | 352 | } |
| ... | ... | @@ -368,7 +368,7 @@ bool ir_should_inline(Stage1Zir *exec, Scope *scope) { |
| 368 | 368 | return false; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | static void ir_instruction_append(Stage1ZirBasicBlock *basic_block, IrInstSrc *instruction) { | |
| 371 | static void ir_instruction_append(Stage1ZirBasicBlock *basic_block, Stage1ZirInst *instruction) { | |
| 372 | 372 | assert(basic_block); |
| 373 | 373 | assert(instruction); |
| 374 | 374 | basic_block->instruction_list.append(instruction); |
| ... | ... | @@ -384,11 +384,11 @@ static void ir_ref_bb(Stage1ZirBasicBlock *bb) { |
| 384 | 384 | bb->ref_count += 1; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | static void ir_ref_instruction(IrInstSrc *instruction, Stage1ZirBasicBlock *cur_bb) { | |
| 388 | assert(instruction->id != IrInstSrcIdInvalid); | |
| 387 | static void ir_ref_instruction(Stage1ZirInst *instruction, Stage1ZirBasicBlock *cur_bb) { | |
| 388 | assert(instruction->id != Stage1ZirInstIdInvalid); | |
| 389 | 389 | instruction->ref_count += 1; |
| 390 | 390 | if (instruction->owner_bb != cur_bb && !instr_is_unreachable(instruction) |
| 391 | && instruction->id != IrInstSrcIdConst) | |
| 391 | && instruction->id != Stage1ZirInstIdConst) | |
| 392 | 392 | { |
| 393 | 393 | ir_ref_bb(instruction->owner_bb); |
| 394 | 394 | } |
| ... | ... | @@ -403,536 +403,536 @@ static Stage1ZirBasicBlock *ir_create_basic_block(Stage1AstGen *ag, Scope *scope |
| 403 | 403 | return result; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcDeclVar *) { | |
| 407 | return IrInstSrcIdDeclVar; | |
| 406 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstDeclVar *) { | |
| 407 | return Stage1ZirInstIdDeclVar; | |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBr *) { | |
| 411 | return IrInstSrcIdBr; | |
| 410 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstBr *) { | |
| 411 | return Stage1ZirInstIdBr; | |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCondBr *) { | |
| 415 | return IrInstSrcIdCondBr; | |
| 414 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCondBr *) { | |
| 415 | return Stage1ZirInstIdCondBr; | |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchBr *) { | |
| 419 | return IrInstSrcIdSwitchBr; | |
| 418 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSwitchBr *) { | |
| 419 | return Stage1ZirInstIdSwitchBr; | |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchVar *) { | |
| 423 | return IrInstSrcIdSwitchVar; | |
| 422 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSwitchVar *) { | |
| 423 | return Stage1ZirInstIdSwitchVar; | |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchElseVar *) { | |
| 427 | return IrInstSrcIdSwitchElseVar; | |
| 426 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSwitchElseVar *) { | |
| 427 | return Stage1ZirInstIdSwitchElseVar; | |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchTarget *) { | |
| 431 | return IrInstSrcIdSwitchTarget; | |
| 430 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSwitchTarget *) { | |
| 431 | return Stage1ZirInstIdSwitchTarget; | |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPhi *) { | |
| 435 | return IrInstSrcIdPhi; | |
| 434 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstPhi *) { | |
| 435 | return Stage1ZirInstIdPhi; | |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnOp *) { | |
| 439 | return IrInstSrcIdUnOp; | |
| 438 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstUnOp *) { | |
| 439 | return Stage1ZirInstIdUnOp; | |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBinOp *) { | |
| 443 | return IrInstSrcIdBinOp; | |
| 442 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstBinOp *) { | |
| 443 | return Stage1ZirInstIdBinOp; | |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMergeErrSets *) { | |
| 447 | return IrInstSrcIdMergeErrSets; | |
| 446 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstMergeErrSets *) { | |
| 447 | return Stage1ZirInstIdMergeErrSets; | |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcLoadPtr *) { | |
| 451 | return IrInstSrcIdLoadPtr; | |
| 450 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstLoadPtr *) { | |
| 451 | return Stage1ZirInstIdLoadPtr; | |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcStorePtr *) { | |
| 455 | return IrInstSrcIdStorePtr; | |
| 454 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstStorePtr *) { | |
| 455 | return Stage1ZirInstIdStorePtr; | |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFieldPtr *) { | |
| 459 | return IrInstSrcIdFieldPtr; | |
| 458 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstFieldPtr *) { | |
| 459 | return Stage1ZirInstIdFieldPtr; | |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcElemPtr *) { | |
| 463 | return IrInstSrcIdElemPtr; | |
| 462 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstElemPtr *) { | |
| 463 | return Stage1ZirInstIdElemPtr; | |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcVarPtr *) { | |
| 467 | return IrInstSrcIdVarPtr; | |
| 466 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstVarPtr *) { | |
| 467 | return Stage1ZirInstIdVarPtr; | |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCall *) { | |
| 471 | return IrInstSrcIdCall; | |
| 470 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCall *) { | |
| 471 | return Stage1ZirInstIdCall; | |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCallArgs *) { | |
| 475 | return IrInstSrcIdCallArgs; | |
| 474 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCallArgs *) { | |
| 475 | return Stage1ZirInstIdCallArgs; | |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCallExtra *) { | |
| 479 | return IrInstSrcIdCallExtra; | |
| 478 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCallExtra *) { | |
| 479 | return Stage1ZirInstIdCallExtra; | |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAsyncCallExtra *) { | |
| 483 | return IrInstSrcIdAsyncCallExtra; | |
| 482 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstAsyncCallExtra *) { | |
| 483 | return Stage1ZirInstIdAsyncCallExtra; | |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcConst *) { | |
| 487 | return IrInstSrcIdConst; | |
| 486 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstConst *) { | |
| 487 | return Stage1ZirInstIdConst; | |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcReturn *) { | |
| 491 | return IrInstSrcIdReturn; | |
| 490 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstReturn *) { | |
| 491 | return Stage1ZirInstIdReturn; | |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcContainerInitList *) { | |
| 495 | return IrInstSrcIdContainerInitList; | |
| 494 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstContainerInitList *) { | |
| 495 | return Stage1ZirInstIdContainerInitList; | |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcContainerInitFields *) { | |
| 499 | return IrInstSrcIdContainerInitFields; | |
| 498 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstContainerInitFields *) { | |
| 499 | return Stage1ZirInstIdContainerInitFields; | |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnreachable *) { | |
| 503 | return IrInstSrcIdUnreachable; | |
| 502 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstUnreachable *) { | |
| 503 | return Stage1ZirInstIdUnreachable; | |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeOf *) { | |
| 507 | return IrInstSrcIdTypeOf; | |
| 506 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstTypeOf *) { | |
| 507 | return Stage1ZirInstIdTypeOf; | |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetCold *) { | |
| 511 | return IrInstSrcIdSetCold; | |
| 510 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSetCold *) { | |
| 511 | return Stage1ZirInstIdSetCold; | |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetRuntimeSafety *) { | |
| 515 | return IrInstSrcIdSetRuntimeSafety; | |
| 514 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSetRuntimeSafety *) { | |
| 515 | return Stage1ZirInstIdSetRuntimeSafety; | |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetFloatMode *) { | |
| 519 | return IrInstSrcIdSetFloatMode; | |
| 518 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSetFloatMode *) { | |
| 519 | return Stage1ZirInstIdSetFloatMode; | |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcArrayType *) { | |
| 523 | return IrInstSrcIdArrayType; | |
| 522 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstArrayType *) { | |
| 523 | return Stage1ZirInstIdArrayType; | |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAnyFrameType *) { | |
| 527 | return IrInstSrcIdAnyFrameType; | |
| 526 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstAnyFrameType *) { | |
| 527 | return Stage1ZirInstIdAnyFrameType; | |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSliceType *) { | |
| 531 | return IrInstSrcIdSliceType; | |
| 530 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSliceType *) { | |
| 531 | return Stage1ZirInstIdSliceType; | |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAsm *) { | |
| 535 | return IrInstSrcIdAsm; | |
| 534 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstAsm *) { | |
| 535 | return Stage1ZirInstIdAsm; | |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSizeOf *) { | |
| 539 | return IrInstSrcIdSizeOf; | |
| 538 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSizeOf *) { | |
| 539 | return Stage1ZirInstIdSizeOf; | |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTestNonNull *) { | |
| 543 | return IrInstSrcIdTestNonNull; | |
| 542 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstTestNonNull *) { | |
| 543 | return Stage1ZirInstIdTestNonNull; | |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcOptionalUnwrapPtr *) { | |
| 547 | return IrInstSrcIdOptionalUnwrapPtr; | |
| 546 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstOptionalUnwrapPtr *) { | |
| 547 | return Stage1ZirInstIdOptionalUnwrapPtr; | |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcClz *) { | |
| 551 | return IrInstSrcIdClz; | |
| 550 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstClz *) { | |
| 551 | return Stage1ZirInstIdClz; | |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCtz *) { | |
| 555 | return IrInstSrcIdCtz; | |
| 554 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCtz *) { | |
| 555 | return Stage1ZirInstIdCtz; | |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPopCount *) { | |
| 559 | return IrInstSrcIdPopCount; | |
| 558 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstPopCount *) { | |
| 559 | return Stage1ZirInstIdPopCount; | |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBswap *) { | |
| 563 | return IrInstSrcIdBswap; | |
| 562 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstBswap *) { | |
| 563 | return Stage1ZirInstIdBswap; | |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBitReverse *) { | |
| 567 | return IrInstSrcIdBitReverse; | |
| 566 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstBitReverse *) { | |
| 567 | return Stage1ZirInstIdBitReverse; | |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcImport *) { | |
| 571 | return IrInstSrcIdImport; | |
| 570 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstImport *) { | |
| 571 | return Stage1ZirInstIdImport; | |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCImport *) { | |
| 575 | return IrInstSrcIdCImport; | |
| 574 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCImport *) { | |
| 575 | return Stage1ZirInstIdCImport; | |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCInclude *) { | |
| 579 | return IrInstSrcIdCInclude; | |
| 578 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCInclude *) { | |
| 579 | return Stage1ZirInstIdCInclude; | |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCDefine *) { | |
| 583 | return IrInstSrcIdCDefine; | |
| 582 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCDefine *) { | |
| 583 | return Stage1ZirInstIdCDefine; | |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCUndef *) { | |
| 587 | return IrInstSrcIdCUndef; | |
| 586 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCUndef *) { | |
| 587 | return Stage1ZirInstIdCUndef; | |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcRef *) { | |
| 591 | return IrInstSrcIdRef; | |
| 590 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstRef *) { | |
| 591 | return Stage1ZirInstIdRef; | |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCompileErr *) { | |
| 595 | return IrInstSrcIdCompileErr; | |
| 594 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCompileErr *) { | |
| 595 | return Stage1ZirInstIdCompileErr; | |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCompileLog *) { | |
| 599 | return IrInstSrcIdCompileLog; | |
| 598 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCompileLog *) { | |
| 599 | return Stage1ZirInstIdCompileLog; | |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrName *) { | |
| 603 | return IrInstSrcIdErrName; | |
| 602 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstErrName *) { | |
| 603 | return Stage1ZirInstIdErrName; | |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcEmbedFile *) { | |
| 607 | return IrInstSrcIdEmbedFile; | |
| 606 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstEmbedFile *) { | |
| 607 | return Stage1ZirInstIdEmbedFile; | |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCmpxchg *) { | |
| 611 | return IrInstSrcIdCmpxchg; | |
| 610 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCmpxchg *) { | |
| 611 | return Stage1ZirInstIdCmpxchg; | |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFence *) { | |
| 615 | return IrInstSrcIdFence; | |
| 614 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstFence *) { | |
| 615 | return Stage1ZirInstIdFence; | |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcReduce *) { | |
| 619 | return IrInstSrcIdReduce; | |
| 618 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstReduce *) { | |
| 619 | return Stage1ZirInstIdReduce; | |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTruncate *) { | |
| 623 | return IrInstSrcIdTruncate; | |
| 622 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstTruncate *) { | |
| 623 | return Stage1ZirInstIdTruncate; | |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntCast *) { | |
| 627 | return IrInstSrcIdIntCast; | |
| 626 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstIntCast *) { | |
| 627 | return Stage1ZirInstIdIntCast; | |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFloatCast *) { | |
| 631 | return IrInstSrcIdFloatCast; | |
| 630 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstFloatCast *) { | |
| 631 | return Stage1ZirInstIdFloatCast; | |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToFloat *) { | |
| 635 | return IrInstSrcIdIntToFloat; | |
| 634 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstIntToFloat *) { | |
| 635 | return Stage1ZirInstIdIntToFloat; | |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFloatToInt *) { | |
| 639 | return IrInstSrcIdFloatToInt; | |
| 638 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstFloatToInt *) { | |
| 639 | return Stage1ZirInstIdFloatToInt; | |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBoolToInt *) { | |
| 643 | return IrInstSrcIdBoolToInt; | |
| 642 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstBoolToInt *) { | |
| 643 | return Stage1ZirInstIdBoolToInt; | |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcVectorType *) { | |
| 647 | return IrInstSrcIdVectorType; | |
| 646 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstVectorType *) { | |
| 647 | return Stage1ZirInstIdVectorType; | |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcShuffleVector *) { | |
| 651 | return IrInstSrcIdShuffleVector; | |
| 650 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstShuffleVector *) { | |
| 651 | return Stage1ZirInstIdShuffleVector; | |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSplat *) { | |
| 655 | return IrInstSrcIdSplat; | |
| 654 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSplat *) { | |
| 655 | return Stage1ZirInstIdSplat; | |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBoolNot *) { | |
| 659 | return IrInstSrcIdBoolNot; | |
| 658 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstBoolNot *) { | |
| 659 | return Stage1ZirInstIdBoolNot; | |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemset *) { | |
| 663 | return IrInstSrcIdMemset; | |
| 662 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstMemset *) { | |
| 663 | return Stage1ZirInstIdMemset; | |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemcpy *) { | |
| 667 | return IrInstSrcIdMemcpy; | |
| 666 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstMemcpy *) { | |
| 667 | return Stage1ZirInstIdMemcpy; | |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSlice *) { | |
| 671 | return IrInstSrcIdSlice; | |
| 670 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSlice *) { | |
| 671 | return Stage1ZirInstIdSlice; | |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBreakpoint *) { | |
| 675 | return IrInstSrcIdBreakpoint; | |
| 674 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstBreakpoint *) { | |
| 675 | return Stage1ZirInstIdBreakpoint; | |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcReturnAddress *) { | |
| 679 | return IrInstSrcIdReturnAddress; | |
| 678 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstReturnAddress *) { | |
| 679 | return Stage1ZirInstIdReturnAddress; | |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameAddress *) { | |
| 683 | return IrInstSrcIdFrameAddress; | |
| 682 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstFrameAddress *) { | |
| 683 | return Stage1ZirInstIdFrameAddress; | |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameHandle *) { | |
| 687 | return IrInstSrcIdFrameHandle; | |
| 686 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstFrameHandle *) { | |
| 687 | return Stage1ZirInstIdFrameHandle; | |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameType *) { | |
| 691 | return IrInstSrcIdFrameType; | |
| 690 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstFrameType *) { | |
| 691 | return Stage1ZirInstIdFrameType; | |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameSize *) { | |
| 695 | return IrInstSrcIdFrameSize; | |
| 694 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstFrameSize *) { | |
| 695 | return Stage1ZirInstIdFrameSize; | |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAlignOf *) { | |
| 699 | return IrInstSrcIdAlignOf; | |
| 698 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstAlignOf *) { | |
| 699 | return Stage1ZirInstIdAlignOf; | |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcOverflowOp *) { | |
| 703 | return IrInstSrcIdOverflowOp; | |
| 702 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstOverflowOp *) { | |
| 703 | return Stage1ZirInstIdOverflowOp; | |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTestErr *) { | |
| 707 | return IrInstSrcIdTestErr; | |
| 706 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstTestErr *) { | |
| 707 | return Stage1ZirInstIdTestErr; | |
| 708 | 708 | } |
| 709 | 709 | |
| 710 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMulAdd *) { | |
| 711 | return IrInstSrcIdMulAdd; | |
| 710 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstMulAdd *) { | |
| 711 | return Stage1ZirInstIdMulAdd; | |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFloatOp *) { | |
| 715 | return IrInstSrcIdFloatOp; | |
| 714 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstFloatOp *) { | |
| 715 | return Stage1ZirInstIdFloatOp; | |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnwrapErrCode *) { | |
| 719 | return IrInstSrcIdUnwrapErrCode; | |
| 718 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstUnwrapErrCode *) { | |
| 719 | return Stage1ZirInstIdUnwrapErrCode; | |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnwrapErrPayload *) { | |
| 723 | return IrInstSrcIdUnwrapErrPayload; | |
| 722 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstUnwrapErrPayload *) { | |
| 723 | return Stage1ZirInstIdUnwrapErrPayload; | |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFnProto *) { | |
| 727 | return IrInstSrcIdFnProto; | |
| 726 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstFnProto *) { | |
| 727 | return Stage1ZirInstIdFnProto; | |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTestComptime *) { | |
| 731 | return IrInstSrcIdTestComptime; | |
| 730 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstTestComptime *) { | |
| 731 | return Stage1ZirInstIdTestComptime; | |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPtrCast *) { | |
| 735 | return IrInstSrcIdPtrCast; | |
| 734 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstPtrCast *) { | |
| 735 | return Stage1ZirInstIdPtrCast; | |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBitCast *) { | |
| 739 | return IrInstSrcIdBitCast; | |
| 738 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstBitCast *) { | |
| 739 | return Stage1ZirInstIdBitCast; | |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToPtr *) { | |
| 743 | return IrInstSrcIdIntToPtr; | |
| 742 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstIntToPtr *) { | |
| 743 | return Stage1ZirInstIdIntToPtr; | |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPtrToInt *) { | |
| 747 | return IrInstSrcIdPtrToInt; | |
| 746 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstPtrToInt *) { | |
| 747 | return Stage1ZirInstIdPtrToInt; | |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToEnum *) { | |
| 751 | return IrInstSrcIdIntToEnum; | |
| 750 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstIntToEnum *) { | |
| 751 | return Stage1ZirInstIdIntToEnum; | |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcEnumToInt *) { | |
| 755 | return IrInstSrcIdEnumToInt; | |
| 754 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstEnumToInt *) { | |
| 755 | return Stage1ZirInstIdEnumToInt; | |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToErr *) { | |
| 759 | return IrInstSrcIdIntToErr; | |
| 758 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstIntToErr *) { | |
| 759 | return Stage1ZirInstIdIntToErr; | |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrToInt *) { | |
| 763 | return IrInstSrcIdErrToInt; | |
| 762 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstErrToInt *) { | |
| 763 | return Stage1ZirInstIdErrToInt; | |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckStatementIsVoid *) { | |
| 767 | return IrInstSrcIdCheckStatementIsVoid; | |
| 766 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCheckStatementIsVoid *) { | |
| 767 | return Stage1ZirInstIdCheckStatementIsVoid; | |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeName *) { | |
| 771 | return IrInstSrcIdTypeName; | |
| 770 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstTypeName *) { | |
| 771 | return Stage1ZirInstIdTypeName; | |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcDeclRef *) { | |
| 775 | return IrInstSrcIdDeclRef; | |
| 774 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstDeclRef *) { | |
| 775 | return Stage1ZirInstIdDeclRef; | |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPanic *) { | |
| 779 | return IrInstSrcIdPanic; | |
| 778 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstPanic *) { | |
| 779 | return Stage1ZirInstIdPanic; | |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTagName *) { | |
| 783 | return IrInstSrcIdTagName; | |
| 782 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstTagName *) { | |
| 783 | return Stage1ZirInstIdTagName; | |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFieldParentPtr *) { | |
| 787 | return IrInstSrcIdFieldParentPtr; | |
| 786 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstFieldParentPtr *) { | |
| 787 | return Stage1ZirInstIdFieldParentPtr; | |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcOffsetOf *) { | |
| 791 | return IrInstSrcIdOffsetOf; | |
| 790 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstOffsetOf *) { | |
| 791 | return Stage1ZirInstIdOffsetOf; | |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBitOffsetOf *) { | |
| 795 | return IrInstSrcIdBitOffsetOf; | |
| 794 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstBitOffsetOf *) { | |
| 795 | return Stage1ZirInstIdBitOffsetOf; | |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeInfo *) { | |
| 799 | return IrInstSrcIdTypeInfo; | |
| 798 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstTypeInfo *) { | |
| 799 | return Stage1ZirInstIdTypeInfo; | |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcType *) { | |
| 803 | return IrInstSrcIdType; | |
| 802 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstType *) { | |
| 803 | return Stage1ZirInstIdType; | |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcHasField *) { | |
| 807 | return IrInstSrcIdHasField; | |
| 806 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstHasField *) { | |
| 807 | return Stage1ZirInstIdHasField; | |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetEvalBranchQuota *) { | |
| 811 | return IrInstSrcIdSetEvalBranchQuota; | |
| 810 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSetEvalBranchQuota *) { | |
| 811 | return Stage1ZirInstIdSetEvalBranchQuota; | |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPtrType *) { | |
| 815 | return IrInstSrcIdPtrType; | |
| 814 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstPtrType *) { | |
| 815 | return Stage1ZirInstIdPtrType; | |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAlignCast *) { | |
| 819 | return IrInstSrcIdAlignCast; | |
| 818 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstAlignCast *) { | |
| 819 | return Stage1ZirInstIdAlignCast; | |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcImplicitCast *) { | |
| 823 | return IrInstSrcIdImplicitCast; | |
| 822 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstImplicitCast *) { | |
| 823 | return Stage1ZirInstIdImplicitCast; | |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcResolveResult *) { | |
| 827 | return IrInstSrcIdResolveResult; | |
| 826 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstResolveResult *) { | |
| 827 | return Stage1ZirInstIdResolveResult; | |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcResetResult *) { | |
| 831 | return IrInstSrcIdResetResult; | |
| 830 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstResetResult *) { | |
| 831 | return Stage1ZirInstIdResetResult; | |
| 832 | 832 | } |
| 833 | 833 | |
| 834 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetAlignStack *) { | |
| 835 | return IrInstSrcIdSetAlignStack; | |
| 834 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSetAlignStack *) { | |
| 835 | return Stage1ZirInstIdSetAlignStack; | |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcExport *) { | |
| 839 | return IrInstSrcIdExport; | |
| 838 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstExport *) { | |
| 839 | return Stage1ZirInstIdExport; | |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcExtern *) { | |
| 843 | return IrInstSrcIdExtern; | |
| 842 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstExtern *) { | |
| 843 | return Stage1ZirInstIdExtern; | |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrorReturnTrace *) { | |
| 847 | return IrInstSrcIdErrorReturnTrace; | |
| 846 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstErrorReturnTrace *) { | |
| 847 | return Stage1ZirInstIdErrorReturnTrace; | |
| 848 | 848 | } |
| 849 | 849 | |
| 850 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrorUnion *) { | |
| 851 | return IrInstSrcIdErrorUnion; | |
| 850 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstErrorUnion *) { | |
| 851 | return Stage1ZirInstIdErrorUnion; | |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAtomicRmw *) { | |
| 855 | return IrInstSrcIdAtomicRmw; | |
| 854 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstAtomicRmw *) { | |
| 855 | return Stage1ZirInstIdAtomicRmw; | |
| 856 | 856 | } |
| 857 | 857 | |
| 858 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAtomicLoad *) { | |
| 859 | return IrInstSrcIdAtomicLoad; | |
| 858 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstAtomicLoad *) { | |
| 859 | return Stage1ZirInstIdAtomicLoad; | |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAtomicStore *) { | |
| 863 | return IrInstSrcIdAtomicStore; | |
| 862 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstAtomicStore *) { | |
| 863 | return Stage1ZirInstIdAtomicStore; | |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSaveErrRetAddr *) { | |
| 867 | return IrInstSrcIdSaveErrRetAddr; | |
| 866 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSaveErrRetAddr *) { | |
| 867 | return Stage1ZirInstIdSaveErrRetAddr; | |
| 868 | 868 | } |
| 869 | 869 | |
| 870 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAddImplicitReturnType *) { | |
| 871 | return IrInstSrcIdAddImplicitReturnType; | |
| 870 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstAddImplicitReturnType *) { | |
| 871 | return Stage1ZirInstIdAddImplicitReturnType; | |
| 872 | 872 | } |
| 873 | 873 | |
| 874 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrSetCast *) { | |
| 875 | return IrInstSrcIdErrSetCast; | |
| 874 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstErrSetCast *) { | |
| 875 | return Stage1ZirInstIdErrSetCast; | |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckRuntimeScope *) { | |
| 879 | return IrInstSrcIdCheckRuntimeScope; | |
| 878 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstCheckRuntimeScope *) { | |
| 879 | return Stage1ZirInstIdCheckRuntimeScope; | |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcHasDecl *) { | |
| 883 | return IrInstSrcIdHasDecl; | |
| 882 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstHasDecl *) { | |
| 883 | return Stage1ZirInstIdHasDecl; | |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUndeclaredIdent *) { | |
| 887 | return IrInstSrcIdUndeclaredIdent; | |
| 886 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstUndeclaredIdent *) { | |
| 887 | return Stage1ZirInstIdUndeclaredIdent; | |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAlloca *) { | |
| 891 | return IrInstSrcIdAlloca; | |
| 890 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstAlloca *) { | |
| 891 | return Stage1ZirInstIdAlloca; | |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcEndExpr *) { | |
| 895 | return IrInstSrcIdEndExpr; | |
| 894 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstEndExpr *) { | |
| 895 | return Stage1ZirInstIdEndExpr; | |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnionInitNamedField *) { | |
| 899 | return IrInstSrcIdUnionInitNamedField; | |
| 898 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstUnionInitNamedField *) { | |
| 899 | return Stage1ZirInstIdUnionInitNamedField; | |
| 900 | 900 | } |
| 901 | 901 | |
| 902 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSuspendBegin *) { | |
| 903 | return IrInstSrcIdSuspendBegin; | |
| 902 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSuspendBegin *) { | |
| 903 | return Stage1ZirInstIdSuspendBegin; | |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSuspendFinish *) { | |
| 907 | return IrInstSrcIdSuspendFinish; | |
| 906 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSuspendFinish *) { | |
| 907 | return Stage1ZirInstIdSuspendFinish; | |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAwait *) { | |
| 911 | return IrInstSrcIdAwait; | |
| 910 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstAwait *) { | |
| 911 | return Stage1ZirInstIdAwait; | |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcResume *) { | |
| 915 | return IrInstSrcIdResume; | |
| 914 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstResume *) { | |
| 915 | return Stage1ZirInstIdResume; | |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSpillBegin *) { | |
| 919 | return IrInstSrcIdSpillBegin; | |
| 918 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSpillBegin *) { | |
| 919 | return Stage1ZirInstIdSpillBegin; | |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSpillEnd *) { | |
| 923 | return IrInstSrcIdSpillEnd; | |
| 922 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSpillEnd *) { | |
| 923 | return Stage1ZirInstIdSpillEnd; | |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcWasmMemorySize *) { | |
| 927 | return IrInstSrcIdWasmMemorySize; | |
| 926 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstWasmMemorySize *) { | |
| 927 | return Stage1ZirInstIdWasmMemorySize; | |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcWasmMemoryGrow *) { | |
| 931 | return IrInstSrcIdWasmMemoryGrow; | |
| 930 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstWasmMemoryGrow *) { | |
| 931 | return Stage1ZirInstIdWasmMemoryGrow; | |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSrc *) { | |
| 935 | return IrInstSrcIdSrc; | |
| 934 | static constexpr Stage1ZirInstId ir_inst_id(Stage1ZirInstSrc *) { | |
| 935 | return Stage1ZirInstIdSrc; | |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | template<typename T> |
| ... | ... | @@ -953,10 +953,10 @@ static T *ir_build_instruction(Stage1AstGen *ag, Scope *scope, AstNode *source_n |
| 953 | 953 | return special_instruction; |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | static IrInstSrc *ir_build_cond_br(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *condition, | |
| 957 | Stage1ZirBasicBlock *then_block, Stage1ZirBasicBlock *else_block, IrInstSrc *is_comptime) | |
| 956 | static Stage1ZirInst *ir_build_cond_br(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *condition, | |
| 957 | Stage1ZirBasicBlock *then_block, Stage1ZirBasicBlock *else_block, Stage1ZirInst *is_comptime) | |
| 958 | 958 | { |
| 959 | IrInstSrcCondBr *inst = ir_build_instruction<IrInstSrcCondBr>(ag, scope, source_node); | |
| 959 | Stage1ZirInstCondBr *inst = ir_build_instruction<Stage1ZirInstCondBr>(ag, scope, source_node); | |
| 960 | 960 | inst->condition = condition; |
| 961 | 961 | inst->then_block = then_block; |
| 962 | 962 | inst->else_block = else_block; |
| ... | ... | @@ -970,8 +970,8 @@ static IrInstSrc *ir_build_cond_br(Stage1AstGen *ag, Scope *scope, AstNode *sour |
| 970 | 970 | return &inst->base; |
| 971 | 971 | } |
| 972 | 972 | |
| 973 | static IrInstSrc *ir_build_return_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *operand) { | |
| 974 | IrInstSrcReturn *inst = ir_build_instruction<IrInstSrcReturn>(ag, scope, source_node); | |
| 973 | static Stage1ZirInst *ir_build_return_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *operand) { | |
| 974 | Stage1ZirInstReturn *inst = ir_build_instruction<Stage1ZirInstReturn>(ag, scope, source_node); | |
| 975 | 975 | inst->operand = operand; |
| 976 | 976 | |
| 977 | 977 | if (operand != nullptr) ir_ref_instruction(operand, ag->current_basic_block); |
| ... | ... | @@ -979,23 +979,23 @@ static IrInstSrc *ir_build_return_src(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 979 | 979 | return &inst->base; |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | static IrInstSrc *ir_build_const_void(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 983 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 982 | static Stage1ZirInst *ir_build_const_void(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 983 | Stage1ZirInstConst *const_instruction = ir_create_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 984 | 984 | ir_instruction_append(ag->current_basic_block, &const_instruction->base); |
| 985 | 985 | const_instruction->value = ag->codegen->intern.for_void(); |
| 986 | 986 | return &const_instruction->base; |
| 987 | 987 | } |
| 988 | 988 | |
| 989 | static IrInstSrc *ir_build_const_undefined(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 990 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 989 | static Stage1ZirInst *ir_build_const_undefined(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 990 | Stage1ZirInstConst *const_instruction = ir_create_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 991 | 991 | ir_instruction_append(ag->current_basic_block, &const_instruction->base); |
| 992 | 992 | const_instruction->value = ag->codegen->intern.for_undefined(); |
| 993 | 993 | const_instruction->value->special = ConstValSpecialUndef; |
| 994 | 994 | return &const_instruction->base; |
| 995 | 995 | } |
| 996 | 996 | |
| 997 | static IrInstSrc *ir_build_const_uint(Stage1AstGen *ag, Scope *scope, AstNode *source_node, uint64_t value) { | |
| 998 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 997 | static Stage1ZirInst *ir_build_const_uint(Stage1AstGen *ag, Scope *scope, AstNode *source_node, uint64_t value) { | |
| 998 | Stage1ZirInstConst *const_instruction = ir_build_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 999 | 999 | const_instruction->value = ag->codegen->pass1_arena->create<ZigValue>(); |
| 1000 | 1000 | const_instruction->value->type = ag->codegen->builtin_types.entry_num_lit_int; |
| 1001 | 1001 | const_instruction->value->special = ConstValSpecialStatic; |
| ... | ... | @@ -1003,10 +1003,10 @@ static IrInstSrc *ir_build_const_uint(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 1003 | 1003 | return &const_instruction->base; |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | static IrInstSrc *ir_build_const_bigint(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1006 | static Stage1ZirInst *ir_build_const_bigint(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1007 | 1007 | BigInt bigint) |
| 1008 | 1008 | { |
| 1009 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 1009 | Stage1ZirInstConst *const_instruction = ir_build_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 1010 | 1010 | const_instruction->value = ag->codegen->pass1_arena->create<ZigValue>(); |
| 1011 | 1011 | const_instruction->value->type = ag->codegen->builtin_types.entry_num_lit_int; |
| 1012 | 1012 | const_instruction->value->special = ConstValSpecialStatic; |
| ... | ... | @@ -1014,10 +1014,10 @@ static IrInstSrc *ir_build_const_bigint(Stage1AstGen *ag, Scope *scope, AstNode |
| 1014 | 1014 | return &const_instruction->base; |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | static IrInstSrc *ir_build_const_bigfloat(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1017 | static Stage1ZirInst *ir_build_const_bigfloat(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1018 | 1018 | BigFloat bigfloat) |
| 1019 | 1019 | { |
| 1020 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 1020 | Stage1ZirInstConst *const_instruction = ir_build_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 1021 | 1021 | const_instruction->value = ag->codegen->pass1_arena->create<ZigValue>(); |
| 1022 | 1022 | const_instruction->value->type = ag->codegen->builtin_types.entry_num_lit_float; |
| 1023 | 1023 | const_instruction->value->special = ConstValSpecialStatic; |
| ... | ... | @@ -1025,15 +1025,15 @@ static IrInstSrc *ir_build_const_bigfloat(Stage1AstGen *ag, Scope *scope, AstNod |
| 1025 | 1025 | return &const_instruction->base; |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | static IrInstSrc *ir_build_const_null(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 1029 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 1028 | static Stage1ZirInst *ir_build_const_null(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 1029 | Stage1ZirInstConst *const_instruction = ir_create_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 1030 | 1030 | ir_instruction_append(ag->current_basic_block, &const_instruction->base); |
| 1031 | 1031 | const_instruction->value = ag->codegen->intern.for_null(); |
| 1032 | 1032 | return &const_instruction->base; |
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | static IrInstSrc *ir_build_const_usize(Stage1AstGen *ag, Scope *scope, AstNode *source_node, uint64_t value) { | |
| 1036 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 1035 | static Stage1ZirInst *ir_build_const_usize(Stage1AstGen *ag, Scope *scope, AstNode *source_node, uint64_t value) { | |
| 1036 | Stage1ZirInstConst *const_instruction = ir_build_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 1037 | 1037 | const_instruction->value = ag->codegen->pass1_arena->create<ZigValue>(); |
| 1038 | 1038 | const_instruction->value->type = ag->codegen->builtin_types.entry_usize; |
| 1039 | 1039 | const_instruction->value->special = ConstValSpecialStatic; |
| ... | ... | @@ -1041,10 +1041,10 @@ static IrInstSrc *ir_build_const_usize(Stage1AstGen *ag, Scope *scope, AstNode * |
| 1041 | 1041 | return &const_instruction->base; |
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | static IrInstSrc *ir_create_const_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1044 | static Stage1ZirInst *ir_create_const_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1045 | 1045 | ZigType *type_entry) |
| 1046 | 1046 | { |
| 1047 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 1047 | Stage1ZirInstConst *const_instruction = ir_create_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 1048 | 1048 | const_instruction->value = ag->codegen->pass1_arena->create<ZigValue>(); |
| 1049 | 1049 | const_instruction->value->type = ag->codegen->builtin_types.entry_type; |
| 1050 | 1050 | const_instruction->value->special = ConstValSpecialStatic; |
| ... | ... | @@ -1052,16 +1052,16 @@ static IrInstSrc *ir_create_const_type(Stage1AstGen *ag, Scope *scope, AstNode * |
| 1052 | 1052 | return &const_instruction->base; |
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | static IrInstSrc *ir_build_const_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1055 | static Stage1ZirInst *ir_build_const_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1056 | 1056 | ZigType *type_entry) |
| 1057 | 1057 | { |
| 1058 | IrInstSrc *instruction = ir_create_const_type(ag, scope, source_node, type_entry); | |
| 1058 | Stage1ZirInst *instruction = ir_create_const_type(ag, scope, source_node, type_entry); | |
| 1059 | 1059 | ir_instruction_append(ag->current_basic_block, instruction); |
| 1060 | 1060 | return instruction; |
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | static IrInstSrc *ir_build_const_import(Stage1AstGen *ag, Scope *scope, AstNode *source_node, ZigType *import) { | |
| 1064 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 1063 | static Stage1ZirInst *ir_build_const_import(Stage1AstGen *ag, Scope *scope, AstNode *source_node, ZigType *import) { | |
| 1064 | Stage1ZirInstConst *const_instruction = ir_build_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 1065 | 1065 | const_instruction->value = ag->codegen->pass1_arena->create<ZigValue>(); |
| 1066 | 1066 | const_instruction->value->type = ag->codegen->builtin_types.entry_type; |
| 1067 | 1067 | const_instruction->value->special = ConstValSpecialStatic; |
| ... | ... | @@ -1069,8 +1069,8 @@ static IrInstSrc *ir_build_const_import(Stage1AstGen *ag, Scope *scope, AstNode |
| 1069 | 1069 | return &const_instruction->base; |
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | static IrInstSrc *ir_build_const_bool(Stage1AstGen *ag, Scope *scope, AstNode *source_node, bool value) { | |
| 1073 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 1072 | static Stage1ZirInst *ir_build_const_bool(Stage1AstGen *ag, Scope *scope, AstNode *source_node, bool value) { | |
| 1073 | Stage1ZirInstConst *const_instruction = ir_build_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 1074 | 1074 | const_instruction->value = ag->codegen->pass1_arena->create<ZigValue>(); |
| 1075 | 1075 | const_instruction->value->type = ag->codegen->builtin_types.entry_bool; |
| 1076 | 1076 | const_instruction->value->special = ConstValSpecialStatic; |
| ... | ... | @@ -1078,8 +1078,8 @@ static IrInstSrc *ir_build_const_bool(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 1078 | 1078 | return &const_instruction->base; |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | static IrInstSrc *ir_build_const_enum_literal(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Buf *name) { | |
| 1082 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 1081 | static Stage1ZirInst *ir_build_const_enum_literal(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Buf *name) { | |
| 1082 | Stage1ZirInstConst *const_instruction = ir_build_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 1083 | 1083 | const_instruction->value = ag->codegen->pass1_arena->create<ZigValue>(); |
| 1084 | 1084 | const_instruction->value->type = ag->codegen->builtin_types.entry_enum_literal; |
| 1085 | 1085 | const_instruction->value->special = ConstValSpecialStatic; |
| ... | ... | @@ -1088,8 +1088,8 @@ static IrInstSrc *ir_build_const_enum_literal(Stage1AstGen *ag, Scope *scope, As |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | // Consumes `str`. |
| 1091 | static IrInstSrc *ir_create_const_str_lit(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Buf *str) { | |
| 1092 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(ag, scope, source_node); | |
| 1091 | static Stage1ZirInst *ir_create_const_str_lit(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Buf *str) { | |
| 1092 | Stage1ZirInstConst *const_instruction = ir_create_instruction<Stage1ZirInstConst>(ag, scope, source_node); | |
| 1093 | 1093 | const_instruction->value = ag->codegen->pass1_arena->create<ZigValue>(); |
| 1094 | 1094 | init_const_str_lit(ag->codegen, const_instruction->value, str, true); |
| 1095 | 1095 | |
| ... | ... | @@ -1097,16 +1097,16 @@ static IrInstSrc *ir_create_const_str_lit(Stage1AstGen *ag, Scope *scope, AstNod |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | 1099 | // Consumes `str`. |
| 1100 | static IrInstSrc *ir_build_const_str_lit(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Buf *str) { | |
| 1101 | IrInstSrc *instruction = ir_create_const_str_lit(ag, scope, source_node, str); | |
| 1100 | static Stage1ZirInst *ir_build_const_str_lit(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Buf *str) { | |
| 1101 | Stage1ZirInst *instruction = ir_create_const_str_lit(ag, scope, source_node, str); | |
| 1102 | 1102 | ir_instruction_append(ag->current_basic_block, instruction); |
| 1103 | 1103 | return instruction; |
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | static IrInstSrc *ir_build_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrBinOp op_id, | |
| 1107 | IrInstSrc *op1, IrInstSrc *op2, bool safety_check_on) | |
| 1106 | static Stage1ZirInst *ir_build_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrBinOp op_id, | |
| 1107 | Stage1ZirInst *op1, Stage1ZirInst *op2, bool safety_check_on) | |
| 1108 | 1108 | { |
| 1109 | IrInstSrcBinOp *inst = ir_build_instruction<IrInstSrcBinOp>(ag, scope, source_node); | |
| 1109 | Stage1ZirInstBinOp *inst = ir_build_instruction<Stage1ZirInstBinOp>(ag, scope, source_node); | |
| 1110 | 1110 | inst->op_id = op_id; |
| 1111 | 1111 | inst->op1 = op1; |
| 1112 | 1112 | inst->op2 = op2; |
| ... | ... | @@ -1118,10 +1118,10 @@ static IrInstSrc *ir_build_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *sourc |
| 1118 | 1118 | return &inst->base; |
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | static IrInstSrc *ir_build_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1122 | IrInstSrc *op1, IrInstSrc *op2, Buf *type_name) | |
| 1121 | static Stage1ZirInst *ir_build_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1122 | Stage1ZirInst *op1, Stage1ZirInst *op2, Buf *type_name) | |
| 1123 | 1123 | { |
| 1124 | IrInstSrcMergeErrSets *inst = ir_build_instruction<IrInstSrcMergeErrSets>(ag, scope, source_node); | |
| 1124 | Stage1ZirInstMergeErrSets *inst = ir_build_instruction<Stage1ZirInstMergeErrSets>(ag, scope, source_node); | |
| 1125 | 1125 | inst->op1 = op1; |
| 1126 | 1126 | inst->op2 = op2; |
| 1127 | 1127 | inst->type_name = type_name; |
| ... | ... | @@ -1132,10 +1132,10 @@ static IrInstSrc *ir_build_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNod |
| 1132 | 1132 | return &inst->base; |
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | static IrInstSrc *ir_build_var_ptr_x(Stage1AstGen *ag, Scope *scope, AstNode *source_node, ZigVar *var, | |
| 1135 | static Stage1ZirInst *ir_build_var_ptr_x(Stage1AstGen *ag, Scope *scope, AstNode *source_node, ZigVar *var, | |
| 1136 | 1136 | ScopeFnDef *crossed_fndef_scope) |
| 1137 | 1137 | { |
| 1138 | IrInstSrcVarPtr *instruction = ir_build_instruction<IrInstSrcVarPtr>(ag, scope, source_node); | |
| 1138 | Stage1ZirInstVarPtr *instruction = ir_build_instruction<Stage1ZirInstVarPtr>(ag, scope, source_node); | |
| 1139 | 1139 | instruction->var = var; |
| 1140 | 1140 | instruction->crossed_fndef_scope = crossed_fndef_scope; |
| 1141 | 1141 | |
| ... | ... | @@ -1144,15 +1144,15 @@ static IrInstSrc *ir_build_var_ptr_x(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 1144 | 1144 | return &instruction->base; |
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | static IrInstSrc *ir_build_var_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, ZigVar *var) { | |
| 1147 | static Stage1ZirInst *ir_build_var_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, ZigVar *var) { | |
| 1148 | 1148 | return ir_build_var_ptr_x(ag, scope, source_node, var, nullptr); |
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | static IrInstSrc *ir_build_elem_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1152 | IrInstSrc *array_ptr, IrInstSrc *elem_index, bool safety_check_on, PtrLen ptr_len, | |
| 1151 | static Stage1ZirInst *ir_build_elem_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1152 | Stage1ZirInst *array_ptr, Stage1ZirInst *elem_index, bool safety_check_on, PtrLen ptr_len, | |
| 1153 | 1153 | AstNode *init_array_type_source_node) |
| 1154 | 1154 | { |
| 1155 | IrInstSrcElemPtr *instruction = ir_build_instruction<IrInstSrcElemPtr>(ag, scope, source_node); | |
| 1155 | Stage1ZirInstElemPtr *instruction = ir_build_instruction<Stage1ZirInstElemPtr>(ag, scope, source_node); | |
| 1156 | 1156 | instruction->array_ptr = array_ptr; |
| 1157 | 1157 | instruction->elem_index = elem_index; |
| 1158 | 1158 | instruction->safety_check_on = safety_check_on; |
| ... | ... | @@ -1165,10 +1165,10 @@ static IrInstSrc *ir_build_elem_ptr(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1165 | 1165 | return &instruction->base; |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | static IrInstSrc *ir_build_field_ptr_instruction(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1169 | IrInstSrc *container_ptr, IrInstSrc *field_name_expr, bool initializing) | |
| 1168 | static Stage1ZirInst *ir_build_field_ptr_instruction(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1169 | Stage1ZirInst *container_ptr, Stage1ZirInst *field_name_expr, bool initializing) | |
| 1170 | 1170 | { |
| 1171 | IrInstSrcFieldPtr *instruction = ir_build_instruction<IrInstSrcFieldPtr>(ag, scope, source_node); | |
| 1171 | Stage1ZirInstFieldPtr *instruction = ir_build_instruction<Stage1ZirInstFieldPtr>(ag, scope, source_node); | |
| 1172 | 1172 | instruction->container_ptr = container_ptr; |
| 1173 | 1173 | instruction->field_name_buffer = nullptr; |
| 1174 | 1174 | instruction->field_name_expr = field_name_expr; |
| ... | ... | @@ -1180,10 +1180,10 @@ static IrInstSrc *ir_build_field_ptr_instruction(Stage1AstGen *ag, Scope *scope, |
| 1180 | 1180 | return &instruction->base; |
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | static IrInstSrc *ir_build_field_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1184 | IrInstSrc *container_ptr, Buf *field_name, bool initializing) | |
| 1183 | static Stage1ZirInst *ir_build_field_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1184 | Stage1ZirInst *container_ptr, Buf *field_name, bool initializing) | |
| 1185 | 1185 | { |
| 1186 | IrInstSrcFieldPtr *instruction = ir_build_instruction<IrInstSrcFieldPtr>(ag, scope, source_node); | |
| 1186 | Stage1ZirInstFieldPtr *instruction = ir_build_instruction<Stage1ZirInstFieldPtr>(ag, scope, source_node); | |
| 1187 | 1187 | instruction->container_ptr = container_ptr; |
| 1188 | 1188 | instruction->field_name_buffer = field_name; |
| 1189 | 1189 | instruction->field_name_expr = nullptr; |
| ... | ... | @@ -1194,10 +1194,10 @@ static IrInstSrc *ir_build_field_ptr(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 1194 | 1194 | return &instruction->base; |
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | static IrInstSrc *ir_build_has_field(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1198 | IrInstSrc *container_type, IrInstSrc *field_name) | |
| 1197 | static Stage1ZirInst *ir_build_has_field(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1198 | Stage1ZirInst *container_type, Stage1ZirInst *field_name) | |
| 1199 | 1199 | { |
| 1200 | IrInstSrcHasField *instruction = ir_build_instruction<IrInstSrcHasField>(ag, scope, source_node); | |
| 1200 | Stage1ZirInstHasField *instruction = ir_build_instruction<Stage1ZirInstHasField>(ag, scope, source_node); | |
| 1201 | 1201 | instruction->container_type = container_type; |
| 1202 | 1202 | instruction->field_name = field_name; |
| 1203 | 1203 | |
| ... | ... | @@ -1207,10 +1207,10 @@ static IrInstSrc *ir_build_has_field(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 1207 | 1207 | return &instruction->base; |
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | static IrInstSrc *ir_build_call_extra(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1211 | IrInstSrc *options, IrInstSrc *fn_ref, IrInstSrc *args, ResultLoc *result_loc) | |
| 1210 | static Stage1ZirInst *ir_build_call_extra(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1211 | Stage1ZirInst *options, Stage1ZirInst *fn_ref, Stage1ZirInst *args, ResultLoc *result_loc) | |
| 1212 | 1212 | { |
| 1213 | IrInstSrcCallExtra *call_instruction = ir_build_instruction<IrInstSrcCallExtra>(ag, scope, source_node); | |
| 1213 | Stage1ZirInstCallExtra *call_instruction = ir_build_instruction<Stage1ZirInstCallExtra>(ag, scope, source_node); | |
| 1214 | 1214 | call_instruction->options = options; |
| 1215 | 1215 | call_instruction->fn_ref = fn_ref; |
| 1216 | 1216 | call_instruction->args = args; |
| ... | ... | @@ -1223,10 +1223,10 @@ static IrInstSrc *ir_build_call_extra(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 1223 | 1223 | return &call_instruction->base; |
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | static IrInstSrc *ir_build_async_call_extra(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1227 | CallModifier modifier, IrInstSrc *fn_ref, IrInstSrc *ret_ptr, IrInstSrc *new_stack, IrInstSrc *args, ResultLoc *result_loc) | |
| 1226 | static Stage1ZirInst *ir_build_async_call_extra(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1227 | CallModifier modifier, Stage1ZirInst *fn_ref, Stage1ZirInst *ret_ptr, Stage1ZirInst *new_stack, Stage1ZirInst *args, ResultLoc *result_loc) | |
| 1228 | 1228 | { |
| 1229 | IrInstSrcAsyncCallExtra *call_instruction = ir_build_instruction<IrInstSrcAsyncCallExtra>(ag, scope, source_node); | |
| 1229 | Stage1ZirInstAsyncCallExtra *call_instruction = ir_build_instruction<Stage1ZirInstAsyncCallExtra>(ag, scope, source_node); | |
| 1230 | 1230 | call_instruction->modifier = modifier; |
| 1231 | 1231 | call_instruction->fn_ref = fn_ref; |
| 1232 | 1232 | call_instruction->ret_ptr = ret_ptr; |
| ... | ... | @@ -1242,11 +1242,11 @@ static IrInstSrc *ir_build_async_call_extra(Stage1AstGen *ag, Scope *scope, AstN |
| 1242 | 1242 | return &call_instruction->base; |
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | static IrInstSrc *ir_build_call_args(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1246 | IrInstSrc *options, IrInstSrc *fn_ref, IrInstSrc **args_ptr, size_t args_len, | |
| 1245 | static Stage1ZirInst *ir_build_call_args(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1246 | Stage1ZirInst *options, Stage1ZirInst *fn_ref, Stage1ZirInst **args_ptr, size_t args_len, | |
| 1247 | 1247 | ResultLoc *result_loc) |
| 1248 | 1248 | { |
| 1249 | IrInstSrcCallArgs *call_instruction = ir_build_instruction<IrInstSrcCallArgs>(ag, scope, source_node); | |
| 1249 | Stage1ZirInstCallArgs *call_instruction = ir_build_instruction<Stage1ZirInstCallArgs>(ag, scope, source_node); | |
| 1250 | 1250 | call_instruction->options = options; |
| 1251 | 1251 | call_instruction->fn_ref = fn_ref; |
| 1252 | 1252 | call_instruction->args_ptr = args_ptr; |
| ... | ... | @@ -1261,12 +1261,12 @@ static IrInstSrc *ir_build_call_args(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 1261 | 1261 | return &call_instruction->base; |
| 1262 | 1262 | } |
| 1263 | 1263 | |
| 1264 | static IrInstSrc *ir_build_call_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1265 | ZigFn *fn_entry, IrInstSrc *fn_ref, size_t arg_count, IrInstSrc **args, | |
| 1266 | IrInstSrc *ret_ptr, CallModifier modifier, bool is_async_call_builtin, | |
| 1267 | IrInstSrc *new_stack, ResultLoc *result_loc) | |
| 1264 | static Stage1ZirInst *ir_build_call_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1265 | ZigFn *fn_entry, Stage1ZirInst *fn_ref, size_t arg_count, Stage1ZirInst **args, | |
| 1266 | Stage1ZirInst *ret_ptr, CallModifier modifier, bool is_async_call_builtin, | |
| 1267 | Stage1ZirInst *new_stack, ResultLoc *result_loc) | |
| 1268 | 1268 | { |
| 1269 | IrInstSrcCall *call_instruction = ir_build_instruction<IrInstSrcCall>(ag, scope, source_node); | |
| 1269 | Stage1ZirInstCall *call_instruction = ir_build_instruction<Stage1ZirInstCall>(ag, scope, source_node); | |
| 1270 | 1270 | call_instruction->fn_entry = fn_entry; |
| 1271 | 1271 | call_instruction->fn_ref = fn_ref; |
| 1272 | 1272 | call_instruction->args = args; |
| ... | ... | @@ -1286,14 +1286,14 @@ static IrInstSrc *ir_build_call_src(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1286 | 1286 | return &call_instruction->base; |
| 1287 | 1287 | } |
| 1288 | 1288 | |
| 1289 | static IrInstSrc *ir_build_phi(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1290 | size_t incoming_count, Stage1ZirBasicBlock **incoming_blocks, IrInstSrc **incoming_values, | |
| 1289 | static Stage1ZirInst *ir_build_phi(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1290 | size_t incoming_count, Stage1ZirBasicBlock **incoming_blocks, Stage1ZirInst **incoming_values, | |
| 1291 | 1291 | ResultLocPeerParent *peer_parent) |
| 1292 | 1292 | { |
| 1293 | 1293 | assert(incoming_count != 0); |
| 1294 | 1294 | assert(incoming_count != SIZE_MAX); |
| 1295 | 1295 | |
| 1296 | IrInstSrcPhi *phi_instruction = ir_build_instruction<IrInstSrcPhi>(ag, scope, source_node); | |
| 1296 | Stage1ZirInstPhi *phi_instruction = ir_build_instruction<Stage1ZirInstPhi>(ag, scope, source_node); | |
| 1297 | 1297 | phi_instruction->incoming_count = incoming_count; |
| 1298 | 1298 | phi_instruction->incoming_blocks = incoming_blocks; |
| 1299 | 1299 | phi_instruction->incoming_values = incoming_values; |
| ... | ... | @@ -1307,10 +1307,10 @@ static IrInstSrc *ir_build_phi(Stage1AstGen *ag, Scope *scope, AstNode *source_n |
| 1307 | 1307 | return &phi_instruction->base; |
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | static IrInstSrc *ir_build_br(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1311 | Stage1ZirBasicBlock *dest_block, IrInstSrc *is_comptime) | |
| 1310 | static Stage1ZirInst *ir_build_br(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1311 | Stage1ZirBasicBlock *dest_block, Stage1ZirInst *is_comptime) | |
| 1312 | 1312 | { |
| 1313 | IrInstSrcBr *inst = ir_build_instruction<IrInstSrcBr>(ag, scope, source_node); | |
| 1313 | Stage1ZirInstBr *inst = ir_build_instruction<Stage1ZirInstBr>(ag, scope, source_node); | |
| 1314 | 1314 | inst->dest_block = dest_block; |
| 1315 | 1315 | inst->is_comptime = is_comptime; |
| 1316 | 1316 | |
| ... | ... | @@ -1320,11 +1320,11 @@ static IrInstSrc *ir_build_br(Stage1AstGen *ag, Scope *scope, AstNode *source_no |
| 1320 | 1320 | return &inst->base; |
| 1321 | 1321 | } |
| 1322 | 1322 | |
| 1323 | static IrInstSrc *ir_build_ptr_type_simple(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1324 | IrInstSrc *child_type, bool is_const) | |
| 1323 | static Stage1ZirInst *ir_build_ptr_type_simple(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1324 | Stage1ZirInst *child_type, bool is_const) | |
| 1325 | 1325 | { |
| 1326 | IrInstSrcPtrTypeSimple *inst = heap::c_allocator.create<IrInstSrcPtrTypeSimple>(); | |
| 1327 | inst->base.id = is_const ? IrInstSrcIdPtrTypeSimpleConst : IrInstSrcIdPtrTypeSimple; | |
| 1326 | Stage1ZirInstPtrTypeSimple *inst = heap::c_allocator.create<Stage1ZirInstPtrTypeSimple>(); | |
| 1327 | inst->base.id = is_const ? Stage1ZirInstIdPtrTypeSimpleConst : Stage1ZirInstIdPtrTypeSimple; | |
| 1328 | 1328 | inst->base.scope = scope; |
| 1329 | 1329 | inst->base.source_node = source_node; |
| 1330 | 1330 | inst->base.debug_id = irb_next_debug_id(ag); |
| ... | ... | @@ -1338,9 +1338,9 @@ static IrInstSrc *ir_build_ptr_type_simple(Stage1AstGen *ag, Scope *scope, AstNo |
| 1338 | 1338 | return &inst->base; |
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | static IrInstSrc *ir_build_ptr_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1342 | IrInstSrc *child_type, bool is_const, bool is_volatile, PtrLen ptr_len, | |
| 1343 | IrInstSrc *sentinel, IrInstSrc *align_value, | |
| 1341 | static Stage1ZirInst *ir_build_ptr_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1342 | Stage1ZirInst *child_type, bool is_const, bool is_volatile, PtrLen ptr_len, | |
| 1343 | Stage1ZirInst *sentinel, Stage1ZirInst *align_value, | |
| 1344 | 1344 | uint32_t bit_offset_start, uint32_t host_int_bytes, bool is_allow_zero) |
| 1345 | 1345 | { |
| 1346 | 1346 | if (!is_volatile && ptr_len == PtrLenSingle && sentinel == nullptr && align_value == nullptr && |
| ... | ... | @@ -1349,7 +1349,7 @@ static IrInstSrc *ir_build_ptr_type(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1349 | 1349 | return ir_build_ptr_type_simple(ag, scope, source_node, child_type, is_const); |
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | IrInstSrcPtrType *inst = ir_build_instruction<IrInstSrcPtrType>(ag, scope, source_node); | |
| 1352 | Stage1ZirInstPtrType *inst = ir_build_instruction<Stage1ZirInstPtrType>(ag, scope, source_node); | |
| 1353 | 1353 | inst->sentinel = sentinel; |
| 1354 | 1354 | inst->align_value = align_value; |
| 1355 | 1355 | inst->child_type = child_type; |
| ... | ... | @@ -1367,10 +1367,10 @@ static IrInstSrc *ir_build_ptr_type(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1367 | 1367 | return &inst->base; |
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | static IrInstSrc *ir_build_un_op_lval(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrUnOp op_id, | |
| 1371 | IrInstSrc *value, LVal lval, ResultLoc *result_loc) | |
| 1370 | static Stage1ZirInst *ir_build_un_op_lval(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrUnOp op_id, | |
| 1371 | Stage1ZirInst *value, LVal lval, ResultLoc *result_loc) | |
| 1372 | 1372 | { |
| 1373 | IrInstSrcUnOp *instruction = ir_build_instruction<IrInstSrcUnOp>(ag, scope, source_node); | |
| 1373 | Stage1ZirInstUnOp *instruction = ir_build_instruction<Stage1ZirInstUnOp>(ag, scope, source_node); | |
| 1374 | 1374 | instruction->op_id = op_id; |
| 1375 | 1375 | instruction->value = value; |
| 1376 | 1376 | instruction->lval = lval; |
| ... | ... | @@ -1381,18 +1381,18 @@ static IrInstSrc *ir_build_un_op_lval(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 1381 | 1381 | return &instruction->base; |
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | static IrInstSrc *ir_build_un_op(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrUnOp op_id, | |
| 1385 | IrInstSrc *value) | |
| 1384 | static Stage1ZirInst *ir_build_un_op(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrUnOp op_id, | |
| 1385 | Stage1ZirInst *value) | |
| 1386 | 1386 | { |
| 1387 | 1387 | return ir_build_un_op_lval(ag, scope, source_node, op_id, value, LValNone, nullptr); |
| 1388 | 1388 | } |
| 1389 | 1389 | |
| 1390 | static IrInstSrc *ir_build_container_init_list(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1391 | size_t item_count, IrInstSrc **elem_result_loc_list, IrInstSrc *result_loc, | |
| 1390 | static Stage1ZirInst *ir_build_container_init_list(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1391 | size_t item_count, Stage1ZirInst **elem_result_loc_list, Stage1ZirInst *result_loc, | |
| 1392 | 1392 | AstNode *init_array_type_source_node) |
| 1393 | 1393 | { |
| 1394 | IrInstSrcContainerInitList *container_init_list_instruction = | |
| 1395 | ir_build_instruction<IrInstSrcContainerInitList>(ag, scope, source_node); | |
| 1394 | Stage1ZirInstContainerInitList *container_init_list_instruction = | |
| 1395 | ir_build_instruction<Stage1ZirInstContainerInitList>(ag, scope, source_node); | |
| 1396 | 1396 | container_init_list_instruction->item_count = item_count; |
| 1397 | 1397 | container_init_list_instruction->elem_result_loc_list = elem_result_loc_list; |
| 1398 | 1398 | container_init_list_instruction->result_loc = result_loc; |
| ... | ... | @@ -1406,11 +1406,11 @@ static IrInstSrc *ir_build_container_init_list(Stage1AstGen *ag, Scope *scope, A |
| 1406 | 1406 | return &container_init_list_instruction->base; |
| 1407 | 1407 | } |
| 1408 | 1408 | |
| 1409 | static IrInstSrc *ir_build_container_init_fields(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1410 | size_t field_count, IrInstSrcContainerInitFieldsField *fields, IrInstSrc *result_loc) | |
| 1409 | static Stage1ZirInst *ir_build_container_init_fields(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1410 | size_t field_count, Stage1ZirInstContainerInitFieldsField *fields, Stage1ZirInst *result_loc) | |
| 1411 | 1411 | { |
| 1412 | IrInstSrcContainerInitFields *container_init_fields_instruction = | |
| 1413 | ir_build_instruction<IrInstSrcContainerInitFields>(ag, scope, source_node); | |
| 1412 | Stage1ZirInstContainerInitFields *container_init_fields_instruction = | |
| 1413 | ir_build_instruction<Stage1ZirInstContainerInitFields>(ag, scope, source_node); | |
| 1414 | 1414 | container_init_fields_instruction->field_count = field_count; |
| 1415 | 1415 | container_init_fields_instruction->fields = fields; |
| 1416 | 1416 | container_init_fields_instruction->result_loc = result_loc; |
| ... | ... | @@ -1423,15 +1423,15 @@ static IrInstSrc *ir_build_container_init_fields(Stage1AstGen *ag, Scope *scope, |
| 1423 | 1423 | return &container_init_fields_instruction->base; |
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | static IrInstSrc *ir_build_unreachable(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 1427 | IrInstSrcUnreachable *inst = ir_build_instruction<IrInstSrcUnreachable>(ag, scope, source_node); | |
| 1426 | static Stage1ZirInst *ir_build_unreachable(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 1427 | Stage1ZirInstUnreachable *inst = ir_build_instruction<Stage1ZirInstUnreachable>(ag, scope, source_node); | |
| 1428 | 1428 | return &inst->base; |
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | static IrInstSrcStorePtr *ir_build_store_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1432 | IrInstSrc *ptr, IrInstSrc *value) | |
| 1431 | static Stage1ZirInstStorePtr *ir_build_store_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1432 | Stage1ZirInst *ptr, Stage1ZirInst *value) | |
| 1433 | 1433 | { |
| 1434 | IrInstSrcStorePtr *instruction = ir_build_instruction<IrInstSrcStorePtr>(ag, scope, source_node); | |
| 1434 | Stage1ZirInstStorePtr *instruction = ir_build_instruction<Stage1ZirInstStorePtr>(ag, scope, source_node); | |
| 1435 | 1435 | instruction->ptr = ptr; |
| 1436 | 1436 | instruction->value = value; |
| 1437 | 1437 | |
| ... | ... | @@ -1441,10 +1441,10 @@ static IrInstSrcStorePtr *ir_build_store_ptr(Stage1AstGen *ag, Scope *scope, Ast |
| 1441 | 1441 | return instruction; |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | static IrInstSrc *ir_build_var_decl_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1445 | ZigVar *var, IrInstSrc *align_value, IrInstSrc *ptr) | |
| 1444 | static Stage1ZirInst *ir_build_var_decl_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1445 | ZigVar *var, Stage1ZirInst *align_value, Stage1ZirInst *ptr) | |
| 1446 | 1446 | { |
| 1447 | IrInstSrcDeclVar *inst = ir_build_instruction<IrInstSrcDeclVar>(ag, scope, source_node); | |
| 1447 | Stage1ZirInstDeclVar *inst = ir_build_instruction<Stage1ZirInstDeclVar>(ag, scope, source_node); | |
| 1448 | 1448 | inst->var = var; |
| 1449 | 1449 | inst->align_value = align_value; |
| 1450 | 1450 | inst->ptr = ptr; |
| ... | ... | @@ -1455,10 +1455,10 @@ static IrInstSrc *ir_build_var_decl_src(Stage1AstGen *ag, Scope *scope, AstNode |
| 1455 | 1455 | return &inst->base; |
| 1456 | 1456 | } |
| 1457 | 1457 | |
| 1458 | static IrInstSrc *ir_build_export(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1459 | IrInstSrc *target, IrInstSrc *options) | |
| 1458 | static Stage1ZirInst *ir_build_export(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1459 | Stage1ZirInst *target, Stage1ZirInst *options) | |
| 1460 | 1460 | { |
| 1461 | IrInstSrcExport *export_instruction = ir_build_instruction<IrInstSrcExport>( | |
| 1461 | Stage1ZirInstExport *export_instruction = ir_build_instruction<Stage1ZirInstExport>( | |
| 1462 | 1462 | ag, scope, source_node); |
| 1463 | 1463 | export_instruction->target = target; |
| 1464 | 1464 | export_instruction->options = options; |
| ... | ... | @@ -1469,10 +1469,10 @@ static IrInstSrc *ir_build_export(Stage1AstGen *ag, Scope *scope, AstNode *sourc |
| 1469 | 1469 | return &export_instruction->base; |
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | static IrInstSrc *ir_build_extern(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1473 | IrInstSrc *type, IrInstSrc *options) | |
| 1472 | static Stage1ZirInst *ir_build_extern(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1473 | Stage1ZirInst *type, Stage1ZirInst *options) | |
| 1474 | 1474 | { |
| 1475 | IrInstSrcExtern *extern_instruction = ir_build_instruction<IrInstSrcExtern>( | |
| 1475 | Stage1ZirInstExtern *extern_instruction = ir_build_instruction<Stage1ZirInstExtern>( | |
| 1476 | 1476 | ag, scope, source_node); |
| 1477 | 1477 | extern_instruction->type = type; |
| 1478 | 1478 | extern_instruction->options = options; |
| ... | ... | @@ -1483,8 +1483,8 @@ static IrInstSrc *ir_build_extern(Stage1AstGen *ag, Scope *scope, AstNode *sourc |
| 1483 | 1483 | return &extern_instruction->base; |
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | static IrInstSrc *ir_build_load_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *ptr) { | |
| 1487 | IrInstSrcLoadPtr *instruction = ir_build_instruction<IrInstSrcLoadPtr>(ag, scope, source_node); | |
| 1486 | static Stage1ZirInst *ir_build_load_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *ptr) { | |
| 1487 | Stage1ZirInstLoadPtr *instruction = ir_build_instruction<Stage1ZirInstLoadPtr>(ag, scope, source_node); | |
| 1488 | 1488 | instruction->ptr = ptr; |
| 1489 | 1489 | |
| 1490 | 1490 | ir_ref_instruction(ptr, ag->current_basic_block); |
| ... | ... | @@ -1492,12 +1492,12 @@ static IrInstSrc *ir_build_load_ptr(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1492 | 1492 | return &instruction->base; |
| 1493 | 1493 | } |
| 1494 | 1494 | |
| 1495 | static IrInstSrc *ir_build_typeof_n(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1496 | IrInstSrc **values, size_t value_count) | |
| 1495 | static Stage1ZirInst *ir_build_typeof_n(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1496 | Stage1ZirInst **values, size_t value_count) | |
| 1497 | 1497 | { |
| 1498 | 1498 | assert(value_count >= 2); |
| 1499 | 1499 | |
| 1500 | IrInstSrcTypeOf *instruction = ir_build_instruction<IrInstSrcTypeOf>(ag, scope, source_node); | |
| 1500 | Stage1ZirInstTypeOf *instruction = ir_build_instruction<Stage1ZirInstTypeOf>(ag, scope, source_node); | |
| 1501 | 1501 | instruction->value.list = values; |
| 1502 | 1502 | instruction->value_count = value_count; |
| 1503 | 1503 | |
| ... | ... | @@ -1507,8 +1507,8 @@ static IrInstSrc *ir_build_typeof_n(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1507 | 1507 | return &instruction->base; |
| 1508 | 1508 | } |
| 1509 | 1509 | |
| 1510 | static IrInstSrc *ir_build_typeof_1(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *value) { | |
| 1511 | IrInstSrcTypeOf *instruction = ir_build_instruction<IrInstSrcTypeOf>(ag, scope, source_node); | |
| 1510 | static Stage1ZirInst *ir_build_typeof_1(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *value) { | |
| 1511 | Stage1ZirInstTypeOf *instruction = ir_build_instruction<Stage1ZirInstTypeOf>(ag, scope, source_node); | |
| 1512 | 1512 | instruction->value.scalar = value; |
| 1513 | 1513 | |
| 1514 | 1514 | ir_ref_instruction(value, ag->current_basic_block); |
| ... | ... | @@ -1516,8 +1516,8 @@ static IrInstSrc *ir_build_typeof_1(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1516 | 1516 | return &instruction->base; |
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | static IrInstSrc *ir_build_set_cold(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *is_cold) { | |
| 1520 | IrInstSrcSetCold *instruction = ir_build_instruction<IrInstSrcSetCold>(ag, scope, source_node); | |
| 1519 | static Stage1ZirInst *ir_build_set_cold(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *is_cold) { | |
| 1520 | Stage1ZirInstSetCold *instruction = ir_build_instruction<Stage1ZirInstSetCold>(ag, scope, source_node); | |
| 1521 | 1521 | instruction->is_cold = is_cold; |
| 1522 | 1522 | |
| 1523 | 1523 | ir_ref_instruction(is_cold, ag->current_basic_block); |
| ... | ... | @@ -1525,10 +1525,10 @@ static IrInstSrc *ir_build_set_cold(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1525 | 1525 | return &instruction->base; |
| 1526 | 1526 | } |
| 1527 | 1527 | |
| 1528 | static IrInstSrc *ir_build_set_runtime_safety(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1529 | IrInstSrc *safety_on) | |
| 1528 | static Stage1ZirInst *ir_build_set_runtime_safety(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1529 | Stage1ZirInst *safety_on) | |
| 1530 | 1530 | { |
| 1531 | IrInstSrcSetRuntimeSafety *inst = ir_build_instruction<IrInstSrcSetRuntimeSafety>(ag, scope, source_node); | |
| 1531 | Stage1ZirInstSetRuntimeSafety *inst = ir_build_instruction<Stage1ZirInstSetRuntimeSafety>(ag, scope, source_node); | |
| 1532 | 1532 | inst->safety_on = safety_on; |
| 1533 | 1533 | |
| 1534 | 1534 | ir_ref_instruction(safety_on, ag->current_basic_block); |
| ... | ... | @@ -1536,10 +1536,10 @@ static IrInstSrc *ir_build_set_runtime_safety(Stage1AstGen *ag, Scope *scope, As |
| 1536 | 1536 | return &inst->base; |
| 1537 | 1537 | } |
| 1538 | 1538 | |
| 1539 | static IrInstSrc *ir_build_set_float_mode(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1540 | IrInstSrc *mode_value) | |
| 1539 | static Stage1ZirInst *ir_build_set_float_mode(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1540 | Stage1ZirInst *mode_value) | |
| 1541 | 1541 | { |
| 1542 | IrInstSrcSetFloatMode *instruction = ir_build_instruction<IrInstSrcSetFloatMode>(ag, scope, source_node); | |
| 1542 | Stage1ZirInstSetFloatMode *instruction = ir_build_instruction<Stage1ZirInstSetFloatMode>(ag, scope, source_node); | |
| 1543 | 1543 | instruction->mode_value = mode_value; |
| 1544 | 1544 | |
| 1545 | 1545 | ir_ref_instruction(mode_value, ag->current_basic_block); |
| ... | ... | @@ -1547,10 +1547,10 @@ static IrInstSrc *ir_build_set_float_mode(Stage1AstGen *ag, Scope *scope, AstNod |
| 1547 | 1547 | return &instruction->base; |
| 1548 | 1548 | } |
| 1549 | 1549 | |
| 1550 | static IrInstSrc *ir_build_array_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *size, | |
| 1551 | IrInstSrc *sentinel, IrInstSrc *child_type) | |
| 1550 | static Stage1ZirInst *ir_build_array_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *size, | |
| 1551 | Stage1ZirInst *sentinel, Stage1ZirInst *child_type) | |
| 1552 | 1552 | { |
| 1553 | IrInstSrcArrayType *instruction = ir_build_instruction<IrInstSrcArrayType>(ag, scope, source_node); | |
| 1553 | Stage1ZirInstArrayType *instruction = ir_build_instruction<Stage1ZirInstArrayType>(ag, scope, source_node); | |
| 1554 | 1554 | instruction->size = size; |
| 1555 | 1555 | instruction->sentinel = sentinel; |
| 1556 | 1556 | instruction->child_type = child_type; |
| ... | ... | @@ -1562,10 +1562,10 @@ static IrInstSrc *ir_build_array_type(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 1562 | 1562 | return &instruction->base; |
| 1563 | 1563 | } |
| 1564 | 1564 | |
| 1565 | static IrInstSrc *ir_build_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1566 | IrInstSrc *payload_type) | |
| 1565 | static Stage1ZirInst *ir_build_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1566 | Stage1ZirInst *payload_type) | |
| 1567 | 1567 | { |
| 1568 | IrInstSrcAnyFrameType *instruction = ir_build_instruction<IrInstSrcAnyFrameType>(ag, scope, source_node); | |
| 1568 | Stage1ZirInstAnyFrameType *instruction = ir_build_instruction<Stage1ZirInstAnyFrameType>(ag, scope, source_node); | |
| 1569 | 1569 | instruction->payload_type = payload_type; |
| 1570 | 1570 | |
| 1571 | 1571 | if (payload_type != nullptr) ir_ref_instruction(payload_type, ag->current_basic_block); |
| ... | ... | @@ -1573,11 +1573,11 @@ static IrInstSrc *ir_build_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode |
| 1573 | 1573 | return &instruction->base; |
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | static IrInstSrc *ir_build_slice_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1577 | IrInstSrc *child_type, bool is_const, bool is_volatile, | |
| 1578 | IrInstSrc *sentinel, IrInstSrc *align_value, bool is_allow_zero) | |
| 1576 | static Stage1ZirInst *ir_build_slice_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1577 | Stage1ZirInst *child_type, bool is_const, bool is_volatile, | |
| 1578 | Stage1ZirInst *sentinel, Stage1ZirInst *align_value, bool is_allow_zero) | |
| 1579 | 1579 | { |
| 1580 | IrInstSrcSliceType *instruction = ir_build_instruction<IrInstSrcSliceType>(ag, scope, source_node); | |
| 1580 | Stage1ZirInstSliceType *instruction = ir_build_instruction<Stage1ZirInstSliceType>(ag, scope, source_node); | |
| 1581 | 1581 | instruction->is_const = is_const; |
| 1582 | 1582 | instruction->is_volatile = is_volatile; |
| 1583 | 1583 | instruction->child_type = child_type; |
| ... | ... | @@ -1592,11 +1592,11 @@ static IrInstSrc *ir_build_slice_type(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 1592 | 1592 | return &instruction->base; |
| 1593 | 1593 | } |
| 1594 | 1594 | |
| 1595 | static IrInstSrc *ir_build_asm_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1596 | IrInstSrc *asm_template, IrInstSrc **input_list, IrInstSrc **output_types, | |
| 1595 | static Stage1ZirInst *ir_build_asm_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1596 | Stage1ZirInst *asm_template, Stage1ZirInst **input_list, Stage1ZirInst **output_types, | |
| 1597 | 1597 | ZigVar **output_vars, size_t return_count, bool has_side_effects, bool is_global) |
| 1598 | 1598 | { |
| 1599 | IrInstSrcAsm *instruction = ir_build_instruction<IrInstSrcAsm>(ag, scope, source_node); | |
| 1599 | Stage1ZirInstAsm *instruction = ir_build_instruction<Stage1ZirInstAsm>(ag, scope, source_node); | |
| 1600 | 1600 | instruction->asm_template = asm_template; |
| 1601 | 1601 | instruction->input_list = input_list; |
| 1602 | 1602 | instruction->output_types = output_types; |
| ... | ... | @@ -1607,22 +1607,22 @@ static IrInstSrc *ir_build_asm_src(Stage1AstGen *ag, Scope *scope, AstNode *sour |
| 1607 | 1607 | |
| 1608 | 1608 | assert(source_node->type == NodeTypeAsmExpr); |
| 1609 | 1609 | for (size_t i = 0; i < source_node->data.asm_expr.output_list.length; i += 1) { |
| 1610 | IrInstSrc *output_type = output_types[i]; | |
| 1610 | Stage1ZirInst *output_type = output_types[i]; | |
| 1611 | 1611 | if (output_type) ir_ref_instruction(output_type, ag->current_basic_block); |
| 1612 | 1612 | } |
| 1613 | 1613 | |
| 1614 | 1614 | for (size_t i = 0; i < source_node->data.asm_expr.input_list.length; i += 1) { |
| 1615 | IrInstSrc *input_value = input_list[i]; | |
| 1615 | Stage1ZirInst *input_value = input_list[i]; | |
| 1616 | 1616 | ir_ref_instruction(input_value, ag->current_basic_block); |
| 1617 | 1617 | } |
| 1618 | 1618 | |
| 1619 | 1619 | return &instruction->base; |
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | static IrInstSrc *ir_build_size_of(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *type_value, | |
| 1622 | static Stage1ZirInst *ir_build_size_of(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *type_value, | |
| 1623 | 1623 | bool bit_size) |
| 1624 | 1624 | { |
| 1625 | IrInstSrcSizeOf *instruction = ir_build_instruction<IrInstSrcSizeOf>(ag, scope, source_node); | |
| 1625 | Stage1ZirInstSizeOf *instruction = ir_build_instruction<Stage1ZirInstSizeOf>(ag, scope, source_node); | |
| 1626 | 1626 | instruction->type_value = type_value; |
| 1627 | 1627 | instruction->bit_size = bit_size; |
| 1628 | 1628 | |
| ... | ... | @@ -1631,10 +1631,10 @@ static IrInstSrc *ir_build_size_of(Stage1AstGen *ag, Scope *scope, AstNode *sour |
| 1631 | 1631 | return &instruction->base; |
| 1632 | 1632 | } |
| 1633 | 1633 | |
| 1634 | static IrInstSrc *ir_build_test_non_null_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1635 | IrInstSrc *value) | |
| 1634 | static Stage1ZirInst *ir_build_test_non_null_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1635 | Stage1ZirInst *value) | |
| 1636 | 1636 | { |
| 1637 | IrInstSrcTestNonNull *instruction = ir_build_instruction<IrInstSrcTestNonNull>(ag, scope, source_node); | |
| 1637 | Stage1ZirInstTestNonNull *instruction = ir_build_instruction<Stage1ZirInstTestNonNull>(ag, scope, source_node); | |
| 1638 | 1638 | instruction->value = value; |
| 1639 | 1639 | |
| 1640 | 1640 | ir_ref_instruction(value, ag->current_basic_block); |
| ... | ... | @@ -1642,10 +1642,10 @@ static IrInstSrc *ir_build_test_non_null_src(Stage1AstGen *ag, Scope *scope, Ast |
| 1642 | 1642 | return &instruction->base; |
| 1643 | 1643 | } |
| 1644 | 1644 | |
| 1645 | static IrInstSrc *ir_build_optional_unwrap_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1646 | IrInstSrc *base_ptr, bool safety_check_on) | |
| 1645 | static Stage1ZirInst *ir_build_optional_unwrap_ptr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1646 | Stage1ZirInst *base_ptr, bool safety_check_on) | |
| 1647 | 1647 | { |
| 1648 | IrInstSrcOptionalUnwrapPtr *instruction = ir_build_instruction<IrInstSrcOptionalUnwrapPtr>(ag, scope, source_node); | |
| 1648 | Stage1ZirInstOptionalUnwrapPtr *instruction = ir_build_instruction<Stage1ZirInstOptionalUnwrapPtr>(ag, scope, source_node); | |
| 1649 | 1649 | instruction->base_ptr = base_ptr; |
| 1650 | 1650 | instruction->safety_check_on = safety_check_on; |
| 1651 | 1651 | |
| ... | ... | @@ -1654,10 +1654,10 @@ static IrInstSrc *ir_build_optional_unwrap_ptr(Stage1AstGen *ag, Scope *scope, A |
| 1654 | 1654 | return &instruction->base; |
| 1655 | 1655 | } |
| 1656 | 1656 | |
| 1657 | static IrInstSrc *ir_build_clz(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *type, | |
| 1658 | IrInstSrc *op) | |
| 1657 | static Stage1ZirInst *ir_build_clz(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *type, | |
| 1658 | Stage1ZirInst *op) | |
| 1659 | 1659 | { |
| 1660 | IrInstSrcClz *instruction = ir_build_instruction<IrInstSrcClz>(ag, scope, source_node); | |
| 1660 | Stage1ZirInstClz *instruction = ir_build_instruction<Stage1ZirInstClz>(ag, scope, source_node); | |
| 1661 | 1661 | instruction->type = type; |
| 1662 | 1662 | instruction->op = op; |
| 1663 | 1663 | |
| ... | ... | @@ -1667,10 +1667,10 @@ static IrInstSrc *ir_build_clz(Stage1AstGen *ag, Scope *scope, AstNode *source_n |
| 1667 | 1667 | return &instruction->base; |
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | static IrInstSrc *ir_build_ctz(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *type, | |
| 1671 | IrInstSrc *op) | |
| 1670 | static Stage1ZirInst *ir_build_ctz(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *type, | |
| 1671 | Stage1ZirInst *op) | |
| 1672 | 1672 | { |
| 1673 | IrInstSrcCtz *instruction = ir_build_instruction<IrInstSrcCtz>(ag, scope, source_node); | |
| 1673 | Stage1ZirInstCtz *instruction = ir_build_instruction<Stage1ZirInstCtz>(ag, scope, source_node); | |
| 1674 | 1674 | instruction->type = type; |
| 1675 | 1675 | instruction->op = op; |
| 1676 | 1676 | |
| ... | ... | @@ -1680,10 +1680,10 @@ static IrInstSrc *ir_build_ctz(Stage1AstGen *ag, Scope *scope, AstNode *source_n |
| 1680 | 1680 | return &instruction->base; |
| 1681 | 1681 | } |
| 1682 | 1682 | |
| 1683 | static IrInstSrc *ir_build_pop_count(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *type, | |
| 1684 | IrInstSrc *op) | |
| 1683 | static Stage1ZirInst *ir_build_pop_count(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *type, | |
| 1684 | Stage1ZirInst *op) | |
| 1685 | 1685 | { |
| 1686 | IrInstSrcPopCount *instruction = ir_build_instruction<IrInstSrcPopCount>(ag, scope, source_node); | |
| 1686 | Stage1ZirInstPopCount *instruction = ir_build_instruction<Stage1ZirInstPopCount>(ag, scope, source_node); | |
| 1687 | 1687 | instruction->type = type; |
| 1688 | 1688 | instruction->op = op; |
| 1689 | 1689 | |
| ... | ... | @@ -1693,10 +1693,10 @@ static IrInstSrc *ir_build_pop_count(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 1693 | 1693 | return &instruction->base; |
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | static IrInstSrc *ir_build_bswap(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *type, | |
| 1697 | IrInstSrc *op) | |
| 1696 | static Stage1ZirInst *ir_build_bswap(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *type, | |
| 1697 | Stage1ZirInst *op) | |
| 1698 | 1698 | { |
| 1699 | IrInstSrcBswap *instruction = ir_build_instruction<IrInstSrcBswap>(ag, scope, source_node); | |
| 1699 | Stage1ZirInstBswap *instruction = ir_build_instruction<Stage1ZirInstBswap>(ag, scope, source_node); | |
| 1700 | 1700 | instruction->type = type; |
| 1701 | 1701 | instruction->op = op; |
| 1702 | 1702 | |
| ... | ... | @@ -1706,10 +1706,10 @@ static IrInstSrc *ir_build_bswap(Stage1AstGen *ag, Scope *scope, AstNode *source |
| 1706 | 1706 | return &instruction->base; |
| 1707 | 1707 | } |
| 1708 | 1708 | |
| 1709 | static IrInstSrc *ir_build_bit_reverse(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *type, | |
| 1710 | IrInstSrc *op) | |
| 1709 | static Stage1ZirInst *ir_build_bit_reverse(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *type, | |
| 1710 | Stage1ZirInst *op) | |
| 1711 | 1711 | { |
| 1712 | IrInstSrcBitReverse *instruction = ir_build_instruction<IrInstSrcBitReverse>(ag, scope, source_node); | |
| 1712 | Stage1ZirInstBitReverse *instruction = ir_build_instruction<Stage1ZirInstBitReverse>(ag, scope, source_node); | |
| 1713 | 1713 | instruction->type = type; |
| 1714 | 1714 | instruction->op = op; |
| 1715 | 1715 | |
| ... | ... | @@ -1719,11 +1719,11 @@ static IrInstSrc *ir_build_bit_reverse(Stage1AstGen *ag, Scope *scope, AstNode * |
| 1719 | 1719 | return &instruction->base; |
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | static IrInstSrcSwitchBr *ir_build_switch_br_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1723 | IrInstSrc *target_value, Stage1ZirBasicBlock *else_block, size_t case_count, IrInstSrcSwitchBrCase *cases, | |
| 1724 | IrInstSrc *is_comptime, IrInstSrc *switch_prongs_void) | |
| 1722 | static Stage1ZirInstSwitchBr *ir_build_switch_br_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1723 | Stage1ZirInst *target_value, Stage1ZirBasicBlock *else_block, size_t case_count, Stage1ZirInstSwitchBrCase *cases, | |
| 1724 | Stage1ZirInst *is_comptime, Stage1ZirInst *switch_prongs_void) | |
| 1725 | 1725 | { |
| 1726 | IrInstSrcSwitchBr *instruction = ir_build_instruction<IrInstSrcSwitchBr>(ag, scope, source_node); | |
| 1726 | Stage1ZirInstSwitchBr *instruction = ir_build_instruction<Stage1ZirInstSwitchBr>(ag, scope, source_node); | |
| 1727 | 1727 | instruction->target_value = target_value; |
| 1728 | 1728 | instruction->else_block = else_block; |
| 1729 | 1729 | instruction->case_count = case_count; |
| ... | ... | @@ -1744,10 +1744,10 @@ static IrInstSrcSwitchBr *ir_build_switch_br_src(Stage1AstGen *ag, Scope *scope, |
| 1744 | 1744 | return instruction; |
| 1745 | 1745 | } |
| 1746 | 1746 | |
| 1747 | static IrInstSrc *ir_build_switch_target(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1748 | IrInstSrc *target_value_ptr) | |
| 1747 | static Stage1ZirInst *ir_build_switch_target(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1748 | Stage1ZirInst *target_value_ptr) | |
| 1749 | 1749 | { |
| 1750 | IrInstSrcSwitchTarget *instruction = ir_build_instruction<IrInstSrcSwitchTarget>(ag, scope, source_node); | |
| 1750 | Stage1ZirInstSwitchTarget *instruction = ir_build_instruction<Stage1ZirInstSwitchTarget>(ag, scope, source_node); | |
| 1751 | 1751 | instruction->target_value_ptr = target_value_ptr; |
| 1752 | 1752 | |
| 1753 | 1753 | ir_ref_instruction(target_value_ptr, ag->current_basic_block); |
| ... | ... | @@ -1755,10 +1755,10 @@ static IrInstSrc *ir_build_switch_target(Stage1AstGen *ag, Scope *scope, AstNode |
| 1755 | 1755 | return &instruction->base; |
| 1756 | 1756 | } |
| 1757 | 1757 | |
| 1758 | static IrInstSrc *ir_build_switch_var(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1759 | IrInstSrc *target_value_ptr, IrInstSrc **prongs_ptr, size_t prongs_len) | |
| 1758 | static Stage1ZirInst *ir_build_switch_var(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1759 | Stage1ZirInst *target_value_ptr, Stage1ZirInst **prongs_ptr, size_t prongs_len) | |
| 1760 | 1760 | { |
| 1761 | IrInstSrcSwitchVar *instruction = ir_build_instruction<IrInstSrcSwitchVar>(ag, scope, source_node); | |
| 1761 | Stage1ZirInstSwitchVar *instruction = ir_build_instruction<Stage1ZirInstSwitchVar>(ag, scope, source_node); | |
| 1762 | 1762 | instruction->target_value_ptr = target_value_ptr; |
| 1763 | 1763 | instruction->prongs_ptr = prongs_ptr; |
| 1764 | 1764 | instruction->prongs_len = prongs_len; |
| ... | ... | @@ -1772,10 +1772,10 @@ static IrInstSrc *ir_build_switch_var(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 1772 | 1772 | } |
| 1773 | 1773 | |
| 1774 | 1774 | // For this instruction the switch_br must be set later. |
| 1775 | static IrInstSrcSwitchElseVar *ir_build_switch_else_var(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1776 | IrInstSrc *target_value_ptr) | |
| 1775 | static Stage1ZirInstSwitchElseVar *ir_build_switch_else_var(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1776 | Stage1ZirInst *target_value_ptr) | |
| 1777 | 1777 | { |
| 1778 | IrInstSrcSwitchElseVar *instruction = ir_build_instruction<IrInstSrcSwitchElseVar>(ag, scope, source_node); | |
| 1778 | Stage1ZirInstSwitchElseVar *instruction = ir_build_instruction<Stage1ZirInstSwitchElseVar>(ag, scope, source_node); | |
| 1779 | 1779 | instruction->target_value_ptr = target_value_ptr; |
| 1780 | 1780 | |
| 1781 | 1781 | ir_ref_instruction(target_value_ptr, ag->current_basic_block); |
| ... | ... | @@ -1783,8 +1783,8 @@ static IrInstSrcSwitchElseVar *ir_build_switch_else_var(Stage1AstGen *ag, Scope |
| 1783 | 1783 | return instruction; |
| 1784 | 1784 | } |
| 1785 | 1785 | |
| 1786 | static IrInstSrc *ir_build_import(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *name) { | |
| 1787 | IrInstSrcImport *instruction = ir_build_instruction<IrInstSrcImport>(ag, scope, source_node); | |
| 1786 | static Stage1ZirInst *ir_build_import(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *name) { | |
| 1787 | Stage1ZirInstImport *instruction = ir_build_instruction<Stage1ZirInstImport>(ag, scope, source_node); | |
| 1788 | 1788 | instruction->name = name; |
| 1789 | 1789 | |
| 1790 | 1790 | ir_ref_instruction(name, ag->current_basic_block); |
| ... | ... | @@ -1792,8 +1792,8 @@ static IrInstSrc *ir_build_import(Stage1AstGen *ag, Scope *scope, AstNode *sourc |
| 1792 | 1792 | return &instruction->base; |
| 1793 | 1793 | } |
| 1794 | 1794 | |
| 1795 | static IrInstSrc *ir_build_ref_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *value) { | |
| 1796 | IrInstSrcRef *instruction = ir_build_instruction<IrInstSrcRef>(ag, scope, source_node); | |
| 1795 | static Stage1ZirInst *ir_build_ref_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *value) { | |
| 1796 | Stage1ZirInstRef *instruction = ir_build_instruction<Stage1ZirInstRef>(ag, scope, source_node); | |
| 1797 | 1797 | instruction->value = value; |
| 1798 | 1798 | |
| 1799 | 1799 | ir_ref_instruction(value, ag->current_basic_block); |
| ... | ... | @@ -1801,8 +1801,8 @@ static IrInstSrc *ir_build_ref_src(Stage1AstGen *ag, Scope *scope, AstNode *sour |
| 1801 | 1801 | return &instruction->base; |
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | static IrInstSrc *ir_build_compile_err(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *msg) { | |
| 1805 | IrInstSrcCompileErr *instruction = ir_build_instruction<IrInstSrcCompileErr>(ag, scope, source_node); | |
| 1804 | static Stage1ZirInst *ir_build_compile_err(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *msg) { | |
| 1805 | Stage1ZirInstCompileErr *instruction = ir_build_instruction<Stage1ZirInstCompileErr>(ag, scope, source_node); | |
| 1806 | 1806 | instruction->msg = msg; |
| 1807 | 1807 | |
| 1808 | 1808 | ir_ref_instruction(msg, ag->current_basic_block); |
| ... | ... | @@ -1810,10 +1810,10 @@ static IrInstSrc *ir_build_compile_err(Stage1AstGen *ag, Scope *scope, AstNode * |
| 1810 | 1810 | return &instruction->base; |
| 1811 | 1811 | } |
| 1812 | 1812 | |
| 1813 | static IrInstSrc *ir_build_compile_log(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1814 | size_t msg_count, IrInstSrc **msg_list) | |
| 1813 | static Stage1ZirInst *ir_build_compile_log(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1814 | size_t msg_count, Stage1ZirInst **msg_list) | |
| 1815 | 1815 | { |
| 1816 | IrInstSrcCompileLog *instruction = ir_build_instruction<IrInstSrcCompileLog>(ag, scope, source_node); | |
| 1816 | Stage1ZirInstCompileLog *instruction = ir_build_instruction<Stage1ZirInstCompileLog>(ag, scope, source_node); | |
| 1817 | 1817 | instruction->msg_count = msg_count; |
| 1818 | 1818 | instruction->msg_list = msg_list; |
| 1819 | 1819 | |
| ... | ... | @@ -1824,8 +1824,8 @@ static IrInstSrc *ir_build_compile_log(Stage1AstGen *ag, Scope *scope, AstNode * |
| 1824 | 1824 | return &instruction->base; |
| 1825 | 1825 | } |
| 1826 | 1826 | |
| 1827 | static IrInstSrc *ir_build_err_name(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *value) { | |
| 1828 | IrInstSrcErrName *instruction = ir_build_instruction<IrInstSrcErrName>(ag, scope, source_node); | |
| 1827 | static Stage1ZirInst *ir_build_err_name(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *value) { | |
| 1828 | Stage1ZirInstErrName *instruction = ir_build_instruction<Stage1ZirInstErrName>(ag, scope, source_node); | |
| 1829 | 1829 | instruction->value = value; |
| 1830 | 1830 | |
| 1831 | 1831 | ir_ref_instruction(value, ag->current_basic_block); |
| ... | ... | @@ -1833,13 +1833,13 @@ static IrInstSrc *ir_build_err_name(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1833 | 1833 | return &instruction->base; |
| 1834 | 1834 | } |
| 1835 | 1835 | |
| 1836 | static IrInstSrc *ir_build_c_import(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 1837 | IrInstSrcCImport *instruction = ir_build_instruction<IrInstSrcCImport>(ag, scope, source_node); | |
| 1836 | static Stage1ZirInst *ir_build_c_import(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 1837 | Stage1ZirInstCImport *instruction = ir_build_instruction<Stage1ZirInstCImport>(ag, scope, source_node); | |
| 1838 | 1838 | return &instruction->base; |
| 1839 | 1839 | } |
| 1840 | 1840 | |
| 1841 | static IrInstSrc *ir_build_c_include(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *name) { | |
| 1842 | IrInstSrcCInclude *instruction = ir_build_instruction<IrInstSrcCInclude>(ag, scope, source_node); | |
| 1841 | static Stage1ZirInst *ir_build_c_include(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *name) { | |
| 1842 | Stage1ZirInstCInclude *instruction = ir_build_instruction<Stage1ZirInstCInclude>(ag, scope, source_node); | |
| 1843 | 1843 | instruction->name = name; |
| 1844 | 1844 | |
| 1845 | 1845 | ir_ref_instruction(name, ag->current_basic_block); |
| ... | ... | @@ -1847,8 +1847,8 @@ static IrInstSrc *ir_build_c_include(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 1847 | 1847 | return &instruction->base; |
| 1848 | 1848 | } |
| 1849 | 1849 | |
| 1850 | static IrInstSrc *ir_build_c_define(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *name, IrInstSrc *value) { | |
| 1851 | IrInstSrcCDefine *instruction = ir_build_instruction<IrInstSrcCDefine>(ag, scope, source_node); | |
| 1850 | static Stage1ZirInst *ir_build_c_define(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *name, Stage1ZirInst *value) { | |
| 1851 | Stage1ZirInstCDefine *instruction = ir_build_instruction<Stage1ZirInstCDefine>(ag, scope, source_node); | |
| 1852 | 1852 | instruction->name = name; |
| 1853 | 1853 | instruction->value = value; |
| 1854 | 1854 | |
| ... | ... | @@ -1858,8 +1858,8 @@ static IrInstSrc *ir_build_c_define(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1858 | 1858 | return &instruction->base; |
| 1859 | 1859 | } |
| 1860 | 1860 | |
| 1861 | static IrInstSrc *ir_build_c_undef(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *name) { | |
| 1862 | IrInstSrcCUndef *instruction = ir_build_instruction<IrInstSrcCUndef>(ag, scope, source_node); | |
| 1861 | static Stage1ZirInst *ir_build_c_undef(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *name) { | |
| 1862 | Stage1ZirInstCUndef *instruction = ir_build_instruction<Stage1ZirInstCUndef>(ag, scope, source_node); | |
| 1863 | 1863 | instruction->name = name; |
| 1864 | 1864 | |
| 1865 | 1865 | ir_ref_instruction(name, ag->current_basic_block); |
| ... | ... | @@ -1867,8 +1867,8 @@ static IrInstSrc *ir_build_c_undef(Stage1AstGen *ag, Scope *scope, AstNode *sour |
| 1867 | 1867 | return &instruction->base; |
| 1868 | 1868 | } |
| 1869 | 1869 | |
| 1870 | static IrInstSrc *ir_build_embed_file(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *name) { | |
| 1871 | IrInstSrcEmbedFile *instruction = ir_build_instruction<IrInstSrcEmbedFile>(ag, scope, source_node); | |
| 1870 | static Stage1ZirInst *ir_build_embed_file(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *name) { | |
| 1871 | Stage1ZirInstEmbedFile *instruction = ir_build_instruction<Stage1ZirInstEmbedFile>(ag, scope, source_node); | |
| 1872 | 1872 | instruction->name = name; |
| 1873 | 1873 | |
| 1874 | 1874 | ir_ref_instruction(name, ag->current_basic_block); |
| ... | ... | @@ -1876,11 +1876,11 @@ static IrInstSrc *ir_build_embed_file(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 1876 | 1876 | return &instruction->base; |
| 1877 | 1877 | } |
| 1878 | 1878 | |
| 1879 | static IrInstSrc *ir_build_cmpxchg_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1880 | IrInstSrc *type_value, IrInstSrc *ptr, IrInstSrc *cmp_value, IrInstSrc *new_value, | |
| 1881 | IrInstSrc *success_order_value, IrInstSrc *failure_order_value, bool is_weak, ResultLoc *result_loc) | |
| 1879 | static Stage1ZirInst *ir_build_cmpxchg_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1880 | Stage1ZirInst *type_value, Stage1ZirInst *ptr, Stage1ZirInst *cmp_value, Stage1ZirInst *new_value, | |
| 1881 | Stage1ZirInst *success_order_value, Stage1ZirInst *failure_order_value, bool is_weak, ResultLoc *result_loc) | |
| 1882 | 1882 | { |
| 1883 | IrInstSrcCmpxchg *instruction = ir_build_instruction<IrInstSrcCmpxchg>(ag, scope, source_node); | |
| 1883 | Stage1ZirInstCmpxchg *instruction = ir_build_instruction<Stage1ZirInstCmpxchg>(ag, scope, source_node); | |
| 1884 | 1884 | instruction->type_value = type_value; |
| 1885 | 1885 | instruction->ptr = ptr; |
| 1886 | 1886 | instruction->cmp_value = cmp_value; |
| ... | ... | @@ -1900,8 +1900,8 @@ static IrInstSrc *ir_build_cmpxchg_src(Stage1AstGen *ag, Scope *scope, AstNode * |
| 1900 | 1900 | return &instruction->base; |
| 1901 | 1901 | } |
| 1902 | 1902 | |
| 1903 | static IrInstSrc *ir_build_fence(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *order) { | |
| 1904 | IrInstSrcFence *instruction = ir_build_instruction<IrInstSrcFence>(ag, scope, source_node); | |
| 1903 | static Stage1ZirInst *ir_build_fence(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *order) { | |
| 1904 | Stage1ZirInstFence *instruction = ir_build_instruction<Stage1ZirInstFence>(ag, scope, source_node); | |
| 1905 | 1905 | instruction->order = order; |
| 1906 | 1906 | |
| 1907 | 1907 | ir_ref_instruction(order, ag->current_basic_block); |
| ... | ... | @@ -1909,8 +1909,8 @@ static IrInstSrc *ir_build_fence(Stage1AstGen *ag, Scope *scope, AstNode *source |
| 1909 | 1909 | return &instruction->base; |
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | static IrInstSrc *ir_build_reduce(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *op, IrInstSrc *value) { | |
| 1913 | IrInstSrcReduce *instruction = ir_build_instruction<IrInstSrcReduce>(ag, scope, source_node); | |
| 1912 | static Stage1ZirInst *ir_build_reduce(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *op, Stage1ZirInst *value) { | |
| 1913 | Stage1ZirInstReduce *instruction = ir_build_instruction<Stage1ZirInstReduce>(ag, scope, source_node); | |
| 1914 | 1914 | instruction->op = op; |
| 1915 | 1915 | instruction->value = value; |
| 1916 | 1916 | |
| ... | ... | @@ -1920,10 +1920,10 @@ static IrInstSrc *ir_build_reduce(Stage1AstGen *ag, Scope *scope, AstNode *sourc |
| 1920 | 1920 | return &instruction->base; |
| 1921 | 1921 | } |
| 1922 | 1922 | |
| 1923 | static IrInstSrc *ir_build_truncate(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1924 | IrInstSrc *dest_type, IrInstSrc *target) | |
| 1923 | static Stage1ZirInst *ir_build_truncate(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1924 | Stage1ZirInst *dest_type, Stage1ZirInst *target) | |
| 1925 | 1925 | { |
| 1926 | IrInstSrcTruncate *instruction = ir_build_instruction<IrInstSrcTruncate>(ag, scope, source_node); | |
| 1926 | Stage1ZirInstTruncate *instruction = ir_build_instruction<Stage1ZirInstTruncate>(ag, scope, source_node); | |
| 1927 | 1927 | instruction->dest_type = dest_type; |
| 1928 | 1928 | instruction->target = target; |
| 1929 | 1929 | |
| ... | ... | @@ -1933,10 +1933,10 @@ static IrInstSrc *ir_build_truncate(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1933 | 1933 | return &instruction->base; |
| 1934 | 1934 | } |
| 1935 | 1935 | |
| 1936 | static IrInstSrc *ir_build_int_cast(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *dest_type, | |
| 1937 | IrInstSrc *target) | |
| 1936 | static Stage1ZirInst *ir_build_int_cast(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *dest_type, | |
| 1937 | Stage1ZirInst *target) | |
| 1938 | 1938 | { |
| 1939 | IrInstSrcIntCast *instruction = ir_build_instruction<IrInstSrcIntCast>(ag, scope, source_node); | |
| 1939 | Stage1ZirInstIntCast *instruction = ir_build_instruction<Stage1ZirInstIntCast>(ag, scope, source_node); | |
| 1940 | 1940 | instruction->dest_type = dest_type; |
| 1941 | 1941 | instruction->target = target; |
| 1942 | 1942 | |
| ... | ... | @@ -1946,10 +1946,10 @@ static IrInstSrc *ir_build_int_cast(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1946 | 1946 | return &instruction->base; |
| 1947 | 1947 | } |
| 1948 | 1948 | |
| 1949 | static IrInstSrc *ir_build_float_cast(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *dest_type, | |
| 1950 | IrInstSrc *target) | |
| 1949 | static Stage1ZirInst *ir_build_float_cast(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *dest_type, | |
| 1950 | Stage1ZirInst *target) | |
| 1951 | 1951 | { |
| 1952 | IrInstSrcFloatCast *instruction = ir_build_instruction<IrInstSrcFloatCast>(ag, scope, source_node); | |
| 1952 | Stage1ZirInstFloatCast *instruction = ir_build_instruction<Stage1ZirInstFloatCast>(ag, scope, source_node); | |
| 1953 | 1953 | instruction->dest_type = dest_type; |
| 1954 | 1954 | instruction->target = target; |
| 1955 | 1955 | |
| ... | ... | @@ -1959,10 +1959,10 @@ static IrInstSrc *ir_build_float_cast(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 1959 | 1959 | return &instruction->base; |
| 1960 | 1960 | } |
| 1961 | 1961 | |
| 1962 | static IrInstSrc *ir_build_err_set_cast(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1963 | IrInstSrc *dest_type, IrInstSrc *target) | |
| 1962 | static Stage1ZirInst *ir_build_err_set_cast(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1963 | Stage1ZirInst *dest_type, Stage1ZirInst *target) | |
| 1964 | 1964 | { |
| 1965 | IrInstSrcErrSetCast *instruction = ir_build_instruction<IrInstSrcErrSetCast>(ag, scope, source_node); | |
| 1965 | Stage1ZirInstErrSetCast *instruction = ir_build_instruction<Stage1ZirInstErrSetCast>(ag, scope, source_node); | |
| 1966 | 1966 | instruction->dest_type = dest_type; |
| 1967 | 1967 | instruction->target = target; |
| 1968 | 1968 | |
| ... | ... | @@ -1972,10 +1972,10 @@ static IrInstSrc *ir_build_err_set_cast(Stage1AstGen *ag, Scope *scope, AstNode |
| 1972 | 1972 | return &instruction->base; |
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | static IrInstSrc *ir_build_int_to_float(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1976 | IrInstSrc *dest_type, IrInstSrc *target) | |
| 1975 | static Stage1ZirInst *ir_build_int_to_float(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1976 | Stage1ZirInst *dest_type, Stage1ZirInst *target) | |
| 1977 | 1977 | { |
| 1978 | IrInstSrcIntToFloat *instruction = ir_build_instruction<IrInstSrcIntToFloat>(ag, scope, source_node); | |
| 1978 | Stage1ZirInstIntToFloat *instruction = ir_build_instruction<Stage1ZirInstIntToFloat>(ag, scope, source_node); | |
| 1979 | 1979 | instruction->dest_type = dest_type; |
| 1980 | 1980 | instruction->target = target; |
| 1981 | 1981 | |
| ... | ... | @@ -1985,10 +1985,10 @@ static IrInstSrc *ir_build_int_to_float(Stage1AstGen *ag, Scope *scope, AstNode |
| 1985 | 1985 | return &instruction->base; |
| 1986 | 1986 | } |
| 1987 | 1987 | |
| 1988 | static IrInstSrc *ir_build_float_to_int(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1989 | IrInstSrc *dest_type, IrInstSrc *target) | |
| 1988 | static Stage1ZirInst *ir_build_float_to_int(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 1989 | Stage1ZirInst *dest_type, Stage1ZirInst *target) | |
| 1990 | 1990 | { |
| 1991 | IrInstSrcFloatToInt *instruction = ir_build_instruction<IrInstSrcFloatToInt>(ag, scope, source_node); | |
| 1991 | Stage1ZirInstFloatToInt *instruction = ir_build_instruction<Stage1ZirInstFloatToInt>(ag, scope, source_node); | |
| 1992 | 1992 | instruction->dest_type = dest_type; |
| 1993 | 1993 | instruction->target = target; |
| 1994 | 1994 | |
| ... | ... | @@ -1998,8 +1998,8 @@ static IrInstSrc *ir_build_float_to_int(Stage1AstGen *ag, Scope *scope, AstNode |
| 1998 | 1998 | return &instruction->base; |
| 1999 | 1999 | } |
| 2000 | 2000 | |
| 2001 | static IrInstSrc *ir_build_bool_to_int(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *target) { | |
| 2002 | IrInstSrcBoolToInt *instruction = ir_build_instruction<IrInstSrcBoolToInt>(ag, scope, source_node); | |
| 2001 | static Stage1ZirInst *ir_build_bool_to_int(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *target) { | |
| 2002 | Stage1ZirInstBoolToInt *instruction = ir_build_instruction<Stage1ZirInstBoolToInt>(ag, scope, source_node); | |
| 2003 | 2003 | instruction->target = target; |
| 2004 | 2004 | |
| 2005 | 2005 | ir_ref_instruction(target, ag->current_basic_block); |
| ... | ... | @@ -2007,10 +2007,10 @@ static IrInstSrc *ir_build_bool_to_int(Stage1AstGen *ag, Scope *scope, AstNode * |
| 2007 | 2007 | return &instruction->base; |
| 2008 | 2008 | } |
| 2009 | 2009 | |
| 2010 | static IrInstSrc *ir_build_vector_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *len, | |
| 2011 | IrInstSrc *elem_type) | |
| 2010 | static Stage1ZirInst *ir_build_vector_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *len, | |
| 2011 | Stage1ZirInst *elem_type) | |
| 2012 | 2012 | { |
| 2013 | IrInstSrcVectorType *instruction = ir_build_instruction<IrInstSrcVectorType>(ag, scope, source_node); | |
| 2013 | Stage1ZirInstVectorType *instruction = ir_build_instruction<Stage1ZirInstVectorType>(ag, scope, source_node); | |
| 2014 | 2014 | instruction->len = len; |
| 2015 | 2015 | instruction->elem_type = elem_type; |
| 2016 | 2016 | |
| ... | ... | @@ -2020,10 +2020,10 @@ static IrInstSrc *ir_build_vector_type(Stage1AstGen *ag, Scope *scope, AstNode * |
| 2020 | 2020 | return &instruction->base; |
| 2021 | 2021 | } |
| 2022 | 2022 | |
| 2023 | static IrInstSrc *ir_build_shuffle_vector(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2024 | IrInstSrc *scalar_type, IrInstSrc *a, IrInstSrc *b, IrInstSrc *mask) | |
| 2023 | static Stage1ZirInst *ir_build_shuffle_vector(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2024 | Stage1ZirInst *scalar_type, Stage1ZirInst *a, Stage1ZirInst *b, Stage1ZirInst *mask) | |
| 2025 | 2025 | { |
| 2026 | IrInstSrcShuffleVector *instruction = ir_build_instruction<IrInstSrcShuffleVector>(ag, scope, source_node); | |
| 2026 | Stage1ZirInstShuffleVector *instruction = ir_build_instruction<Stage1ZirInstShuffleVector>(ag, scope, source_node); | |
| 2027 | 2027 | instruction->scalar_type = scalar_type; |
| 2028 | 2028 | instruction->a = a; |
| 2029 | 2029 | instruction->b = b; |
| ... | ... | @@ -2037,10 +2037,10 @@ static IrInstSrc *ir_build_shuffle_vector(Stage1AstGen *ag, Scope *scope, AstNod |
| 2037 | 2037 | return &instruction->base; |
| 2038 | 2038 | } |
| 2039 | 2039 | |
| 2040 | static IrInstSrc *ir_build_splat_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2041 | IrInstSrc *len, IrInstSrc *scalar) | |
| 2040 | static Stage1ZirInst *ir_build_splat_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2041 | Stage1ZirInst *len, Stage1ZirInst *scalar) | |
| 2042 | 2042 | { |
| 2043 | IrInstSrcSplat *instruction = ir_build_instruction<IrInstSrcSplat>(ag, scope, source_node); | |
| 2043 | Stage1ZirInstSplat *instruction = ir_build_instruction<Stage1ZirInstSplat>(ag, scope, source_node); | |
| 2044 | 2044 | instruction->len = len; |
| 2045 | 2045 | instruction->scalar = scalar; |
| 2046 | 2046 | |
| ... | ... | @@ -2050,8 +2050,8 @@ static IrInstSrc *ir_build_splat_src(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 2050 | 2050 | return &instruction->base; |
| 2051 | 2051 | } |
| 2052 | 2052 | |
| 2053 | static IrInstSrc *ir_build_bool_not(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *value) { | |
| 2054 | IrInstSrcBoolNot *instruction = ir_build_instruction<IrInstSrcBoolNot>(ag, scope, source_node); | |
| 2053 | static Stage1ZirInst *ir_build_bool_not(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *value) { | |
| 2054 | Stage1ZirInstBoolNot *instruction = ir_build_instruction<Stage1ZirInstBoolNot>(ag, scope, source_node); | |
| 2055 | 2055 | instruction->value = value; |
| 2056 | 2056 | |
| 2057 | 2057 | ir_ref_instruction(value, ag->current_basic_block); |
| ... | ... | @@ -2059,10 +2059,10 @@ static IrInstSrc *ir_build_bool_not(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 2059 | 2059 | return &instruction->base; |
| 2060 | 2060 | } |
| 2061 | 2061 | |
| 2062 | static IrInstSrc *ir_build_memset_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2063 | IrInstSrc *dest_ptr, IrInstSrc *byte, IrInstSrc *count) | |
| 2062 | static Stage1ZirInst *ir_build_memset_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2063 | Stage1ZirInst *dest_ptr, Stage1ZirInst *byte, Stage1ZirInst *count) | |
| 2064 | 2064 | { |
| 2065 | IrInstSrcMemset *instruction = ir_build_instruction<IrInstSrcMemset>(ag, scope, source_node); | |
| 2065 | Stage1ZirInstMemset *instruction = ir_build_instruction<Stage1ZirInstMemset>(ag, scope, source_node); | |
| 2066 | 2066 | instruction->dest_ptr = dest_ptr; |
| 2067 | 2067 | instruction->byte = byte; |
| 2068 | 2068 | instruction->count = count; |
| ... | ... | @@ -2074,10 +2074,10 @@ static IrInstSrc *ir_build_memset_src(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 2074 | 2074 | return &instruction->base; |
| 2075 | 2075 | } |
| 2076 | 2076 | |
| 2077 | static IrInstSrc *ir_build_memcpy_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2078 | IrInstSrc *dest_ptr, IrInstSrc *src_ptr, IrInstSrc *count) | |
| 2077 | static Stage1ZirInst *ir_build_memcpy_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2078 | Stage1ZirInst *dest_ptr, Stage1ZirInst *src_ptr, Stage1ZirInst *count) | |
| 2079 | 2079 | { |
| 2080 | IrInstSrcMemcpy *instruction = ir_build_instruction<IrInstSrcMemcpy>(ag, scope, source_node); | |
| 2080 | Stage1ZirInstMemcpy *instruction = ir_build_instruction<Stage1ZirInstMemcpy>(ag, scope, source_node); | |
| 2081 | 2081 | instruction->dest_ptr = dest_ptr; |
| 2082 | 2082 | instruction->src_ptr = src_ptr; |
| 2083 | 2083 | instruction->count = count; |
| ... | ... | @@ -2089,11 +2089,11 @@ static IrInstSrc *ir_build_memcpy_src(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 2089 | 2089 | return &instruction->base; |
| 2090 | 2090 | } |
| 2091 | 2091 | |
| 2092 | static IrInstSrc *ir_build_slice_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2093 | IrInstSrc *ptr, IrInstSrc *start, IrInstSrc *end, IrInstSrc *sentinel, | |
| 2092 | static Stage1ZirInst *ir_build_slice_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2093 | Stage1ZirInst *ptr, Stage1ZirInst *start, Stage1ZirInst *end, Stage1ZirInst *sentinel, | |
| 2094 | 2094 | bool safety_check_on, ResultLoc *result_loc) |
| 2095 | 2095 | { |
| 2096 | IrInstSrcSlice *instruction = ir_build_instruction<IrInstSrcSlice>(ag, scope, source_node); | |
| 2096 | Stage1ZirInstSlice *instruction = ir_build_instruction<Stage1ZirInstSlice>(ag, scope, source_node); | |
| 2097 | 2097 | instruction->ptr = ptr; |
| 2098 | 2098 | instruction->start = start; |
| 2099 | 2099 | instruction->end = end; |
| ... | ... | @@ -2109,28 +2109,28 @@ static IrInstSrc *ir_build_slice_src(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 2109 | 2109 | return &instruction->base; |
| 2110 | 2110 | } |
| 2111 | 2111 | |
| 2112 | static IrInstSrc *ir_build_breakpoint(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2113 | IrInstSrcBreakpoint *instruction = ir_build_instruction<IrInstSrcBreakpoint>(ag, scope, source_node); | |
| 2112 | static Stage1ZirInst *ir_build_breakpoint(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2113 | Stage1ZirInstBreakpoint *instruction = ir_build_instruction<Stage1ZirInstBreakpoint>(ag, scope, source_node); | |
| 2114 | 2114 | return &instruction->base; |
| 2115 | 2115 | } |
| 2116 | 2116 | |
| 2117 | static IrInstSrc *ir_build_return_address_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2118 | IrInstSrcReturnAddress *instruction = ir_build_instruction<IrInstSrcReturnAddress>(ag, scope, source_node); | |
| 2117 | static Stage1ZirInst *ir_build_return_address_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2118 | Stage1ZirInstReturnAddress *instruction = ir_build_instruction<Stage1ZirInstReturnAddress>(ag, scope, source_node); | |
| 2119 | 2119 | return &instruction->base; |
| 2120 | 2120 | } |
| 2121 | 2121 | |
| 2122 | static IrInstSrc *ir_build_frame_address_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2123 | IrInstSrcFrameAddress *inst = ir_build_instruction<IrInstSrcFrameAddress>(ag, scope, source_node); | |
| 2122 | static Stage1ZirInst *ir_build_frame_address_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2123 | Stage1ZirInstFrameAddress *inst = ir_build_instruction<Stage1ZirInstFrameAddress>(ag, scope, source_node); | |
| 2124 | 2124 | return &inst->base; |
| 2125 | 2125 | } |
| 2126 | 2126 | |
| 2127 | static IrInstSrc *ir_build_handle_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2128 | IrInstSrcFrameHandle *inst = ir_build_instruction<IrInstSrcFrameHandle>(ag, scope, source_node); | |
| 2127 | static Stage1ZirInst *ir_build_handle_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2128 | Stage1ZirInstFrameHandle *inst = ir_build_instruction<Stage1ZirInstFrameHandle>(ag, scope, source_node); | |
| 2129 | 2129 | return &inst->base; |
| 2130 | 2130 | } |
| 2131 | 2131 | |
| 2132 | static IrInstSrc *ir_build_frame_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *fn) { | |
| 2133 | IrInstSrcFrameType *inst = ir_build_instruction<IrInstSrcFrameType>(ag, scope, source_node); | |
| 2132 | static Stage1ZirInst *ir_build_frame_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *fn) { | |
| 2133 | Stage1ZirInstFrameType *inst = ir_build_instruction<Stage1ZirInstFrameType>(ag, scope, source_node); | |
| 2134 | 2134 | inst->fn = fn; |
| 2135 | 2135 | |
| 2136 | 2136 | ir_ref_instruction(fn, ag->current_basic_block); |
| ... | ... | @@ -2138,8 +2138,8 @@ static IrInstSrc *ir_build_frame_type(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 2138 | 2138 | return &inst->base; |
| 2139 | 2139 | } |
| 2140 | 2140 | |
| 2141 | static IrInstSrc *ir_build_frame_size_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *fn) { | |
| 2142 | IrInstSrcFrameSize *inst = ir_build_instruction<IrInstSrcFrameSize>(ag, scope, source_node); | |
| 2141 | static Stage1ZirInst *ir_build_frame_size_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *fn) { | |
| 2142 | Stage1ZirInstFrameSize *inst = ir_build_instruction<Stage1ZirInstFrameSize>(ag, scope, source_node); | |
| 2143 | 2143 | inst->fn = fn; |
| 2144 | 2144 | |
| 2145 | 2145 | ir_ref_instruction(fn, ag->current_basic_block); |
| ... | ... | @@ -2147,10 +2147,10 @@ static IrInstSrc *ir_build_frame_size_src(Stage1AstGen *ag, Scope *scope, AstNod |
| 2147 | 2147 | return &inst->base; |
| 2148 | 2148 | } |
| 2149 | 2149 | |
| 2150 | static IrInstSrc *ir_build_overflow_op_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2151 | IrOverflowOp op, IrInstSrc *type_value, IrInstSrc *op1, IrInstSrc *op2, IrInstSrc *result_ptr) | |
| 2150 | static Stage1ZirInst *ir_build_overflow_op_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2151 | IrOverflowOp op, Stage1ZirInst *type_value, Stage1ZirInst *op1, Stage1ZirInst *op2, Stage1ZirInst *result_ptr) | |
| 2152 | 2152 | { |
| 2153 | IrInstSrcOverflowOp *instruction = ir_build_instruction<IrInstSrcOverflowOp>(ag, scope, source_node); | |
| 2153 | Stage1ZirInstOverflowOp *instruction = ir_build_instruction<Stage1ZirInstOverflowOp>(ag, scope, source_node); | |
| 2154 | 2154 | instruction->op = op; |
| 2155 | 2155 | instruction->type_value = type_value; |
| 2156 | 2156 | instruction->op1 = op1; |
| ... | ... | @@ -2165,10 +2165,10 @@ static IrInstSrc *ir_build_overflow_op_src(Stage1AstGen *ag, Scope *scope, AstNo |
| 2165 | 2165 | return &instruction->base; |
| 2166 | 2166 | } |
| 2167 | 2167 | |
| 2168 | static IrInstSrc *ir_build_float_op_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *operand, | |
| 2168 | static Stage1ZirInst *ir_build_float_op_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *operand, | |
| 2169 | 2169 | BuiltinFnId fn_id) |
| 2170 | 2170 | { |
| 2171 | IrInstSrcFloatOp *instruction = ir_build_instruction<IrInstSrcFloatOp>(ag, scope, source_node); | |
| 2171 | Stage1ZirInstFloatOp *instruction = ir_build_instruction<Stage1ZirInstFloatOp>(ag, scope, source_node); | |
| 2172 | 2172 | instruction->operand = operand; |
| 2173 | 2173 | instruction->fn_id = fn_id; |
| 2174 | 2174 | |
| ... | ... | @@ -2177,10 +2177,10 @@ static IrInstSrc *ir_build_float_op_src(Stage1AstGen *ag, Scope *scope, AstNode |
| 2177 | 2177 | return &instruction->base; |
| 2178 | 2178 | } |
| 2179 | 2179 | |
| 2180 | static IrInstSrc *ir_build_mul_add_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2181 | IrInstSrc *type_value, IrInstSrc *op1, IrInstSrc *op2, IrInstSrc *op3) | |
| 2180 | static Stage1ZirInst *ir_build_mul_add_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2181 | Stage1ZirInst *type_value, Stage1ZirInst *op1, Stage1ZirInst *op2, Stage1ZirInst *op3) | |
| 2182 | 2182 | { |
| 2183 | IrInstSrcMulAdd *instruction = ir_build_instruction<IrInstSrcMulAdd>(ag, scope, source_node); | |
| 2183 | Stage1ZirInstMulAdd *instruction = ir_build_instruction<Stage1ZirInstMulAdd>(ag, scope, source_node); | |
| 2184 | 2184 | instruction->type_value = type_value; |
| 2185 | 2185 | instruction->op1 = op1; |
| 2186 | 2186 | instruction->op2 = op2; |
| ... | ... | @@ -2194,8 +2194,8 @@ static IrInstSrc *ir_build_mul_add_src(Stage1AstGen *ag, Scope *scope, AstNode * |
| 2194 | 2194 | return &instruction->base; |
| 2195 | 2195 | } |
| 2196 | 2196 | |
| 2197 | static IrInstSrc *ir_build_align_of(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *type_value) { | |
| 2198 | IrInstSrcAlignOf *instruction = ir_build_instruction<IrInstSrcAlignOf>(ag, scope, source_node); | |
| 2197 | static Stage1ZirInst *ir_build_align_of(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *type_value) { | |
| 2198 | Stage1ZirInstAlignOf *instruction = ir_build_instruction<Stage1ZirInstAlignOf>(ag, scope, source_node); | |
| 2199 | 2199 | instruction->type_value = type_value; |
| 2200 | 2200 | |
| 2201 | 2201 | ir_ref_instruction(type_value, ag->current_basic_block); |
| ... | ... | @@ -2203,10 +2203,10 @@ static IrInstSrc *ir_build_align_of(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 2203 | 2203 | return &instruction->base; |
| 2204 | 2204 | } |
| 2205 | 2205 | |
| 2206 | static IrInstSrc *ir_build_test_err_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2207 | IrInstSrc *base_ptr, bool resolve_err_set, bool base_ptr_is_payload) | |
| 2206 | static Stage1ZirInst *ir_build_test_err_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2207 | Stage1ZirInst *base_ptr, bool resolve_err_set, bool base_ptr_is_payload) | |
| 2208 | 2208 | { |
| 2209 | IrInstSrcTestErr *instruction = ir_build_instruction<IrInstSrcTestErr>(ag, scope, source_node); | |
| 2209 | Stage1ZirInstTestErr *instruction = ir_build_instruction<Stage1ZirInstTestErr>(ag, scope, source_node); | |
| 2210 | 2210 | instruction->base_ptr = base_ptr; |
| 2211 | 2211 | instruction->resolve_err_set = resolve_err_set; |
| 2212 | 2212 | instruction->base_ptr_is_payload = base_ptr_is_payload; |
| ... | ... | @@ -2216,10 +2216,10 @@ static IrInstSrc *ir_build_test_err_src(Stage1AstGen *ag, Scope *scope, AstNode |
| 2216 | 2216 | return &instruction->base; |
| 2217 | 2217 | } |
| 2218 | 2218 | |
| 2219 | static IrInstSrc *ir_build_unwrap_err_code_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2220 | IrInstSrc *err_union_ptr) | |
| 2219 | static Stage1ZirInst *ir_build_unwrap_err_code_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2220 | Stage1ZirInst *err_union_ptr) | |
| 2221 | 2221 | { |
| 2222 | IrInstSrcUnwrapErrCode *inst = ir_build_instruction<IrInstSrcUnwrapErrCode>(ag, scope, source_node); | |
| 2222 | Stage1ZirInstUnwrapErrCode *inst = ir_build_instruction<Stage1ZirInstUnwrapErrCode>(ag, scope, source_node); | |
| 2223 | 2223 | inst->err_union_ptr = err_union_ptr; |
| 2224 | 2224 | |
| 2225 | 2225 | ir_ref_instruction(err_union_ptr, ag->current_basic_block); |
| ... | ... | @@ -2227,10 +2227,10 @@ static IrInstSrc *ir_build_unwrap_err_code_src(Stage1AstGen *ag, Scope *scope, A |
| 2227 | 2227 | return &inst->base; |
| 2228 | 2228 | } |
| 2229 | 2229 | |
| 2230 | static IrInstSrc *ir_build_unwrap_err_payload_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2231 | IrInstSrc *value, bool safety_check_on, bool initializing) | |
| 2230 | static Stage1ZirInst *ir_build_unwrap_err_payload_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2231 | Stage1ZirInst *value, bool safety_check_on, bool initializing) | |
| 2232 | 2232 | { |
| 2233 | IrInstSrcUnwrapErrPayload *inst = ir_build_instruction<IrInstSrcUnwrapErrPayload>(ag, scope, source_node); | |
| 2233 | Stage1ZirInstUnwrapErrPayload *inst = ir_build_instruction<Stage1ZirInstUnwrapErrPayload>(ag, scope, source_node); | |
| 2234 | 2234 | inst->value = value; |
| 2235 | 2235 | inst->safety_check_on = safety_check_on; |
| 2236 | 2236 | inst->initializing = initializing; |
| ... | ... | @@ -2240,11 +2240,11 @@ static IrInstSrc *ir_build_unwrap_err_payload_src(Stage1AstGen *ag, Scope *scope |
| 2240 | 2240 | return &inst->base; |
| 2241 | 2241 | } |
| 2242 | 2242 | |
| 2243 | static IrInstSrc *ir_build_fn_proto(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2244 | IrInstSrc **param_types, IrInstSrc *align_value, IrInstSrc *callconv_value, | |
| 2245 | IrInstSrc *return_type, bool is_var_args) | |
| 2243 | static Stage1ZirInst *ir_build_fn_proto(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2244 | Stage1ZirInst **param_types, Stage1ZirInst *align_value, Stage1ZirInst *callconv_value, | |
| 2245 | Stage1ZirInst *return_type, bool is_var_args) | |
| 2246 | 2246 | { |
| 2247 | IrInstSrcFnProto *instruction = ir_build_instruction<IrInstSrcFnProto>(ag, scope, source_node); | |
| 2247 | Stage1ZirInstFnProto *instruction = ir_build_instruction<Stage1ZirInstFnProto>(ag, scope, source_node); | |
| 2248 | 2248 | instruction->param_types = param_types; |
| 2249 | 2249 | instruction->align_value = align_value; |
| 2250 | 2250 | instruction->callconv_value = callconv_value; |
| ... | ... | @@ -2264,8 +2264,8 @@ static IrInstSrc *ir_build_fn_proto(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 2264 | 2264 | return &instruction->base; |
| 2265 | 2265 | } |
| 2266 | 2266 | |
| 2267 | static IrInstSrc *ir_build_test_comptime(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *value) { | |
| 2268 | IrInstSrcTestComptime *instruction = ir_build_instruction<IrInstSrcTestComptime>(ag, scope, source_node); | |
| 2267 | static Stage1ZirInst *ir_build_test_comptime(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *value) { | |
| 2268 | Stage1ZirInstTestComptime *instruction = ir_build_instruction<Stage1ZirInstTestComptime>(ag, scope, source_node); | |
| 2269 | 2269 | instruction->value = value; |
| 2270 | 2270 | |
| 2271 | 2271 | ir_ref_instruction(value, ag->current_basic_block); |
| ... | ... | @@ -2273,10 +2273,10 @@ static IrInstSrc *ir_build_test_comptime(Stage1AstGen *ag, Scope *scope, AstNode |
| 2273 | 2273 | return &instruction->base; |
| 2274 | 2274 | } |
| 2275 | 2275 | |
| 2276 | static IrInstSrc *ir_build_ptr_cast_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2277 | IrInstSrc *dest_type, IrInstSrc *ptr, bool safety_check_on) | |
| 2276 | static Stage1ZirInst *ir_build_ptr_cast_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2277 | Stage1ZirInst *dest_type, Stage1ZirInst *ptr, bool safety_check_on) | |
| 2278 | 2278 | { |
| 2279 | IrInstSrcPtrCast *instruction = ir_build_instruction<IrInstSrcPtrCast>( | |
| 2279 | Stage1ZirInstPtrCast *instruction = ir_build_instruction<Stage1ZirInstPtrCast>( | |
| 2280 | 2280 | ag, scope, source_node); |
| 2281 | 2281 | instruction->dest_type = dest_type; |
| 2282 | 2282 | instruction->ptr = ptr; |
| ... | ... | @@ -2288,10 +2288,10 @@ static IrInstSrc *ir_build_ptr_cast_src(Stage1AstGen *ag, Scope *scope, AstNode |
| 2288 | 2288 | return &instruction->base; |
| 2289 | 2289 | } |
| 2290 | 2290 | |
| 2291 | static IrInstSrc *ir_build_implicit_cast(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2292 | IrInstSrc *operand, ResultLocCast *result_loc_cast) | |
| 2291 | static Stage1ZirInst *ir_build_implicit_cast(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2292 | Stage1ZirInst *operand, ResultLocCast *result_loc_cast) | |
| 2293 | 2293 | { |
| 2294 | IrInstSrcImplicitCast *instruction = ir_build_instruction<IrInstSrcImplicitCast>(ag, scope, source_node); | |
| 2294 | Stage1ZirInstImplicitCast *instruction = ir_build_instruction<Stage1ZirInstImplicitCast>(ag, scope, source_node); | |
| 2295 | 2295 | instruction->operand = operand; |
| 2296 | 2296 | instruction->result_loc_cast = result_loc_cast; |
| 2297 | 2297 | |
| ... | ... | @@ -2300,10 +2300,10 @@ static IrInstSrc *ir_build_implicit_cast(Stage1AstGen *ag, Scope *scope, AstNode |
| 2300 | 2300 | return &instruction->base; |
| 2301 | 2301 | } |
| 2302 | 2302 | |
| 2303 | static IrInstSrc *ir_build_bit_cast_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2304 | IrInstSrc *operand, ResultLocBitCast *result_loc_bit_cast) | |
| 2303 | static Stage1ZirInst *ir_build_bit_cast_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2304 | Stage1ZirInst *operand, ResultLocBitCast *result_loc_bit_cast) | |
| 2305 | 2305 | { |
| 2306 | IrInstSrcBitCast *instruction = ir_build_instruction<IrInstSrcBitCast>(ag, scope, source_node); | |
| 2306 | Stage1ZirInstBitCast *instruction = ir_build_instruction<Stage1ZirInstBitCast>(ag, scope, source_node); | |
| 2307 | 2307 | instruction->operand = operand; |
| 2308 | 2308 | instruction->result_loc_bit_cast = result_loc_bit_cast; |
| 2309 | 2309 | |
| ... | ... | @@ -2312,10 +2312,10 @@ static IrInstSrc *ir_build_bit_cast_src(Stage1AstGen *ag, Scope *scope, AstNode |
| 2312 | 2312 | return &instruction->base; |
| 2313 | 2313 | } |
| 2314 | 2314 | |
| 2315 | static IrInstSrc *ir_build_int_to_ptr_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2316 | IrInstSrc *dest_type, IrInstSrc *target) | |
| 2315 | static Stage1ZirInst *ir_build_int_to_ptr_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2316 | Stage1ZirInst *dest_type, Stage1ZirInst *target) | |
| 2317 | 2317 | { |
| 2318 | IrInstSrcIntToPtr *instruction = ir_build_instruction<IrInstSrcIntToPtr>(ag, scope, source_node); | |
| 2318 | Stage1ZirInstIntToPtr *instruction = ir_build_instruction<Stage1ZirInstIntToPtr>(ag, scope, source_node); | |
| 2319 | 2319 | instruction->dest_type = dest_type; |
| 2320 | 2320 | instruction->target = target; |
| 2321 | 2321 | |
| ... | ... | @@ -2325,10 +2325,10 @@ static IrInstSrc *ir_build_int_to_ptr_src(Stage1AstGen *ag, Scope *scope, AstNod |
| 2325 | 2325 | return &instruction->base; |
| 2326 | 2326 | } |
| 2327 | 2327 | |
| 2328 | static IrInstSrc *ir_build_ptr_to_int_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2329 | IrInstSrc *target) | |
| 2328 | static Stage1ZirInst *ir_build_ptr_to_int_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2329 | Stage1ZirInst *target) | |
| 2330 | 2330 | { |
| 2331 | IrInstSrcPtrToInt *inst = ir_build_instruction<IrInstSrcPtrToInt>(ag, scope, source_node); | |
| 2331 | Stage1ZirInstPtrToInt *inst = ir_build_instruction<Stage1ZirInstPtrToInt>(ag, scope, source_node); | |
| 2332 | 2332 | inst->target = target; |
| 2333 | 2333 | |
| 2334 | 2334 | ir_ref_instruction(target, ag->current_basic_block); |
| ... | ... | @@ -2336,10 +2336,10 @@ static IrInstSrc *ir_build_ptr_to_int_src(Stage1AstGen *ag, Scope *scope, AstNod |
| 2336 | 2336 | return &inst->base; |
| 2337 | 2337 | } |
| 2338 | 2338 | |
| 2339 | static IrInstSrc *ir_build_int_to_enum_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2340 | IrInstSrc *dest_type, IrInstSrc *target) | |
| 2339 | static Stage1ZirInst *ir_build_int_to_enum_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2340 | Stage1ZirInst *dest_type, Stage1ZirInst *target) | |
| 2341 | 2341 | { |
| 2342 | IrInstSrcIntToEnum *instruction = ir_build_instruction<IrInstSrcIntToEnum>(ag, scope, source_node); | |
| 2342 | Stage1ZirInstIntToEnum *instruction = ir_build_instruction<Stage1ZirInstIntToEnum>(ag, scope, source_node); | |
| 2343 | 2343 | instruction->dest_type = dest_type; |
| 2344 | 2344 | instruction->target = target; |
| 2345 | 2345 | |
| ... | ... | @@ -2349,10 +2349,10 @@ static IrInstSrc *ir_build_int_to_enum_src(Stage1AstGen *ag, Scope *scope, AstNo |
| 2349 | 2349 | return &instruction->base; |
| 2350 | 2350 | } |
| 2351 | 2351 | |
| 2352 | static IrInstSrc *ir_build_enum_to_int(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2353 | IrInstSrc *target) | |
| 2352 | static Stage1ZirInst *ir_build_enum_to_int(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2353 | Stage1ZirInst *target) | |
| 2354 | 2354 | { |
| 2355 | IrInstSrcEnumToInt *instruction = ir_build_instruction<IrInstSrcEnumToInt>( | |
| 2355 | Stage1ZirInstEnumToInt *instruction = ir_build_instruction<Stage1ZirInstEnumToInt>( | |
| 2356 | 2356 | ag, scope, source_node); |
| 2357 | 2357 | instruction->target = target; |
| 2358 | 2358 | |
| ... | ... | @@ -2361,10 +2361,10 @@ static IrInstSrc *ir_build_enum_to_int(Stage1AstGen *ag, Scope *scope, AstNode * |
| 2361 | 2361 | return &instruction->base; |
| 2362 | 2362 | } |
| 2363 | 2363 | |
| 2364 | static IrInstSrc *ir_build_int_to_err_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2365 | IrInstSrc *target) | |
| 2364 | static Stage1ZirInst *ir_build_int_to_err_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2365 | Stage1ZirInst *target) | |
| 2366 | 2366 | { |
| 2367 | IrInstSrcIntToErr *instruction = ir_build_instruction<IrInstSrcIntToErr>(ag, scope, source_node); | |
| 2367 | Stage1ZirInstIntToErr *instruction = ir_build_instruction<Stage1ZirInstIntToErr>(ag, scope, source_node); | |
| 2368 | 2368 | instruction->target = target; |
| 2369 | 2369 | |
| 2370 | 2370 | ir_ref_instruction(target, ag->current_basic_block); |
| ... | ... | @@ -2372,10 +2372,10 @@ static IrInstSrc *ir_build_int_to_err_src(Stage1AstGen *ag, Scope *scope, AstNod |
| 2372 | 2372 | return &instruction->base; |
| 2373 | 2373 | } |
| 2374 | 2374 | |
| 2375 | static IrInstSrc *ir_build_err_to_int_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2376 | IrInstSrc *target) | |
| 2375 | static Stage1ZirInst *ir_build_err_to_int_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2376 | Stage1ZirInst *target) | |
| 2377 | 2377 | { |
| 2378 | IrInstSrcErrToInt *instruction = ir_build_instruction<IrInstSrcErrToInt>( | |
| 2378 | Stage1ZirInstErrToInt *instruction = ir_build_instruction<Stage1ZirInstErrToInt>( | |
| 2379 | 2379 | ag, scope, source_node); |
| 2380 | 2380 | instruction->target = target; |
| 2381 | 2381 | |
| ... | ... | @@ -2384,13 +2384,13 @@ static IrInstSrc *ir_build_err_to_int_src(Stage1AstGen *ag, Scope *scope, AstNod |
| 2384 | 2384 | return &instruction->base; |
| 2385 | 2385 | } |
| 2386 | 2386 | |
| 2387 | static IrInstSrc *ir_build_check_switch_prongs(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2388 | IrInstSrc *target_value, IrInstSrcCheckSwitchProngsRange *ranges, size_t range_count, | |
| 2387 | static Stage1ZirInst *ir_build_check_switch_prongs(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2388 | Stage1ZirInst *target_value, Stage1ZirInstCheckSwitchProngsRange *ranges, size_t range_count, | |
| 2389 | 2389 | AstNode* else_prong, bool have_underscore_prong) |
| 2390 | 2390 | { |
| 2391 | IrInstSrcCheckSwitchProngs *instruction = heap::c_allocator.create<IrInstSrcCheckSwitchProngs>(); | |
| 2391 | Stage1ZirInstCheckSwitchProngs *instruction = heap::c_allocator.create<Stage1ZirInstCheckSwitchProngs>(); | |
| 2392 | 2392 | instruction->base.id = have_underscore_prong ? |
| 2393 | IrInstSrcIdCheckSwitchProngsUnderYes : IrInstSrcIdCheckSwitchProngsUnderNo; | |
| 2393 | Stage1ZirInstIdCheckSwitchProngsUnderYes : Stage1ZirInstIdCheckSwitchProngsUnderNo; | |
| 2394 | 2394 | instruction->base.scope = scope; |
| 2395 | 2395 | instruction->base.source_node = source_node; |
| 2396 | 2396 | instruction->base.debug_id = irb_next_debug_id(ag); |
| ... | ... | @@ -2411,10 +2411,10 @@ static IrInstSrc *ir_build_check_switch_prongs(Stage1AstGen *ag, Scope *scope, A |
| 2411 | 2411 | return &instruction->base; |
| 2412 | 2412 | } |
| 2413 | 2413 | |
| 2414 | static IrInstSrc *ir_build_check_statement_is_void(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2415 | IrInstSrc* statement_value) | |
| 2414 | static Stage1ZirInst *ir_build_check_statement_is_void(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2415 | Stage1ZirInst* statement_value) | |
| 2416 | 2416 | { |
| 2417 | IrInstSrcCheckStatementIsVoid *instruction = ir_build_instruction<IrInstSrcCheckStatementIsVoid>( | |
| 2417 | Stage1ZirInstCheckStatementIsVoid *instruction = ir_build_instruction<Stage1ZirInstCheckStatementIsVoid>( | |
| 2418 | 2418 | ag, scope, source_node); |
| 2419 | 2419 | instruction->statement_value = statement_value; |
| 2420 | 2420 | |
| ... | ... | @@ -2423,10 +2423,10 @@ static IrInstSrc *ir_build_check_statement_is_void(Stage1AstGen *ag, Scope *scop |
| 2423 | 2423 | return &instruction->base; |
| 2424 | 2424 | } |
| 2425 | 2425 | |
| 2426 | static IrInstSrc *ir_build_type_name(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2427 | IrInstSrc *type_value) | |
| 2426 | static Stage1ZirInst *ir_build_type_name(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2427 | Stage1ZirInst *type_value) | |
| 2428 | 2428 | { |
| 2429 | IrInstSrcTypeName *instruction = ir_build_instruction<IrInstSrcTypeName>(ag, scope, source_node); | |
| 2429 | Stage1ZirInstTypeName *instruction = ir_build_instruction<Stage1ZirInstTypeName>(ag, scope, source_node); | |
| 2430 | 2430 | instruction->type_value = type_value; |
| 2431 | 2431 | |
| 2432 | 2432 | ir_ref_instruction(type_value, ag->current_basic_block); |
| ... | ... | @@ -2434,16 +2434,16 @@ static IrInstSrc *ir_build_type_name(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 2434 | 2434 | return &instruction->base; |
| 2435 | 2435 | } |
| 2436 | 2436 | |
| 2437 | static IrInstSrc *ir_build_decl_ref(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Tld *tld, LVal lval) { | |
| 2438 | IrInstSrcDeclRef *instruction = ir_build_instruction<IrInstSrcDeclRef>(ag, scope, source_node); | |
| 2437 | static Stage1ZirInst *ir_build_decl_ref(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Tld *tld, LVal lval) { | |
| 2438 | Stage1ZirInstDeclRef *instruction = ir_build_instruction<Stage1ZirInstDeclRef>(ag, scope, source_node); | |
| 2439 | 2439 | instruction->tld = tld; |
| 2440 | 2440 | instruction->lval = lval; |
| 2441 | 2441 | |
| 2442 | 2442 | return &instruction->base; |
| 2443 | 2443 | } |
| 2444 | 2444 | |
| 2445 | static IrInstSrc *ir_build_panic_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *msg) { | |
| 2446 | IrInstSrcPanic *instruction = ir_build_instruction<IrInstSrcPanic>(ag, scope, source_node); | |
| 2445 | static Stage1ZirInst *ir_build_panic_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *msg) { | |
| 2446 | Stage1ZirInstPanic *instruction = ir_build_instruction<Stage1ZirInstPanic>(ag, scope, source_node); | |
| 2447 | 2447 | instruction->msg = msg; |
| 2448 | 2448 | |
| 2449 | 2449 | ir_ref_instruction(msg, ag->current_basic_block); |
| ... | ... | @@ -2451,8 +2451,8 @@ static IrInstSrc *ir_build_panic_src(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 2451 | 2451 | return &instruction->base; |
| 2452 | 2452 | } |
| 2453 | 2453 | |
| 2454 | static IrInstSrc *ir_build_tag_name_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *target) { | |
| 2455 | IrInstSrcTagName *instruction = ir_build_instruction<IrInstSrcTagName>(ag, scope, source_node); | |
| 2454 | static Stage1ZirInst *ir_build_tag_name_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *target) { | |
| 2455 | Stage1ZirInstTagName *instruction = ir_build_instruction<Stage1ZirInstTagName>(ag, scope, source_node); | |
| 2456 | 2456 | instruction->target = target; |
| 2457 | 2457 | |
| 2458 | 2458 | ir_ref_instruction(target, ag->current_basic_block); |
| ... | ... | @@ -2460,10 +2460,10 @@ static IrInstSrc *ir_build_tag_name_src(Stage1AstGen *ag, Scope *scope, AstNode |
| 2460 | 2460 | return &instruction->base; |
| 2461 | 2461 | } |
| 2462 | 2462 | |
| 2463 | static IrInstSrc *ir_build_field_parent_ptr_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2464 | IrInstSrc *type_value, IrInstSrc *field_name, IrInstSrc *field_ptr) | |
| 2463 | static Stage1ZirInst *ir_build_field_parent_ptr_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2464 | Stage1ZirInst *type_value, Stage1ZirInst *field_name, Stage1ZirInst *field_ptr) | |
| 2465 | 2465 | { |
| 2466 | IrInstSrcFieldParentPtr *inst = ir_build_instruction<IrInstSrcFieldParentPtr>( | |
| 2466 | Stage1ZirInstFieldParentPtr *inst = ir_build_instruction<Stage1ZirInstFieldParentPtr>( | |
| 2467 | 2467 | ag, scope, source_node); |
| 2468 | 2468 | inst->type_value = type_value; |
| 2469 | 2469 | inst->field_name = field_name; |
| ... | ... | @@ -2476,10 +2476,10 @@ static IrInstSrc *ir_build_field_parent_ptr_src(Stage1AstGen *ag, Scope *scope, |
| 2476 | 2476 | return &inst->base; |
| 2477 | 2477 | } |
| 2478 | 2478 | |
| 2479 | static IrInstSrc *ir_build_offset_of(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2480 | IrInstSrc *type_value, IrInstSrc *field_name) | |
| 2479 | static Stage1ZirInst *ir_build_offset_of(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2480 | Stage1ZirInst *type_value, Stage1ZirInst *field_name) | |
| 2481 | 2481 | { |
| 2482 | IrInstSrcOffsetOf *instruction = ir_build_instruction<IrInstSrcOffsetOf>(ag, scope, source_node); | |
| 2482 | Stage1ZirInstOffsetOf *instruction = ir_build_instruction<Stage1ZirInstOffsetOf>(ag, scope, source_node); | |
| 2483 | 2483 | instruction->type_value = type_value; |
| 2484 | 2484 | instruction->field_name = field_name; |
| 2485 | 2485 | |
| ... | ... | @@ -2489,10 +2489,10 @@ static IrInstSrc *ir_build_offset_of(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 2489 | 2489 | return &instruction->base; |
| 2490 | 2490 | } |
| 2491 | 2491 | |
| 2492 | static IrInstSrc *ir_build_bit_offset_of(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2493 | IrInstSrc *type_value, IrInstSrc *field_name) | |
| 2492 | static Stage1ZirInst *ir_build_bit_offset_of(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2493 | Stage1ZirInst *type_value, Stage1ZirInst *field_name) | |
| 2494 | 2494 | { |
| 2495 | IrInstSrcBitOffsetOf *instruction = ir_build_instruction<IrInstSrcBitOffsetOf>(ag, scope, source_node); | |
| 2495 | Stage1ZirInstBitOffsetOf *instruction = ir_build_instruction<Stage1ZirInstBitOffsetOf>(ag, scope, source_node); | |
| 2496 | 2496 | instruction->type_value = type_value; |
| 2497 | 2497 | instruction->field_name = field_name; |
| 2498 | 2498 | |
| ... | ... | @@ -2502,8 +2502,8 @@ static IrInstSrc *ir_build_bit_offset_of(Stage1AstGen *ag, Scope *scope, AstNode |
| 2502 | 2502 | return &instruction->base; |
| 2503 | 2503 | } |
| 2504 | 2504 | |
| 2505 | static IrInstSrc *ir_build_type_info(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *type_value) { | |
| 2506 | IrInstSrcTypeInfo *instruction = ir_build_instruction<IrInstSrcTypeInfo>(ag, scope, source_node); | |
| 2505 | static Stage1ZirInst *ir_build_type_info(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *type_value) { | |
| 2506 | Stage1ZirInstTypeInfo *instruction = ir_build_instruction<Stage1ZirInstTypeInfo>(ag, scope, source_node); | |
| 2507 | 2507 | instruction->type_value = type_value; |
| 2508 | 2508 | |
| 2509 | 2509 | ir_ref_instruction(type_value, ag->current_basic_block); |
| ... | ... | @@ -2511,8 +2511,8 @@ static IrInstSrc *ir_build_type_info(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 2511 | 2511 | return &instruction->base; |
| 2512 | 2512 | } |
| 2513 | 2513 | |
| 2514 | static IrInstSrc *ir_build_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *type_info) { | |
| 2515 | IrInstSrcType *instruction = ir_build_instruction<IrInstSrcType>(ag, scope, source_node); | |
| 2514 | static Stage1ZirInst *ir_build_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *type_info) { | |
| 2515 | Stage1ZirInstType *instruction = ir_build_instruction<Stage1ZirInstType>(ag, scope, source_node); | |
| 2516 | 2516 | instruction->type_info = type_info; |
| 2517 | 2517 | |
| 2518 | 2518 | ir_ref_instruction(type_info, ag->current_basic_block); |
| ... | ... | @@ -2520,10 +2520,10 @@ static IrInstSrc *ir_build_type(Stage1AstGen *ag, Scope *scope, AstNode *source_ |
| 2520 | 2520 | return &instruction->base; |
| 2521 | 2521 | } |
| 2522 | 2522 | |
| 2523 | static IrInstSrc *ir_build_set_eval_branch_quota(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2524 | IrInstSrc *new_quota) | |
| 2523 | static Stage1ZirInst *ir_build_set_eval_branch_quota(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2524 | Stage1ZirInst *new_quota) | |
| 2525 | 2525 | { |
| 2526 | IrInstSrcSetEvalBranchQuota *instruction = ir_build_instruction<IrInstSrcSetEvalBranchQuota>(ag, scope, source_node); | |
| 2526 | Stage1ZirInstSetEvalBranchQuota *instruction = ir_build_instruction<Stage1ZirInstSetEvalBranchQuota>(ag, scope, source_node); | |
| 2527 | 2527 | instruction->new_quota = new_quota; |
| 2528 | 2528 | |
| 2529 | 2529 | ir_ref_instruction(new_quota, ag->current_basic_block); |
| ... | ... | @@ -2531,10 +2531,10 @@ static IrInstSrc *ir_build_set_eval_branch_quota(Stage1AstGen *ag, Scope *scope, |
| 2531 | 2531 | return &instruction->base; |
| 2532 | 2532 | } |
| 2533 | 2533 | |
| 2534 | static IrInstSrc *ir_build_align_cast_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2535 | IrInstSrc *align_bytes, IrInstSrc *target) | |
| 2534 | static Stage1ZirInst *ir_build_align_cast_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2535 | Stage1ZirInst *align_bytes, Stage1ZirInst *target) | |
| 2536 | 2536 | { |
| 2537 | IrInstSrcAlignCast *instruction = ir_build_instruction<IrInstSrcAlignCast>(ag, scope, source_node); | |
| 2537 | Stage1ZirInstAlignCast *instruction = ir_build_instruction<Stage1ZirInstAlignCast>(ag, scope, source_node); | |
| 2538 | 2538 | instruction->align_bytes = align_bytes; |
| 2539 | 2539 | instruction->target = target; |
| 2540 | 2540 | |
| ... | ... | @@ -2544,10 +2544,10 @@ static IrInstSrc *ir_build_align_cast_src(Stage1AstGen *ag, Scope *scope, AstNod |
| 2544 | 2544 | return &instruction->base; |
| 2545 | 2545 | } |
| 2546 | 2546 | |
| 2547 | static IrInstSrc *ir_build_resolve_result(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2548 | ResultLoc *result_loc, IrInstSrc *ty) | |
| 2547 | static Stage1ZirInst *ir_build_resolve_result(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2548 | ResultLoc *result_loc, Stage1ZirInst *ty) | |
| 2549 | 2549 | { |
| 2550 | IrInstSrcResolveResult *instruction = ir_build_instruction<IrInstSrcResolveResult>(ag, scope, source_node); | |
| 2550 | Stage1ZirInstResolveResult *instruction = ir_build_instruction<Stage1ZirInstResolveResult>(ag, scope, source_node); | |
| 2551 | 2551 | instruction->result_loc = result_loc; |
| 2552 | 2552 | instruction->ty = ty; |
| 2553 | 2553 | |
| ... | ... | @@ -2556,19 +2556,19 @@ static IrInstSrc *ir_build_resolve_result(Stage1AstGen *ag, Scope *scope, AstNod |
| 2556 | 2556 | return &instruction->base; |
| 2557 | 2557 | } |
| 2558 | 2558 | |
| 2559 | static IrInstSrc *ir_build_reset_result(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2559 | static Stage1ZirInst *ir_build_reset_result(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2560 | 2560 | ResultLoc *result_loc) |
| 2561 | 2561 | { |
| 2562 | IrInstSrcResetResult *instruction = ir_build_instruction<IrInstSrcResetResult>(ag, scope, source_node); | |
| 2562 | Stage1ZirInstResetResult *instruction = ir_build_instruction<Stage1ZirInstResetResult>(ag, scope, source_node); | |
| 2563 | 2563 | instruction->result_loc = result_loc; |
| 2564 | 2564 | |
| 2565 | 2565 | return &instruction->base; |
| 2566 | 2566 | } |
| 2567 | 2567 | |
| 2568 | static IrInstSrc *ir_build_set_align_stack(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2569 | IrInstSrc *align_bytes) | |
| 2568 | static Stage1ZirInst *ir_build_set_align_stack(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2569 | Stage1ZirInst *align_bytes) | |
| 2570 | 2570 | { |
| 2571 | IrInstSrcSetAlignStack *instruction = ir_build_instruction<IrInstSrcSetAlignStack>(ag, scope, source_node); | |
| 2571 | Stage1ZirInstSetAlignStack *instruction = ir_build_instruction<Stage1ZirInstSetAlignStack>(ag, scope, source_node); | |
| 2572 | 2572 | instruction->align_bytes = align_bytes; |
| 2573 | 2573 | |
| 2574 | 2574 | ir_ref_instruction(align_bytes, ag->current_basic_block); |
| ... | ... | @@ -2576,12 +2576,12 @@ static IrInstSrc *ir_build_set_align_stack(Stage1AstGen *ag, Scope *scope, AstNo |
| 2576 | 2576 | return &instruction->base; |
| 2577 | 2577 | } |
| 2578 | 2578 | |
| 2579 | static IrInstSrc *ir_build_arg_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2580 | IrInstSrc *fn_type, IrInstSrc *arg_index, bool allow_var) | |
| 2579 | static Stage1ZirInst *ir_build_arg_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2580 | Stage1ZirInst *fn_type, Stage1ZirInst *arg_index, bool allow_var) | |
| 2581 | 2581 | { |
| 2582 | IrInstSrcArgType *instruction = heap::c_allocator.create<IrInstSrcArgType>(); | |
| 2582 | Stage1ZirInstArgType *instruction = heap::c_allocator.create<Stage1ZirInstArgType>(); | |
| 2583 | 2583 | instruction->base.id = allow_var ? |
| 2584 | IrInstSrcIdArgTypeAllowVarTrue : IrInstSrcIdArgTypeAllowVarFalse; | |
| 2584 | Stage1ZirInstIdArgTypeAllowVarTrue : Stage1ZirInstIdArgTypeAllowVarFalse; | |
| 2585 | 2585 | instruction->base.scope = scope; |
| 2586 | 2586 | instruction->base.source_node = source_node; |
| 2587 | 2587 | instruction->base.debug_id = irb_next_debug_id(ag); |
| ... | ... | @@ -2597,19 +2597,19 @@ static IrInstSrc *ir_build_arg_type(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 2597 | 2597 | return &instruction->base; |
| 2598 | 2598 | } |
| 2599 | 2599 | |
| 2600 | static IrInstSrc *ir_build_error_return_trace_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2600 | static Stage1ZirInst *ir_build_error_return_trace_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2601 | 2601 | IrInstErrorReturnTraceOptional optional) |
| 2602 | 2602 | { |
| 2603 | IrInstSrcErrorReturnTrace *inst = ir_build_instruction<IrInstSrcErrorReturnTrace>(ag, scope, source_node); | |
| 2603 | Stage1ZirInstErrorReturnTrace *inst = ir_build_instruction<Stage1ZirInstErrorReturnTrace>(ag, scope, source_node); | |
| 2604 | 2604 | inst->optional = optional; |
| 2605 | 2605 | |
| 2606 | 2606 | return &inst->base; |
| 2607 | 2607 | } |
| 2608 | 2608 | |
| 2609 | static IrInstSrc *ir_build_error_union(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2610 | IrInstSrc *err_set, IrInstSrc *payload) | |
| 2609 | static Stage1ZirInst *ir_build_error_union(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2610 | Stage1ZirInst *err_set, Stage1ZirInst *payload) | |
| 2611 | 2611 | { |
| 2612 | IrInstSrcErrorUnion *instruction = ir_build_instruction<IrInstSrcErrorUnion>(ag, scope, source_node); | |
| 2612 | Stage1ZirInstErrorUnion *instruction = ir_build_instruction<Stage1ZirInstErrorUnion>(ag, scope, source_node); | |
| 2613 | 2613 | instruction->err_set = err_set; |
| 2614 | 2614 | instruction->payload = payload; |
| 2615 | 2615 | |
| ... | ... | @@ -2619,11 +2619,11 @@ static IrInstSrc *ir_build_error_union(Stage1AstGen *ag, Scope *scope, AstNode * |
| 2619 | 2619 | return &instruction->base; |
| 2620 | 2620 | } |
| 2621 | 2621 | |
| 2622 | static IrInstSrc *ir_build_atomic_rmw_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2623 | IrInstSrc *operand_type, IrInstSrc *ptr, IrInstSrc *op, IrInstSrc *operand, | |
| 2624 | IrInstSrc *ordering) | |
| 2622 | static Stage1ZirInst *ir_build_atomic_rmw_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2623 | Stage1ZirInst *operand_type, Stage1ZirInst *ptr, Stage1ZirInst *op, Stage1ZirInst *operand, | |
| 2624 | Stage1ZirInst *ordering) | |
| 2625 | 2625 | { |
| 2626 | IrInstSrcAtomicRmw *instruction = ir_build_instruction<IrInstSrcAtomicRmw>(ag, scope, source_node); | |
| 2626 | Stage1ZirInstAtomicRmw *instruction = ir_build_instruction<Stage1ZirInstAtomicRmw>(ag, scope, source_node); | |
| 2627 | 2627 | instruction->operand_type = operand_type; |
| 2628 | 2628 | instruction->ptr = ptr; |
| 2629 | 2629 | instruction->op = op; |
| ... | ... | @@ -2639,10 +2639,10 @@ static IrInstSrc *ir_build_atomic_rmw_src(Stage1AstGen *ag, Scope *scope, AstNod |
| 2639 | 2639 | return &instruction->base; |
| 2640 | 2640 | } |
| 2641 | 2641 | |
| 2642 | static IrInstSrc *ir_build_atomic_load_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2643 | IrInstSrc *operand_type, IrInstSrc *ptr, IrInstSrc *ordering) | |
| 2642 | static Stage1ZirInst *ir_build_atomic_load_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2643 | Stage1ZirInst *operand_type, Stage1ZirInst *ptr, Stage1ZirInst *ordering) | |
| 2644 | 2644 | { |
| 2645 | IrInstSrcAtomicLoad *instruction = ir_build_instruction<IrInstSrcAtomicLoad>(ag, scope, source_node); | |
| 2645 | Stage1ZirInstAtomicLoad *instruction = ir_build_instruction<Stage1ZirInstAtomicLoad>(ag, scope, source_node); | |
| 2646 | 2646 | instruction->operand_type = operand_type; |
| 2647 | 2647 | instruction->ptr = ptr; |
| 2648 | 2648 | instruction->ordering = ordering; |
| ... | ... | @@ -2654,10 +2654,10 @@ static IrInstSrc *ir_build_atomic_load_src(Stage1AstGen *ag, Scope *scope, AstNo |
| 2654 | 2654 | return &instruction->base; |
| 2655 | 2655 | } |
| 2656 | 2656 | |
| 2657 | static IrInstSrc *ir_build_atomic_store_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2658 | IrInstSrc *operand_type, IrInstSrc *ptr, IrInstSrc *value, IrInstSrc *ordering) | |
| 2657 | static Stage1ZirInst *ir_build_atomic_store_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2658 | Stage1ZirInst *operand_type, Stage1ZirInst *ptr, Stage1ZirInst *value, Stage1ZirInst *ordering) | |
| 2659 | 2659 | { |
| 2660 | IrInstSrcAtomicStore *instruction = ir_build_instruction<IrInstSrcAtomicStore>(ag, scope, source_node); | |
| 2660 | Stage1ZirInstAtomicStore *instruction = ir_build_instruction<Stage1ZirInstAtomicStore>(ag, scope, source_node); | |
| 2661 | 2661 | instruction->operand_type = operand_type; |
| 2662 | 2662 | instruction->ptr = ptr; |
| 2663 | 2663 | instruction->value = value; |
| ... | ... | @@ -2671,15 +2671,15 @@ static IrInstSrc *ir_build_atomic_store_src(Stage1AstGen *ag, Scope *scope, AstN |
| 2671 | 2671 | return &instruction->base; |
| 2672 | 2672 | } |
| 2673 | 2673 | |
| 2674 | static IrInstSrc *ir_build_save_err_ret_addr_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2675 | IrInstSrcSaveErrRetAddr *inst = ir_build_instruction<IrInstSrcSaveErrRetAddr>(ag, scope, source_node); | |
| 2674 | static Stage1ZirInst *ir_build_save_err_ret_addr_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2675 | Stage1ZirInstSaveErrRetAddr *inst = ir_build_instruction<Stage1ZirInstSaveErrRetAddr>(ag, scope, source_node); | |
| 2676 | 2676 | return &inst->base; |
| 2677 | 2677 | } |
| 2678 | 2678 | |
| 2679 | static IrInstSrc *ir_build_add_implicit_return_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2680 | IrInstSrc *value, ResultLocReturn *result_loc_ret) | |
| 2679 | static Stage1ZirInst *ir_build_add_implicit_return_type(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2680 | Stage1ZirInst *value, ResultLocReturn *result_loc_ret) | |
| 2681 | 2681 | { |
| 2682 | IrInstSrcAddImplicitReturnType *inst = ir_build_instruction<IrInstSrcAddImplicitReturnType>(ag, scope, source_node); | |
| 2682 | Stage1ZirInstAddImplicitReturnType *inst = ir_build_instruction<Stage1ZirInstAddImplicitReturnType>(ag, scope, source_node); | |
| 2683 | 2683 | inst->value = value; |
| 2684 | 2684 | inst->result_loc_ret = result_loc_ret; |
| 2685 | 2685 | |
| ... | ... | @@ -2688,10 +2688,10 @@ static IrInstSrc *ir_build_add_implicit_return_type(Stage1AstGen *ag, Scope *sco |
| 2688 | 2688 | return &inst->base; |
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | static IrInstSrc *ir_build_has_decl(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2692 | IrInstSrc *container, IrInstSrc *name) | |
| 2691 | static Stage1ZirInst *ir_build_has_decl(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2692 | Stage1ZirInst *container, Stage1ZirInst *name) | |
| 2693 | 2693 | { |
| 2694 | IrInstSrcHasDecl *instruction = ir_build_instruction<IrInstSrcHasDecl>(ag, scope, source_node); | |
| 2694 | Stage1ZirInstHasDecl *instruction = ir_build_instruction<Stage1ZirInstHasDecl>(ag, scope, source_node); | |
| 2695 | 2695 | instruction->container = container; |
| 2696 | 2696 | instruction->name = name; |
| 2697 | 2697 | |
| ... | ... | @@ -2701,15 +2701,15 @@ static IrInstSrc *ir_build_has_decl(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 2701 | 2701 | return &instruction->base; |
| 2702 | 2702 | } |
| 2703 | 2703 | |
| 2704 | static IrInstSrc *ir_build_undeclared_identifier(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Buf *name) { | |
| 2705 | IrInstSrcUndeclaredIdent *instruction = ir_build_instruction<IrInstSrcUndeclaredIdent>(ag, scope, source_node); | |
| 2704 | static Stage1ZirInst *ir_build_undeclared_identifier(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Buf *name) { | |
| 2705 | Stage1ZirInstUndeclaredIdent *instruction = ir_build_instruction<Stage1ZirInstUndeclaredIdent>(ag, scope, source_node); | |
| 2706 | 2706 | instruction->name = name; |
| 2707 | 2707 | |
| 2708 | 2708 | return &instruction->base; |
| 2709 | 2709 | } |
| 2710 | 2710 | |
| 2711 | static IrInstSrc *ir_build_check_runtime_scope(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *scope_is_comptime, IrInstSrc *is_comptime) { | |
| 2712 | IrInstSrcCheckRuntimeScope *instruction = ir_build_instruction<IrInstSrcCheckRuntimeScope>(ag, scope, source_node); | |
| 2711 | static Stage1ZirInst *ir_build_check_runtime_scope(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *scope_is_comptime, Stage1ZirInst *is_comptime) { | |
| 2712 | Stage1ZirInstCheckRuntimeScope *instruction = ir_build_instruction<Stage1ZirInstCheckRuntimeScope>(ag, scope, source_node); | |
| 2713 | 2713 | instruction->scope_is_comptime = scope_is_comptime; |
| 2714 | 2714 | instruction->is_comptime = is_comptime; |
| 2715 | 2715 | |
| ... | ... | @@ -2719,10 +2719,10 @@ static IrInstSrc *ir_build_check_runtime_scope(Stage1AstGen *ag, Scope *scope, A |
| 2719 | 2719 | return &instruction->base; |
| 2720 | 2720 | } |
| 2721 | 2721 | |
| 2722 | static IrInstSrc *ir_build_union_init_named_field(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2723 | IrInstSrc *union_type, IrInstSrc *field_name, IrInstSrc *field_result_loc, IrInstSrc *result_loc) | |
| 2722 | static Stage1ZirInst *ir_build_union_init_named_field(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2723 | Stage1ZirInst *union_type, Stage1ZirInst *field_name, Stage1ZirInst *field_result_loc, Stage1ZirInst *result_loc) | |
| 2724 | 2724 | { |
| 2725 | IrInstSrcUnionInitNamedField *instruction = ir_build_instruction<IrInstSrcUnionInitNamedField>(ag, scope, source_node); | |
| 2725 | Stage1ZirInstUnionInitNamedField *instruction = ir_build_instruction<Stage1ZirInstUnionInitNamedField>(ag, scope, source_node); | |
| 2726 | 2726 | instruction->union_type = union_type; |
| 2727 | 2727 | instruction->field_name = field_name; |
| 2728 | 2728 | instruction->field_result_loc = field_result_loc; |
| ... | ... | @@ -2736,10 +2736,10 @@ static IrInstSrc *ir_build_union_init_named_field(Stage1AstGen *ag, Scope *scope |
| 2736 | 2736 | return &instruction->base; |
| 2737 | 2737 | } |
| 2738 | 2738 | |
| 2739 | static IrInstSrc *ir_build_alloca_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2740 | IrInstSrc *align, const char *name_hint, IrInstSrc *is_comptime) | |
| 2739 | static Stage1ZirInst *ir_build_alloca_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2740 | Stage1ZirInst *align, const char *name_hint, Stage1ZirInst *is_comptime) | |
| 2741 | 2741 | { |
| 2742 | IrInstSrcAlloca *instruction = ir_build_instruction<IrInstSrcAlloca>(ag, scope, source_node); | |
| 2742 | Stage1ZirInstAlloca *instruction = ir_build_instruction<Stage1ZirInstAlloca>(ag, scope, source_node); | |
| 2743 | 2743 | instruction->align = align; |
| 2744 | 2744 | instruction->name_hint = name_hint; |
| 2745 | 2745 | instruction->is_comptime = is_comptime; |
| ... | ... | @@ -2750,10 +2750,10 @@ static IrInstSrc *ir_build_alloca_src(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 2750 | 2750 | return &instruction->base; |
| 2751 | 2751 | } |
| 2752 | 2752 | |
| 2753 | static IrInstSrc *ir_build_end_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2754 | IrInstSrc *value, ResultLoc *result_loc) | |
| 2753 | static Stage1ZirInst *ir_build_end_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2754 | Stage1ZirInst *value, ResultLoc *result_loc) | |
| 2755 | 2755 | { |
| 2756 | IrInstSrcEndExpr *instruction = ir_build_instruction<IrInstSrcEndExpr>(ag, scope, source_node); | |
| 2756 | Stage1ZirInstEndExpr *instruction = ir_build_instruction<Stage1ZirInstEndExpr>(ag, scope, source_node); | |
| 2757 | 2757 | instruction->value = value; |
| 2758 | 2758 | instruction->result_loc = result_loc; |
| 2759 | 2759 | |
| ... | ... | @@ -2762,14 +2762,14 @@ static IrInstSrc *ir_build_end_expr(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 2762 | 2762 | return &instruction->base; |
| 2763 | 2763 | } |
| 2764 | 2764 | |
| 2765 | static IrInstSrcSuspendBegin *ir_build_suspend_begin_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2766 | return ir_build_instruction<IrInstSrcSuspendBegin>(ag, scope, source_node); | |
| 2765 | static Stage1ZirInstSuspendBegin *ir_build_suspend_begin_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2766 | return ir_build_instruction<Stage1ZirInstSuspendBegin>(ag, scope, source_node); | |
| 2767 | 2767 | } |
| 2768 | 2768 | |
| 2769 | static IrInstSrc *ir_build_suspend_finish_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2770 | IrInstSrcSuspendBegin *begin) | |
| 2769 | static Stage1ZirInst *ir_build_suspend_finish_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2770 | Stage1ZirInstSuspendBegin *begin) | |
| 2771 | 2771 | { |
| 2772 | IrInstSrcSuspendFinish *inst = ir_build_instruction<IrInstSrcSuspendFinish>(ag, scope, source_node); | |
| 2772 | Stage1ZirInstSuspendFinish *inst = ir_build_instruction<Stage1ZirInstSuspendFinish>(ag, scope, source_node); | |
| 2773 | 2773 | inst->begin = begin; |
| 2774 | 2774 | |
| 2775 | 2775 | ir_ref_instruction(&begin->base, ag->current_basic_block); |
| ... | ... | @@ -2777,10 +2777,10 @@ static IrInstSrc *ir_build_suspend_finish_src(Stage1AstGen *ag, Scope *scope, As |
| 2777 | 2777 | return &inst->base; |
| 2778 | 2778 | } |
| 2779 | 2779 | |
| 2780 | static IrInstSrc *ir_build_await_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2781 | IrInstSrc *frame, ResultLoc *result_loc, bool is_nosuspend) | |
| 2780 | static Stage1ZirInst *ir_build_await_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2781 | Stage1ZirInst *frame, ResultLoc *result_loc, bool is_nosuspend) | |
| 2782 | 2782 | { |
| 2783 | IrInstSrcAwait *instruction = ir_build_instruction<IrInstSrcAwait>(ag, scope, source_node); | |
| 2783 | Stage1ZirInstAwait *instruction = ir_build_instruction<Stage1ZirInstAwait>(ag, scope, source_node); | |
| 2784 | 2784 | instruction->frame = frame; |
| 2785 | 2785 | instruction->result_loc = result_loc; |
| 2786 | 2786 | instruction->is_nosuspend = is_nosuspend; |
| ... | ... | @@ -2790,8 +2790,8 @@ static IrInstSrc *ir_build_await_src(Stage1AstGen *ag, Scope *scope, AstNode *so |
| 2790 | 2790 | return &instruction->base; |
| 2791 | 2791 | } |
| 2792 | 2792 | |
| 2793 | static IrInstSrc *ir_build_resume_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *frame) { | |
| 2794 | IrInstSrcResume *instruction = ir_build_instruction<IrInstSrcResume>(ag, scope, source_node); | |
| 2793 | static Stage1ZirInst *ir_build_resume_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *frame) { | |
| 2794 | Stage1ZirInstResume *instruction = ir_build_instruction<Stage1ZirInstResume>(ag, scope, source_node); | |
| 2795 | 2795 | instruction->frame = frame; |
| 2796 | 2796 | |
| 2797 | 2797 | ir_ref_instruction(frame, ag->current_basic_block); |
| ... | ... | @@ -2799,10 +2799,10 @@ static IrInstSrc *ir_build_resume_src(Stage1AstGen *ag, Scope *scope, AstNode *s |
| 2799 | 2799 | return &instruction->base; |
| 2800 | 2800 | } |
| 2801 | 2801 | |
| 2802 | static IrInstSrcSpillBegin *ir_build_spill_begin_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2803 | IrInstSrc *operand, SpillId spill_id) | |
| 2802 | static Stage1ZirInstSpillBegin *ir_build_spill_begin_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2803 | Stage1ZirInst *operand, SpillId spill_id) | |
| 2804 | 2804 | { |
| 2805 | IrInstSrcSpillBegin *instruction = ir_build_instruction<IrInstSrcSpillBegin>(ag, scope, source_node); | |
| 2805 | Stage1ZirInstSpillBegin *instruction = ir_build_instruction<Stage1ZirInstSpillBegin>(ag, scope, source_node); | |
| 2806 | 2806 | instruction->operand = operand; |
| 2807 | 2807 | instruction->spill_id = spill_id; |
| 2808 | 2808 | |
| ... | ... | @@ -2811,10 +2811,10 @@ static IrInstSrcSpillBegin *ir_build_spill_begin_src(Stage1AstGen *ag, Scope *sc |
| 2811 | 2811 | return instruction; |
| 2812 | 2812 | } |
| 2813 | 2813 | |
| 2814 | static IrInstSrc *ir_build_spill_end_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2815 | IrInstSrcSpillBegin *begin) | |
| 2814 | static Stage1ZirInst *ir_build_spill_end_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 2815 | Stage1ZirInstSpillBegin *begin) | |
| 2816 | 2816 | { |
| 2817 | IrInstSrcSpillEnd *instruction = ir_build_instruction<IrInstSrcSpillEnd>(ag, scope, source_node); | |
| 2817 | Stage1ZirInstSpillEnd *instruction = ir_build_instruction<Stage1ZirInstSpillEnd>(ag, scope, source_node); | |
| 2818 | 2818 | instruction->begin = begin; |
| 2819 | 2819 | |
| 2820 | 2820 | ir_ref_instruction(&begin->base, ag->current_basic_block); |
| ... | ... | @@ -2822,8 +2822,8 @@ static IrInstSrc *ir_build_spill_end_src(Stage1AstGen *ag, Scope *scope, AstNode |
| 2822 | 2822 | return &instruction->base; |
| 2823 | 2823 | } |
| 2824 | 2824 | |
| 2825 | static IrInstSrc *ir_build_wasm_memory_size_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *index) { | |
| 2826 | IrInstSrcWasmMemorySize *instruction = ir_build_instruction<IrInstSrcWasmMemorySize>(ag, scope, source_node); | |
| 2825 | static Stage1ZirInst *ir_build_wasm_memory_size_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *index) { | |
| 2826 | Stage1ZirInstWasmMemorySize *instruction = ir_build_instruction<Stage1ZirInstWasmMemorySize>(ag, scope, source_node); | |
| 2827 | 2827 | instruction->index = index; |
| 2828 | 2828 | |
| 2829 | 2829 | ir_ref_instruction(index, ag->current_basic_block); |
| ... | ... | @@ -2831,8 +2831,8 @@ static IrInstSrc *ir_build_wasm_memory_size_src(Stage1AstGen *ag, Scope *scope, |
| 2831 | 2831 | return &instruction->base; |
| 2832 | 2832 | } |
| 2833 | 2833 | |
| 2834 | static IrInstSrc *ir_build_wasm_memory_grow_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *index, IrInstSrc *delta) { | |
| 2835 | IrInstSrcWasmMemoryGrow *instruction = ir_build_instruction<IrInstSrcWasmMemoryGrow>(ag, scope, source_node); | |
| 2834 | static Stage1ZirInst *ir_build_wasm_memory_grow_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, Stage1ZirInst *index, Stage1ZirInst *delta) { | |
| 2835 | Stage1ZirInstWasmMemoryGrow *instruction = ir_build_instruction<Stage1ZirInstWasmMemoryGrow>(ag, scope, source_node); | |
| 2836 | 2836 | instruction->index = index; |
| 2837 | 2837 | instruction->delta = delta; |
| 2838 | 2838 | |
| ... | ... | @@ -2842,8 +2842,8 @@ static IrInstSrc *ir_build_wasm_memory_grow_src(Stage1AstGen *ag, Scope *scope, |
| 2842 | 2842 | return &instruction->base; |
| 2843 | 2843 | } |
| 2844 | 2844 | |
| 2845 | static IrInstSrc *ir_build_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2846 | IrInstSrcSrc *instruction = ir_build_instruction<IrInstSrcSrc>(ag, scope, source_node); | |
| 2845 | static Stage1ZirInst *ir_build_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node) { | |
| 2846 | Stage1ZirInstSrc *instruction = ir_build_instruction<Stage1ZirInstSrc>(ag, scope, source_node); | |
| 2847 | 2847 | |
| 2848 | 2848 | return &instruction->base; |
| 2849 | 2849 | } |
| ... | ... | @@ -2886,7 +2886,7 @@ static void ir_count_defers(Stage1AstGen *ag, Scope *inner_scope, Scope *outer_s |
| 2886 | 2886 | } |
| 2887 | 2887 | } |
| 2888 | 2888 | |
| 2889 | static bool astgen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope *outer_scope, bool *is_noreturn, IrInstSrc *err_value) { | |
| 2889 | static bool astgen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope *outer_scope, bool *is_noreturn, Stage1ZirInst *err_value) { | |
| 2890 | 2890 | Scope *scope = inner_scope; |
| 2891 | 2891 | if (is_noreturn != nullptr) *is_noreturn = false; |
| 2892 | 2892 | while (scope != outer_scope) { |
| ... | ... | @@ -2920,7 +2920,7 @@ static bool astgen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope |
| 2920 | 2920 | return false; |
| 2921 | 2921 | } |
| 2922 | 2922 | |
| 2923 | IrInstSrc *is_comptime; | |
| 2923 | Stage1ZirInst *is_comptime; | |
| 2924 | 2924 | if (ir_should_inline(ag->exec, defer_expr_scope)) { |
| 2925 | 2925 | is_comptime = ir_build_const_bool(ag, defer_expr_scope, |
| 2926 | 2926 | defer_expr_node, true); |
| ... | ... | @@ -2937,7 +2937,7 @@ static bool astgen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope |
| 2937 | 2937 | defer_expr_scope = err_var->child_scope; |
| 2938 | 2938 | } |
| 2939 | 2939 | |
| 2940 | IrInstSrc *defer_expr_value = astgen_node(ag, defer_expr_node, defer_expr_scope); | |
| 2940 | Stage1ZirInst *defer_expr_value = astgen_node(ag, defer_expr_node, defer_expr_scope); | |
| 2941 | 2941 | if (defer_expr_value == ag->codegen->invalid_inst_src) |
| 2942 | 2942 | return ag->codegen->invalid_inst_src; |
| 2943 | 2943 | |
| ... | ... | @@ -3007,7 +3007,7 @@ static ScopeDeferExpr *get_scope_defer_expr(Scope *scope) { |
| 3007 | 3007 | return nullptr; |
| 3008 | 3008 | } |
| 3009 | 3009 | |
| 3010 | static IrInstSrc *astgen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | |
| 3010 | static Stage1ZirInst *astgen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | |
| 3011 | 3011 | assert(node->type == NodeTypeReturnExpr); |
| 3012 | 3012 | |
| 3013 | 3013 | ScopeDeferExpr *scope_defer_expr = get_scope_defer_expr(scope); |
| ... | ... | @@ -3029,7 +3029,7 @@ static IrInstSrc *astgen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3029 | 3029 | result_loc_ret->base.id = ResultLocIdReturn; |
| 3030 | 3030 | ir_build_reset_result(ag, scope, node, &result_loc_ret->base); |
| 3031 | 3031 | |
| 3032 | IrInstSrc *return_value; | |
| 3032 | Stage1ZirInst *return_value; | |
| 3033 | 3033 | if (expr_node) { |
| 3034 | 3034 | // Temporarily set this so that if we return a type it gets the name of the function |
| 3035 | 3035 | ZigFn *prev_name_fn = ag->exec->name_fn; |
| ... | ... | @@ -3052,7 +3052,7 @@ static IrInstSrc *astgen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3052 | 3052 | // only generate unconditional defers |
| 3053 | 3053 | if (!astgen_defers_for_block(ag, scope, outer_scope, nullptr, nullptr)) |
| 3054 | 3054 | return ag->codegen->invalid_inst_src; |
| 3055 | IrInstSrc *result = ir_build_return_src(ag, scope, node, nullptr); | |
| 3055 | Stage1ZirInst *result = ir_build_return_src(ag, scope, node, nullptr); | |
| 3056 | 3056 | result_loc_ret->base.source_instruction = result; |
| 3057 | 3057 | return result; |
| 3058 | 3058 | } |
| ... | ... | @@ -3061,9 +3061,9 @@ static IrInstSrc *astgen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3061 | 3061 | Stage1ZirBasicBlock *err_block = ir_create_basic_block(ag, scope, "ErrRetErr"); |
| 3062 | 3062 | Stage1ZirBasicBlock *ok_block = ir_create_basic_block(ag, scope, "ErrRetOk"); |
| 3063 | 3063 | |
| 3064 | IrInstSrc *is_err = ir_build_test_err_src(ag, scope, node, return_value, false, true); | |
| 3064 | Stage1ZirInst *is_err = ir_build_test_err_src(ag, scope, node, return_value, false, true); | |
| 3065 | 3065 | |
| 3066 | IrInstSrc *is_comptime; | |
| 3066 | Stage1ZirInst *is_comptime; | |
| 3067 | 3067 | if (should_inline) { |
| 3068 | 3068 | is_comptime = ir_build_const_bool(ag, scope, node, should_inline); |
| 3069 | 3069 | } else { |
| ... | ... | @@ -3087,21 +3087,21 @@ static IrInstSrc *astgen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3087 | 3087 | ir_build_br(ag, scope, node, ret_stmt_block, is_comptime); |
| 3088 | 3088 | |
| 3089 | 3089 | ir_set_cursor_at_end_and_append_block(ag, ret_stmt_block); |
| 3090 | IrInstSrc *result = ir_build_return_src(ag, scope, node, nullptr); | |
| 3090 | Stage1ZirInst *result = ir_build_return_src(ag, scope, node, nullptr); | |
| 3091 | 3091 | result_loc_ret->base.source_instruction = result; |
| 3092 | 3092 | return result; |
| 3093 | 3093 | } |
| 3094 | 3094 | case ReturnKindError: |
| 3095 | 3095 | { |
| 3096 | 3096 | assert(expr_node); |
| 3097 | IrInstSrc *err_union_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); | |
| 3097 | Stage1ZirInst *err_union_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); | |
| 3098 | 3098 | if (err_union_ptr == ag->codegen->invalid_inst_src) |
| 3099 | 3099 | return ag->codegen->invalid_inst_src; |
| 3100 | IrInstSrc *is_err_val = ir_build_test_err_src(ag, scope, node, err_union_ptr, true, false); | |
| 3100 | Stage1ZirInst *is_err_val = ir_build_test_err_src(ag, scope, node, err_union_ptr, true, false); | |
| 3101 | 3101 | |
| 3102 | 3102 | Stage1ZirBasicBlock *return_block = ir_create_basic_block(ag, scope, "ErrRetReturn"); |
| 3103 | 3103 | Stage1ZirBasicBlock *continue_block = ir_create_basic_block(ag, scope, "ErrRetContinue"); |
| 3104 | IrInstSrc *is_comptime; | |
| 3104 | Stage1ZirInst *is_comptime; | |
| 3105 | 3105 | bool should_inline = ir_should_inline(ag->exec, scope); |
| 3106 | 3106 | if (should_inline) { |
| 3107 | 3107 | is_comptime = ir_build_const_bool(ag, scope, node, true); |
| ... | ... | @@ -3111,10 +3111,10 @@ static IrInstSrc *astgen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3111 | 3111 | ir_build_cond_br(ag, scope, node, is_err_val, return_block, continue_block, is_comptime); |
| 3112 | 3112 | |
| 3113 | 3113 | ir_set_cursor_at_end_and_append_block(ag, return_block); |
| 3114 | IrInstSrc *err_val_ptr = ir_build_unwrap_err_code_src(ag, scope, node, err_union_ptr); | |
| 3115 | IrInstSrc *err_val = ir_build_load_ptr(ag, scope, node, err_val_ptr); | |
| 3114 | Stage1ZirInst *err_val_ptr = ir_build_unwrap_err_code_src(ag, scope, node, err_union_ptr); | |
| 3115 | Stage1ZirInst *err_val = ir_build_load_ptr(ag, scope, node, err_val_ptr); | |
| 3116 | 3116 | ir_build_add_implicit_return_type(ag, scope, node, err_val, nullptr); |
| 3117 | IrInstSrcSpillBegin *spill_begin = ir_build_spill_begin_src(ag, scope, node, err_val, | |
| 3117 | Stage1ZirInstSpillBegin *spill_begin = ir_build_spill_begin_src(ag, scope, node, err_val, | |
| 3118 | 3118 | SpillIdRetErrCode); |
| 3119 | 3119 | ResultLocReturn *result_loc_ret = heap::c_allocator.create<ResultLocReturn>(); |
| 3120 | 3120 | result_loc_ret->base.id = ResultLocIdReturn; |
| ... | ... | @@ -3130,12 +3130,12 @@ static IrInstSrc *astgen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3130 | 3130 | ir_build_save_err_ret_addr_src(ag, scope, node); |
| 3131 | 3131 | } |
| 3132 | 3132 | err_val = ir_build_spill_end_src(ag, scope, node, spill_begin); |
| 3133 | IrInstSrc *ret_inst = ir_build_return_src(ag, scope, node, err_val); | |
| 3133 | Stage1ZirInst *ret_inst = ir_build_return_src(ag, scope, node, err_val); | |
| 3134 | 3134 | result_loc_ret->base.source_instruction = ret_inst; |
| 3135 | 3135 | } |
| 3136 | 3136 | |
| 3137 | 3137 | ir_set_cursor_at_end_and_append_block(ag, continue_block); |
| 3138 | IrInstSrc *unwrapped_ptr = ir_build_unwrap_err_payload_src(ag, scope, node, err_union_ptr, false, false); | |
| 3138 | Stage1ZirInst *unwrapped_ptr = ir_build_unwrap_err_payload_src(ag, scope, node, err_union_ptr, false, false); | |
| 3139 | 3139 | if (lval == LValPtr) |
| 3140 | 3140 | return unwrapped_ptr; |
| 3141 | 3141 | else |
| ... | ... | @@ -3146,7 +3146,7 @@ static IrInstSrc *astgen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3146 | 3146 | } |
| 3147 | 3147 | |
| 3148 | 3148 | ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_scope, |
| 3149 | Buf *name, bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstSrc *is_comptime, | |
| 3149 | Buf *name, bool src_is_const, bool gen_is_const, bool is_shadowable, Stage1ZirInst *is_comptime, | |
| 3150 | 3150 | bool skip_name_check) |
| 3151 | 3151 | { |
| 3152 | 3152 | ZigVar *variable_entry = heap::c_allocator.create<ZigVar>(); |
| ... | ... | @@ -3218,7 +3218,7 @@ ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_scope, |
| 3218 | 3218 | // Set name to nullptr to make the variable anonymous (not visible to programmer). |
| 3219 | 3219 | // After you call this function var->child_scope has the variable in scope |
| 3220 | 3220 | static ZigVar *ir_create_var(Stage1AstGen *ag, AstNode *node, Scope *scope, Buf *name, |
| 3221 | bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstSrc *is_comptime) | |
| 3221 | bool src_is_const, bool gen_is_const, bool is_shadowable, Stage1ZirInst *is_comptime) | |
| 3222 | 3222 | { |
| 3223 | 3223 | bool is_underscored = name ? buf_eql_str(name, "_") : false; |
| 3224 | 3224 | ZigVar *var = create_local_var(ag->codegen, node, scope, |
| ... | ... | @@ -3256,12 +3256,12 @@ static bool is_duplicate_label(CodeGen *g, Scope *scope, AstNode *node, Buf *nam |
| 3256 | 3256 | return false; |
| 3257 | 3257 | } |
| 3258 | 3258 | |
| 3259 | static IrInstSrc *astgen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *block_node, LVal lval, | |
| 3259 | static Stage1ZirInst *astgen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *block_node, LVal lval, | |
| 3260 | 3260 | ResultLoc *result_loc) |
| 3261 | 3261 | { |
| 3262 | 3262 | assert(block_node->type == NodeTypeBlock); |
| 3263 | 3263 | |
| 3264 | ZigList<IrInstSrc *> incoming_values = {0}; | |
| 3264 | ZigList<Stage1ZirInst *> incoming_values = {0}; | |
| 3265 | 3265 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 3266 | 3266 | |
| 3267 | 3267 | if (is_duplicate_label(ag->codegen, parent_scope, block_node, block_node->data.block.name)) |
| ... | ... | @@ -3305,11 +3305,11 @@ static IrInstSrc *astgen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b |
| 3305 | 3305 | |
| 3306 | 3306 | bool is_continuation_unreachable = false; |
| 3307 | 3307 | bool found_invalid_inst = false; |
| 3308 | IrInstSrc *noreturn_return_value = nullptr; | |
| 3308 | Stage1ZirInst *noreturn_return_value = nullptr; | |
| 3309 | 3309 | for (size_t i = 0; i < block_node->data.block.statements.length; i += 1) { |
| 3310 | 3310 | AstNode *statement_node = block_node->data.block.statements.at(i); |
| 3311 | 3311 | |
| 3312 | IrInstSrc *statement_value = astgen_node(ag, statement_node, child_scope); | |
| 3312 | Stage1ZirInst *statement_value = astgen_node(ag, statement_node, child_scope); | |
| 3313 | 3313 | if (statement_value == ag->codegen->invalid_inst_src) { |
| 3314 | 3314 | // keep generating all the elements of the block in case of error, |
| 3315 | 3315 | // we want to collect other compile errors |
| ... | ... | @@ -3328,9 +3328,9 @@ static IrInstSrc *astgen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b |
| 3328 | 3328 | // defer starts a new scope |
| 3329 | 3329 | child_scope = statement_node->data.defer.child_scope; |
| 3330 | 3330 | assert(child_scope); |
| 3331 | } else if (statement_value->id == IrInstSrcIdDeclVar) { | |
| 3331 | } else if (statement_value->id == Stage1ZirInstIdDeclVar) { | |
| 3332 | 3332 | // variable declarations start a new scope |
| 3333 | IrInstSrcDeclVar *decl_var_instruction = (IrInstSrcDeclVar *)statement_value; | |
| 3333 | Stage1ZirInstDeclVar *decl_var_instruction = (Stage1ZirInstDeclVar *)statement_value; | |
| 3334 | 3334 | child_scope = decl_var_instruction->var->child_scope; |
| 3335 | 3335 | } else if (!is_continuation_unreachable) { |
| 3336 | 3336 | // this statement's value must be void |
| ... | ... | @@ -3355,12 +3355,12 @@ static IrInstSrc *astgen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b |
| 3355 | 3355 | scope_block->peer_parent->peers.last()->next_bb = scope_block->end_block; |
| 3356 | 3356 | } |
| 3357 | 3357 | ir_set_cursor_at_end_and_append_block(ag, scope_block->end_block); |
| 3358 | IrInstSrc *phi = ir_build_phi(ag, parent_scope, block_node, incoming_blocks.length, | |
| 3358 | Stage1ZirInst *phi = ir_build_phi(ag, parent_scope, block_node, incoming_blocks.length, | |
| 3359 | 3359 | incoming_blocks.items, incoming_values.items, scope_block->peer_parent); |
| 3360 | 3360 | return ir_expr_wrap(ag, parent_scope, phi, result_loc); |
| 3361 | 3361 | } else { |
| 3362 | 3362 | incoming_blocks.append(ag->current_basic_block); |
| 3363 | IrInstSrc *else_expr_result = ir_build_const_void(ag, parent_scope, block_node); | |
| 3363 | Stage1ZirInst *else_expr_result = ir_build_const_void(ag, parent_scope, block_node); | |
| 3364 | 3364 | |
| 3365 | 3365 | if (scope_block->peer_parent != nullptr) { |
| 3366 | 3366 | ResultLocPeer *peer_result = create_peer_result(scope_block->peer_parent); |
| ... | ... | @@ -3381,15 +3381,15 @@ static IrInstSrc *astgen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b |
| 3381 | 3381 | return ag->codegen->invalid_inst_src; |
| 3382 | 3382 | } |
| 3383 | 3383 | |
| 3384 | IrInstSrc *result; | |
| 3384 | Stage1ZirInst *result; | |
| 3385 | 3385 | if (block_node->data.block.name != nullptr) { |
| 3386 | 3386 | ir_build_br(ag, parent_scope, block_node, scope_block->end_block, scope_block->is_comptime); |
| 3387 | 3387 | ir_set_cursor_at_end_and_append_block(ag, scope_block->end_block); |
| 3388 | IrInstSrc *phi = ir_build_phi(ag, parent_scope, block_node, incoming_blocks.length, | |
| 3388 | Stage1ZirInst *phi = ir_build_phi(ag, parent_scope, block_node, incoming_blocks.length, | |
| 3389 | 3389 | incoming_blocks.items, incoming_values.items, scope_block->peer_parent); |
| 3390 | 3390 | result = ir_expr_wrap(ag, parent_scope, phi, result_loc); |
| 3391 | 3391 | } else { |
| 3392 | IrInstSrc *void_inst = ir_build_const_void(ag, child_scope, block_node); | |
| 3392 | Stage1ZirInst *void_inst = ir_build_const_void(ag, child_scope, block_node); | |
| 3393 | 3393 | result = ir_lval_wrap(ag, parent_scope, void_inst, lval, result_loc); |
| 3394 | 3394 | } |
| 3395 | 3395 | if (!is_return_from_fn) |
| ... | ... | @@ -3408,14 +3408,14 @@ static IrInstSrc *astgen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b |
| 3408 | 3408 | return ir_build_return_src(ag, child_scope, result->source_node, result); |
| 3409 | 3409 | } |
| 3410 | 3410 | |
| 3411 | static IrInstSrc *astgen_bin_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) { | |
| 3411 | static Stage1ZirInst *astgen_bin_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) { | |
| 3412 | 3412 | Scope *inner_scope = scope; |
| 3413 | 3413 | if (op_id == IrBinOpArrayCat || op_id == IrBinOpArrayMult) { |
| 3414 | 3414 | inner_scope = create_comptime_scope(ag->codegen, node, scope); |
| 3415 | 3415 | } |
| 3416 | 3416 | |
| 3417 | IrInstSrc *op1 = astgen_node(ag, node->data.bin_op_expr.op1, inner_scope); | |
| 3418 | IrInstSrc *op2 = astgen_node(ag, node->data.bin_op_expr.op2, inner_scope); | |
| 3417 | Stage1ZirInst *op1 = astgen_node(ag, node->data.bin_op_expr.op1, inner_scope); | |
| 3418 | Stage1ZirInst *op2 = astgen_node(ag, node->data.bin_op_expr.op2, inner_scope); | |
| 3419 | 3419 | |
| 3420 | 3420 | if (op1 == ag->codegen->invalid_inst_src || op2 == ag->codegen->invalid_inst_src) |
| 3421 | 3421 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -3423,9 +3423,9 @@ static IrInstSrc *astgen_bin_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node |
| 3423 | 3423 | return ir_build_bin_op(ag, scope, node, op_id, op1, op2, true); |
| 3424 | 3424 | } |
| 3425 | 3425 | |
| 3426 | static IrInstSrc *astgen_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3427 | IrInstSrc *op1 = astgen_node(ag, node->data.bin_op_expr.op1, scope); | |
| 3428 | IrInstSrc *op2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); | |
| 3426 | static Stage1ZirInst *astgen_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3427 | Stage1ZirInst *op1 = astgen_node(ag, node->data.bin_op_expr.op1, scope); | |
| 3428 | Stage1ZirInst *op2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); | |
| 3429 | 3429 | |
| 3430 | 3430 | if (op1 == ag->codegen->invalid_inst_src || op2 == ag->codegen->invalid_inst_src) |
| 3431 | 3431 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -3437,8 +3437,8 @@ static IrInstSrc *astgen_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNode |
| 3437 | 3437 | return ir_build_merge_err_sets(ag, scope, node, op1, op2, type_name); |
| 3438 | 3438 | } |
| 3439 | 3439 | |
| 3440 | static IrInstSrc *astgen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3441 | IrInstSrc *lvalue = astgen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr); | |
| 3440 | static Stage1ZirInst *astgen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3441 | Stage1ZirInst *lvalue = astgen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr); | |
| 3442 | 3442 | if (lvalue == ag->codegen->invalid_inst_src) |
| 3443 | 3443 | return ag->codegen->invalid_inst_src; |
| 3444 | 3444 | |
| ... | ... | @@ -3448,7 +3448,7 @@ static IrInstSrc *astgen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3448 | 3448 | ir_ref_instruction(lvalue, ag->current_basic_block); |
| 3449 | 3449 | ir_build_reset_result(ag, scope, node, &result_loc_inst->base); |
| 3450 | 3450 | |
| 3451 | IrInstSrc *rvalue = astgen_node_extra(ag, node->data.bin_op_expr.op2, scope, LValNone, | |
| 3451 | Stage1ZirInst *rvalue = astgen_node_extra(ag, node->data.bin_op_expr.op2, scope, LValNone, | |
| 3452 | 3452 | &result_loc_inst->base); |
| 3453 | 3453 | if (rvalue == ag->codegen->invalid_inst_src) |
| 3454 | 3454 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -3456,28 +3456,28 @@ static IrInstSrc *astgen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3456 | 3456 | return ir_build_const_void(ag, scope, node); |
| 3457 | 3457 | } |
| 3458 | 3458 | |
| 3459 | static IrInstSrc *astgen_assign_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) { | |
| 3460 | IrInstSrc *lvalue = astgen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr); | |
| 3459 | static Stage1ZirInst *astgen_assign_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) { | |
| 3460 | Stage1ZirInst *lvalue = astgen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr); | |
| 3461 | 3461 | if (lvalue == ag->codegen->invalid_inst_src) |
| 3462 | 3462 | return lvalue; |
| 3463 | IrInstSrc *op1 = ir_build_load_ptr(ag, scope, node->data.bin_op_expr.op1, lvalue); | |
| 3464 | IrInstSrc *op2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); | |
| 3463 | Stage1ZirInst *op1 = ir_build_load_ptr(ag, scope, node->data.bin_op_expr.op1, lvalue); | |
| 3464 | Stage1ZirInst *op2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); | |
| 3465 | 3465 | if (op2 == ag->codegen->invalid_inst_src) |
| 3466 | 3466 | return op2; |
| 3467 | IrInstSrc *result = ir_build_bin_op(ag, scope, node, op_id, op1, op2, true); | |
| 3467 | Stage1ZirInst *result = ir_build_bin_op(ag, scope, node, op_id, op1, op2, true); | |
| 3468 | 3468 | ir_build_store_ptr(ag, scope, node, lvalue, result); |
| 3469 | 3469 | return ir_build_const_void(ag, scope, node); |
| 3470 | 3470 | } |
| 3471 | 3471 | |
| 3472 | static IrInstSrc *astgen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3472 | static Stage1ZirInst *astgen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3473 | 3473 | assert(node->type == NodeTypeBinOpExpr); |
| 3474 | 3474 | |
| 3475 | IrInstSrc *val1 = astgen_node(ag, node->data.bin_op_expr.op1, scope); | |
| 3475 | Stage1ZirInst *val1 = astgen_node(ag, node->data.bin_op_expr.op1, scope); | |
| 3476 | 3476 | if (val1 == ag->codegen->invalid_inst_src) |
| 3477 | 3477 | return ag->codegen->invalid_inst_src; |
| 3478 | 3478 | Stage1ZirBasicBlock *post_val1_block = ag->current_basic_block; |
| 3479 | 3479 | |
| 3480 | IrInstSrc *is_comptime; | |
| 3480 | Stage1ZirInst *is_comptime; | |
| 3481 | 3481 | if (ir_should_inline(ag->exec, scope)) { |
| 3482 | 3482 | is_comptime = ir_build_const_bool(ag, scope, node, true); |
| 3483 | 3483 | } else { |
| ... | ... | @@ -3492,7 +3492,7 @@ static IrInstSrc *astgen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3492 | 3492 | ir_build_cond_br(ag, scope, node, val1, true_block, false_block, is_comptime); |
| 3493 | 3493 | |
| 3494 | 3494 | ir_set_cursor_at_end_and_append_block(ag, false_block); |
| 3495 | IrInstSrc *val2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); | |
| 3495 | Stage1ZirInst *val2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); | |
| 3496 | 3496 | if (val2 == ag->codegen->invalid_inst_src) |
| 3497 | 3497 | return ag->codegen->invalid_inst_src; |
| 3498 | 3498 | Stage1ZirBasicBlock *post_val2_block = ag->current_basic_block; |
| ... | ... | @@ -3501,7 +3501,7 @@ static IrInstSrc *astgen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3501 | 3501 | |
| 3502 | 3502 | ir_set_cursor_at_end_and_append_block(ag, true_block); |
| 3503 | 3503 | |
| 3504 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | |
| 3504 | Stage1ZirInst **incoming_values = heap::c_allocator.allocate<Stage1ZirInst *>(2); | |
| 3505 | 3505 | incoming_values[0] = val1; |
| 3506 | 3506 | incoming_values[1] = val2; |
| 3507 | 3507 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| ... | ... | @@ -3511,15 +3511,15 @@ static IrInstSrc *astgen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3511 | 3511 | return ir_build_phi(ag, scope, node, 2, incoming_blocks, incoming_values, nullptr); |
| 3512 | 3512 | } |
| 3513 | 3513 | |
| 3514 | static IrInstSrc *astgen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3514 | static Stage1ZirInst *astgen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3515 | 3515 | assert(node->type == NodeTypeBinOpExpr); |
| 3516 | 3516 | |
| 3517 | IrInstSrc *val1 = astgen_node(ag, node->data.bin_op_expr.op1, scope); | |
| 3517 | Stage1ZirInst *val1 = astgen_node(ag, node->data.bin_op_expr.op1, scope); | |
| 3518 | 3518 | if (val1 == ag->codegen->invalid_inst_src) |
| 3519 | 3519 | return ag->codegen->invalid_inst_src; |
| 3520 | 3520 | Stage1ZirBasicBlock *post_val1_block = ag->current_basic_block; |
| 3521 | 3521 | |
| 3522 | IrInstSrc *is_comptime; | |
| 3522 | Stage1ZirInst *is_comptime; | |
| 3523 | 3523 | if (ir_should_inline(ag->exec, scope)) { |
| 3524 | 3524 | is_comptime = ir_build_const_bool(ag, scope, node, true); |
| 3525 | 3525 | } else { |
| ... | ... | @@ -3534,7 +3534,7 @@ static IrInstSrc *astgen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3534 | 3534 | ir_build_cond_br(ag, scope, node, val1, true_block, false_block, is_comptime); |
| 3535 | 3535 | |
| 3536 | 3536 | ir_set_cursor_at_end_and_append_block(ag, true_block); |
| 3537 | IrInstSrc *val2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); | |
| 3537 | Stage1ZirInst *val2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); | |
| 3538 | 3538 | if (val2 == ag->codegen->invalid_inst_src) |
| 3539 | 3539 | return ag->codegen->invalid_inst_src; |
| 3540 | 3540 | Stage1ZirBasicBlock *post_val2_block = ag->current_basic_block; |
| ... | ... | @@ -3543,7 +3543,7 @@ static IrInstSrc *astgen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3543 | 3543 | |
| 3544 | 3544 | ir_set_cursor_at_end_and_append_block(ag, false_block); |
| 3545 | 3545 | |
| 3546 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | |
| 3546 | Stage1ZirInst **incoming_values = heap::c_allocator.allocate<Stage1ZirInst *>(2); | |
| 3547 | 3547 | incoming_values[0] = val1; |
| 3548 | 3548 | incoming_values[1] = val2; |
| 3549 | 3549 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| ... | ... | @@ -3553,8 +3553,8 @@ static IrInstSrc *astgen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3553 | 3553 | return ir_build_phi(ag, scope, node, 2, incoming_blocks, incoming_values, nullptr); |
| 3554 | 3554 | } |
| 3555 | 3555 | |
| 3556 | static ResultLocPeerParent *ir_build_result_peers(Stage1AstGen *ag, IrInstSrc *cond_br_inst, | |
| 3557 | Stage1ZirBasicBlock *end_block, ResultLoc *parent, IrInstSrc *is_comptime) | |
| 3556 | static ResultLocPeerParent *ir_build_result_peers(Stage1AstGen *ag, Stage1ZirInst *cond_br_inst, | |
| 3557 | Stage1ZirBasicBlock *end_block, ResultLoc *parent, Stage1ZirInst *is_comptime) | |
| 3558 | 3558 | { |
| 3559 | 3559 | ResultLocPeerParent *peer_parent = heap::c_allocator.create<ResultLocPeerParent>(); |
| 3560 | 3560 | peer_parent->base.id = ResultLocIdPeerParent; |
| ... | ... | @@ -3564,7 +3564,7 @@ static ResultLocPeerParent *ir_build_result_peers(Stage1AstGen *ag, IrInstSrc *c |
| 3564 | 3564 | peer_parent->is_comptime = is_comptime; |
| 3565 | 3565 | peer_parent->parent = parent; |
| 3566 | 3566 | |
| 3567 | IrInstSrc *popped_inst = ag->current_basic_block->instruction_list.pop(); | |
| 3567 | Stage1ZirInst *popped_inst = ag->current_basic_block->instruction_list.pop(); | |
| 3568 | 3568 | ir_assert(popped_inst == cond_br_inst, cond_br_inst); |
| 3569 | 3569 | |
| 3570 | 3570 | ir_build_reset_result(ag, cond_br_inst->scope, cond_br_inst->source_node, &peer_parent->base); |
| ... | ... | @@ -3573,8 +3573,8 @@ static ResultLocPeerParent *ir_build_result_peers(Stage1AstGen *ag, IrInstSrc *c |
| 3573 | 3573 | return peer_parent; |
| 3574 | 3574 | } |
| 3575 | 3575 | |
| 3576 | static ResultLocPeerParent *ir_build_binary_result_peers(Stage1AstGen *ag, IrInstSrc *cond_br_inst, | |
| 3577 | Stage1ZirBasicBlock *else_block, Stage1ZirBasicBlock *end_block, ResultLoc *parent, IrInstSrc *is_comptime) | |
| 3576 | static ResultLocPeerParent *ir_build_binary_result_peers(Stage1AstGen *ag, Stage1ZirInst *cond_br_inst, | |
| 3577 | Stage1ZirBasicBlock *else_block, Stage1ZirBasicBlock *end_block, ResultLoc *parent, Stage1ZirInst *is_comptime) | |
| 3578 | 3578 | { |
| 3579 | 3579 | ResultLocPeerParent *peer_parent = ir_build_result_peers(ag, cond_br_inst, end_block, parent, is_comptime); |
| 3580 | 3580 | |
| ... | ... | @@ -3587,7 +3587,7 @@ static ResultLocPeerParent *ir_build_binary_result_peers(Stage1AstGen *ag, IrIns |
| 3587 | 3587 | return peer_parent; |
| 3588 | 3588 | } |
| 3589 | 3589 | |
| 3590 | static IrInstSrc *astgen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, | |
| 3590 | static Stage1ZirInst *astgen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, | |
| 3591 | 3591 | ResultLoc *result_loc) |
| 3592 | 3592 | { |
| 3593 | 3593 | assert(node->type == NodeTypeBinOpExpr); |
| ... | ... | @@ -3595,14 +3595,14 @@ static IrInstSrc *astgen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * |
| 3595 | 3595 | AstNode *op1_node = node->data.bin_op_expr.op1; |
| 3596 | 3596 | AstNode *op2_node = node->data.bin_op_expr.op2; |
| 3597 | 3597 | |
| 3598 | IrInstSrc *maybe_ptr = astgen_node_extra(ag, op1_node, parent_scope, LValPtr, nullptr); | |
| 3598 | Stage1ZirInst *maybe_ptr = astgen_node_extra(ag, op1_node, parent_scope, LValPtr, nullptr); | |
| 3599 | 3599 | if (maybe_ptr == ag->codegen->invalid_inst_src) |
| 3600 | 3600 | return ag->codegen->invalid_inst_src; |
| 3601 | 3601 | |
| 3602 | IrInstSrc *maybe_val = ir_build_load_ptr(ag, parent_scope, node, maybe_ptr); | |
| 3603 | IrInstSrc *is_non_null = ir_build_test_non_null_src(ag, parent_scope, node, maybe_val); | |
| 3602 | Stage1ZirInst *maybe_val = ir_build_load_ptr(ag, parent_scope, node, maybe_ptr); | |
| 3603 | Stage1ZirInst *is_non_null = ir_build_test_non_null_src(ag, parent_scope, node, maybe_val); | |
| 3604 | 3604 | |
| 3605 | IrInstSrc *is_comptime; | |
| 3605 | Stage1ZirInst *is_comptime; | |
| 3606 | 3606 | if (ir_should_inline(ag->exec, parent_scope)) { |
| 3607 | 3607 | is_comptime = ir_build_const_bool(ag, parent_scope, node, true); |
| 3608 | 3608 | } else { |
| ... | ... | @@ -3612,13 +3612,13 @@ static IrInstSrc *astgen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * |
| 3612 | 3612 | Stage1ZirBasicBlock *ok_block = ir_create_basic_block(ag, parent_scope, "OptionalNonNull"); |
| 3613 | 3613 | Stage1ZirBasicBlock *null_block = ir_create_basic_block(ag, parent_scope, "OptionalNull"); |
| 3614 | 3614 | Stage1ZirBasicBlock *end_block = ir_create_basic_block(ag, parent_scope, "OptionalEnd"); |
| 3615 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, parent_scope, node, is_non_null, ok_block, null_block, is_comptime); | |
| 3615 | Stage1ZirInst *cond_br_inst = ir_build_cond_br(ag, parent_scope, node, is_non_null, ok_block, null_block, is_comptime); | |
| 3616 | 3616 | |
| 3617 | 3617 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(ag, cond_br_inst, ok_block, end_block, |
| 3618 | 3618 | result_loc, is_comptime); |
| 3619 | 3619 | |
| 3620 | 3620 | ir_set_cursor_at_end_and_append_block(ag, null_block); |
| 3621 | IrInstSrc *null_result = astgen_node_extra(ag, op2_node, parent_scope, LValNone, | |
| 3621 | Stage1ZirInst *null_result = astgen_node_extra(ag, op2_node, parent_scope, LValNone, | |
| 3622 | 3622 | &peer_parent->peers.at(0)->base); |
| 3623 | 3623 | if (null_result == ag->codegen->invalid_inst_src) |
| 3624 | 3624 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -3627,41 +3627,41 @@ static IrInstSrc *astgen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * |
| 3627 | 3627 | ir_build_br(ag, parent_scope, node, end_block, is_comptime); |
| 3628 | 3628 | |
| 3629 | 3629 | ir_set_cursor_at_end_and_append_block(ag, ok_block); |
| 3630 | IrInstSrc *unwrapped_ptr = ir_build_optional_unwrap_ptr(ag, parent_scope, node, maybe_ptr, false); | |
| 3631 | IrInstSrc *unwrapped_payload = ir_build_load_ptr(ag, parent_scope, node, unwrapped_ptr); | |
| 3630 | Stage1ZirInst *unwrapped_ptr = ir_build_optional_unwrap_ptr(ag, parent_scope, node, maybe_ptr, false); | |
| 3631 | Stage1ZirInst *unwrapped_payload = ir_build_load_ptr(ag, parent_scope, node, unwrapped_ptr); | |
| 3632 | 3632 | ir_build_end_expr(ag, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); |
| 3633 | 3633 | Stage1ZirBasicBlock *after_ok_block = ag->current_basic_block; |
| 3634 | 3634 | ir_build_br(ag, parent_scope, node, end_block, is_comptime); |
| 3635 | 3635 | |
| 3636 | 3636 | ir_set_cursor_at_end_and_append_block(ag, end_block); |
| 3637 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | |
| 3637 | Stage1ZirInst **incoming_values = heap::c_allocator.allocate<Stage1ZirInst *>(2); | |
| 3638 | 3638 | incoming_values[0] = null_result; |
| 3639 | 3639 | incoming_values[1] = unwrapped_payload; |
| 3640 | 3640 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 3641 | 3641 | incoming_blocks[0] = after_null_block; |
| 3642 | 3642 | incoming_blocks[1] = after_ok_block; |
| 3643 | IrInstSrc *phi = ir_build_phi(ag, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | |
| 3643 | Stage1ZirInst *phi = ir_build_phi(ag, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | |
| 3644 | 3644 | return ir_lval_wrap(ag, parent_scope, phi, lval, result_loc); |
| 3645 | 3645 | } |
| 3646 | 3646 | |
| 3647 | static IrInstSrc *astgen_error_union(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 3647 | static Stage1ZirInst *astgen_error_union(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 3648 | 3648 | assert(node->type == NodeTypeBinOpExpr); |
| 3649 | 3649 | |
| 3650 | 3650 | AstNode *op1_node = node->data.bin_op_expr.op1; |
| 3651 | 3651 | AstNode *op2_node = node->data.bin_op_expr.op2; |
| 3652 | 3652 | |
| 3653 | IrInstSrc *err_set = astgen_node(ag, op1_node, parent_scope); | |
| 3653 | Stage1ZirInst *err_set = astgen_node(ag, op1_node, parent_scope); | |
| 3654 | 3654 | if (err_set == ag->codegen->invalid_inst_src) |
| 3655 | 3655 | return ag->codegen->invalid_inst_src; |
| 3656 | 3656 | |
| 3657 | IrInstSrc *payload = astgen_node(ag, op2_node, parent_scope); | |
| 3657 | Stage1ZirInst *payload = astgen_node(ag, op2_node, parent_scope); | |
| 3658 | 3658 | if (payload == ag->codegen->invalid_inst_src) |
| 3659 | 3659 | return ag->codegen->invalid_inst_src; |
| 3660 | 3660 | |
| 3661 | 3661 | return ir_build_error_union(ag, parent_scope, node, err_set, payload); |
| 3662 | 3662 | } |
| 3663 | 3663 | |
| 3664 | static IrInstSrc *astgen_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | |
| 3664 | static Stage1ZirInst *astgen_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | |
| 3665 | 3665 | assert(node->type == NodeTypeBinOpExpr); |
| 3666 | 3666 | |
| 3667 | 3667 | BinOpType bin_op_type = node->data.bin_op_expr.bin_op; |
| ... | ... | @@ -3752,7 +3752,7 @@ static IrInstSrc *astgen_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3752 | 3752 | zig_unreachable(); |
| 3753 | 3753 | } |
| 3754 | 3754 | |
| 3755 | static IrInstSrc *astgen_int_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3755 | static Stage1ZirInst *astgen_int_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3756 | 3756 | assert(node->type == NodeTypeIntLiteral); |
| 3757 | 3757 | |
| 3758 | 3758 | RootStruct *root_struct = node->owner->data.structure.root_struct; |
| ... | ... | @@ -3761,7 +3761,7 @@ static IrInstSrc *astgen_int_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3761 | 3761 | return ir_build_const_bigint(ag, scope, node, bigint); |
| 3762 | 3762 | } |
| 3763 | 3763 | |
| 3764 | static IrInstSrc *astgen_float_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3764 | static Stage1ZirInst *astgen_float_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3765 | 3765 | Error err; |
| 3766 | 3766 | assert(node->type == NodeTypeFloatLiteral); |
| 3767 | 3767 | |
| ... | ... | @@ -3778,7 +3778,7 @@ static IrInstSrc *astgen_float_lit(Stage1AstGen *ag, Scope *scope, AstNode *node |
| 3778 | 3778 | return ir_build_const_bigfloat(ag, scope, node, bigfloat); |
| 3779 | 3779 | } |
| 3780 | 3780 | |
| 3781 | static IrInstSrc *astgen_char_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3781 | static Stage1ZirInst *astgen_char_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3782 | 3782 | Error err; |
| 3783 | 3783 | assert(node->type == NodeTypeCharLiteral); |
| 3784 | 3784 | |
| ... | ... | @@ -3798,13 +3798,13 @@ static IrInstSrc *astgen_char_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3798 | 3798 | return ir_build_const_uint(ag, scope, node, codepoint); |
| 3799 | 3799 | } |
| 3800 | 3800 | |
| 3801 | static IrInstSrc *astgen_null_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3801 | static Stage1ZirInst *astgen_null_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3802 | 3802 | assert(node->type == NodeTypeNullLiteral); |
| 3803 | 3803 | |
| 3804 | 3804 | return ir_build_const_null(ag, scope, node); |
| 3805 | 3805 | } |
| 3806 | 3806 | |
| 3807 | static IrInstSrc *astgen_identifier(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 3807 | static Stage1ZirInst *astgen_identifier(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 3808 | 3808 | ResultLoc *result_loc) |
| 3809 | 3809 | { |
| 3810 | 3810 | Error err; |
| ... | ... | @@ -3814,7 +3814,7 @@ static IrInstSrc *astgen_identifier(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 3814 | 3814 | |
| 3815 | 3815 | if (buf_eql_str(variable_name, "_")) { |
| 3816 | 3816 | if (lval == LValAssign) { |
| 3817 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(ag, scope, node); | |
| 3817 | Stage1ZirInstConst *const_instruction = ir_build_instruction<Stage1ZirInstConst>(ag, scope, node); | |
| 3818 | 3818 | const_instruction->value = ag->codegen->pass1_arena->create<ZigValue>(); |
| 3819 | 3819 | const_instruction->value->type = get_pointer_to_type(ag->codegen, |
| 3820 | 3820 | ag->codegen->builtin_types.entry_void, false); |
| ... | ... | @@ -3837,7 +3837,7 @@ static IrInstSrc *astgen_identifier(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 3837 | 3837 | } |
| 3838 | 3838 | assert(err == ErrorPrimitiveTypeNotFound); |
| 3839 | 3839 | } else { |
| 3840 | IrInstSrc *value = ir_build_const_type(ag, scope, node, primitive_type); | |
| 3840 | Stage1ZirInst *value = ir_build_const_type(ag, scope, node, primitive_type); | |
| 3841 | 3841 | if (lval == LValPtr || lval == LValAssign) { |
| 3842 | 3842 | return ir_build_ref_src(ag, scope, node, value); |
| 3843 | 3843 | } else { |
| ... | ... | @@ -3848,7 +3848,7 @@ static IrInstSrc *astgen_identifier(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 3848 | 3848 | ScopeFnDef *crossed_fndef_scope; |
| 3849 | 3849 | ZigVar *var = find_variable(ag->codegen, scope, variable_name, &crossed_fndef_scope); |
| 3850 | 3850 | if (var) { |
| 3851 | IrInstSrc *var_ptr = ir_build_var_ptr_x(ag, scope, node, var, crossed_fndef_scope); | |
| 3851 | Stage1ZirInst *var_ptr = ir_build_var_ptr_x(ag, scope, node, var, crossed_fndef_scope); | |
| 3852 | 3852 | if (lval == LValPtr || lval == LValAssign) { |
| 3853 | 3853 | return var_ptr; |
| 3854 | 3854 | } else { |
| ... | ... | @@ -3858,7 +3858,7 @@ static IrInstSrc *astgen_identifier(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 3858 | 3858 | |
| 3859 | 3859 | Tld *tld = find_decl(ag->codegen, scope, variable_name); |
| 3860 | 3860 | if (tld) { |
| 3861 | IrInstSrc *decl_ref = ir_build_decl_ref(ag, scope, node, tld, lval); | |
| 3861 | Stage1ZirInst *decl_ref = ir_build_decl_ref(ag, scope, node, tld, lval); | |
| 3862 | 3862 | if (lval == LValPtr || lval == LValAssign) { |
| 3863 | 3863 | return decl_ref; |
| 3864 | 3864 | } else { |
| ... | ... | @@ -3875,52 +3875,52 @@ static IrInstSrc *astgen_identifier(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 3875 | 3875 | return ir_build_undeclared_identifier(ag, scope, node, variable_name); |
| 3876 | 3876 | } |
| 3877 | 3877 | |
| 3878 | static IrInstSrc *astgen_array_access(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 3878 | static Stage1ZirInst *astgen_array_access(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 3879 | 3879 | ResultLoc *result_loc) |
| 3880 | 3880 | { |
| 3881 | 3881 | assert(node->type == NodeTypeArrayAccessExpr); |
| 3882 | 3882 | |
| 3883 | 3883 | AstNode *array_ref_node = node->data.array_access_expr.array_ref_expr; |
| 3884 | IrInstSrc *array_ref_instruction = astgen_node_extra(ag, array_ref_node, scope, LValPtr, nullptr); | |
| 3884 | Stage1ZirInst *array_ref_instruction = astgen_node_extra(ag, array_ref_node, scope, LValPtr, nullptr); | |
| 3885 | 3885 | if (array_ref_instruction == ag->codegen->invalid_inst_src) |
| 3886 | 3886 | return array_ref_instruction; |
| 3887 | 3887 | |
| 3888 | 3888 | // Create an usize-typed result location to hold the subscript value, this |
| 3889 | 3889 | // makes it possible for the compiler to infer the subscript expression type |
| 3890 | 3890 | // if needed |
| 3891 | IrInstSrc *usize_type_inst = ir_build_const_type(ag, scope, node, ag->codegen->builtin_types.entry_usize); | |
| 3891 | Stage1ZirInst *usize_type_inst = ir_build_const_type(ag, scope, node, ag->codegen->builtin_types.entry_usize); | |
| 3892 | 3892 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, usize_type_inst, no_result_loc()); |
| 3893 | 3893 | |
| 3894 | 3894 | AstNode *subscript_node = node->data.array_access_expr.subscript; |
| 3895 | IrInstSrc *subscript_value = astgen_node_extra(ag, subscript_node, scope, LValNone, &result_loc_cast->base); | |
| 3895 | Stage1ZirInst *subscript_value = astgen_node_extra(ag, subscript_node, scope, LValNone, &result_loc_cast->base); | |
| 3896 | 3896 | if (subscript_value == ag->codegen->invalid_inst_src) |
| 3897 | 3897 | return ag->codegen->invalid_inst_src; |
| 3898 | 3898 | |
| 3899 | IrInstSrc *subscript_instruction = ir_build_implicit_cast(ag, scope, subscript_node, subscript_value, result_loc_cast); | |
| 3899 | Stage1ZirInst *subscript_instruction = ir_build_implicit_cast(ag, scope, subscript_node, subscript_value, result_loc_cast); | |
| 3900 | 3900 | |
| 3901 | IrInstSrc *ptr_instruction = ir_build_elem_ptr(ag, scope, node, array_ref_instruction, | |
| 3901 | Stage1ZirInst *ptr_instruction = ir_build_elem_ptr(ag, scope, node, array_ref_instruction, | |
| 3902 | 3902 | subscript_instruction, true, PtrLenSingle, nullptr); |
| 3903 | 3903 | if (lval == LValPtr || lval == LValAssign) |
| 3904 | 3904 | return ptr_instruction; |
| 3905 | 3905 | |
| 3906 | IrInstSrc *load_ptr = ir_build_load_ptr(ag, scope, node, ptr_instruction); | |
| 3906 | Stage1ZirInst *load_ptr = ir_build_load_ptr(ag, scope, node, ptr_instruction); | |
| 3907 | 3907 | return ir_expr_wrap(ag, scope, load_ptr, result_loc); |
| 3908 | 3908 | } |
| 3909 | 3909 | |
| 3910 | static IrInstSrc *astgen_field_access(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3910 | static Stage1ZirInst *astgen_field_access(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3911 | 3911 | assert(node->type == NodeTypeFieldAccessExpr); |
| 3912 | 3912 | |
| 3913 | 3913 | AstNode *container_ref_node = node->data.field_access_expr.struct_expr; |
| 3914 | 3914 | Buf *field_name = node->data.field_access_expr.field_name; |
| 3915 | 3915 | |
| 3916 | IrInstSrc *container_ref_instruction = astgen_node_extra(ag, container_ref_node, scope, LValPtr, nullptr); | |
| 3916 | Stage1ZirInst *container_ref_instruction = astgen_node_extra(ag, container_ref_node, scope, LValPtr, nullptr); | |
| 3917 | 3917 | if (container_ref_instruction == ag->codegen->invalid_inst_src) |
| 3918 | 3918 | return container_ref_instruction; |
| 3919 | 3919 | |
| 3920 | 3920 | return ir_build_field_ptr(ag, scope, node, container_ref_instruction, field_name, false); |
| 3921 | 3921 | } |
| 3922 | 3922 | |
| 3923 | static IrInstSrc *astgen_overflow_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrOverflowOp op) { | |
| 3923 | static Stage1ZirInst *astgen_overflow_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrOverflowOp op) { | |
| 3924 | 3924 | assert(node->type == NodeTypeFnCallExpr); |
| 3925 | 3925 | |
| 3926 | 3926 | AstNode *type_node = node->data.fn_call_expr.params.at(0); |
| ... | ... | @@ -3929,26 +3929,26 @@ static IrInstSrc *astgen_overflow_op(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 3929 | 3929 | AstNode *result_ptr_node = node->data.fn_call_expr.params.at(3); |
| 3930 | 3930 | |
| 3931 | 3931 | |
| 3932 | IrInstSrc *type_value = astgen_node(ag, type_node, scope); | |
| 3932 | Stage1ZirInst *type_value = astgen_node(ag, type_node, scope); | |
| 3933 | 3933 | if (type_value == ag->codegen->invalid_inst_src) |
| 3934 | 3934 | return ag->codegen->invalid_inst_src; |
| 3935 | 3935 | |
| 3936 | IrInstSrc *op1 = astgen_node(ag, op1_node, scope); | |
| 3936 | Stage1ZirInst *op1 = astgen_node(ag, op1_node, scope); | |
| 3937 | 3937 | if (op1 == ag->codegen->invalid_inst_src) |
| 3938 | 3938 | return ag->codegen->invalid_inst_src; |
| 3939 | 3939 | |
| 3940 | IrInstSrc *op2 = astgen_node(ag, op2_node, scope); | |
| 3940 | Stage1ZirInst *op2 = astgen_node(ag, op2_node, scope); | |
| 3941 | 3941 | if (op2 == ag->codegen->invalid_inst_src) |
| 3942 | 3942 | return ag->codegen->invalid_inst_src; |
| 3943 | 3943 | |
| 3944 | IrInstSrc *result_ptr = astgen_node(ag, result_ptr_node, scope); | |
| 3944 | Stage1ZirInst *result_ptr = astgen_node(ag, result_ptr_node, scope); | |
| 3945 | 3945 | if (result_ptr == ag->codegen->invalid_inst_src) |
| 3946 | 3946 | return ag->codegen->invalid_inst_src; |
| 3947 | 3947 | |
| 3948 | 3948 | return ir_build_overflow_op_src(ag, scope, node, op, type_value, op1, op2, result_ptr); |
| 3949 | 3949 | } |
| 3950 | 3950 | |
| 3951 | static IrInstSrc *astgen_mul_add(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3951 | static Stage1ZirInst *astgen_mul_add(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 3952 | 3952 | assert(node->type == NodeTypeFnCallExpr); |
| 3953 | 3953 | |
| 3954 | 3954 | AstNode *type_node = node->data.fn_call_expr.params.at(0); |
| ... | ... | @@ -3956,26 +3956,26 @@ static IrInstSrc *astgen_mul_add(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3956 | 3956 | AstNode *op2_node = node->data.fn_call_expr.params.at(2); |
| 3957 | 3957 | AstNode *op3_node = node->data.fn_call_expr.params.at(3); |
| 3958 | 3958 | |
| 3959 | IrInstSrc *type_value = astgen_node(ag, type_node, scope); | |
| 3959 | Stage1ZirInst *type_value = astgen_node(ag, type_node, scope); | |
| 3960 | 3960 | if (type_value == ag->codegen->invalid_inst_src) |
| 3961 | 3961 | return ag->codegen->invalid_inst_src; |
| 3962 | 3962 | |
| 3963 | IrInstSrc *op1 = astgen_node(ag, op1_node, scope); | |
| 3963 | Stage1ZirInst *op1 = astgen_node(ag, op1_node, scope); | |
| 3964 | 3964 | if (op1 == ag->codegen->invalid_inst_src) |
| 3965 | 3965 | return ag->codegen->invalid_inst_src; |
| 3966 | 3966 | |
| 3967 | IrInstSrc *op2 = astgen_node(ag, op2_node, scope); | |
| 3967 | Stage1ZirInst *op2 = astgen_node(ag, op2_node, scope); | |
| 3968 | 3968 | if (op2 == ag->codegen->invalid_inst_src) |
| 3969 | 3969 | return ag->codegen->invalid_inst_src; |
| 3970 | 3970 | |
| 3971 | IrInstSrc *op3 = astgen_node(ag, op3_node, scope); | |
| 3971 | Stage1ZirInst *op3 = astgen_node(ag, op3_node, scope); | |
| 3972 | 3972 | if (op3 == ag->codegen->invalid_inst_src) |
| 3973 | 3973 | return ag->codegen->invalid_inst_src; |
| 3974 | 3974 | |
| 3975 | 3975 | return ir_build_mul_add_src(ag, scope, node, type_value, op1, op2, op3); |
| 3976 | 3976 | } |
| 3977 | 3977 | |
| 3978 | static IrInstSrc *astgen_this(Stage1AstGen *ag, Scope *orig_scope, AstNode *node) { | |
| 3978 | static Stage1ZirInst *astgen_this(Stage1AstGen *ag, Scope *orig_scope, AstNode *node) { | |
| 3979 | 3979 | for (Scope *it_scope = orig_scope; it_scope != nullptr; it_scope = it_scope->parent) { |
| 3980 | 3980 | if (it_scope->id == ScopeIdDecls) { |
| 3981 | 3981 | ScopeDecls *decls_scope = (ScopeDecls *)it_scope; |
| ... | ... | @@ -3990,7 +3990,7 @@ static IrInstSrc *astgen_this(Stage1AstGen *ag, Scope *orig_scope, AstNode *node |
| 3990 | 3990 | zig_unreachable(); |
| 3991 | 3991 | } |
| 3992 | 3992 | |
| 3993 | static IrInstSrc *astgen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *await_node, AstNode *call_node, | |
| 3993 | static Stage1ZirInst *astgen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *await_node, AstNode *call_node, | |
| 3994 | 3994 | LVal lval, ResultLoc *result_loc) |
| 3995 | 3995 | { |
| 3996 | 3996 | if (call_node->data.fn_call_expr.params.length != 4) { |
| ... | ... | @@ -4001,17 +4001,17 @@ static IrInstSrc *astgen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *awa |
| 4001 | 4001 | } |
| 4002 | 4002 | |
| 4003 | 4003 | AstNode *bytes_node = call_node->data.fn_call_expr.params.at(0); |
| 4004 | IrInstSrc *bytes = astgen_node(ag, bytes_node, scope); | |
| 4004 | Stage1ZirInst *bytes = astgen_node(ag, bytes_node, scope); | |
| 4005 | 4005 | if (bytes == ag->codegen->invalid_inst_src) |
| 4006 | 4006 | return bytes; |
| 4007 | 4007 | |
| 4008 | 4008 | AstNode *ret_ptr_node = call_node->data.fn_call_expr.params.at(1); |
| 4009 | IrInstSrc *ret_ptr = astgen_node(ag, ret_ptr_node, scope); | |
| 4009 | Stage1ZirInst *ret_ptr = astgen_node(ag, ret_ptr_node, scope); | |
| 4010 | 4010 | if (ret_ptr == ag->codegen->invalid_inst_src) |
| 4011 | 4011 | return ret_ptr; |
| 4012 | 4012 | |
| 4013 | 4013 | AstNode *fn_ref_node = call_node->data.fn_call_expr.params.at(2); |
| 4014 | IrInstSrc *fn_ref = astgen_node(ag, fn_ref_node, scope); | |
| 4014 | Stage1ZirInst *fn_ref = astgen_node(ag, fn_ref_node, scope); | |
| 4015 | 4015 | if (fn_ref == ag->codegen->invalid_inst_src) |
| 4016 | 4016 | return fn_ref; |
| 4017 | 4017 | |
| ... | ... | @@ -4023,16 +4023,16 @@ static IrInstSrc *astgen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *awa |
| 4023 | 4023 | args_node->data.container_init_expr.entries.length == 0) |
| 4024 | 4024 | { |
| 4025 | 4025 | size_t arg_count = args_node->data.container_init_expr.entries.length; |
| 4026 | IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(arg_count); | |
| 4026 | Stage1ZirInst **args = heap::c_allocator.allocate<Stage1ZirInst*>(arg_count); | |
| 4027 | 4027 | for (size_t i = 0; i < arg_count; i += 1) { |
| 4028 | 4028 | AstNode *arg_node = args_node->data.container_init_expr.entries.at(i); |
| 4029 | IrInstSrc *arg = astgen_node(ag, arg_node, scope); | |
| 4029 | Stage1ZirInst *arg = astgen_node(ag, arg_node, scope); | |
| 4030 | 4030 | if (arg == ag->codegen->invalid_inst_src) |
| 4031 | 4031 | return arg; |
| 4032 | 4032 | args[i] = arg; |
| 4033 | 4033 | } |
| 4034 | 4034 | |
| 4035 | IrInstSrc *call = ir_build_call_src(ag, scope, call_node, nullptr, fn_ref, arg_count, args, | |
| 4035 | Stage1ZirInst *call = ir_build_call_src(ag, scope, call_node, nullptr, fn_ref, arg_count, args, | |
| 4036 | 4036 | ret_ptr, modifier, is_async_call_builtin, bytes, result_loc); |
| 4037 | 4037 | return ir_lval_wrap(ag, scope, call, lval, result_loc); |
| 4038 | 4038 | } else { |
| ... | ... | @@ -4041,42 +4041,42 @@ static IrInstSrc *astgen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *awa |
| 4041 | 4041 | return ag->codegen->invalid_inst_src; |
| 4042 | 4042 | } |
| 4043 | 4043 | } |
| 4044 | IrInstSrc *args = astgen_node(ag, args_node, scope); | |
| 4044 | Stage1ZirInst *args = astgen_node(ag, args_node, scope); | |
| 4045 | 4045 | if (args == ag->codegen->invalid_inst_src) |
| 4046 | 4046 | return args; |
| 4047 | 4047 | |
| 4048 | IrInstSrc *call = ir_build_async_call_extra(ag, scope, call_node, modifier, fn_ref, ret_ptr, bytes, args, result_loc); | |
| 4048 | Stage1ZirInst *call = ir_build_async_call_extra(ag, scope, call_node, modifier, fn_ref, ret_ptr, bytes, args, result_loc); | |
| 4049 | 4049 | return ir_lval_wrap(ag, scope, call, lval, result_loc); |
| 4050 | 4050 | } |
| 4051 | 4051 | |
| 4052 | static IrInstSrc *astgen_fn_call_with_args(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 4053 | AstNode *fn_ref_node, CallModifier modifier, IrInstSrc *options, | |
| 4052 | static Stage1ZirInst *astgen_fn_call_with_args(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 4053 | AstNode *fn_ref_node, CallModifier modifier, Stage1ZirInst *options, | |
| 4054 | 4054 | AstNode **args_ptr, size_t args_len, LVal lval, ResultLoc *result_loc) |
| 4055 | 4055 | { |
| 4056 | IrInstSrc *fn_ref = astgen_node(ag, fn_ref_node, scope); | |
| 4056 | Stage1ZirInst *fn_ref = astgen_node(ag, fn_ref_node, scope); | |
| 4057 | 4057 | if (fn_ref == ag->codegen->invalid_inst_src) |
| 4058 | 4058 | return fn_ref; |
| 4059 | 4059 | |
| 4060 | IrInstSrc *fn_type = ir_build_typeof_1(ag, scope, source_node, fn_ref); | |
| 4060 | Stage1ZirInst *fn_type = ir_build_typeof_1(ag, scope, source_node, fn_ref); | |
| 4061 | 4061 | |
| 4062 | IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(args_len); | |
| 4062 | Stage1ZirInst **args = heap::c_allocator.allocate<Stage1ZirInst*>(args_len); | |
| 4063 | 4063 | for (size_t i = 0; i < args_len; i += 1) { |
| 4064 | 4064 | AstNode *arg_node = args_ptr[i]; |
| 4065 | 4065 | |
| 4066 | IrInstSrc *arg_index = ir_build_const_usize(ag, scope, arg_node, i); | |
| 4067 | IrInstSrc *arg_type = ir_build_arg_type(ag, scope, source_node, fn_type, arg_index, true); | |
| 4066 | Stage1ZirInst *arg_index = ir_build_const_usize(ag, scope, arg_node, i); | |
| 4067 | Stage1ZirInst *arg_type = ir_build_arg_type(ag, scope, source_node, fn_type, arg_index, true); | |
| 4068 | 4068 | ResultLoc *no_result = no_result_loc(); |
| 4069 | 4069 | ir_build_reset_result(ag, scope, source_node, no_result); |
| 4070 | 4070 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, arg_type, no_result); |
| 4071 | 4071 | |
| 4072 | IrInstSrc *arg = astgen_node_extra(ag, arg_node, scope, LValNone, &result_loc_cast->base); | |
| 4072 | Stage1ZirInst *arg = astgen_node_extra(ag, arg_node, scope, LValNone, &result_loc_cast->base); | |
| 4073 | 4073 | if (arg == ag->codegen->invalid_inst_src) |
| 4074 | 4074 | return arg; |
| 4075 | 4075 | |
| 4076 | 4076 | args[i] = ir_build_implicit_cast(ag, scope, arg_node, arg, result_loc_cast); |
| 4077 | 4077 | } |
| 4078 | 4078 | |
| 4079 | IrInstSrc *fn_call; | |
| 4079 | Stage1ZirInst *fn_call; | |
| 4080 | 4080 | if (options != nullptr) { |
| 4081 | 4081 | fn_call = ir_build_call_args(ag, scope, source_node, options, fn_ref, args, args_len, result_loc); |
| 4082 | 4082 | } else { |
| ... | ... | @@ -4086,7 +4086,7 @@ static IrInstSrc *astgen_fn_call_with_args(Stage1AstGen *ag, Scope *scope, AstNo |
| 4086 | 4086 | return ir_lval_wrap(ag, scope, fn_call, lval, result_loc); |
| 4087 | 4087 | } |
| 4088 | 4088 | |
| 4089 | static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 4089 | static Stage1ZirInst *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 4090 | 4090 | ResultLoc *result_loc) |
| 4091 | 4091 | { |
| 4092 | 4092 | assert(node->type == NodeTypeFnCallExpr); |
| ... | ... | @@ -4120,7 +4120,7 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4120 | 4120 | |
| 4121 | 4121 | size_t arg_count = node->data.fn_call_expr.params.length; |
| 4122 | 4122 | |
| 4123 | IrInstSrc *type_of; | |
| 4123 | Stage1ZirInst *type_of; | |
| 4124 | 4124 | |
| 4125 | 4125 | if (arg_count == 0) { |
| 4126 | 4126 | add_node_error(ag->codegen, node, |
| ... | ... | @@ -4128,16 +4128,16 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4128 | 4128 | return ag->codegen->invalid_inst_src; |
| 4129 | 4129 | } else if (arg_count == 1) { |
| 4130 | 4130 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4131 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, sub_scope); | |
| 4131 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, sub_scope); | |
| 4132 | 4132 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4133 | 4133 | return arg0_value; |
| 4134 | 4134 | |
| 4135 | 4135 | type_of = ir_build_typeof_1(ag, scope, node, arg0_value); |
| 4136 | 4136 | } else { |
| 4137 | IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(arg_count); | |
| 4137 | Stage1ZirInst **args = heap::c_allocator.allocate<Stage1ZirInst*>(arg_count); | |
| 4138 | 4138 | for (size_t i = 0; i < arg_count; i += 1) { |
| 4139 | 4139 | AstNode *arg_node = node->data.fn_call_expr.params.at(i); |
| 4140 | IrInstSrc *arg = astgen_node(ag, arg_node, sub_scope); | |
| 4140 | Stage1ZirInst *arg = astgen_node(ag, arg_node, sub_scope); | |
| 4141 | 4141 | if (arg == ag->codegen->invalid_inst_src) |
| 4142 | 4142 | return ag->codegen->invalid_inst_src; |
| 4143 | 4143 | args[i] = arg; |
| ... | ... | @@ -4150,63 +4150,63 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4150 | 4150 | case BuiltinFnIdSetCold: |
| 4151 | 4151 | { |
| 4152 | 4152 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4153 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4153 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4154 | 4154 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4155 | 4155 | return arg0_value; |
| 4156 | 4156 | |
| 4157 | IrInstSrc *set_cold = ir_build_set_cold(ag, scope, node, arg0_value); | |
| 4157 | Stage1ZirInst *set_cold = ir_build_set_cold(ag, scope, node, arg0_value); | |
| 4158 | 4158 | return ir_lval_wrap(ag, scope, set_cold, lval, result_loc); |
| 4159 | 4159 | } |
| 4160 | 4160 | case BuiltinFnIdSetRuntimeSafety: |
| 4161 | 4161 | { |
| 4162 | 4162 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4163 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4163 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4164 | 4164 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4165 | 4165 | return arg0_value; |
| 4166 | 4166 | |
| 4167 | IrInstSrc *set_safety = ir_build_set_runtime_safety(ag, scope, node, arg0_value); | |
| 4167 | Stage1ZirInst *set_safety = ir_build_set_runtime_safety(ag, scope, node, arg0_value); | |
| 4168 | 4168 | return ir_lval_wrap(ag, scope, set_safety, lval, result_loc); |
| 4169 | 4169 | } |
| 4170 | 4170 | case BuiltinFnIdSetFloatMode: |
| 4171 | 4171 | { |
| 4172 | 4172 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4173 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4173 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4174 | 4174 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4175 | 4175 | return arg0_value; |
| 4176 | 4176 | |
| 4177 | IrInstSrc *set_float_mode = ir_build_set_float_mode(ag, scope, node, arg0_value); | |
| 4177 | Stage1ZirInst *set_float_mode = ir_build_set_float_mode(ag, scope, node, arg0_value); | |
| 4178 | 4178 | return ir_lval_wrap(ag, scope, set_float_mode, lval, result_loc); |
| 4179 | 4179 | } |
| 4180 | 4180 | case BuiltinFnIdSizeof: |
| 4181 | 4181 | case BuiltinFnIdBitSizeof: |
| 4182 | 4182 | { |
| 4183 | 4183 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4184 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4184 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4185 | 4185 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4186 | 4186 | return arg0_value; |
| 4187 | 4187 | |
| 4188 | IrInstSrc *size_of = ir_build_size_of(ag, scope, node, arg0_value, builtin_fn->id == BuiltinFnIdBitSizeof); | |
| 4188 | Stage1ZirInst *size_of = ir_build_size_of(ag, scope, node, arg0_value, builtin_fn->id == BuiltinFnIdBitSizeof); | |
| 4189 | 4189 | return ir_lval_wrap(ag, scope, size_of, lval, result_loc); |
| 4190 | 4190 | } |
| 4191 | 4191 | case BuiltinFnIdImport: |
| 4192 | 4192 | { |
| 4193 | 4193 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4194 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4194 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4195 | 4195 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4196 | 4196 | return arg0_value; |
| 4197 | 4197 | |
| 4198 | IrInstSrc *import = ir_build_import(ag, scope, node, arg0_value); | |
| 4198 | Stage1ZirInst *import = ir_build_import(ag, scope, node, arg0_value); | |
| 4199 | 4199 | return ir_lval_wrap(ag, scope, import, lval, result_loc); |
| 4200 | 4200 | } |
| 4201 | 4201 | case BuiltinFnIdCImport: |
| 4202 | 4202 | { |
| 4203 | IrInstSrc *c_import = ir_build_c_import(ag, scope, node); | |
| 4203 | Stage1ZirInst *c_import = ir_build_c_import(ag, scope, node); | |
| 4204 | 4204 | return ir_lval_wrap(ag, scope, c_import, lval, result_loc); |
| 4205 | 4205 | } |
| 4206 | 4206 | case BuiltinFnIdCInclude: |
| 4207 | 4207 | { |
| 4208 | 4208 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4209 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4209 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4210 | 4210 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4211 | 4211 | return arg0_value; |
| 4212 | 4212 | |
| ... | ... | @@ -4215,18 +4215,18 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4215 | 4215 | return ag->codegen->invalid_inst_src; |
| 4216 | 4216 | } |
| 4217 | 4217 | |
| 4218 | IrInstSrc *c_include = ir_build_c_include(ag, scope, node, arg0_value); | |
| 4218 | Stage1ZirInst *c_include = ir_build_c_include(ag, scope, node, arg0_value); | |
| 4219 | 4219 | return ir_lval_wrap(ag, scope, c_include, lval, result_loc); |
| 4220 | 4220 | } |
| 4221 | 4221 | case BuiltinFnIdCDefine: |
| 4222 | 4222 | { |
| 4223 | 4223 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4224 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4224 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4225 | 4225 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4226 | 4226 | return arg0_value; |
| 4227 | 4227 | |
| 4228 | 4228 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4229 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4229 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4230 | 4230 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4231 | 4231 | return arg1_value; |
| 4232 | 4232 | |
| ... | ... | @@ -4235,13 +4235,13 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4235 | 4235 | return ag->codegen->invalid_inst_src; |
| 4236 | 4236 | } |
| 4237 | 4237 | |
| 4238 | IrInstSrc *c_define = ir_build_c_define(ag, scope, node, arg0_value, arg1_value); | |
| 4238 | Stage1ZirInst *c_define = ir_build_c_define(ag, scope, node, arg0_value, arg1_value); | |
| 4239 | 4239 | return ir_lval_wrap(ag, scope, c_define, lval, result_loc); |
| 4240 | 4240 | } |
| 4241 | 4241 | case BuiltinFnIdCUndef: |
| 4242 | 4242 | { |
| 4243 | 4243 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4244 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4244 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4245 | 4245 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4246 | 4246 | return arg0_value; |
| 4247 | 4247 | |
| ... | ... | @@ -4250,22 +4250,22 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4250 | 4250 | return ag->codegen->invalid_inst_src; |
| 4251 | 4251 | } |
| 4252 | 4252 | |
| 4253 | IrInstSrc *c_undef = ir_build_c_undef(ag, scope, node, arg0_value); | |
| 4253 | Stage1ZirInst *c_undef = ir_build_c_undef(ag, scope, node, arg0_value); | |
| 4254 | 4254 | return ir_lval_wrap(ag, scope, c_undef, lval, result_loc); |
| 4255 | 4255 | } |
| 4256 | 4256 | case BuiltinFnIdCompileErr: |
| 4257 | 4257 | { |
| 4258 | 4258 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4259 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4259 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4260 | 4260 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4261 | 4261 | return arg0_value; |
| 4262 | 4262 | |
| 4263 | IrInstSrc *compile_err = ir_build_compile_err(ag, scope, node, arg0_value); | |
| 4263 | Stage1ZirInst *compile_err = ir_build_compile_err(ag, scope, node, arg0_value); | |
| 4264 | 4264 | return ir_lval_wrap(ag, scope, compile_err, lval, result_loc); |
| 4265 | 4265 | } |
| 4266 | 4266 | case BuiltinFnIdCompileLog: |
| 4267 | 4267 | { |
| 4268 | IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(actual_param_count); | |
| 4268 | Stage1ZirInst **args = heap::c_allocator.allocate<Stage1ZirInst*>(actual_param_count); | |
| 4269 | 4269 | |
| 4270 | 4270 | for (size_t i = 0; i < actual_param_count; i += 1) { |
| 4271 | 4271 | AstNode *arg_node = node->data.fn_call_expr.params.at(i); |
| ... | ... | @@ -4274,63 +4274,63 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4274 | 4274 | return ag->codegen->invalid_inst_src; |
| 4275 | 4275 | } |
| 4276 | 4276 | |
| 4277 | IrInstSrc *compile_log = ir_build_compile_log(ag, scope, node, actual_param_count, args); | |
| 4277 | Stage1ZirInst *compile_log = ir_build_compile_log(ag, scope, node, actual_param_count, args); | |
| 4278 | 4278 | return ir_lval_wrap(ag, scope, compile_log, lval, result_loc); |
| 4279 | 4279 | } |
| 4280 | 4280 | case BuiltinFnIdErrName: |
| 4281 | 4281 | { |
| 4282 | 4282 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4283 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4283 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4284 | 4284 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4285 | 4285 | return arg0_value; |
| 4286 | 4286 | |
| 4287 | IrInstSrc *err_name = ir_build_err_name(ag, scope, node, arg0_value); | |
| 4287 | Stage1ZirInst *err_name = ir_build_err_name(ag, scope, node, arg0_value); | |
| 4288 | 4288 | return ir_lval_wrap(ag, scope, err_name, lval, result_loc); |
| 4289 | 4289 | } |
| 4290 | 4290 | case BuiltinFnIdEmbedFile: |
| 4291 | 4291 | { |
| 4292 | 4292 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4293 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4293 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4294 | 4294 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4295 | 4295 | return arg0_value; |
| 4296 | 4296 | |
| 4297 | IrInstSrc *embed_file = ir_build_embed_file(ag, scope, node, arg0_value); | |
| 4297 | Stage1ZirInst *embed_file = ir_build_embed_file(ag, scope, node, arg0_value); | |
| 4298 | 4298 | return ir_lval_wrap(ag, scope, embed_file, lval, result_loc); |
| 4299 | 4299 | } |
| 4300 | 4300 | case BuiltinFnIdCmpxchgWeak: |
| 4301 | 4301 | case BuiltinFnIdCmpxchgStrong: |
| 4302 | 4302 | { |
| 4303 | 4303 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4304 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4304 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4305 | 4305 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4306 | 4306 | return arg0_value; |
| 4307 | 4307 | |
| 4308 | 4308 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4309 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4309 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4310 | 4310 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4311 | 4311 | return arg1_value; |
| 4312 | 4312 | |
| 4313 | 4313 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 4314 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 4314 | Stage1ZirInst *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 4315 | 4315 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 4316 | 4316 | return arg2_value; |
| 4317 | 4317 | |
| 4318 | 4318 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 4319 | IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope); | |
| 4319 | Stage1ZirInst *arg3_value = astgen_node(ag, arg3_node, scope); | |
| 4320 | 4320 | if (arg3_value == ag->codegen->invalid_inst_src) |
| 4321 | 4321 | return arg3_value; |
| 4322 | 4322 | |
| 4323 | 4323 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); |
| 4324 | IrInstSrc *arg4_value = astgen_node(ag, arg4_node, scope); | |
| 4324 | Stage1ZirInst *arg4_value = astgen_node(ag, arg4_node, scope); | |
| 4325 | 4325 | if (arg4_value == ag->codegen->invalid_inst_src) |
| 4326 | 4326 | return arg4_value; |
| 4327 | 4327 | |
| 4328 | 4328 | AstNode *arg5_node = node->data.fn_call_expr.params.at(5); |
| 4329 | IrInstSrc *arg5_value = astgen_node(ag, arg5_node, scope); | |
| 4329 | Stage1ZirInst *arg5_value = astgen_node(ag, arg5_node, scope); | |
| 4330 | 4330 | if (arg5_value == ag->codegen->invalid_inst_src) |
| 4331 | 4331 | return arg5_value; |
| 4332 | 4332 | |
| 4333 | IrInstSrc *cmpxchg = ir_build_cmpxchg_src(ag, scope, node, arg0_value, arg1_value, | |
| 4333 | Stage1ZirInst *cmpxchg = ir_build_cmpxchg_src(ag, scope, node, arg0_value, arg1_value, | |
| 4334 | 4334 | arg2_value, arg3_value, arg4_value, arg5_value, (builtin_fn->id == BuiltinFnIdCmpxchgWeak), |
| 4335 | 4335 | result_loc); |
| 4336 | 4336 | return ir_lval_wrap(ag, scope, cmpxchg, lval, result_loc); |
| ... | ... | @@ -4338,101 +4338,101 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4338 | 4338 | case BuiltinFnIdFence: |
| 4339 | 4339 | { |
| 4340 | 4340 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4341 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4341 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4342 | 4342 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4343 | 4343 | return arg0_value; |
| 4344 | 4344 | |
| 4345 | IrInstSrc *fence = ir_build_fence(ag, scope, node, arg0_value); | |
| 4345 | Stage1ZirInst *fence = ir_build_fence(ag, scope, node, arg0_value); | |
| 4346 | 4346 | return ir_lval_wrap(ag, scope, fence, lval, result_loc); |
| 4347 | 4347 | } |
| 4348 | 4348 | case BuiltinFnIdReduce: |
| 4349 | 4349 | { |
| 4350 | 4350 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4351 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4351 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4352 | 4352 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4353 | 4353 | return arg0_value; |
| 4354 | 4354 | |
| 4355 | 4355 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4356 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4356 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4357 | 4357 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4358 | 4358 | return arg1_value; |
| 4359 | 4359 | |
| 4360 | IrInstSrc *reduce = ir_build_reduce(ag, scope, node, arg0_value, arg1_value); | |
| 4360 | Stage1ZirInst *reduce = ir_build_reduce(ag, scope, node, arg0_value, arg1_value); | |
| 4361 | 4361 | return ir_lval_wrap(ag, scope, reduce, lval, result_loc); |
| 4362 | 4362 | } |
| 4363 | 4363 | case BuiltinFnIdDivExact: |
| 4364 | 4364 | { |
| 4365 | 4365 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4366 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4366 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4367 | 4367 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4368 | 4368 | return arg0_value; |
| 4369 | 4369 | |
| 4370 | 4370 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4371 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4371 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4372 | 4372 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4373 | 4373 | return arg1_value; |
| 4374 | 4374 | |
| 4375 | IrInstSrc *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpDivExact, arg0_value, arg1_value, true); | |
| 4375 | Stage1ZirInst *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpDivExact, arg0_value, arg1_value, true); | |
| 4376 | 4376 | return ir_lval_wrap(ag, scope, bin_op, lval, result_loc); |
| 4377 | 4377 | } |
| 4378 | 4378 | case BuiltinFnIdDivTrunc: |
| 4379 | 4379 | { |
| 4380 | 4380 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4381 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4381 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4382 | 4382 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4383 | 4383 | return arg0_value; |
| 4384 | 4384 | |
| 4385 | 4385 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4386 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4386 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4387 | 4387 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4388 | 4388 | return arg1_value; |
| 4389 | 4389 | |
| 4390 | IrInstSrc *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpDivTrunc, arg0_value, arg1_value, true); | |
| 4390 | Stage1ZirInst *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpDivTrunc, arg0_value, arg1_value, true); | |
| 4391 | 4391 | return ir_lval_wrap(ag, scope, bin_op, lval, result_loc); |
| 4392 | 4392 | } |
| 4393 | 4393 | case BuiltinFnIdDivFloor: |
| 4394 | 4394 | { |
| 4395 | 4395 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4396 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4396 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4397 | 4397 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4398 | 4398 | return arg0_value; |
| 4399 | 4399 | |
| 4400 | 4400 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4401 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4401 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4402 | 4402 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4403 | 4403 | return arg1_value; |
| 4404 | 4404 | |
| 4405 | IrInstSrc *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpDivFloor, arg0_value, arg1_value, true); | |
| 4405 | Stage1ZirInst *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpDivFloor, arg0_value, arg1_value, true); | |
| 4406 | 4406 | return ir_lval_wrap(ag, scope, bin_op, lval, result_loc); |
| 4407 | 4407 | } |
| 4408 | 4408 | case BuiltinFnIdRem: |
| 4409 | 4409 | { |
| 4410 | 4410 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4411 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4411 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4412 | 4412 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4413 | 4413 | return arg0_value; |
| 4414 | 4414 | |
| 4415 | 4415 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4416 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4416 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4417 | 4417 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4418 | 4418 | return arg1_value; |
| 4419 | 4419 | |
| 4420 | IrInstSrc *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpRemRem, arg0_value, arg1_value, true); | |
| 4420 | Stage1ZirInst *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpRemRem, arg0_value, arg1_value, true); | |
| 4421 | 4421 | return ir_lval_wrap(ag, scope, bin_op, lval, result_loc); |
| 4422 | 4422 | } |
| 4423 | 4423 | case BuiltinFnIdMod: |
| 4424 | 4424 | { |
| 4425 | 4425 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4426 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4426 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4427 | 4427 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4428 | 4428 | return arg0_value; |
| 4429 | 4429 | |
| 4430 | 4430 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4431 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4431 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4432 | 4432 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4433 | 4433 | return arg1_value; |
| 4434 | 4434 | |
| 4435 | IrInstSrc *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpRemMod, arg0_value, arg1_value, true); | |
| 4435 | Stage1ZirInst *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpRemMod, arg0_value, arg1_value, true); | |
| 4436 | 4436 | return ir_lval_wrap(ag, scope, bin_op, lval, result_loc); |
| 4437 | 4437 | } |
| 4438 | 4438 | case BuiltinFnIdSqrt: |
| ... | ... | @@ -4451,146 +4451,146 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4451 | 4451 | case BuiltinFnIdRound: |
| 4452 | 4452 | { |
| 4453 | 4453 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4454 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4454 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4455 | 4455 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4456 | 4456 | return arg0_value; |
| 4457 | 4457 | |
| 4458 | IrInstSrc *inst = ir_build_float_op_src(ag, scope, node, arg0_value, builtin_fn->id); | |
| 4458 | Stage1ZirInst *inst = ir_build_float_op_src(ag, scope, node, arg0_value, builtin_fn->id); | |
| 4459 | 4459 | return ir_lval_wrap(ag, scope, inst, lval, result_loc); |
| 4460 | 4460 | } |
| 4461 | 4461 | case BuiltinFnIdTruncate: |
| 4462 | 4462 | { |
| 4463 | 4463 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4464 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4464 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4465 | 4465 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4466 | 4466 | return arg0_value; |
| 4467 | 4467 | |
| 4468 | 4468 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4469 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4469 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4470 | 4470 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4471 | 4471 | return arg1_value; |
| 4472 | 4472 | |
| 4473 | IrInstSrc *truncate = ir_build_truncate(ag, scope, node, arg0_value, arg1_value); | |
| 4473 | Stage1ZirInst *truncate = ir_build_truncate(ag, scope, node, arg0_value, arg1_value); | |
| 4474 | 4474 | return ir_lval_wrap(ag, scope, truncate, lval, result_loc); |
| 4475 | 4475 | } |
| 4476 | 4476 | case BuiltinFnIdIntCast: |
| 4477 | 4477 | { |
| 4478 | 4478 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4479 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4479 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4480 | 4480 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4481 | 4481 | return arg0_value; |
| 4482 | 4482 | |
| 4483 | 4483 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4484 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4484 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4485 | 4485 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4486 | 4486 | return arg1_value; |
| 4487 | 4487 | |
| 4488 | IrInstSrc *result = ir_build_int_cast(ag, scope, node, arg0_value, arg1_value); | |
| 4488 | Stage1ZirInst *result = ir_build_int_cast(ag, scope, node, arg0_value, arg1_value); | |
| 4489 | 4489 | return ir_lval_wrap(ag, scope, result, lval, result_loc); |
| 4490 | 4490 | } |
| 4491 | 4491 | case BuiltinFnIdFloatCast: |
| 4492 | 4492 | { |
| 4493 | 4493 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4494 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4494 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4495 | 4495 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4496 | 4496 | return arg0_value; |
| 4497 | 4497 | |
| 4498 | 4498 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4499 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4499 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4500 | 4500 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4501 | 4501 | return arg1_value; |
| 4502 | 4502 | |
| 4503 | IrInstSrc *result = ir_build_float_cast(ag, scope, node, arg0_value, arg1_value); | |
| 4503 | Stage1ZirInst *result = ir_build_float_cast(ag, scope, node, arg0_value, arg1_value); | |
| 4504 | 4504 | return ir_lval_wrap(ag, scope, result, lval, result_loc); |
| 4505 | 4505 | } |
| 4506 | 4506 | case BuiltinFnIdErrSetCast: |
| 4507 | 4507 | { |
| 4508 | 4508 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4509 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4509 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4510 | 4510 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4511 | 4511 | return arg0_value; |
| 4512 | 4512 | |
| 4513 | 4513 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4514 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4514 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4515 | 4515 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4516 | 4516 | return arg1_value; |
| 4517 | 4517 | |
| 4518 | IrInstSrc *result = ir_build_err_set_cast(ag, scope, node, arg0_value, arg1_value); | |
| 4518 | Stage1ZirInst *result = ir_build_err_set_cast(ag, scope, node, arg0_value, arg1_value); | |
| 4519 | 4519 | return ir_lval_wrap(ag, scope, result, lval, result_loc); |
| 4520 | 4520 | } |
| 4521 | 4521 | case BuiltinFnIdIntToFloat: |
| 4522 | 4522 | { |
| 4523 | 4523 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4524 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4524 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4525 | 4525 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4526 | 4526 | return arg0_value; |
| 4527 | 4527 | |
| 4528 | 4528 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4529 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4529 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4530 | 4530 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4531 | 4531 | return arg1_value; |
| 4532 | 4532 | |
| 4533 | IrInstSrc *result = ir_build_int_to_float(ag, scope, node, arg0_value, arg1_value); | |
| 4533 | Stage1ZirInst *result = ir_build_int_to_float(ag, scope, node, arg0_value, arg1_value); | |
| 4534 | 4534 | return ir_lval_wrap(ag, scope, result, lval, result_loc); |
| 4535 | 4535 | } |
| 4536 | 4536 | case BuiltinFnIdFloatToInt: |
| 4537 | 4537 | { |
| 4538 | 4538 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4539 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4539 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4540 | 4540 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4541 | 4541 | return arg0_value; |
| 4542 | 4542 | |
| 4543 | 4543 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4544 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4544 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4545 | 4545 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4546 | 4546 | return arg1_value; |
| 4547 | 4547 | |
| 4548 | IrInstSrc *result = ir_build_float_to_int(ag, scope, node, arg0_value, arg1_value); | |
| 4548 | Stage1ZirInst *result = ir_build_float_to_int(ag, scope, node, arg0_value, arg1_value); | |
| 4549 | 4549 | return ir_lval_wrap(ag, scope, result, lval, result_loc); |
| 4550 | 4550 | } |
| 4551 | 4551 | case BuiltinFnIdErrToInt: |
| 4552 | 4552 | { |
| 4553 | 4553 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4554 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4554 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4555 | 4555 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4556 | 4556 | return arg0_value; |
| 4557 | 4557 | |
| 4558 | IrInstSrc *result = ir_build_err_to_int_src(ag, scope, node, arg0_value); | |
| 4558 | Stage1ZirInst *result = ir_build_err_to_int_src(ag, scope, node, arg0_value); | |
| 4559 | 4559 | return ir_lval_wrap(ag, scope, result, lval, result_loc); |
| 4560 | 4560 | } |
| 4561 | 4561 | case BuiltinFnIdIntToErr: |
| 4562 | 4562 | { |
| 4563 | 4563 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4564 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4564 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4565 | 4565 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4566 | 4566 | return arg0_value; |
| 4567 | 4567 | |
| 4568 | IrInstSrc *result = ir_build_int_to_err_src(ag, scope, node, arg0_value); | |
| 4568 | Stage1ZirInst *result = ir_build_int_to_err_src(ag, scope, node, arg0_value); | |
| 4569 | 4569 | return ir_lval_wrap(ag, scope, result, lval, result_loc); |
| 4570 | 4570 | } |
| 4571 | 4571 | case BuiltinFnIdBoolToInt: |
| 4572 | 4572 | { |
| 4573 | 4573 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4574 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4574 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4575 | 4575 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4576 | 4576 | return arg0_value; |
| 4577 | 4577 | |
| 4578 | IrInstSrc *result = ir_build_bool_to_int(ag, scope, node, arg0_value); | |
| 4578 | Stage1ZirInst *result = ir_build_bool_to_int(ag, scope, node, arg0_value); | |
| 4579 | 4579 | return ir_lval_wrap(ag, scope, result, lval, result_loc); |
| 4580 | 4580 | } |
| 4581 | 4581 | case BuiltinFnIdVectorType: |
| 4582 | 4582 | { |
| 4583 | 4583 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4584 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4584 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4585 | 4585 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4586 | 4586 | return arg0_value; |
| 4587 | 4587 | |
| 4588 | 4588 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4589 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4589 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4590 | 4590 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4591 | 4591 | return arg1_value; |
| 4592 | 4592 | |
| 4593 | IrInstSrc *vector_type = ir_build_vector_type(ag, scope, node, arg0_value, arg1_value); | |
| 4593 | Stage1ZirInst *vector_type = ir_build_vector_type(ag, scope, node, arg0_value, arg1_value); | |
| 4594 | 4594 | return ir_lval_wrap(ag, scope, vector_type, lval, result_loc); |
| 4595 | 4595 | } |
| 4596 | 4596 | case BuiltinFnIdShuffle: |
| ... | ... | @@ -4599,164 +4599,164 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4599 | 4599 | Scope *comptime_scope = create_comptime_scope(ag->codegen, node, scope); |
| 4600 | 4600 | |
| 4601 | 4601 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4602 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, comptime_scope); | |
| 4602 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, comptime_scope); | |
| 4603 | 4603 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4604 | 4604 | return arg0_value; |
| 4605 | 4605 | |
| 4606 | 4606 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4607 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4607 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4608 | 4608 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4609 | 4609 | return arg1_value; |
| 4610 | 4610 | |
| 4611 | 4611 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 4612 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 4612 | Stage1ZirInst *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 4613 | 4613 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 4614 | 4614 | return arg2_value; |
| 4615 | 4615 | |
| 4616 | 4616 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 4617 | IrInstSrc *arg3_value = astgen_node(ag, arg3_node, comptime_scope); | |
| 4617 | Stage1ZirInst *arg3_value = astgen_node(ag, arg3_node, comptime_scope); | |
| 4618 | 4618 | if (arg3_value == ag->codegen->invalid_inst_src) |
| 4619 | 4619 | return arg3_value; |
| 4620 | 4620 | |
| 4621 | IrInstSrc *shuffle_vector = ir_build_shuffle_vector(ag, scope, node, | |
| 4621 | Stage1ZirInst *shuffle_vector = ir_build_shuffle_vector(ag, scope, node, | |
| 4622 | 4622 | arg0_value, arg1_value, arg2_value, arg3_value); |
| 4623 | 4623 | return ir_lval_wrap(ag, scope, shuffle_vector, lval, result_loc); |
| 4624 | 4624 | } |
| 4625 | 4625 | case BuiltinFnIdSplat: |
| 4626 | 4626 | { |
| 4627 | 4627 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4628 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4628 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4629 | 4629 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4630 | 4630 | return arg0_value; |
| 4631 | 4631 | |
| 4632 | 4632 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4633 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4633 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4634 | 4634 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4635 | 4635 | return arg1_value; |
| 4636 | 4636 | |
| 4637 | IrInstSrc *splat = ir_build_splat_src(ag, scope, node, | |
| 4637 | Stage1ZirInst *splat = ir_build_splat_src(ag, scope, node, | |
| 4638 | 4638 | arg0_value, arg1_value); |
| 4639 | 4639 | return ir_lval_wrap(ag, scope, splat, lval, result_loc); |
| 4640 | 4640 | } |
| 4641 | 4641 | case BuiltinFnIdMemcpy: |
| 4642 | 4642 | { |
| 4643 | 4643 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4644 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4644 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4645 | 4645 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4646 | 4646 | return arg0_value; |
| 4647 | 4647 | |
| 4648 | 4648 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4649 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4649 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4650 | 4650 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4651 | 4651 | return arg1_value; |
| 4652 | 4652 | |
| 4653 | 4653 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 4654 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 4654 | Stage1ZirInst *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 4655 | 4655 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 4656 | 4656 | return arg2_value; |
| 4657 | 4657 | |
| 4658 | IrInstSrc *ir_memcpy = ir_build_memcpy_src(ag, scope, node, arg0_value, arg1_value, arg2_value); | |
| 4658 | Stage1ZirInst *ir_memcpy = ir_build_memcpy_src(ag, scope, node, arg0_value, arg1_value, arg2_value); | |
| 4659 | 4659 | return ir_lval_wrap(ag, scope, ir_memcpy, lval, result_loc); |
| 4660 | 4660 | } |
| 4661 | 4661 | case BuiltinFnIdMemset: |
| 4662 | 4662 | { |
| 4663 | 4663 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4664 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4664 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4665 | 4665 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4666 | 4666 | return arg0_value; |
| 4667 | 4667 | |
| 4668 | 4668 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4669 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4669 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4670 | 4670 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4671 | 4671 | return arg1_value; |
| 4672 | 4672 | |
| 4673 | 4673 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 4674 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 4674 | Stage1ZirInst *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 4675 | 4675 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 4676 | 4676 | return arg2_value; |
| 4677 | 4677 | |
| 4678 | IrInstSrc *ir_memset = ir_build_memset_src(ag, scope, node, arg0_value, arg1_value, arg2_value); | |
| 4678 | Stage1ZirInst *ir_memset = ir_build_memset_src(ag, scope, node, arg0_value, arg1_value, arg2_value); | |
| 4679 | 4679 | return ir_lval_wrap(ag, scope, ir_memset, lval, result_loc); |
| 4680 | 4680 | } |
| 4681 | 4681 | case BuiltinFnIdWasmMemorySize: |
| 4682 | 4682 | { |
| 4683 | 4683 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4684 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4684 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4685 | 4685 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4686 | 4686 | return arg0_value; |
| 4687 | 4687 | |
| 4688 | IrInstSrc *ir_wasm_memory_size = ir_build_wasm_memory_size_src(ag, scope, node, arg0_value); | |
| 4688 | Stage1ZirInst *ir_wasm_memory_size = ir_build_wasm_memory_size_src(ag, scope, node, arg0_value); | |
| 4689 | 4689 | return ir_lval_wrap(ag, scope, ir_wasm_memory_size, lval, result_loc); |
| 4690 | 4690 | } |
| 4691 | 4691 | case BuiltinFnIdWasmMemoryGrow: |
| 4692 | 4692 | { |
| 4693 | 4693 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4694 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4694 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4695 | 4695 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4696 | 4696 | return arg0_value; |
| 4697 | 4697 | |
| 4698 | 4698 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4699 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4699 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4700 | 4700 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4701 | 4701 | return arg1_value; |
| 4702 | 4702 | |
| 4703 | IrInstSrc *ir_wasm_memory_grow = ir_build_wasm_memory_grow_src(ag, scope, node, arg0_value, arg1_value); | |
| 4703 | Stage1ZirInst *ir_wasm_memory_grow = ir_build_wasm_memory_grow_src(ag, scope, node, arg0_value, arg1_value); | |
| 4704 | 4704 | return ir_lval_wrap(ag, scope, ir_wasm_memory_grow, lval, result_loc); |
| 4705 | 4705 | } |
| 4706 | 4706 | case BuiltinFnIdField: |
| 4707 | 4707 | { |
| 4708 | 4708 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4709 | IrInstSrc *arg0_value = astgen_node_extra(ag, arg0_node, scope, LValPtr, nullptr); | |
| 4709 | Stage1ZirInst *arg0_value = astgen_node_extra(ag, arg0_node, scope, LValPtr, nullptr); | |
| 4710 | 4710 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4711 | 4711 | return arg0_value; |
| 4712 | 4712 | |
| 4713 | 4713 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4714 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4714 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4715 | 4715 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4716 | 4716 | return arg1_value; |
| 4717 | 4717 | |
| 4718 | IrInstSrc *ptr_instruction = ir_build_field_ptr_instruction(ag, scope, node, | |
| 4718 | Stage1ZirInst *ptr_instruction = ir_build_field_ptr_instruction(ag, scope, node, | |
| 4719 | 4719 | arg0_value, arg1_value, false); |
| 4720 | 4720 | |
| 4721 | 4721 | if (lval == LValPtr || lval == LValAssign) |
| 4722 | 4722 | return ptr_instruction; |
| 4723 | 4723 | |
| 4724 | IrInstSrc *load_ptr = ir_build_load_ptr(ag, scope, node, ptr_instruction); | |
| 4724 | Stage1ZirInst *load_ptr = ir_build_load_ptr(ag, scope, node, ptr_instruction); | |
| 4725 | 4725 | return ir_expr_wrap(ag, scope, load_ptr, result_loc); |
| 4726 | 4726 | } |
| 4727 | 4727 | case BuiltinFnIdHasField: |
| 4728 | 4728 | { |
| 4729 | 4729 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4730 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4730 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4731 | 4731 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4732 | 4732 | return arg0_value; |
| 4733 | 4733 | |
| 4734 | 4734 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4735 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4735 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4736 | 4736 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4737 | 4737 | return arg1_value; |
| 4738 | 4738 | |
| 4739 | IrInstSrc *type_info = ir_build_has_field(ag, scope, node, arg0_value, arg1_value); | |
| 4739 | Stage1ZirInst *type_info = ir_build_has_field(ag, scope, node, arg0_value, arg1_value); | |
| 4740 | 4740 | return ir_lval_wrap(ag, scope, type_info, lval, result_loc); |
| 4741 | 4741 | } |
| 4742 | 4742 | case BuiltinFnIdTypeInfo: |
| 4743 | 4743 | { |
| 4744 | 4744 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4745 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4745 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4746 | 4746 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4747 | 4747 | return arg0_value; |
| 4748 | 4748 | |
| 4749 | IrInstSrc *type_info = ir_build_type_info(ag, scope, node, arg0_value); | |
| 4749 | Stage1ZirInst *type_info = ir_build_type_info(ag, scope, node, arg0_value); | |
| 4750 | 4750 | return ir_lval_wrap(ag, scope, type_info, lval, result_loc); |
| 4751 | 4751 | } |
| 4752 | 4752 | case BuiltinFnIdType: |
| 4753 | 4753 | { |
| 4754 | 4754 | AstNode *arg_node = node->data.fn_call_expr.params.at(0); |
| 4755 | IrInstSrc *arg = astgen_node(ag, arg_node, scope); | |
| 4755 | Stage1ZirInst *arg = astgen_node(ag, arg_node, scope); | |
| 4756 | 4756 | if (arg == ag->codegen->invalid_inst_src) |
| 4757 | 4757 | return arg; |
| 4758 | 4758 | |
| 4759 | IrInstSrc *type = ir_build_type(ag, scope, node, arg); | |
| 4759 | Stage1ZirInst *type = ir_build_type(ag, scope, node, arg); | |
| 4760 | 4760 | return ir_lval_wrap(ag, scope, type, lval, result_loc); |
| 4761 | 4761 | } |
| 4762 | 4762 | case BuiltinFnIdBreakpoint: |
| ... | ... | @@ -4774,30 +4774,30 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4774 | 4774 | return ir_lval_wrap(ag, scope, ir_build_handle_src(ag, scope, node), lval, result_loc); |
| 4775 | 4775 | case BuiltinFnIdFrameType: { |
| 4776 | 4776 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4777 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4777 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4778 | 4778 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4779 | 4779 | return arg0_value; |
| 4780 | 4780 | |
| 4781 | IrInstSrc *frame_type = ir_build_frame_type(ag, scope, node, arg0_value); | |
| 4781 | Stage1ZirInst *frame_type = ir_build_frame_type(ag, scope, node, arg0_value); | |
| 4782 | 4782 | return ir_lval_wrap(ag, scope, frame_type, lval, result_loc); |
| 4783 | 4783 | } |
| 4784 | 4784 | case BuiltinFnIdFrameSize: { |
| 4785 | 4785 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4786 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4786 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4787 | 4787 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4788 | 4788 | return arg0_value; |
| 4789 | 4789 | |
| 4790 | IrInstSrc *frame_size = ir_build_frame_size_src(ag, scope, node, arg0_value); | |
| 4790 | Stage1ZirInst *frame_size = ir_build_frame_size_src(ag, scope, node, arg0_value); | |
| 4791 | 4791 | return ir_lval_wrap(ag, scope, frame_size, lval, result_loc); |
| 4792 | 4792 | } |
| 4793 | 4793 | case BuiltinFnIdAlignOf: |
| 4794 | 4794 | { |
| 4795 | 4795 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4796 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4796 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4797 | 4797 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4798 | 4798 | return arg0_value; |
| 4799 | 4799 | |
| 4800 | IrInstSrc *align_of = ir_build_align_of(ag, scope, node, arg0_value); | |
| 4800 | Stage1ZirInst *align_of = ir_build_align_of(ag, scope, node, arg0_value); | |
| 4801 | 4801 | return ir_lval_wrap(ag, scope, align_of, lval, result_loc); |
| 4802 | 4802 | } |
| 4803 | 4803 | case BuiltinFnIdAddWithOverflow: |
| ... | ... | @@ -4813,42 +4813,42 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4813 | 4813 | case BuiltinFnIdTypeName: |
| 4814 | 4814 | { |
| 4815 | 4815 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4816 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4816 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4817 | 4817 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4818 | 4818 | return arg0_value; |
| 4819 | 4819 | |
| 4820 | IrInstSrc *type_name = ir_build_type_name(ag, scope, node, arg0_value); | |
| 4820 | Stage1ZirInst *type_name = ir_build_type_name(ag, scope, node, arg0_value); | |
| 4821 | 4821 | return ir_lval_wrap(ag, scope, type_name, lval, result_loc); |
| 4822 | 4822 | } |
| 4823 | 4823 | case BuiltinFnIdPanic: |
| 4824 | 4824 | { |
| 4825 | 4825 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4826 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4826 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4827 | 4827 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4828 | 4828 | return arg0_value; |
| 4829 | 4829 | |
| 4830 | IrInstSrc *panic = ir_build_panic_src(ag, scope, node, arg0_value); | |
| 4830 | Stage1ZirInst *panic = ir_build_panic_src(ag, scope, node, arg0_value); | |
| 4831 | 4831 | return ir_lval_wrap(ag, scope, panic, lval, result_loc); |
| 4832 | 4832 | } |
| 4833 | 4833 | case BuiltinFnIdPtrCast: |
| 4834 | 4834 | { |
| 4835 | 4835 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4836 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4836 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4837 | 4837 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4838 | 4838 | return arg0_value; |
| 4839 | 4839 | |
| 4840 | 4840 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4841 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4841 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4842 | 4842 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4843 | 4843 | return arg1_value; |
| 4844 | 4844 | |
| 4845 | IrInstSrc *ptr_cast = ir_build_ptr_cast_src(ag, scope, node, arg0_value, arg1_value, true); | |
| 4845 | Stage1ZirInst *ptr_cast = ir_build_ptr_cast_src(ag, scope, node, arg0_value, arg1_value, true); | |
| 4846 | 4846 | return ir_lval_wrap(ag, scope, ptr_cast, lval, result_loc); |
| 4847 | 4847 | } |
| 4848 | 4848 | case BuiltinFnIdBitCast: |
| 4849 | 4849 | { |
| 4850 | 4850 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); |
| 4851 | IrInstSrc *dest_type = astgen_node(ag, dest_type_node, scope); | |
| 4851 | Stage1ZirInst *dest_type = astgen_node(ag, dest_type_node, scope); | |
| 4852 | 4852 | if (dest_type == ag->codegen->invalid_inst_src) |
| 4853 | 4853 | return dest_type; |
| 4854 | 4854 | |
| ... | ... | @@ -4862,130 +4862,130 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4862 | 4862 | ir_build_reset_result(ag, scope, node, &result_loc_bit_cast->base); |
| 4863 | 4863 | |
| 4864 | 4864 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4865 | IrInstSrc *arg1_value = astgen_node_extra(ag, arg1_node, scope, LValNone, | |
| 4865 | Stage1ZirInst *arg1_value = astgen_node_extra(ag, arg1_node, scope, LValNone, | |
| 4866 | 4866 | &result_loc_bit_cast->base); |
| 4867 | 4867 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4868 | 4868 | return arg1_value; |
| 4869 | 4869 | |
| 4870 | IrInstSrc *bitcast = ir_build_bit_cast_src(ag, scope, arg1_node, arg1_value, result_loc_bit_cast); | |
| 4870 | Stage1ZirInst *bitcast = ir_build_bit_cast_src(ag, scope, arg1_node, arg1_value, result_loc_bit_cast); | |
| 4871 | 4871 | return ir_lval_wrap(ag, scope, bitcast, lval, result_loc); |
| 4872 | 4872 | } |
| 4873 | 4873 | case BuiltinFnIdAs: |
| 4874 | 4874 | { |
| 4875 | 4875 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); |
| 4876 | IrInstSrc *dest_type = astgen_node(ag, dest_type_node, scope); | |
| 4876 | Stage1ZirInst *dest_type = astgen_node(ag, dest_type_node, scope); | |
| 4877 | 4877 | if (dest_type == ag->codegen->invalid_inst_src) |
| 4878 | 4878 | return dest_type; |
| 4879 | 4879 | |
| 4880 | 4880 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, dest_type, result_loc); |
| 4881 | 4881 | |
| 4882 | 4882 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4883 | IrInstSrc *arg1_value = astgen_node_extra(ag, arg1_node, scope, LValNone, | |
| 4883 | Stage1ZirInst *arg1_value = astgen_node_extra(ag, arg1_node, scope, LValNone, | |
| 4884 | 4884 | &result_loc_cast->base); |
| 4885 | 4885 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4886 | 4886 | return arg1_value; |
| 4887 | 4887 | |
| 4888 | IrInstSrc *result = ir_build_implicit_cast(ag, scope, node, arg1_value, result_loc_cast); | |
| 4888 | Stage1ZirInst *result = ir_build_implicit_cast(ag, scope, node, arg1_value, result_loc_cast); | |
| 4889 | 4889 | return ir_lval_wrap(ag, scope, result, lval, result_loc); |
| 4890 | 4890 | } |
| 4891 | 4891 | case BuiltinFnIdIntToPtr: |
| 4892 | 4892 | { |
| 4893 | 4893 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4894 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4894 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4895 | 4895 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4896 | 4896 | return arg0_value; |
| 4897 | 4897 | |
| 4898 | 4898 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4899 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4899 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4900 | 4900 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4901 | 4901 | return arg1_value; |
| 4902 | 4902 | |
| 4903 | IrInstSrc *int_to_ptr = ir_build_int_to_ptr_src(ag, scope, node, arg0_value, arg1_value); | |
| 4903 | Stage1ZirInst *int_to_ptr = ir_build_int_to_ptr_src(ag, scope, node, arg0_value, arg1_value); | |
| 4904 | 4904 | return ir_lval_wrap(ag, scope, int_to_ptr, lval, result_loc); |
| 4905 | 4905 | } |
| 4906 | 4906 | case BuiltinFnIdPtrToInt: |
| 4907 | 4907 | { |
| 4908 | 4908 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4909 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4909 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4910 | 4910 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4911 | 4911 | return arg0_value; |
| 4912 | 4912 | |
| 4913 | IrInstSrc *ptr_to_int = ir_build_ptr_to_int_src(ag, scope, node, arg0_value); | |
| 4913 | Stage1ZirInst *ptr_to_int = ir_build_ptr_to_int_src(ag, scope, node, arg0_value); | |
| 4914 | 4914 | return ir_lval_wrap(ag, scope, ptr_to_int, lval, result_loc); |
| 4915 | 4915 | } |
| 4916 | 4916 | case BuiltinFnIdTagName: |
| 4917 | 4917 | { |
| 4918 | 4918 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4919 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4919 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4920 | 4920 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4921 | 4921 | return arg0_value; |
| 4922 | 4922 | |
| 4923 | IrInstSrc *tag_name = ir_build_tag_name_src(ag, scope, node, arg0_value); | |
| 4923 | Stage1ZirInst *tag_name = ir_build_tag_name_src(ag, scope, node, arg0_value); | |
| 4924 | 4924 | return ir_lval_wrap(ag, scope, tag_name, lval, result_loc); |
| 4925 | 4925 | } |
| 4926 | 4926 | case BuiltinFnIdFieldParentPtr: |
| 4927 | 4927 | { |
| 4928 | 4928 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4929 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4929 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4930 | 4930 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4931 | 4931 | return arg0_value; |
| 4932 | 4932 | |
| 4933 | 4933 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4934 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4934 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4935 | 4935 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4936 | 4936 | return arg1_value; |
| 4937 | 4937 | |
| 4938 | 4938 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 4939 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 4939 | Stage1ZirInst *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 4940 | 4940 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 4941 | 4941 | return arg2_value; |
| 4942 | 4942 | |
| 4943 | IrInstSrc *field_parent_ptr = ir_build_field_parent_ptr_src(ag, scope, node, | |
| 4943 | Stage1ZirInst *field_parent_ptr = ir_build_field_parent_ptr_src(ag, scope, node, | |
| 4944 | 4944 | arg0_value, arg1_value, arg2_value); |
| 4945 | 4945 | return ir_lval_wrap(ag, scope, field_parent_ptr, lval, result_loc); |
| 4946 | 4946 | } |
| 4947 | 4947 | case BuiltinFnIdOffsetOf: |
| 4948 | 4948 | { |
| 4949 | 4949 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4950 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4950 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4951 | 4951 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4952 | 4952 | return arg0_value; |
| 4953 | 4953 | |
| 4954 | 4954 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4955 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4955 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4956 | 4956 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4957 | 4957 | return arg1_value; |
| 4958 | 4958 | |
| 4959 | IrInstSrc *offset_of = ir_build_offset_of(ag, scope, node, arg0_value, arg1_value); | |
| 4959 | Stage1ZirInst *offset_of = ir_build_offset_of(ag, scope, node, arg0_value, arg1_value); | |
| 4960 | 4960 | return ir_lval_wrap(ag, scope, offset_of, lval, result_loc); |
| 4961 | 4961 | } |
| 4962 | 4962 | case BuiltinFnIdBitOffsetOf: |
| 4963 | 4963 | { |
| 4964 | 4964 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4965 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4965 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4966 | 4966 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4967 | 4967 | return arg0_value; |
| 4968 | 4968 | |
| 4969 | 4969 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4970 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4970 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 4971 | 4971 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4972 | 4972 | return arg1_value; |
| 4973 | 4973 | |
| 4974 | IrInstSrc *offset_of = ir_build_bit_offset_of(ag, scope, node, arg0_value, arg1_value); | |
| 4974 | Stage1ZirInst *offset_of = ir_build_bit_offset_of(ag, scope, node, arg0_value, arg1_value); | |
| 4975 | 4975 | return ir_lval_wrap(ag, scope, offset_of, lval, result_loc); |
| 4976 | 4976 | } |
| 4977 | 4977 | case BuiltinFnIdCall: { |
| 4978 | 4978 | // Cast the options parameter to the options type |
| 4979 | 4979 | ZigType *options_type = get_builtin_type(ag->codegen, "CallOptions"); |
| 4980 | IrInstSrc *options_type_inst = ir_build_const_type(ag, scope, node, options_type); | |
| 4980 | Stage1ZirInst *options_type_inst = ir_build_const_type(ag, scope, node, options_type); | |
| 4981 | 4981 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, options_type_inst, no_result_loc()); |
| 4982 | 4982 | |
| 4983 | 4983 | AstNode *options_node = node->data.fn_call_expr.params.at(0); |
| 4984 | IrInstSrc *options_inner = astgen_node_extra(ag, options_node, scope, | |
| 4984 | Stage1ZirInst *options_inner = astgen_node_extra(ag, options_node, scope, | |
| 4985 | 4985 | LValNone, &result_loc_cast->base); |
| 4986 | 4986 | if (options_inner == ag->codegen->invalid_inst_src) |
| 4987 | 4987 | return options_inner; |
| 4988 | IrInstSrc *options = ir_build_implicit_cast(ag, scope, options_node, options_inner, result_loc_cast); | |
| 4988 | Stage1ZirInst *options = ir_build_implicit_cast(ag, scope, options_node, options_inner, result_loc_cast); | |
| 4989 | 4989 | |
| 4990 | 4990 | AstNode *fn_ref_node = node->data.fn_call_expr.params.at(1); |
| 4991 | 4991 | AstNode *args_node = node->data.fn_call_expr.params.at(2); |
| ... | ... | @@ -5004,15 +5004,15 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5004 | 5004 | return ag->codegen->invalid_inst_src; |
| 5005 | 5005 | } |
| 5006 | 5006 | } else { |
| 5007 | IrInstSrc *fn_ref = astgen_node(ag, fn_ref_node, scope); | |
| 5007 | Stage1ZirInst *fn_ref = astgen_node(ag, fn_ref_node, scope); | |
| 5008 | 5008 | if (fn_ref == ag->codegen->invalid_inst_src) |
| 5009 | 5009 | return fn_ref; |
| 5010 | 5010 | |
| 5011 | IrInstSrc *args = astgen_node(ag, args_node, scope); | |
| 5011 | Stage1ZirInst *args = astgen_node(ag, args_node, scope); | |
| 5012 | 5012 | if (args == ag->codegen->invalid_inst_src) |
| 5013 | 5013 | return args; |
| 5014 | 5014 | |
| 5015 | IrInstSrc *call = ir_build_call_extra(ag, scope, node, options, fn_ref, args, result_loc); | |
| 5015 | Stage1ZirInst *call = ir_build_call_extra(ag, scope, node, options, fn_ref, args, result_loc); | |
| 5016 | 5016 | return ir_lval_wrap(ag, scope, call, lval, result_loc); |
| 5017 | 5017 | } |
| 5018 | 5018 | } |
| ... | ... | @@ -5021,227 +5021,227 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5021 | 5021 | case BuiltinFnIdShlExact: |
| 5022 | 5022 | { |
| 5023 | 5023 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5024 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5024 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5025 | 5025 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5026 | 5026 | return arg0_value; |
| 5027 | 5027 | |
| 5028 | 5028 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5029 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5029 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5030 | 5030 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5031 | 5031 | return arg1_value; |
| 5032 | 5032 | |
| 5033 | IrInstSrc *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpBitShiftLeftExact, arg0_value, arg1_value, true); | |
| 5033 | Stage1ZirInst *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpBitShiftLeftExact, arg0_value, arg1_value, true); | |
| 5034 | 5034 | return ir_lval_wrap(ag, scope, bin_op, lval, result_loc); |
| 5035 | 5035 | } |
| 5036 | 5036 | case BuiltinFnIdShrExact: |
| 5037 | 5037 | { |
| 5038 | 5038 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5039 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5039 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5040 | 5040 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5041 | 5041 | return arg0_value; |
| 5042 | 5042 | |
| 5043 | 5043 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5044 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5044 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5045 | 5045 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5046 | 5046 | return arg1_value; |
| 5047 | 5047 | |
| 5048 | IrInstSrc *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpBitShiftRightExact, arg0_value, arg1_value, true); | |
| 5048 | Stage1ZirInst *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpBitShiftRightExact, arg0_value, arg1_value, true); | |
| 5049 | 5049 | return ir_lval_wrap(ag, scope, bin_op, lval, result_loc); |
| 5050 | 5050 | } |
| 5051 | 5051 | case BuiltinFnIdSetEvalBranchQuota: |
| 5052 | 5052 | { |
| 5053 | 5053 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5054 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5054 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5055 | 5055 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5056 | 5056 | return arg0_value; |
| 5057 | 5057 | |
| 5058 | IrInstSrc *set_eval_branch_quota = ir_build_set_eval_branch_quota(ag, scope, node, arg0_value); | |
| 5058 | Stage1ZirInst *set_eval_branch_quota = ir_build_set_eval_branch_quota(ag, scope, node, arg0_value); | |
| 5059 | 5059 | return ir_lval_wrap(ag, scope, set_eval_branch_quota, lval, result_loc); |
| 5060 | 5060 | } |
| 5061 | 5061 | case BuiltinFnIdAlignCast: |
| 5062 | 5062 | { |
| 5063 | 5063 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5064 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5064 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5065 | 5065 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5066 | 5066 | return arg0_value; |
| 5067 | 5067 | |
| 5068 | 5068 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5069 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5069 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5070 | 5070 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5071 | 5071 | return arg1_value; |
| 5072 | 5072 | |
| 5073 | IrInstSrc *align_cast = ir_build_align_cast_src(ag, scope, node, arg0_value, arg1_value); | |
| 5073 | Stage1ZirInst *align_cast = ir_build_align_cast_src(ag, scope, node, arg0_value, arg1_value); | |
| 5074 | 5074 | return ir_lval_wrap(ag, scope, align_cast, lval, result_loc); |
| 5075 | 5075 | } |
| 5076 | 5076 | case BuiltinFnIdThis: |
| 5077 | 5077 | { |
| 5078 | IrInstSrc *this_inst = astgen_this(ag, scope, node); | |
| 5078 | Stage1ZirInst *this_inst = astgen_this(ag, scope, node); | |
| 5079 | 5079 | return ir_lval_wrap(ag, scope, this_inst, lval, result_loc); |
| 5080 | 5080 | } |
| 5081 | 5081 | case BuiltinFnIdSetAlignStack: |
| 5082 | 5082 | { |
| 5083 | 5083 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5084 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5084 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5085 | 5085 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5086 | 5086 | return arg0_value; |
| 5087 | 5087 | |
| 5088 | IrInstSrc *set_align_stack = ir_build_set_align_stack(ag, scope, node, arg0_value); | |
| 5088 | Stage1ZirInst *set_align_stack = ir_build_set_align_stack(ag, scope, node, arg0_value); | |
| 5089 | 5089 | return ir_lval_wrap(ag, scope, set_align_stack, lval, result_loc); |
| 5090 | 5090 | } |
| 5091 | 5091 | case BuiltinFnIdExport: |
| 5092 | 5092 | { |
| 5093 | 5093 | // Cast the options parameter to the options type |
| 5094 | 5094 | ZigType *options_type = get_builtin_type(ag->codegen, "ExportOptions"); |
| 5095 | IrInstSrc *options_type_inst = ir_build_const_type(ag, scope, node, options_type); | |
| 5095 | Stage1ZirInst *options_type_inst = ir_build_const_type(ag, scope, node, options_type); | |
| 5096 | 5096 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, options_type_inst, no_result_loc()); |
| 5097 | 5097 | |
| 5098 | 5098 | AstNode *target_node = node->data.fn_call_expr.params.at(0); |
| 5099 | IrInstSrc *target_value = astgen_node(ag, target_node, scope); | |
| 5099 | Stage1ZirInst *target_value = astgen_node(ag, target_node, scope); | |
| 5100 | 5100 | if (target_value == ag->codegen->invalid_inst_src) |
| 5101 | 5101 | return target_value; |
| 5102 | 5102 | |
| 5103 | 5103 | AstNode *options_node = node->data.fn_call_expr.params.at(1); |
| 5104 | IrInstSrc *options_value = astgen_node_extra(ag, options_node, | |
| 5104 | Stage1ZirInst *options_value = astgen_node_extra(ag, options_node, | |
| 5105 | 5105 | scope, LValNone, &result_loc_cast->base); |
| 5106 | 5106 | if (options_value == ag->codegen->invalid_inst_src) |
| 5107 | 5107 | return options_value; |
| 5108 | 5108 | |
| 5109 | IrInstSrc *casted_options_value = ir_build_implicit_cast( | |
| 5109 | Stage1ZirInst *casted_options_value = ir_build_implicit_cast( | |
| 5110 | 5110 | ag, scope, options_node, options_value, result_loc_cast); |
| 5111 | 5111 | |
| 5112 | IrInstSrc *ir_export = ir_build_export(ag, scope, node, target_value, casted_options_value); | |
| 5112 | Stage1ZirInst *ir_export = ir_build_export(ag, scope, node, target_value, casted_options_value); | |
| 5113 | 5113 | return ir_lval_wrap(ag, scope, ir_export, lval, result_loc); |
| 5114 | 5114 | } |
| 5115 | 5115 | case BuiltinFnIdExtern: |
| 5116 | 5116 | { |
| 5117 | 5117 | // Cast the options parameter to the options type |
| 5118 | 5118 | ZigType *options_type = get_builtin_type(ag->codegen, "ExternOptions"); |
| 5119 | IrInstSrc *options_type_inst = ir_build_const_type(ag, scope, node, options_type); | |
| 5119 | Stage1ZirInst *options_type_inst = ir_build_const_type(ag, scope, node, options_type); | |
| 5120 | 5120 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, options_type_inst, no_result_loc()); |
| 5121 | 5121 | |
| 5122 | 5122 | AstNode *type_node = node->data.fn_call_expr.params.at(0); |
| 5123 | IrInstSrc *type_value = astgen_node(ag, type_node, scope); | |
| 5123 | Stage1ZirInst *type_value = astgen_node(ag, type_node, scope); | |
| 5124 | 5124 | if (type_value == ag->codegen->invalid_inst_src) |
| 5125 | 5125 | return type_value; |
| 5126 | 5126 | |
| 5127 | 5127 | AstNode *options_node = node->data.fn_call_expr.params.at(1); |
| 5128 | IrInstSrc *options_value = astgen_node_extra(ag, options_node, | |
| 5128 | Stage1ZirInst *options_value = astgen_node_extra(ag, options_node, | |
| 5129 | 5129 | scope, LValNone, &result_loc_cast->base); |
| 5130 | 5130 | if (options_value == ag->codegen->invalid_inst_src) |
| 5131 | 5131 | return options_value; |
| 5132 | 5132 | |
| 5133 | IrInstSrc *casted_options_value = ir_build_implicit_cast( | |
| 5133 | Stage1ZirInst *casted_options_value = ir_build_implicit_cast( | |
| 5134 | 5134 | ag, scope, options_node, options_value, result_loc_cast); |
| 5135 | 5135 | |
| 5136 | IrInstSrc *ir_extern = ir_build_extern(ag, scope, node, type_value, casted_options_value); | |
| 5136 | Stage1ZirInst *ir_extern = ir_build_extern(ag, scope, node, type_value, casted_options_value); | |
| 5137 | 5137 | return ir_lval_wrap(ag, scope, ir_extern, lval, result_loc); |
| 5138 | 5138 | } |
| 5139 | 5139 | case BuiltinFnIdErrorReturnTrace: |
| 5140 | 5140 | { |
| 5141 | IrInstSrc *error_return_trace = ir_build_error_return_trace_src(ag, scope, node, | |
| 5141 | Stage1ZirInst *error_return_trace = ir_build_error_return_trace_src(ag, scope, node, | |
| 5142 | 5142 | IrInstErrorReturnTraceNull); |
| 5143 | 5143 | return ir_lval_wrap(ag, scope, error_return_trace, lval, result_loc); |
| 5144 | 5144 | } |
| 5145 | 5145 | case BuiltinFnIdAtomicRmw: |
| 5146 | 5146 | { |
| 5147 | 5147 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5148 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5148 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5149 | 5149 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5150 | 5150 | return arg0_value; |
| 5151 | 5151 | |
| 5152 | 5152 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5153 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5153 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5154 | 5154 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5155 | 5155 | return arg1_value; |
| 5156 | 5156 | |
| 5157 | 5157 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5158 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 5158 | Stage1ZirInst *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 5159 | 5159 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 5160 | 5160 | return arg2_value; |
| 5161 | 5161 | |
| 5162 | 5162 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 5163 | IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope); | |
| 5163 | Stage1ZirInst *arg3_value = astgen_node(ag, arg3_node, scope); | |
| 5164 | 5164 | if (arg3_value == ag->codegen->invalid_inst_src) |
| 5165 | 5165 | return arg3_value; |
| 5166 | 5166 | |
| 5167 | 5167 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); |
| 5168 | IrInstSrc *arg4_value = astgen_node(ag, arg4_node, scope); | |
| 5168 | Stage1ZirInst *arg4_value = astgen_node(ag, arg4_node, scope); | |
| 5169 | 5169 | if (arg4_value == ag->codegen->invalid_inst_src) |
| 5170 | 5170 | return arg4_value; |
| 5171 | 5171 | |
| 5172 | IrInstSrc *inst = ir_build_atomic_rmw_src(ag, scope, node, | |
| 5172 | Stage1ZirInst *inst = ir_build_atomic_rmw_src(ag, scope, node, | |
| 5173 | 5173 | arg0_value, arg1_value, arg2_value, arg3_value, arg4_value); |
| 5174 | 5174 | return ir_lval_wrap(ag, scope, inst, lval, result_loc); |
| 5175 | 5175 | } |
| 5176 | 5176 | case BuiltinFnIdAtomicLoad: |
| 5177 | 5177 | { |
| 5178 | 5178 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5179 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5179 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5180 | 5180 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5181 | 5181 | return arg0_value; |
| 5182 | 5182 | |
| 5183 | 5183 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5184 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5184 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5185 | 5185 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5186 | 5186 | return arg1_value; |
| 5187 | 5187 | |
| 5188 | 5188 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5189 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 5189 | Stage1ZirInst *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 5190 | 5190 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 5191 | 5191 | return arg2_value; |
| 5192 | 5192 | |
| 5193 | IrInstSrc *inst = ir_build_atomic_load_src(ag, scope, node, arg0_value, arg1_value, arg2_value); | |
| 5193 | Stage1ZirInst *inst = ir_build_atomic_load_src(ag, scope, node, arg0_value, arg1_value, arg2_value); | |
| 5194 | 5194 | return ir_lval_wrap(ag, scope, inst, lval, result_loc); |
| 5195 | 5195 | } |
| 5196 | 5196 | case BuiltinFnIdAtomicStore: |
| 5197 | 5197 | { |
| 5198 | 5198 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5199 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5199 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5200 | 5200 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5201 | 5201 | return arg0_value; |
| 5202 | 5202 | |
| 5203 | 5203 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5204 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5204 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5205 | 5205 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5206 | 5206 | return arg1_value; |
| 5207 | 5207 | |
| 5208 | 5208 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5209 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 5209 | Stage1ZirInst *arg2_value = astgen_node(ag, arg2_node, scope); | |
| 5210 | 5210 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 5211 | 5211 | return arg2_value; |
| 5212 | 5212 | |
| 5213 | 5213 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 5214 | IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope); | |
| 5214 | Stage1ZirInst *arg3_value = astgen_node(ag, arg3_node, scope); | |
| 5215 | 5215 | if (arg3_value == ag->codegen->invalid_inst_src) |
| 5216 | 5216 | return arg3_value; |
| 5217 | 5217 | |
| 5218 | IrInstSrc *inst = ir_build_atomic_store_src(ag, scope, node, arg0_value, arg1_value, | |
| 5218 | Stage1ZirInst *inst = ir_build_atomic_store_src(ag, scope, node, arg0_value, arg1_value, | |
| 5219 | 5219 | arg2_value, arg3_value); |
| 5220 | 5220 | return ir_lval_wrap(ag, scope, inst, lval, result_loc); |
| 5221 | 5221 | } |
| 5222 | 5222 | case BuiltinFnIdIntToEnum: |
| 5223 | 5223 | { |
| 5224 | 5224 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5225 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5225 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5226 | 5226 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5227 | 5227 | return arg0_value; |
| 5228 | 5228 | |
| 5229 | 5229 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5230 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5230 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5231 | 5231 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5232 | 5232 | return arg1_value; |
| 5233 | 5233 | |
| 5234 | IrInstSrc *result = ir_build_int_to_enum_src(ag, scope, node, arg0_value, arg1_value); | |
| 5234 | Stage1ZirInst *result = ir_build_int_to_enum_src(ag, scope, node, arg0_value, arg1_value); | |
| 5235 | 5235 | return ir_lval_wrap(ag, scope, result, lval, result_loc); |
| 5236 | 5236 | } |
| 5237 | 5237 | case BuiltinFnIdEnumToInt: |
| 5238 | 5238 | { |
| 5239 | 5239 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5240 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5240 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5241 | 5241 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5242 | 5242 | return arg0_value; |
| 5243 | 5243 | |
| 5244 | IrInstSrc *result = ir_build_enum_to_int(ag, scope, node, arg0_value); | |
| 5244 | Stage1ZirInst *result = ir_build_enum_to_int(ag, scope, node, arg0_value); | |
| 5245 | 5245 | return ir_lval_wrap(ag, scope, result, lval, result_loc); |
| 5246 | 5246 | } |
| 5247 | 5247 | case BuiltinFnIdCtz: |
| ... | ... | @@ -5251,16 +5251,16 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5251 | 5251 | case BuiltinFnIdBitReverse: |
| 5252 | 5252 | { |
| 5253 | 5253 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5254 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5254 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5255 | 5255 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5256 | 5256 | return arg0_value; |
| 5257 | 5257 | |
| 5258 | 5258 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5259 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5259 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5260 | 5260 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5261 | 5261 | return arg1_value; |
| 5262 | 5262 | |
| 5263 | IrInstSrc *result; | |
| 5263 | Stage1ZirInst *result; | |
| 5264 | 5264 | switch (builtin_fn->id) { |
| 5265 | 5265 | case BuiltinFnIdCtz: |
| 5266 | 5266 | result = ir_build_ctz(ag, scope, node, arg0_value, arg1_value); |
| ... | ... | @@ -5285,27 +5285,27 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5285 | 5285 | case BuiltinFnIdHasDecl: |
| 5286 | 5286 | { |
| 5287 | 5287 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5288 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5288 | Stage1ZirInst *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 5289 | 5289 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5290 | 5290 | return arg0_value; |
| 5291 | 5291 | |
| 5292 | 5292 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5293 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5293 | Stage1ZirInst *arg1_value = astgen_node(ag, arg1_node, scope); | |
| 5294 | 5294 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5295 | 5295 | return arg1_value; |
| 5296 | 5296 | |
| 5297 | IrInstSrc *has_decl = ir_build_has_decl(ag, scope, node, arg0_value, arg1_value); | |
| 5297 | Stage1ZirInst *has_decl = ir_build_has_decl(ag, scope, node, arg0_value, arg1_value); | |
| 5298 | 5298 | return ir_lval_wrap(ag, scope, has_decl, lval, result_loc); |
| 5299 | 5299 | } |
| 5300 | 5300 | case BuiltinFnIdUnionInit: |
| 5301 | 5301 | { |
| 5302 | 5302 | AstNode *union_type_node = node->data.fn_call_expr.params.at(0); |
| 5303 | IrInstSrc *union_type_inst = astgen_node(ag, union_type_node, scope); | |
| 5303 | Stage1ZirInst *union_type_inst = astgen_node(ag, union_type_node, scope); | |
| 5304 | 5304 | if (union_type_inst == ag->codegen->invalid_inst_src) |
| 5305 | 5305 | return union_type_inst; |
| 5306 | 5306 | |
| 5307 | 5307 | AstNode *name_node = node->data.fn_call_expr.params.at(1); |
| 5308 | IrInstSrc *name_inst = astgen_node(ag, name_node, scope); | |
| 5308 | Stage1ZirInst *name_inst = astgen_node(ag, name_node, scope); | |
| 5309 | 5309 | if (name_inst == ag->codegen->invalid_inst_src) |
| 5310 | 5310 | return name_inst; |
| 5311 | 5311 | |
| ... | ... | @@ -5316,7 +5316,7 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5316 | 5316 | } |
| 5317 | 5317 | case BuiltinFnIdSrc: |
| 5318 | 5318 | { |
| 5319 | IrInstSrc *src_inst = ir_build_src(ag, scope, node); | |
| 5319 | Stage1ZirInst *src_inst = ir_build_src(ag, scope, node); | |
| 5320 | 5320 | return ir_lval_wrap(ag, scope, src_inst, lval, result_loc); |
| 5321 | 5321 | } |
| 5322 | 5322 | } |
| ... | ... | @@ -5335,7 +5335,7 @@ static ScopeNoSuspend *get_scope_nosuspend(Scope *scope) { |
| 5335 | 5335 | return nullptr; |
| 5336 | 5336 | } |
| 5337 | 5337 | |
| 5338 | static IrInstSrc *astgen_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 5338 | static Stage1ZirInst *astgen_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 5339 | 5339 | ResultLoc *result_loc) |
| 5340 | 5340 | { |
| 5341 | 5341 | assert(node->type == NodeTypeFnCallExpr); |
| ... | ... | @@ -5354,16 +5354,16 @@ static IrInstSrc *astgen_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, |
| 5354 | 5354 | nullptr, node->data.fn_call_expr.params.items, node->data.fn_call_expr.params.length, lval, result_loc); |
| 5355 | 5355 | } |
| 5356 | 5356 | |
| 5357 | static IrInstSrc *astgen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 5357 | static Stage1ZirInst *astgen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 5358 | 5358 | ResultLoc *result_loc) |
| 5359 | 5359 | { |
| 5360 | 5360 | assert(node->type == NodeTypeIfBoolExpr); |
| 5361 | 5361 | |
| 5362 | IrInstSrc *condition = astgen_node(ag, node->data.if_bool_expr.condition, scope); | |
| 5362 | Stage1ZirInst *condition = astgen_node(ag, node->data.if_bool_expr.condition, scope); | |
| 5363 | 5363 | if (condition == ag->codegen->invalid_inst_src) |
| 5364 | 5364 | return ag->codegen->invalid_inst_src; |
| 5365 | 5365 | |
| 5366 | IrInstSrc *is_comptime; | |
| 5366 | Stage1ZirInst *is_comptime; | |
| 5367 | 5367 | if (ir_should_inline(ag->exec, scope)) { |
| 5368 | 5368 | is_comptime = ir_build_const_bool(ag, scope, node, true); |
| 5369 | 5369 | } else { |
| ... | ... | @@ -5377,7 +5377,7 @@ static IrInstSrc *astgen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5377 | 5377 | Stage1ZirBasicBlock *else_block = ir_create_basic_block(ag, scope, "Else"); |
| 5378 | 5378 | Stage1ZirBasicBlock *endif_block = ir_create_basic_block(ag, scope, "EndIf"); |
| 5379 | 5379 | |
| 5380 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, scope, node, condition, | |
| 5380 | Stage1ZirInst *cond_br_inst = ir_build_cond_br(ag, scope, node, condition, | |
| 5381 | 5381 | then_block, else_block, is_comptime); |
| 5382 | 5382 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(ag, cond_br_inst, else_block, endif_block, |
| 5383 | 5383 | result_loc, is_comptime); |
| ... | ... | @@ -5385,7 +5385,7 @@ static IrInstSrc *astgen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5385 | 5385 | ir_set_cursor_at_end_and_append_block(ag, then_block); |
| 5386 | 5386 | |
| 5387 | 5387 | Scope *subexpr_scope = create_runtime_scope(ag->codegen, node, scope, is_comptime); |
| 5388 | IrInstSrc *then_expr_result = astgen_node_extra(ag, then_node, subexpr_scope, lval, | |
| 5388 | Stage1ZirInst *then_expr_result = astgen_node_extra(ag, then_node, subexpr_scope, lval, | |
| 5389 | 5389 | &peer_parent->peers.at(0)->base); |
| 5390 | 5390 | if (then_expr_result == ag->codegen->invalid_inst_src) |
| 5391 | 5391 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -5394,7 +5394,7 @@ static IrInstSrc *astgen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5394 | 5394 | ir_build_br(ag, scope, node, endif_block, is_comptime); |
| 5395 | 5395 | |
| 5396 | 5396 | ir_set_cursor_at_end_and_append_block(ag, else_block); |
| 5397 | IrInstSrc *else_expr_result; | |
| 5397 | Stage1ZirInst *else_expr_result; | |
| 5398 | 5398 | if (else_node) { |
| 5399 | 5399 | else_expr_result = astgen_node_extra(ag, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); |
| 5400 | 5400 | if (else_expr_result == ag->codegen->invalid_inst_src) |
| ... | ... | @@ -5408,39 +5408,39 @@ static IrInstSrc *astgen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5408 | 5408 | ir_build_br(ag, scope, node, endif_block, is_comptime); |
| 5409 | 5409 | |
| 5410 | 5410 | ir_set_cursor_at_end_and_append_block(ag, endif_block); |
| 5411 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | |
| 5411 | Stage1ZirInst **incoming_values = heap::c_allocator.allocate<Stage1ZirInst *>(2); | |
| 5412 | 5412 | incoming_values[0] = then_expr_result; |
| 5413 | 5413 | incoming_values[1] = else_expr_result; |
| 5414 | 5414 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 5415 | 5415 | incoming_blocks[0] = after_then_block; |
| 5416 | 5416 | incoming_blocks[1] = after_else_block; |
| 5417 | 5417 | |
| 5418 | IrInstSrc *phi = ir_build_phi(ag, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | |
| 5418 | Stage1ZirInst *phi = ir_build_phi(ag, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | |
| 5419 | 5419 | return ir_expr_wrap(ag, scope, phi, result_loc); |
| 5420 | 5420 | } |
| 5421 | 5421 | |
| 5422 | static IrInstSrc *astgen_prefix_op_id_lval(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) { | |
| 5422 | static Stage1ZirInst *astgen_prefix_op_id_lval(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) { | |
| 5423 | 5423 | assert(node->type == NodeTypePrefixOpExpr); |
| 5424 | 5424 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; |
| 5425 | 5425 | |
| 5426 | IrInstSrc *value = astgen_node_extra(ag, expr_node, scope, lval, nullptr); | |
| 5426 | Stage1ZirInst *value = astgen_node_extra(ag, expr_node, scope, lval, nullptr); | |
| 5427 | 5427 | if (value == ag->codegen->invalid_inst_src) |
| 5428 | 5428 | return value; |
| 5429 | 5429 | |
| 5430 | 5430 | return ir_build_un_op(ag, scope, node, op_id, value); |
| 5431 | 5431 | } |
| 5432 | 5432 | |
| 5433 | static IrInstSrc *astgen_prefix_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id) { | |
| 5433 | static Stage1ZirInst *astgen_prefix_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id) { | |
| 5434 | 5434 | return astgen_prefix_op_id_lval(ag, scope, node, op_id, LValNone); |
| 5435 | 5435 | } |
| 5436 | 5436 | |
| 5437 | static IrInstSrc *ir_expr_wrap(Stage1AstGen *ag, Scope *scope, IrInstSrc *inst, ResultLoc *result_loc) { | |
| 5437 | static Stage1ZirInst *ir_expr_wrap(Stage1AstGen *ag, Scope *scope, Stage1ZirInst *inst, ResultLoc *result_loc) { | |
| 5438 | 5438 | if (inst == ag->codegen->invalid_inst_src) return inst; |
| 5439 | 5439 | ir_build_end_expr(ag, scope, inst->source_node, inst, result_loc); |
| 5440 | 5440 | return inst; |
| 5441 | 5441 | } |
| 5442 | 5442 | |
| 5443 | static IrInstSrc *ir_lval_wrap(Stage1AstGen *ag, Scope *scope, IrInstSrc *value, LVal lval, | |
| 5443 | static Stage1ZirInst *ir_lval_wrap(Stage1AstGen *ag, Scope *scope, Stage1ZirInst *value, LVal lval, | |
| 5444 | 5444 | ResultLoc *result_loc) |
| 5445 | 5445 | { |
| 5446 | 5446 | // This logic must be kept in sync with |
| ... | ... | @@ -5448,7 +5448,7 @@ static IrInstSrc *ir_lval_wrap(Stage1AstGen *ag, Scope *scope, IrInstSrc *value, |
| 5448 | 5448 | if (value == ag->codegen->invalid_inst_src || |
| 5449 | 5449 | instr_is_unreachable(value) || |
| 5450 | 5450 | value->source_node->type == NodeTypeDefer || |
| 5451 | value->id == IrInstSrcIdDeclVar) | |
| 5451 | value->id == Stage1ZirInstIdDeclVar) | |
| 5452 | 5452 | { |
| 5453 | 5453 | return value; |
| 5454 | 5454 | } |
| ... | ... | @@ -5500,7 +5500,7 @@ static Error token_number_literal_u32(Stage1AstGen *ag, AstNode *source_node, |
| 5500 | 5500 | |
| 5501 | 5501 | } |
| 5502 | 5502 | |
| 5503 | static IrInstSrc *astgen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 5503 | static Stage1ZirInst *astgen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 5504 | 5504 | Error err; |
| 5505 | 5505 | assert(node->type == NodeTypePointerType); |
| 5506 | 5506 | |
| ... | ... | @@ -5515,7 +5515,7 @@ static IrInstSrc *astgen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5515 | 5515 | AstNode *expr_node = node->data.pointer_type.op_expr; |
| 5516 | 5516 | AstNode *align_expr = node->data.pointer_type.align_expr; |
| 5517 | 5517 | |
| 5518 | IrInstSrc *sentinel; | |
| 5518 | Stage1ZirInst *sentinel; | |
| 5519 | 5519 | if (sentinel_expr != nullptr) { |
| 5520 | 5520 | sentinel = astgen_node(ag, sentinel_expr, scope); |
| 5521 | 5521 | if (sentinel == ag->codegen->invalid_inst_src) |
| ... | ... | @@ -5524,7 +5524,7 @@ static IrInstSrc *astgen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5524 | 5524 | sentinel = nullptr; |
| 5525 | 5525 | } |
| 5526 | 5526 | |
| 5527 | IrInstSrc *align_value; | |
| 5527 | Stage1ZirInst *align_value; | |
| 5528 | 5528 | if (align_expr != nullptr) { |
| 5529 | 5529 | align_value = astgen_node(ag, align_expr, scope); |
| 5530 | 5530 | if (align_value == ag->codegen->invalid_inst_src) |
| ... | ... | @@ -5533,7 +5533,7 @@ static IrInstSrc *astgen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5533 | 5533 | align_value = nullptr; |
| 5534 | 5534 | } |
| 5535 | 5535 | |
| 5536 | IrInstSrc *child_type = astgen_node(ag, expr_node, scope); | |
| 5536 | Stage1ZirInst *child_type = astgen_node(ag, expr_node, scope); | |
| 5537 | 5537 | if (child_type == ag->codegen->invalid_inst_src) |
| 5538 | 5538 | return child_type; |
| 5539 | 5539 | |
| ... | ... | @@ -5565,36 +5565,36 @@ static IrInstSrc *astgen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5565 | 5565 | ptr_len, sentinel, align_value, bit_offset_start, host_int_bytes, is_allow_zero); |
| 5566 | 5566 | } |
| 5567 | 5567 | |
| 5568 | static IrInstSrc *astgen_catch_unreachable(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 5568 | static Stage1ZirInst *astgen_catch_unreachable(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 5569 | 5569 | AstNode *expr_node, LVal lval, ResultLoc *result_loc) |
| 5570 | 5570 | { |
| 5571 | IrInstSrc *err_union_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); | |
| 5571 | Stage1ZirInst *err_union_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); | |
| 5572 | 5572 | if (err_union_ptr == ag->codegen->invalid_inst_src) |
| 5573 | 5573 | return ag->codegen->invalid_inst_src; |
| 5574 | 5574 | |
| 5575 | IrInstSrc *payload_ptr = ir_build_unwrap_err_payload_src(ag, scope, source_node, err_union_ptr, true, false); | |
| 5575 | Stage1ZirInst *payload_ptr = ir_build_unwrap_err_payload_src(ag, scope, source_node, err_union_ptr, true, false); | |
| 5576 | 5576 | if (payload_ptr == ag->codegen->invalid_inst_src) |
| 5577 | 5577 | return ag->codegen->invalid_inst_src; |
| 5578 | 5578 | |
| 5579 | 5579 | if (lval == LValPtr) |
| 5580 | 5580 | return payload_ptr; |
| 5581 | 5581 | |
| 5582 | IrInstSrc *load_ptr = ir_build_load_ptr(ag, scope, source_node, payload_ptr); | |
| 5582 | Stage1ZirInst *load_ptr = ir_build_load_ptr(ag, scope, source_node, payload_ptr); | |
| 5583 | 5583 | return ir_expr_wrap(ag, scope, load_ptr, result_loc); |
| 5584 | 5584 | } |
| 5585 | 5585 | |
| 5586 | static IrInstSrc *astgen_bool_not(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 5586 | static Stage1ZirInst *astgen_bool_not(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 5587 | 5587 | assert(node->type == NodeTypePrefixOpExpr); |
| 5588 | 5588 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; |
| 5589 | 5589 | |
| 5590 | IrInstSrc *value = astgen_node(ag, expr_node, scope); | |
| 5590 | Stage1ZirInst *value = astgen_node(ag, expr_node, scope); | |
| 5591 | 5591 | if (value == ag->codegen->invalid_inst_src) |
| 5592 | 5592 | return ag->codegen->invalid_inst_src; |
| 5593 | 5593 | |
| 5594 | 5594 | return ir_build_bool_not(ag, scope, node, value); |
| 5595 | 5595 | } |
| 5596 | 5596 | |
| 5597 | static IrInstSrc *astgen_prefix_op_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 5597 | static Stage1ZirInst *astgen_prefix_op_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 5598 | 5598 | ResultLoc *result_loc) |
| 5599 | 5599 | { |
| 5600 | 5600 | assert(node->type == NodeTypePrefixOpExpr); |
| ... | ... | @@ -5622,12 +5622,12 @@ static IrInstSrc *astgen_prefix_op_expr(Stage1AstGen *ag, Scope *scope, AstNode |
| 5622 | 5622 | zig_unreachable(); |
| 5623 | 5623 | } |
| 5624 | 5624 | |
| 5625 | static IrInstSrc *astgen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 5626 | IrInstSrc *union_type, IrInstSrc *field_name, AstNode *expr_node, | |
| 5625 | static Stage1ZirInst *astgen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | |
| 5626 | Stage1ZirInst *union_type, Stage1ZirInst *field_name, AstNode *expr_node, | |
| 5627 | 5627 | LVal lval, ResultLoc *parent_result_loc) |
| 5628 | 5628 | { |
| 5629 | IrInstSrc *container_ptr = ir_build_resolve_result(ag, scope, source_node, parent_result_loc, union_type); | |
| 5630 | IrInstSrc *field_ptr = ir_build_field_ptr_instruction(ag, scope, source_node, container_ptr, | |
| 5629 | Stage1ZirInst *container_ptr = ir_build_resolve_result(ag, scope, source_node, parent_result_loc, union_type); | |
| 5630 | Stage1ZirInst *field_ptr = ir_build_field_ptr_instruction(ag, scope, source_node, container_ptr, | |
| 5631 | 5631 | field_name, true); |
| 5632 | 5632 | |
| 5633 | 5633 | ResultLocInstruction *result_loc_inst = heap::c_allocator.create<ResultLocInstruction>(); |
| ... | ... | @@ -5636,18 +5636,18 @@ static IrInstSrc *astgen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode |
| 5636 | 5636 | ir_ref_instruction(field_ptr, ag->current_basic_block); |
| 5637 | 5637 | ir_build_reset_result(ag, scope, expr_node, &result_loc_inst->base); |
| 5638 | 5638 | |
| 5639 | IrInstSrc *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone, | |
| 5639 | Stage1ZirInst *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone, | |
| 5640 | 5640 | &result_loc_inst->base); |
| 5641 | 5641 | if (expr_value == ag->codegen->invalid_inst_src) |
| 5642 | 5642 | return expr_value; |
| 5643 | 5643 | |
| 5644 | IrInstSrc *init_union = ir_build_union_init_named_field(ag, scope, source_node, union_type, | |
| 5644 | Stage1ZirInst *init_union = ir_build_union_init_named_field(ag, scope, source_node, union_type, | |
| 5645 | 5645 | field_name, field_ptr, container_ptr); |
| 5646 | 5646 | |
| 5647 | 5647 | return ir_lval_wrap(ag, scope, init_union, lval, parent_result_loc); |
| 5648 | 5648 | } |
| 5649 | 5649 | |
| 5650 | static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 5650 | static Stage1ZirInst *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 5651 | 5651 | ResultLoc *parent_result_loc) |
| 5652 | 5652 | { |
| 5653 | 5653 | assert(node->type == NodeTypeContainerInitExpr); |
| ... | ... | @@ -5659,14 +5659,14 @@ static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5659 | 5659 | ResultLoc *child_result_loc; |
| 5660 | 5660 | AstNode *init_array_type_source_node; |
| 5661 | 5661 | if (container_init_expr->type != nullptr) { |
| 5662 | IrInstSrc *container_type; | |
| 5662 | Stage1ZirInst *container_type; | |
| 5663 | 5663 | if (container_init_expr->type->type == NodeTypeInferredArrayType) { |
| 5664 | 5664 | if (kind == ContainerInitKindStruct) { |
| 5665 | 5665 | add_node_error(ag->codegen, container_init_expr->type, |
| 5666 | 5666 | buf_sprintf("initializing array with struct syntax")); |
| 5667 | 5667 | return ag->codegen->invalid_inst_src; |
| 5668 | 5668 | } |
| 5669 | IrInstSrc *sentinel; | |
| 5669 | Stage1ZirInst *sentinel; | |
| 5670 | 5670 | if (container_init_expr->type->data.inferred_array_type.sentinel != nullptr) { |
| 5671 | 5671 | sentinel = astgen_node(ag, container_init_expr->type->data.inferred_array_type.sentinel, scope); |
| 5672 | 5672 | if (sentinel == ag->codegen->invalid_inst_src) |
| ... | ... | @@ -5675,12 +5675,12 @@ static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5675 | 5675 | sentinel = nullptr; |
| 5676 | 5676 | } |
| 5677 | 5677 | |
| 5678 | IrInstSrc *elem_type = astgen_node(ag, | |
| 5678 | Stage1ZirInst *elem_type = astgen_node(ag, | |
| 5679 | 5679 | container_init_expr->type->data.inferred_array_type.child_type, scope); |
| 5680 | 5680 | if (elem_type == ag->codegen->invalid_inst_src) |
| 5681 | 5681 | return elem_type; |
| 5682 | 5682 | size_t item_count = container_init_expr->entries.length; |
| 5683 | IrInstSrc *item_count_inst = ir_build_const_usize(ag, scope, node, item_count); | |
| 5683 | Stage1ZirInst *item_count_inst = ir_build_const_usize(ag, scope, node, item_count); | |
| 5684 | 5684 | container_type = ir_build_array_type(ag, scope, node, item_count_inst, sentinel, elem_type); |
| 5685 | 5685 | } else { |
| 5686 | 5686 | container_type = astgen_node(ag, container_init_expr->type, scope); |
| ... | ... | @@ -5702,11 +5702,11 @@ static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5702 | 5702 | |
| 5703 | 5703 | switch (kind) { |
| 5704 | 5704 | case ContainerInitKindStruct: { |
| 5705 | IrInstSrc *container_ptr = ir_build_resolve_result(ag, scope, node, child_result_loc, | |
| 5705 | Stage1ZirInst *container_ptr = ir_build_resolve_result(ag, scope, node, child_result_loc, | |
| 5706 | 5706 | nullptr); |
| 5707 | 5707 | |
| 5708 | 5708 | size_t field_count = container_init_expr->entries.length; |
| 5709 | IrInstSrcContainerInitFieldsField *fields = heap::c_allocator.allocate<IrInstSrcContainerInitFieldsField>(field_count); | |
| 5709 | Stage1ZirInstContainerInitFieldsField *fields = heap::c_allocator.allocate<Stage1ZirInstContainerInitFieldsField>(field_count); | |
| 5710 | 5710 | for (size_t i = 0; i < field_count; i += 1) { |
| 5711 | 5711 | AstNode *entry_node = container_init_expr->entries.at(i); |
| 5712 | 5712 | assert(entry_node->type == NodeTypeStructValueField); |
| ... | ... | @@ -5714,7 +5714,7 @@ static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5714 | 5714 | Buf *name = entry_node->data.struct_val_field.name; |
| 5715 | 5715 | AstNode *expr_node = entry_node->data.struct_val_field.expr; |
| 5716 | 5716 | |
| 5717 | IrInstSrc *field_ptr = ir_build_field_ptr(ag, scope, entry_node, container_ptr, name, true); | |
| 5717 | Stage1ZirInst *field_ptr = ir_build_field_ptr(ag, scope, entry_node, container_ptr, name, true); | |
| 5718 | 5718 | ResultLocInstruction *result_loc_inst = heap::c_allocator.create<ResultLocInstruction>(); |
| 5719 | 5719 | result_loc_inst->base.id = ResultLocIdInstruction; |
| 5720 | 5720 | result_loc_inst->base.source_instruction = field_ptr; |
| ... | ... | @@ -5722,7 +5722,7 @@ static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5722 | 5722 | ir_ref_instruction(field_ptr, ag->current_basic_block); |
| 5723 | 5723 | ir_build_reset_result(ag, scope, expr_node, &result_loc_inst->base); |
| 5724 | 5724 | |
| 5725 | IrInstSrc *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone, | |
| 5725 | Stage1ZirInst *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone, | |
| 5726 | 5726 | &result_loc_inst->base); |
| 5727 | 5727 | if (expr_value == ag->codegen->invalid_inst_src) |
| 5728 | 5728 | return expr_value; |
| ... | ... | @@ -5731,7 +5731,7 @@ static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5731 | 5731 | fields[i].source_node = entry_node; |
| 5732 | 5732 | fields[i].result_loc = field_ptr; |
| 5733 | 5733 | } |
| 5734 | IrInstSrc *result = ir_build_container_init_fields(ag, scope, node, field_count, | |
| 5734 | Stage1ZirInst *result = ir_build_container_init_fields(ag, scope, node, field_count, | |
| 5735 | 5735 | fields, container_ptr); |
| 5736 | 5736 | |
| 5737 | 5737 | if (result_loc_cast != nullptr) { |
| ... | ... | @@ -5742,15 +5742,15 @@ static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5742 | 5742 | case ContainerInitKindArray: { |
| 5743 | 5743 | size_t item_count = container_init_expr->entries.length; |
| 5744 | 5744 | |
| 5745 | IrInstSrc *container_ptr = ir_build_resolve_result(ag, scope, node, child_result_loc, | |
| 5745 | Stage1ZirInst *container_ptr = ir_build_resolve_result(ag, scope, node, child_result_loc, | |
| 5746 | 5746 | nullptr); |
| 5747 | 5747 | |
| 5748 | IrInstSrc **result_locs = heap::c_allocator.allocate<IrInstSrc *>(item_count); | |
| 5748 | Stage1ZirInst **result_locs = heap::c_allocator.allocate<Stage1ZirInst *>(item_count); | |
| 5749 | 5749 | for (size_t i = 0; i < item_count; i += 1) { |
| 5750 | 5750 | AstNode *expr_node = container_init_expr->entries.at(i); |
| 5751 | 5751 | |
| 5752 | IrInstSrc *elem_index = ir_build_const_usize(ag, scope, expr_node, i); | |
| 5753 | IrInstSrc *elem_ptr = ir_build_elem_ptr(ag, scope, expr_node, container_ptr, | |
| 5752 | Stage1ZirInst *elem_index = ir_build_const_usize(ag, scope, expr_node, i); | |
| 5753 | Stage1ZirInst *elem_ptr = ir_build_elem_ptr(ag, scope, expr_node, container_ptr, | |
| 5754 | 5754 | elem_index, false, PtrLenSingle, init_array_type_source_node); |
| 5755 | 5755 | ResultLocInstruction *result_loc_inst = heap::c_allocator.create<ResultLocInstruction>(); |
| 5756 | 5756 | result_loc_inst->base.id = ResultLocIdInstruction; |
| ... | ... | @@ -5759,14 +5759,14 @@ static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5759 | 5759 | ir_ref_instruction(elem_ptr, ag->current_basic_block); |
| 5760 | 5760 | ir_build_reset_result(ag, scope, expr_node, &result_loc_inst->base); |
| 5761 | 5761 | |
| 5762 | IrInstSrc *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone, | |
| 5762 | Stage1ZirInst *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone, | |
| 5763 | 5763 | &result_loc_inst->base); |
| 5764 | 5764 | if (expr_value == ag->codegen->invalid_inst_src) |
| 5765 | 5765 | return expr_value; |
| 5766 | 5766 | |
| 5767 | 5767 | result_locs[i] = elem_ptr; |
| 5768 | 5768 | } |
| 5769 | IrInstSrc *result = ir_build_container_init_list(ag, scope, node, item_count, | |
| 5769 | Stage1ZirInst *result = ir_build_container_init_list(ag, scope, node, item_count, | |
| 5770 | 5770 | result_locs, container_ptr, init_array_type_source_node); |
| 5771 | 5771 | if (result_loc_cast != nullptr) { |
| 5772 | 5772 | result = ir_build_implicit_cast(ag, scope, node, result, result_loc_cast); |
| ... | ... | @@ -5777,7 +5777,7 @@ static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5777 | 5777 | zig_unreachable(); |
| 5778 | 5778 | } |
| 5779 | 5779 | |
| 5780 | static ResultLocVar *ir_build_var_result_loc(Stage1AstGen *ag, IrInstSrc *alloca, ZigVar *var) { | |
| 5780 | static ResultLocVar *ir_build_var_result_loc(Stage1AstGen *ag, Stage1ZirInst *alloca, ZigVar *var) { | |
| 5781 | 5781 | ResultLocVar *result_loc_var = heap::c_allocator.create<ResultLocVar>(); |
| 5782 | 5782 | result_loc_var->base.id = ResultLocIdVar; |
| 5783 | 5783 | result_loc_var->base.source_instruction = alloca; |
| ... | ... | @@ -5789,7 +5789,7 @@ static ResultLocVar *ir_build_var_result_loc(Stage1AstGen *ag, IrInstSrc *alloca |
| 5789 | 5789 | return result_loc_var; |
| 5790 | 5790 | } |
| 5791 | 5791 | |
| 5792 | static ResultLocCast *ir_build_cast_result_loc(Stage1AstGen *ag, IrInstSrc *dest_type, | |
| 5792 | static ResultLocCast *ir_build_cast_result_loc(Stage1AstGen *ag, Stage1ZirInst *dest_type, | |
| 5793 | 5793 | ResultLoc *parent_result_loc) |
| 5794 | 5794 | { |
| 5795 | 5795 | ResultLocCast *result_loc_cast = heap::c_allocator.create<ResultLocCast>(); |
| ... | ... | @@ -5805,15 +5805,15 @@ static ResultLocCast *ir_build_cast_result_loc(Stage1AstGen *ag, IrInstSrc *dest |
| 5805 | 5805 | } |
| 5806 | 5806 | |
| 5807 | 5807 | static void build_decl_var_and_init(Stage1AstGen *ag, Scope *scope, AstNode *source_node, ZigVar *var, |
| 5808 | IrInstSrc *init, const char *name_hint, IrInstSrc *is_comptime) | |
| 5808 | Stage1ZirInst *init, const char *name_hint, Stage1ZirInst *is_comptime) | |
| 5809 | 5809 | { |
| 5810 | IrInstSrc *alloca = ir_build_alloca_src(ag, scope, source_node, nullptr, name_hint, is_comptime); | |
| 5810 | Stage1ZirInst *alloca = ir_build_alloca_src(ag, scope, source_node, nullptr, name_hint, is_comptime); | |
| 5811 | 5811 | ResultLocVar *var_result_loc = ir_build_var_result_loc(ag, alloca, var); |
| 5812 | 5812 | ir_build_end_expr(ag, scope, source_node, init, &var_result_loc->base); |
| 5813 | 5813 | ir_build_var_decl_src(ag, scope, source_node, var, nullptr, alloca); |
| 5814 | 5814 | } |
| 5815 | 5815 | |
| 5816 | static IrInstSrc *astgen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 5816 | static Stage1ZirInst *astgen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 5817 | 5817 | assert(node->type == NodeTypeVariableDeclaration); |
| 5818 | 5818 | |
| 5819 | 5819 | AstNodeVariableDeclaration *variable_declaration = &node->data.variable_declaration; |
| ... | ... | @@ -5826,7 +5826,7 @@ static IrInstSrc *astgen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 5826 | 5826 | // Used for the type expr and the align expr |
| 5827 | 5827 | Scope *comptime_scope = create_comptime_scope(ag->codegen, node, scope); |
| 5828 | 5828 | |
| 5829 | IrInstSrc *type_instruction; | |
| 5829 | Stage1ZirInst *type_instruction; | |
| 5830 | 5830 | if (variable_declaration->type != nullptr) { |
| 5831 | 5831 | type_instruction = astgen_node(ag, variable_declaration->type, comptime_scope); |
| 5832 | 5832 | if (type_instruction == ag->codegen->invalid_inst_src) |
| ... | ... | @@ -5840,10 +5840,10 @@ static IrInstSrc *astgen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 5840 | 5840 | bool is_extern = variable_declaration->is_extern; |
| 5841 | 5841 | |
| 5842 | 5842 | bool is_comptime_scalar = ir_should_inline(ag->exec, scope) || variable_declaration->is_comptime; |
| 5843 | IrInstSrc *is_comptime = ir_build_const_bool(ag, scope, node, is_comptime_scalar); | |
| 5843 | Stage1ZirInst *is_comptime = ir_build_const_bool(ag, scope, node, is_comptime_scalar); | |
| 5844 | 5844 | ZigVar *var = ir_create_var(ag, node, scope, variable_declaration->symbol, |
| 5845 | 5845 | is_const, is_const, is_shadowable, is_comptime); |
| 5846 | // we detect IrInstSrcDeclVar in gen_block to make sure the next node | |
| 5846 | // we detect Stage1ZirInstDeclVar in gen_block to make sure the next node | |
| 5847 | 5847 | // is inside var->child_scope |
| 5848 | 5848 | |
| 5849 | 5849 | if (!is_extern && !variable_declaration->expr) { |
| ... | ... | @@ -5852,7 +5852,7 @@ static IrInstSrc *astgen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 5852 | 5852 | return ag->codegen->invalid_inst_src; |
| 5853 | 5853 | } |
| 5854 | 5854 | |
| 5855 | IrInstSrc *align_value = nullptr; | |
| 5855 | Stage1ZirInst *align_value = nullptr; | |
| 5856 | 5856 | if (variable_declaration->align_expr != nullptr) { |
| 5857 | 5857 | align_value = astgen_node(ag, variable_declaration->align_expr, comptime_scope); |
| 5858 | 5858 | if (align_value == ag->codegen->invalid_inst_src) |
| ... | ... | @@ -5867,7 +5867,7 @@ static IrInstSrc *astgen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 5867 | 5867 | // Parser should ensure that this never happens |
| 5868 | 5868 | assert(variable_declaration->threadlocal_tok == 0); |
| 5869 | 5869 | |
| 5870 | IrInstSrc *alloca = ir_build_alloca_src(ag, scope, node, align_value, | |
| 5870 | Stage1ZirInst *alloca = ir_build_alloca_src(ag, scope, node, align_value, | |
| 5871 | 5871 | buf_ptr(variable_declaration->symbol), is_comptime); |
| 5872 | 5872 | |
| 5873 | 5873 | // Create a result location for the initialization expression. |
| ... | ... | @@ -5889,7 +5889,7 @@ static IrInstSrc *astgen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 5889 | 5889 | // so that the struct or enum from the init expression inherits the name. |
| 5890 | 5890 | Buf *old_exec_name = ag->exec->name; |
| 5891 | 5891 | ag->exec->name = variable_declaration->symbol; |
| 5892 | IrInstSrc *init_value = astgen_node_extra(ag, variable_declaration->expr, init_scope, | |
| 5892 | Stage1ZirInst *init_value = astgen_node_extra(ag, variable_declaration->expr, init_scope, | |
| 5893 | 5893 | LValNone, init_result_loc); |
| 5894 | 5894 | ag->exec->name = old_exec_name; |
| 5895 | 5895 | |
| ... | ... | @@ -5897,7 +5897,7 @@ static IrInstSrc *astgen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 5897 | 5897 | return ag->codegen->invalid_inst_src; |
| 5898 | 5898 | |
| 5899 | 5899 | if (result_loc_cast != nullptr) { |
| 5900 | IrInstSrc *implicit_cast = ir_build_implicit_cast(ag, scope, init_value->source_node, | |
| 5900 | Stage1ZirInst *implicit_cast = ir_build_implicit_cast(ag, scope, init_value->source_node, | |
| 5901 | 5901 | init_value, result_loc_cast); |
| 5902 | 5902 | ir_build_end_expr(ag, scope, node, implicit_cast, &result_loc_var->base); |
| 5903 | 5903 | } |
| ... | ... | @@ -5905,7 +5905,7 @@ static IrInstSrc *astgen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 5905 | 5905 | return ir_build_var_decl_src(ag, scope, node, var, align_value, alloca); |
| 5906 | 5906 | } |
| 5907 | 5907 | |
| 5908 | static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 5908 | static Stage1ZirInst *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 5909 | 5909 | ResultLoc *result_loc) |
| 5910 | 5910 | { |
| 5911 | 5911 | assert(node->type == NodeTypeWhileExpr); |
| ... | ... | @@ -5921,7 +5921,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 5921 | 5921 | Stage1ZirBasicBlock *else_block = else_node ? |
| 5922 | 5922 | ir_create_basic_block(ag, scope, "WhileElse") : end_block; |
| 5923 | 5923 | |
| 5924 | IrInstSrc *is_comptime = ir_build_const_bool(ag, scope, node, | |
| 5924 | Stage1ZirInst *is_comptime = ir_build_const_bool(ag, scope, node, | |
| 5925 | 5925 | ir_should_inline(ag->exec, scope) || node->data.while_expr.is_inline); |
| 5926 | 5926 | ir_build_br(ag, scope, node, cond_block, is_comptime); |
| 5927 | 5927 | |
| ... | ... | @@ -5943,15 +5943,15 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 5943 | 5943 | payload_scope = subexpr_scope; |
| 5944 | 5944 | } |
| 5945 | 5945 | ScopeExpr *spill_scope = create_expr_scope(ag->codegen, node, payload_scope); |
| 5946 | IrInstSrc *err_val_ptr = astgen_node_extra(ag, node->data.while_expr.condition, subexpr_scope, | |
| 5946 | Stage1ZirInst *err_val_ptr = astgen_node_extra(ag, node->data.while_expr.condition, subexpr_scope, | |
| 5947 | 5947 | LValPtr, nullptr); |
| 5948 | 5948 | if (err_val_ptr == ag->codegen->invalid_inst_src) |
| 5949 | 5949 | return err_val_ptr; |
| 5950 | IrInstSrc *is_err = ir_build_test_err_src(ag, scope, node->data.while_expr.condition, err_val_ptr, | |
| 5950 | Stage1ZirInst *is_err = ir_build_test_err_src(ag, scope, node->data.while_expr.condition, err_val_ptr, | |
| 5951 | 5951 | true, false); |
| 5952 | 5952 | Stage1ZirBasicBlock *after_cond_block = ag->current_basic_block; |
| 5953 | IrInstSrc *void_else_result = else_node ? nullptr : ir_build_const_void(ag, scope, node); | |
| 5954 | IrInstSrc *cond_br_inst; | |
| 5953 | Stage1ZirInst *void_else_result = else_node ? nullptr : ir_build_const_void(ag, scope, node); | |
| 5954 | Stage1ZirInst *cond_br_inst; | |
| 5955 | 5955 | if (!instr_is_unreachable(is_err)) { |
| 5956 | 5956 | cond_br_inst = ir_build_cond_br(ag, scope, node->data.while_expr.condition, is_err, |
| 5957 | 5957 | else_block, body_block, is_comptime); |
| ... | ... | @@ -5965,14 +5965,14 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 5965 | 5965 | |
| 5966 | 5966 | ir_set_cursor_at_end_and_append_block(ag, body_block); |
| 5967 | 5967 | if (var_symbol) { |
| 5968 | IrInstSrc *payload_ptr = ir_build_unwrap_err_payload_src(ag, &spill_scope->base, symbol_node, | |
| 5968 | Stage1ZirInst *payload_ptr = ir_build_unwrap_err_payload_src(ag, &spill_scope->base, symbol_node, | |
| 5969 | 5969 | err_val_ptr, false, false); |
| 5970 | IrInstSrc *var_value = node->data.while_expr.var_is_ptr ? | |
| 5970 | Stage1ZirInst *var_value = node->data.while_expr.var_is_ptr ? | |
| 5971 | 5971 | payload_ptr : ir_build_load_ptr(ag, &spill_scope->base, symbol_node, payload_ptr); |
| 5972 | 5972 | build_decl_var_and_init(ag, payload_scope, symbol_node, payload_var, var_value, buf_ptr(var_symbol), is_comptime); |
| 5973 | 5973 | } |
| 5974 | 5974 | |
| 5975 | ZigList<IrInstSrc *> incoming_values = {0}; | |
| 5975 | ZigList<Stage1ZirInst *> incoming_values = {0}; | |
| 5976 | 5976 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 5977 | 5977 | |
| 5978 | 5978 | if (is_duplicate_label(ag->codegen, payload_scope, node, node->data.while_expr.name)) |
| ... | ... | @@ -5991,7 +5991,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 5991 | 5991 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 5992 | 5992 | // it's actually in break statements, handled similarly to return statements. |
| 5993 | 5993 | // That is why we set those values in loop_scope above and not in this astgen_node call. |
| 5994 | IrInstSrc *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base); | |
| 5994 | Stage1ZirInst *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base); | |
| 5995 | 5995 | if (body_result == ag->codegen->invalid_inst_src) |
| 5996 | 5996 | return body_result; |
| 5997 | 5997 | |
| ... | ... | @@ -6006,7 +6006,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6006 | 6006 | |
| 6007 | 6007 | if (continue_expr_node) { |
| 6008 | 6008 | ir_set_cursor_at_end_and_append_block(ag, continue_block); |
| 6009 | IrInstSrc *expr_result = astgen_node(ag, continue_expr_node, payload_scope); | |
| 6009 | Stage1ZirInst *expr_result = astgen_node(ag, continue_expr_node, payload_scope); | |
| 6010 | 6010 | if (expr_result == ag->codegen->invalid_inst_src) |
| 6011 | 6011 | return expr_result; |
| 6012 | 6012 | if (!instr_is_unreachable(expr_result)) { |
| ... | ... | @@ -6023,8 +6023,8 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6023 | 6023 | ZigVar *err_var = ir_create_var(ag, err_symbol_node, scope, err_symbol, |
| 6024 | 6024 | true, false, false, is_comptime); |
| 6025 | 6025 | Scope *err_scope = err_var->child_scope; |
| 6026 | IrInstSrc *err_ptr = ir_build_unwrap_err_code_src(ag, err_scope, err_symbol_node, err_val_ptr); | |
| 6027 | IrInstSrc *err_value = ir_build_load_ptr(ag, err_scope, err_symbol_node, err_ptr); | |
| 6026 | Stage1ZirInst *err_ptr = ir_build_unwrap_err_code_src(ag, err_scope, err_symbol_node, err_val_ptr); | |
| 6027 | Stage1ZirInst *err_value = ir_build_load_ptr(ag, err_scope, err_symbol_node, err_ptr); | |
| 6028 | 6028 | build_decl_var_and_init(ag, err_scope, err_symbol_node, err_var, err_value, buf_ptr(err_symbol), is_comptime); |
| 6029 | 6029 | |
| 6030 | 6030 | if (peer_parent->peers.length != 0) { |
| ... | ... | @@ -6032,7 +6032,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6032 | 6032 | } |
| 6033 | 6033 | ResultLocPeer *peer_result = create_peer_result(peer_parent); |
| 6034 | 6034 | peer_parent->peers.append(peer_result); |
| 6035 | IrInstSrc *else_result = astgen_node_extra(ag, else_node, err_scope, lval, &peer_result->base); | |
| 6035 | Stage1ZirInst *else_result = astgen_node_extra(ag, else_node, err_scope, lval, &peer_result->base); | |
| 6036 | 6036 | if (else_result == ag->codegen->invalid_inst_src) |
| 6037 | 6037 | return else_result; |
| 6038 | 6038 | if (!instr_is_unreachable(else_result)) |
| ... | ... | @@ -6050,7 +6050,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6050 | 6050 | peer_parent->peers.last()->next_bb = end_block; |
| 6051 | 6051 | } |
| 6052 | 6052 | |
| 6053 | IrInstSrc *phi = ir_build_phi(ag, scope, node, incoming_blocks.length, | |
| 6053 | Stage1ZirInst *phi = ir_build_phi(ag, scope, node, incoming_blocks.length, | |
| 6054 | 6054 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 6055 | 6055 | return ir_expr_wrap(ag, scope, phi, result_loc); |
| 6056 | 6056 | } else if (var_symbol != nullptr) { |
| ... | ... | @@ -6063,15 +6063,15 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6063 | 6063 | true, false, false, is_comptime); |
| 6064 | 6064 | Scope *child_scope = payload_var->child_scope; |
| 6065 | 6065 | ScopeExpr *spill_scope = create_expr_scope(ag->codegen, node, child_scope); |
| 6066 | IrInstSrc *maybe_val_ptr = astgen_node_extra(ag, node->data.while_expr.condition, subexpr_scope, | |
| 6066 | Stage1ZirInst *maybe_val_ptr = astgen_node_extra(ag, node->data.while_expr.condition, subexpr_scope, | |
| 6067 | 6067 | LValPtr, nullptr); |
| 6068 | 6068 | if (maybe_val_ptr == ag->codegen->invalid_inst_src) |
| 6069 | 6069 | return maybe_val_ptr; |
| 6070 | IrInstSrc *maybe_val = ir_build_load_ptr(ag, scope, node->data.while_expr.condition, maybe_val_ptr); | |
| 6071 | IrInstSrc *is_non_null = ir_build_test_non_null_src(ag, scope, node->data.while_expr.condition, maybe_val); | |
| 6070 | Stage1ZirInst *maybe_val = ir_build_load_ptr(ag, scope, node->data.while_expr.condition, maybe_val_ptr); | |
| 6071 | Stage1ZirInst *is_non_null = ir_build_test_non_null_src(ag, scope, node->data.while_expr.condition, maybe_val); | |
| 6072 | 6072 | Stage1ZirBasicBlock *after_cond_block = ag->current_basic_block; |
| 6073 | IrInstSrc *void_else_result = else_node ? nullptr : ir_build_const_void(ag, scope, node); | |
| 6074 | IrInstSrc *cond_br_inst; | |
| 6073 | Stage1ZirInst *void_else_result = else_node ? nullptr : ir_build_const_void(ag, scope, node); | |
| 6074 | Stage1ZirInst *cond_br_inst; | |
| 6075 | 6075 | if (!instr_is_unreachable(is_non_null)) { |
| 6076 | 6076 | cond_br_inst = ir_build_cond_br(ag, scope, node->data.while_expr.condition, is_non_null, |
| 6077 | 6077 | body_block, else_block, is_comptime); |
| ... | ... | @@ -6084,12 +6084,12 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6084 | 6084 | is_comptime); |
| 6085 | 6085 | |
| 6086 | 6086 | ir_set_cursor_at_end_and_append_block(ag, body_block); |
| 6087 | IrInstSrc *payload_ptr = ir_build_optional_unwrap_ptr(ag, &spill_scope->base, symbol_node, maybe_val_ptr, false); | |
| 6088 | IrInstSrc *var_value = node->data.while_expr.var_is_ptr ? | |
| 6087 | Stage1ZirInst *payload_ptr = ir_build_optional_unwrap_ptr(ag, &spill_scope->base, symbol_node, maybe_val_ptr, false); | |
| 6088 | Stage1ZirInst *var_value = node->data.while_expr.var_is_ptr ? | |
| 6089 | 6089 | payload_ptr : ir_build_load_ptr(ag, &spill_scope->base, symbol_node, payload_ptr); |
| 6090 | 6090 | build_decl_var_and_init(ag, child_scope, symbol_node, payload_var, var_value, buf_ptr(var_symbol), is_comptime); |
| 6091 | 6091 | |
| 6092 | ZigList<IrInstSrc *> incoming_values = {0}; | |
| 6092 | ZigList<Stage1ZirInst *> incoming_values = {0}; | |
| 6093 | 6093 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 6094 | 6094 | |
| 6095 | 6095 | if (is_duplicate_label(ag->codegen, child_scope, node, node->data.while_expr.name)) |
| ... | ... | @@ -6108,7 +6108,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6108 | 6108 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 6109 | 6109 | // it's actually in break statements, handled similarly to return statements. |
| 6110 | 6110 | // That is why we set those values in loop_scope above and not in this astgen_node call. |
| 6111 | IrInstSrc *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base); | |
| 6111 | Stage1ZirInst *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base); | |
| 6112 | 6112 | if (body_result == ag->codegen->invalid_inst_src) |
| 6113 | 6113 | return body_result; |
| 6114 | 6114 | |
| ... | ... | @@ -6123,7 +6123,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6123 | 6123 | |
| 6124 | 6124 | if (continue_expr_node) { |
| 6125 | 6125 | ir_set_cursor_at_end_and_append_block(ag, continue_block); |
| 6126 | IrInstSrc *expr_result = astgen_node(ag, continue_expr_node, child_scope); | |
| 6126 | Stage1ZirInst *expr_result = astgen_node(ag, continue_expr_node, child_scope); | |
| 6127 | 6127 | if (expr_result == ag->codegen->invalid_inst_src) |
| 6128 | 6128 | return expr_result; |
| 6129 | 6129 | if (!instr_is_unreachable(expr_result)) { |
| ... | ... | @@ -6132,7 +6132,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6132 | 6132 | } |
| 6133 | 6133 | } |
| 6134 | 6134 | |
| 6135 | IrInstSrc *else_result = nullptr; | |
| 6135 | Stage1ZirInst *else_result = nullptr; | |
| 6136 | 6136 | if (else_node) { |
| 6137 | 6137 | ir_set_cursor_at_end_and_append_block(ag, else_block); |
| 6138 | 6138 | |
| ... | ... | @@ -6160,17 +6160,17 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6160 | 6160 | peer_parent->peers.last()->next_bb = end_block; |
| 6161 | 6161 | } |
| 6162 | 6162 | |
| 6163 | IrInstSrc *phi = ir_build_phi(ag, scope, node, incoming_blocks.length, | |
| 6163 | Stage1ZirInst *phi = ir_build_phi(ag, scope, node, incoming_blocks.length, | |
| 6164 | 6164 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 6165 | 6165 | return ir_expr_wrap(ag, scope, phi, result_loc); |
| 6166 | 6166 | } else { |
| 6167 | 6167 | ir_set_cursor_at_end_and_append_block(ag, cond_block); |
| 6168 | IrInstSrc *cond_val = astgen_node(ag, node->data.while_expr.condition, scope); | |
| 6168 | Stage1ZirInst *cond_val = astgen_node(ag, node->data.while_expr.condition, scope); | |
| 6169 | 6169 | if (cond_val == ag->codegen->invalid_inst_src) |
| 6170 | 6170 | return cond_val; |
| 6171 | 6171 | Stage1ZirBasicBlock *after_cond_block = ag->current_basic_block; |
| 6172 | IrInstSrc *void_else_result = else_node ? nullptr : ir_build_const_void(ag, scope, node); | |
| 6173 | IrInstSrc *cond_br_inst; | |
| 6172 | Stage1ZirInst *void_else_result = else_node ? nullptr : ir_build_const_void(ag, scope, node); | |
| 6173 | Stage1ZirInst *cond_br_inst; | |
| 6174 | 6174 | if (!instr_is_unreachable(cond_val)) { |
| 6175 | 6175 | cond_br_inst = ir_build_cond_br(ag, scope, node->data.while_expr.condition, cond_val, |
| 6176 | 6176 | body_block, else_block, is_comptime); |
| ... | ... | @@ -6183,7 +6183,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6183 | 6183 | is_comptime); |
| 6184 | 6184 | ir_set_cursor_at_end_and_append_block(ag, body_block); |
| 6185 | 6185 | |
| 6186 | ZigList<IrInstSrc *> incoming_values = {0}; | |
| 6186 | ZigList<Stage1ZirInst *> incoming_values = {0}; | |
| 6187 | 6187 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 6188 | 6188 | |
| 6189 | 6189 | Scope *subexpr_scope = create_runtime_scope(ag->codegen, node, scope, is_comptime); |
| ... | ... | @@ -6203,7 +6203,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6203 | 6203 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 6204 | 6204 | // it's actually in break statements, handled similarly to return statements. |
| 6205 | 6205 | // That is why we set those values in loop_scope above and not in this astgen_node call. |
| 6206 | IrInstSrc *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base); | |
| 6206 | Stage1ZirInst *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base); | |
| 6207 | 6207 | if (body_result == ag->codegen->invalid_inst_src) |
| 6208 | 6208 | return body_result; |
| 6209 | 6209 | |
| ... | ... | @@ -6218,7 +6218,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6218 | 6218 | |
| 6219 | 6219 | if (continue_expr_node) { |
| 6220 | 6220 | ir_set_cursor_at_end_and_append_block(ag, continue_block); |
| 6221 | IrInstSrc *expr_result = astgen_node(ag, continue_expr_node, subexpr_scope); | |
| 6221 | Stage1ZirInst *expr_result = astgen_node(ag, continue_expr_node, subexpr_scope); | |
| 6222 | 6222 | if (expr_result == ag->codegen->invalid_inst_src) |
| 6223 | 6223 | return expr_result; |
| 6224 | 6224 | if (!instr_is_unreachable(expr_result)) { |
| ... | ... | @@ -6227,7 +6227,7 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6227 | 6227 | } |
| 6228 | 6228 | } |
| 6229 | 6229 | |
| 6230 | IrInstSrc *else_result = nullptr; | |
| 6230 | Stage1ZirInst *else_result = nullptr; | |
| 6231 | 6231 | if (else_node) { |
| 6232 | 6232 | ir_set_cursor_at_end_and_append_block(ag, else_block); |
| 6233 | 6233 | |
| ... | ... | @@ -6256,13 +6256,13 @@ static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6256 | 6256 | peer_parent->peers.last()->next_bb = end_block; |
| 6257 | 6257 | } |
| 6258 | 6258 | |
| 6259 | IrInstSrc *phi = ir_build_phi(ag, scope, node, incoming_blocks.length, | |
| 6259 | Stage1ZirInst *phi = ir_build_phi(ag, scope, node, incoming_blocks.length, | |
| 6260 | 6260 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 6261 | 6261 | return ir_expr_wrap(ag, scope, phi, result_loc); |
| 6262 | 6262 | } |
| 6263 | 6263 | } |
| 6264 | 6264 | |
| 6265 | static IrInstSrc *astgen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, | |
| 6265 | static Stage1ZirInst *astgen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, | |
| 6266 | 6266 | ResultLoc *result_loc) |
| 6267 | 6267 | { |
| 6268 | 6268 | assert(node->type == NodeTypeForExpr); |
| ... | ... | @@ -6281,11 +6281,11 @@ static IrInstSrc *astgen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6281 | 6281 | |
| 6282 | 6282 | ScopeExpr *spill_scope = create_expr_scope(ag->codegen, node, parent_scope); |
| 6283 | 6283 | |
| 6284 | IrInstSrc *array_val_ptr = astgen_node_extra(ag, array_node, &spill_scope->base, LValPtr, nullptr); | |
| 6284 | Stage1ZirInst *array_val_ptr = astgen_node_extra(ag, array_node, &spill_scope->base, LValPtr, nullptr); | |
| 6285 | 6285 | if (array_val_ptr == ag->codegen->invalid_inst_src) |
| 6286 | 6286 | return array_val_ptr; |
| 6287 | 6287 | |
| 6288 | IrInstSrc *is_comptime = ir_build_const_bool(ag, parent_scope, node, | |
| 6288 | Stage1ZirInst *is_comptime = ir_build_const_bool(ag, parent_scope, node, | |
| 6289 | 6289 | ir_should_inline(ag->exec, parent_scope) || node->data.for_expr.is_inline); |
| 6290 | 6290 | |
| 6291 | 6291 | AstNode *index_var_source_node; |
| ... | ... | @@ -6302,12 +6302,12 @@ static IrInstSrc *astgen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6302 | 6302 | index_var_name = "i"; |
| 6303 | 6303 | } |
| 6304 | 6304 | |
| 6305 | IrInstSrc *zero = ir_build_const_usize(ag, parent_scope, node, 0); | |
| 6305 | Stage1ZirInst *zero = ir_build_const_usize(ag, parent_scope, node, 0); | |
| 6306 | 6306 | build_decl_var_and_init(ag, parent_scope, index_var_source_node, index_var, zero, index_var_name, is_comptime); |
| 6307 | 6307 | parent_scope = index_var->child_scope; |
| 6308 | 6308 | |
| 6309 | IrInstSrc *one = ir_build_const_usize(ag, parent_scope, node, 1); | |
| 6310 | IrInstSrc *index_ptr = ir_build_var_ptr(ag, parent_scope, node, index_var); | |
| 6309 | Stage1ZirInst *one = ir_build_const_usize(ag, parent_scope, node, 1); | |
| 6310 | Stage1ZirInst *index_ptr = ir_build_var_ptr(ag, parent_scope, node, index_var); | |
| 6311 | 6311 | |
| 6312 | 6312 | |
| 6313 | 6313 | Stage1ZirBasicBlock *cond_block = ir_create_basic_block(ag, parent_scope, "ForCond"); |
| ... | ... | @@ -6317,36 +6317,36 @@ static IrInstSrc *astgen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6317 | 6317 | Stage1ZirBasicBlock *continue_block = ir_create_basic_block(ag, parent_scope, "ForContinue"); |
| 6318 | 6318 | |
| 6319 | 6319 | Buf *len_field_name = buf_create_from_str("len"); |
| 6320 | IrInstSrc *len_ref = ir_build_field_ptr(ag, parent_scope, node, array_val_ptr, len_field_name, false); | |
| 6321 | IrInstSrc *len_val = ir_build_load_ptr(ag, &spill_scope->base, node, len_ref); | |
| 6320 | Stage1ZirInst *len_ref = ir_build_field_ptr(ag, parent_scope, node, array_val_ptr, len_field_name, false); | |
| 6321 | Stage1ZirInst *len_val = ir_build_load_ptr(ag, &spill_scope->base, node, len_ref); | |
| 6322 | 6322 | ir_build_br(ag, parent_scope, node, cond_block, is_comptime); |
| 6323 | 6323 | |
| 6324 | 6324 | ir_set_cursor_at_end_and_append_block(ag, cond_block); |
| 6325 | IrInstSrc *index_val = ir_build_load_ptr(ag, &spill_scope->base, node, index_ptr); | |
| 6326 | IrInstSrc *cond = ir_build_bin_op(ag, parent_scope, node, IrBinOpCmpLessThan, index_val, len_val, false); | |
| 6325 | Stage1ZirInst *index_val = ir_build_load_ptr(ag, &spill_scope->base, node, index_ptr); | |
| 6326 | Stage1ZirInst *cond = ir_build_bin_op(ag, parent_scope, node, IrBinOpCmpLessThan, index_val, len_val, false); | |
| 6327 | 6327 | Stage1ZirBasicBlock *after_cond_block = ag->current_basic_block; |
| 6328 | IrInstSrc *void_else_value = else_node ? nullptr : ir_build_const_void(ag, parent_scope, node); | |
| 6329 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, parent_scope, node, cond, | |
| 6328 | Stage1ZirInst *void_else_value = else_node ? nullptr : ir_build_const_void(ag, parent_scope, node); | |
| 6329 | Stage1ZirInst *cond_br_inst = ir_build_cond_br(ag, parent_scope, node, cond, | |
| 6330 | 6330 | body_block, else_block, is_comptime); |
| 6331 | 6331 | |
| 6332 | 6332 | ResultLocPeerParent *peer_parent = ir_build_result_peers(ag, cond_br_inst, end_block, result_loc, is_comptime); |
| 6333 | 6333 | |
| 6334 | 6334 | ir_set_cursor_at_end_and_append_block(ag, body_block); |
| 6335 | IrInstSrc *elem_ptr = ir_build_elem_ptr(ag, &spill_scope->base, node, array_val_ptr, index_val, | |
| 6335 | Stage1ZirInst *elem_ptr = ir_build_elem_ptr(ag, &spill_scope->base, node, array_val_ptr, index_val, | |
| 6336 | 6336 | false, PtrLenSingle, nullptr); |
| 6337 | 6337 | // TODO make it an error to write to element variable or i variable. |
| 6338 | 6338 | Buf *elem_var_name = node_identifier_buf(elem_node); |
| 6339 | 6339 | ZigVar *elem_var = ir_create_var(ag, elem_node, parent_scope, elem_var_name, true, false, false, is_comptime); |
| 6340 | 6340 | Scope *child_scope = elem_var->child_scope; |
| 6341 | 6341 | |
| 6342 | IrInstSrc *elem_value = node->data.for_expr.elem_is_ptr ? | |
| 6342 | Stage1ZirInst *elem_value = node->data.for_expr.elem_is_ptr ? | |
| 6343 | 6343 | elem_ptr : ir_build_load_ptr(ag, &spill_scope->base, elem_node, elem_ptr); |
| 6344 | 6344 | build_decl_var_and_init(ag, parent_scope, elem_node, elem_var, elem_value, buf_ptr(elem_var_name), is_comptime); |
| 6345 | 6345 | |
| 6346 | 6346 | if (is_duplicate_label(ag->codegen, child_scope, node, node->data.for_expr.name)) |
| 6347 | 6347 | return ag->codegen->invalid_inst_src; |
| 6348 | 6348 | |
| 6349 | ZigList<IrInstSrc *> incoming_values = {0}; | |
| 6349 | ZigList<Stage1ZirInst *> incoming_values = {0}; | |
| 6350 | 6350 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 6351 | 6351 | ScopeLoop *loop_scope = create_loop_scope(ag->codegen, node, child_scope); |
| 6352 | 6352 | loop_scope->break_block = end_block; |
| ... | ... | @@ -6361,7 +6361,7 @@ static IrInstSrc *astgen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6361 | 6361 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 6362 | 6362 | // it's actually in break statements, handled similarly to return statements. |
| 6363 | 6363 | // That is why we set those values in loop_scope above and not in this astgen_node call. |
| 6364 | IrInstSrc *body_result = astgen_node(ag, body_node, &loop_scope->base); | |
| 6364 | Stage1ZirInst *body_result = astgen_node(ag, body_node, &loop_scope->base); | |
| 6365 | 6365 | if (body_result == ag->codegen->invalid_inst_src) |
| 6366 | 6366 | return ag->codegen->invalid_inst_src; |
| 6367 | 6367 | |
| ... | ... | @@ -6375,11 +6375,11 @@ static IrInstSrc *astgen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6375 | 6375 | } |
| 6376 | 6376 | |
| 6377 | 6377 | ir_set_cursor_at_end_and_append_block(ag, continue_block); |
| 6378 | IrInstSrc *new_index_val = ir_build_bin_op(ag, child_scope, node, IrBinOpAdd, index_val, one, false); | |
| 6378 | Stage1ZirInst *new_index_val = ir_build_bin_op(ag, child_scope, node, IrBinOpAdd, index_val, one, false); | |
| 6379 | 6379 | ir_build_store_ptr(ag, child_scope, node, index_ptr, new_index_val)->allow_write_through_const = true; |
| 6380 | 6380 | ir_build_br(ag, child_scope, node, cond_block, is_comptime); |
| 6381 | 6381 | |
| 6382 | IrInstSrc *else_result = nullptr; | |
| 6382 | Stage1ZirInst *else_result = nullptr; | |
| 6383 | 6383 | if (else_node) { |
| 6384 | 6384 | ir_set_cursor_at_end_and_append_block(ag, else_block); |
| 6385 | 6385 | |
| ... | ... | @@ -6408,17 +6408,17 @@ static IrInstSrc *astgen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6408 | 6408 | peer_parent->peers.last()->next_bb = end_block; |
| 6409 | 6409 | } |
| 6410 | 6410 | |
| 6411 | IrInstSrc *phi = ir_build_phi(ag, parent_scope, node, incoming_blocks.length, | |
| 6411 | Stage1ZirInst *phi = ir_build_phi(ag, parent_scope, node, incoming_blocks.length, | |
| 6412 | 6412 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 6413 | 6413 | return ir_lval_wrap(ag, parent_scope, phi, lval, result_loc); |
| 6414 | 6414 | } |
| 6415 | 6415 | |
| 6416 | static IrInstSrc *astgen_bool_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6416 | static Stage1ZirInst *astgen_bool_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6417 | 6417 | assert(node->type == NodeTypeBoolLiteral); |
| 6418 | 6418 | return ir_build_const_bool(ag, scope, node, node->data.bool_literal.value); |
| 6419 | 6419 | } |
| 6420 | 6420 | |
| 6421 | static IrInstSrc *astgen_enum_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6421 | static Stage1ZirInst *astgen_enum_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6422 | 6422 | assert(node->type == NodeTypeEnumLiteral); |
| 6423 | 6423 | // Currently, stage1 runs astgen for every comptime function call, |
| 6424 | 6424 | // resulting the allocation here wasting memory. As a workaround until |
| ... | ... | @@ -6431,7 +6431,7 @@ static IrInstSrc *astgen_enum_literal(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 6431 | 6431 | return ir_build_const_enum_literal(ag, scope, node, node->data.enum_literal.name); |
| 6432 | 6432 | } |
| 6433 | 6433 | |
| 6434 | static IrInstSrc *astgen_string_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6434 | static Stage1ZirInst *astgen_string_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6435 | 6435 | Error err; |
| 6436 | 6436 | assert(node->type == NodeTypeStringLiteral); |
| 6437 | 6437 | |
| ... | ... | @@ -6473,7 +6473,7 @@ static IrInstSrc *astgen_string_literal(Stage1AstGen *ag, Scope *scope, AstNode |
| 6473 | 6473 | return ir_build_const_str_lit(ag, scope, node, str); |
| 6474 | 6474 | } |
| 6475 | 6475 | |
| 6476 | static IrInstSrc *astgen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6476 | static Stage1ZirInst *astgen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6477 | 6477 | assert(node->type == NodeTypeArrayType); |
| 6478 | 6478 | |
| 6479 | 6479 | AstNode *size_node = node->data.array_type.size; |
| ... | ... | @@ -6486,7 +6486,7 @@ static IrInstSrc *astgen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6486 | 6486 | |
| 6487 | 6487 | Scope *comptime_scope = create_comptime_scope(ag->codegen, node, scope); |
| 6488 | 6488 | |
| 6489 | IrInstSrc *sentinel; | |
| 6489 | Stage1ZirInst *sentinel; | |
| 6490 | 6490 | if (sentinel_expr != nullptr) { |
| 6491 | 6491 | sentinel = astgen_node(ag, sentinel_expr, comptime_scope); |
| 6492 | 6492 | if (sentinel == ag->codegen->invalid_inst_src) |
| ... | ... | @@ -6513,17 +6513,17 @@ static IrInstSrc *astgen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6513 | 6513 | return ag->codegen->invalid_inst_src; |
| 6514 | 6514 | } |
| 6515 | 6515 | |
| 6516 | IrInstSrc *size_value = astgen_node(ag, size_node, comptime_scope); | |
| 6516 | Stage1ZirInst *size_value = astgen_node(ag, size_node, comptime_scope); | |
| 6517 | 6517 | if (size_value == ag->codegen->invalid_inst_src) |
| 6518 | 6518 | return size_value; |
| 6519 | 6519 | |
| 6520 | IrInstSrc *child_type = astgen_node(ag, child_type_node, comptime_scope); | |
| 6520 | Stage1ZirInst *child_type = astgen_node(ag, child_type_node, comptime_scope); | |
| 6521 | 6521 | if (child_type == ag->codegen->invalid_inst_src) |
| 6522 | 6522 | return child_type; |
| 6523 | 6523 | |
| 6524 | 6524 | return ir_build_array_type(ag, scope, node, size_value, sentinel, child_type); |
| 6525 | 6525 | } else { |
| 6526 | IrInstSrc *align_value; | |
| 6526 | Stage1ZirInst *align_value; | |
| 6527 | 6527 | if (align_expr != nullptr) { |
| 6528 | 6528 | align_value = astgen_node(ag, align_expr, comptime_scope); |
| 6529 | 6529 | if (align_value == ag->codegen->invalid_inst_src) |
| ... | ... | @@ -6532,7 +6532,7 @@ static IrInstSrc *astgen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6532 | 6532 | align_value = nullptr; |
| 6533 | 6533 | } |
| 6534 | 6534 | |
| 6535 | IrInstSrc *child_type = astgen_node(ag, child_type_node, comptime_scope); | |
| 6535 | Stage1ZirInst *child_type = astgen_node(ag, child_type_node, comptime_scope); | |
| 6536 | 6536 | if (child_type == ag->codegen->invalid_inst_src) |
| 6537 | 6537 | return child_type; |
| 6538 | 6538 | |
| ... | ... | @@ -6541,11 +6541,11 @@ static IrInstSrc *astgen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6541 | 6541 | } |
| 6542 | 6542 | } |
| 6543 | 6543 | |
| 6544 | static IrInstSrc *astgen_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6544 | static Stage1ZirInst *astgen_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6545 | 6545 | assert(node->type == NodeTypeAnyFrameType); |
| 6546 | 6546 | |
| 6547 | 6547 | AstNode *payload_type_node = node->data.anyframe_type.payload_type; |
| 6548 | IrInstSrc *payload_type_value = nullptr; | |
| 6548 | Stage1ZirInst *payload_type_value = nullptr; | |
| 6549 | 6549 | |
| 6550 | 6550 | if (payload_type_node != nullptr) { |
| 6551 | 6551 | payload_type_value = astgen_node(ag, payload_type_node, scope); |
| ... | ... | @@ -6557,16 +6557,16 @@ static IrInstSrc *astgen_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode * |
| 6557 | 6557 | return ir_build_anyframe_type(ag, scope, node, payload_type_value); |
| 6558 | 6558 | } |
| 6559 | 6559 | |
| 6560 | static IrInstSrc *astgen_undefined_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6560 | static Stage1ZirInst *astgen_undefined_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6561 | 6561 | assert(node->type == NodeTypeUndefinedLiteral); |
| 6562 | 6562 | return ir_build_const_undefined(ag, scope, node); |
| 6563 | 6563 | } |
| 6564 | 6564 | |
| 6565 | static IrInstSrc *astgen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6565 | static Stage1ZirInst *astgen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 6566 | 6566 | assert(node->type == NodeTypeAsmExpr); |
| 6567 | 6567 | AstNodeAsmExpr *asm_expr = &node->data.asm_expr; |
| 6568 | 6568 | |
| 6569 | IrInstSrc *asm_template = astgen_node(ag, asm_expr->asm_template, scope); | |
| 6569 | Stage1ZirInst *asm_template = astgen_node(ag, asm_expr->asm_template, scope); | |
| 6570 | 6570 | if (asm_template == ag->codegen->invalid_inst_src) |
| 6571 | 6571 | return ag->codegen->invalid_inst_src; |
| 6572 | 6572 | |
| ... | ... | @@ -6592,8 +6592,8 @@ static IrInstSrc *astgen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 6592 | 6592 | nullptr, 0, is_volatile, true); |
| 6593 | 6593 | } |
| 6594 | 6594 | |
| 6595 | IrInstSrc **input_list = heap::c_allocator.allocate<IrInstSrc *>(asm_expr->input_list.length); | |
| 6596 | IrInstSrc **output_types = heap::c_allocator.allocate<IrInstSrc *>(asm_expr->output_list.length); | |
| 6595 | Stage1ZirInst **input_list = heap::c_allocator.allocate<Stage1ZirInst *>(asm_expr->input_list.length); | |
| 6596 | Stage1ZirInst **output_types = heap::c_allocator.allocate<Stage1ZirInst *>(asm_expr->output_list.length); | |
| 6597 | 6597 | ZigVar **output_vars = heap::c_allocator.allocate<ZigVar *>(asm_expr->output_list.length); |
| 6598 | 6598 | size_t return_count = 0; |
| 6599 | 6599 | if (!is_volatile && asm_expr->output_list.length == 0) { |
| ... | ... | @@ -6606,7 +6606,7 @@ static IrInstSrc *astgen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 6606 | 6606 | if (asm_output->return_type) { |
| 6607 | 6607 | return_count += 1; |
| 6608 | 6608 | |
| 6609 | IrInstSrc *return_type = astgen_node(ag, asm_output->return_type, scope); | |
| 6609 | Stage1ZirInst *return_type = astgen_node(ag, asm_output->return_type, scope); | |
| 6610 | 6610 | if (return_type == ag->codegen->invalid_inst_src) |
| 6611 | 6611 | return ag->codegen->invalid_inst_src; |
| 6612 | 6612 | if (return_count > 1) { |
| ... | ... | @@ -6640,7 +6640,7 @@ static IrInstSrc *astgen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 6640 | 6640 | } |
| 6641 | 6641 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { |
| 6642 | 6642 | AsmInput *asm_input = asm_expr->input_list.at(i); |
| 6643 | IrInstSrc *input_value = astgen_node(ag, asm_input->expr, scope); | |
| 6643 | Stage1ZirInst *input_value = astgen_node(ag, asm_input->expr, scope); | |
| 6644 | 6644 | if (input_value == ag->codegen->invalid_inst_src) |
| 6645 | 6645 | return ag->codegen->invalid_inst_src; |
| 6646 | 6646 | |
| ... | ... | @@ -6651,7 +6651,7 @@ static IrInstSrc *astgen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 6651 | 6651 | output_vars, return_count, is_volatile, false); |
| 6652 | 6652 | } |
| 6653 | 6653 | |
| 6654 | static IrInstSrc *astgen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 6654 | static Stage1ZirInst *astgen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 6655 | 6655 | ResultLoc *result_loc) |
| 6656 | 6656 | { |
| 6657 | 6657 | assert(node->type == NodeTypeIfOptional); |
| ... | ... | @@ -6665,24 +6665,24 @@ static IrInstSrc *astgen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6665 | 6665 | ScopeExpr *spill_scope = create_expr_scope(ag->codegen, expr_node, scope); |
| 6666 | 6666 | spill_scope->spill_harder = true; |
| 6667 | 6667 | |
| 6668 | IrInstSrc *maybe_val_ptr = astgen_node_extra(ag, expr_node, &spill_scope->base, LValPtr, nullptr); | |
| 6668 | Stage1ZirInst *maybe_val_ptr = astgen_node_extra(ag, expr_node, &spill_scope->base, LValPtr, nullptr); | |
| 6669 | 6669 | if (maybe_val_ptr == ag->codegen->invalid_inst_src) |
| 6670 | 6670 | return maybe_val_ptr; |
| 6671 | 6671 | |
| 6672 | IrInstSrc *maybe_val = ir_build_load_ptr(ag, scope, node, maybe_val_ptr); | |
| 6673 | IrInstSrc *is_non_null = ir_build_test_non_null_src(ag, scope, node, maybe_val); | |
| 6672 | Stage1ZirInst *maybe_val = ir_build_load_ptr(ag, scope, node, maybe_val_ptr); | |
| 6673 | Stage1ZirInst *is_non_null = ir_build_test_non_null_src(ag, scope, node, maybe_val); | |
| 6674 | 6674 | |
| 6675 | 6675 | Stage1ZirBasicBlock *then_block = ir_create_basic_block(ag, scope, "OptionalThen"); |
| 6676 | 6676 | Stage1ZirBasicBlock *else_block = ir_create_basic_block(ag, scope, "OptionalElse"); |
| 6677 | 6677 | Stage1ZirBasicBlock *endif_block = ir_create_basic_block(ag, scope, "OptionalEndIf"); |
| 6678 | 6678 | |
| 6679 | IrInstSrc *is_comptime; | |
| 6679 | Stage1ZirInst *is_comptime; | |
| 6680 | 6680 | if (ir_should_inline(ag->exec, scope)) { |
| 6681 | 6681 | is_comptime = ir_build_const_bool(ag, scope, node, true); |
| 6682 | 6682 | } else { |
| 6683 | 6683 | is_comptime = ir_build_test_comptime(ag, scope, node, is_non_null); |
| 6684 | 6684 | } |
| 6685 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, scope, node, is_non_null, | |
| 6685 | Stage1ZirInst *cond_br_inst = ir_build_cond_br(ag, scope, node, is_non_null, | |
| 6686 | 6686 | then_block, else_block, is_comptime); |
| 6687 | 6687 | |
| 6688 | 6688 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(ag, cond_br_inst, else_block, endif_block, |
| ... | ... | @@ -6698,15 +6698,15 @@ static IrInstSrc *astgen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6698 | 6698 | ZigVar *var = ir_create_var(ag, node, subexpr_scope, |
| 6699 | 6699 | var_symbol, is_const, is_const, is_shadowable, is_comptime); |
| 6700 | 6700 | |
| 6701 | IrInstSrc *payload_ptr = ir_build_optional_unwrap_ptr(ag, subexpr_scope, node, maybe_val_ptr, false); | |
| 6702 | IrInstSrc *var_value = var_is_ptr ? | |
| 6701 | Stage1ZirInst *payload_ptr = ir_build_optional_unwrap_ptr(ag, subexpr_scope, node, maybe_val_ptr, false); | |
| 6702 | Stage1ZirInst *var_value = var_is_ptr ? | |
| 6703 | 6703 | payload_ptr : ir_build_load_ptr(ag, &spill_scope->base, node, payload_ptr); |
| 6704 | 6704 | build_decl_var_and_init(ag, subexpr_scope, node, var, var_value, buf_ptr(var_symbol), is_comptime); |
| 6705 | 6705 | var_scope = var->child_scope; |
| 6706 | 6706 | } else { |
| 6707 | 6707 | var_scope = subexpr_scope; |
| 6708 | 6708 | } |
| 6709 | IrInstSrc *then_expr_result = astgen_node_extra(ag, then_node, var_scope, lval, | |
| 6709 | Stage1ZirInst *then_expr_result = astgen_node_extra(ag, then_node, var_scope, lval, | |
| 6710 | 6710 | &peer_parent->peers.at(0)->base); |
| 6711 | 6711 | if (then_expr_result == ag->codegen->invalid_inst_src) |
| 6712 | 6712 | return then_expr_result; |
| ... | ... | @@ -6715,7 +6715,7 @@ static IrInstSrc *astgen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6715 | 6715 | ir_build_br(ag, scope, node, endif_block, is_comptime); |
| 6716 | 6716 | |
| 6717 | 6717 | ir_set_cursor_at_end_and_append_block(ag, else_block); |
| 6718 | IrInstSrc *else_expr_result; | |
| 6718 | Stage1ZirInst *else_expr_result; | |
| 6719 | 6719 | if (else_node) { |
| 6720 | 6720 | else_expr_result = astgen_node_extra(ag, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); |
| 6721 | 6721 | if (else_expr_result == ag->codegen->invalid_inst_src) |
| ... | ... | @@ -6729,18 +6729,18 @@ static IrInstSrc *astgen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6729 | 6729 | ir_build_br(ag, scope, node, endif_block, is_comptime); |
| 6730 | 6730 | |
| 6731 | 6731 | ir_set_cursor_at_end_and_append_block(ag, endif_block); |
| 6732 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | |
| 6732 | Stage1ZirInst **incoming_values = heap::c_allocator.allocate<Stage1ZirInst *>(2); | |
| 6733 | 6733 | incoming_values[0] = then_expr_result; |
| 6734 | 6734 | incoming_values[1] = else_expr_result; |
| 6735 | 6735 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 6736 | 6736 | incoming_blocks[0] = after_then_block; |
| 6737 | 6737 | incoming_blocks[1] = after_else_block; |
| 6738 | 6738 | |
| 6739 | IrInstSrc *phi = ir_build_phi(ag, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | |
| 6739 | Stage1ZirInst *phi = ir_build_phi(ag, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | |
| 6740 | 6740 | return ir_expr_wrap(ag, scope, phi, result_loc); |
| 6741 | 6741 | } |
| 6742 | 6742 | |
| 6743 | static IrInstSrc *astgen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 6743 | static Stage1ZirInst *astgen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 6744 | 6744 | ResultLoc *result_loc) |
| 6745 | 6745 | { |
| 6746 | 6746 | assert(node->type == NodeTypeIfErrorExpr); |
| ... | ... | @@ -6753,20 +6753,20 @@ static IrInstSrc *astgen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6753 | 6753 | Buf *var_symbol = node->data.if_err_expr.var_symbol; |
| 6754 | 6754 | Buf *err_symbol = node->data.if_err_expr.err_symbol; |
| 6755 | 6755 | |
| 6756 | IrInstSrc *err_val_ptr = astgen_node_extra(ag, target_node, scope, LValPtr, nullptr); | |
| 6756 | Stage1ZirInst *err_val_ptr = astgen_node_extra(ag, target_node, scope, LValPtr, nullptr); | |
| 6757 | 6757 | if (err_val_ptr == ag->codegen->invalid_inst_src) |
| 6758 | 6758 | return err_val_ptr; |
| 6759 | 6759 | |
| 6760 | IrInstSrc *err_val = ir_build_load_ptr(ag, scope, node, err_val_ptr); | |
| 6761 | IrInstSrc *is_err = ir_build_test_err_src(ag, scope, node, err_val_ptr, true, false); | |
| 6760 | Stage1ZirInst *err_val = ir_build_load_ptr(ag, scope, node, err_val_ptr); | |
| 6761 | Stage1ZirInst *is_err = ir_build_test_err_src(ag, scope, node, err_val_ptr, true, false); | |
| 6762 | 6762 | |
| 6763 | 6763 | Stage1ZirBasicBlock *ok_block = ir_create_basic_block(ag, scope, "TryOk"); |
| 6764 | 6764 | Stage1ZirBasicBlock *else_block = ir_create_basic_block(ag, scope, "TryElse"); |
| 6765 | 6765 | Stage1ZirBasicBlock *endif_block = ir_create_basic_block(ag, scope, "TryEnd"); |
| 6766 | 6766 | |
| 6767 | 6767 | bool force_comptime = ir_should_inline(ag->exec, scope); |
| 6768 | IrInstSrc *is_comptime = force_comptime ? ir_build_const_bool(ag, scope, node, true) : ir_build_test_comptime(ag, scope, node, is_err); | |
| 6769 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, scope, node, is_err, else_block, ok_block, is_comptime); | |
| 6768 | Stage1ZirInst *is_comptime = force_comptime ? ir_build_const_bool(ag, scope, node, true) : ir_build_test_comptime(ag, scope, node, is_err); | |
| 6769 | Stage1ZirInst *cond_br_inst = ir_build_cond_br(ag, scope, node, is_err, else_block, ok_block, is_comptime); | |
| 6770 | 6770 | |
| 6771 | 6771 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(ag, cond_br_inst, else_block, endif_block, |
| 6772 | 6772 | result_loc, is_comptime); |
| ... | ... | @@ -6777,19 +6777,19 @@ static IrInstSrc *astgen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6777 | 6777 | Scope *var_scope; |
| 6778 | 6778 | if (var_symbol) { |
| 6779 | 6779 | bool is_shadowable = false; |
| 6780 | IrInstSrc *var_is_comptime = force_comptime ? ir_build_const_bool(ag, subexpr_scope, node, true) : ir_build_test_comptime(ag, subexpr_scope, node, err_val); | |
| 6780 | Stage1ZirInst *var_is_comptime = force_comptime ? ir_build_const_bool(ag, subexpr_scope, node, true) : ir_build_test_comptime(ag, subexpr_scope, node, err_val); | |
| 6781 | 6781 | ZigVar *var = ir_create_var(ag, node, subexpr_scope, |
| 6782 | 6782 | var_symbol, var_is_const, var_is_const, is_shadowable, var_is_comptime); |
| 6783 | 6783 | |
| 6784 | IrInstSrc *payload_ptr = ir_build_unwrap_err_payload_src(ag, subexpr_scope, node, err_val_ptr, false, false); | |
| 6785 | IrInstSrc *var_value = var_is_ptr ? | |
| 6784 | Stage1ZirInst *payload_ptr = ir_build_unwrap_err_payload_src(ag, subexpr_scope, node, err_val_ptr, false, false); | |
| 6785 | Stage1ZirInst *var_value = var_is_ptr ? | |
| 6786 | 6786 | payload_ptr : ir_build_load_ptr(ag, subexpr_scope, node, payload_ptr); |
| 6787 | 6787 | build_decl_var_and_init(ag, subexpr_scope, node, var, var_value, buf_ptr(var_symbol), var_is_comptime); |
| 6788 | 6788 | var_scope = var->child_scope; |
| 6789 | 6789 | } else { |
| 6790 | 6790 | var_scope = subexpr_scope; |
| 6791 | 6791 | } |
| 6792 | IrInstSrc *then_expr_result = astgen_node_extra(ag, then_node, var_scope, lval, | |
| 6792 | Stage1ZirInst *then_expr_result = astgen_node_extra(ag, then_node, var_scope, lval, | |
| 6793 | 6793 | &peer_parent->peers.at(0)->base); |
| 6794 | 6794 | if (then_expr_result == ag->codegen->invalid_inst_src) |
| 6795 | 6795 | return then_expr_result; |
| ... | ... | @@ -6799,7 +6799,7 @@ static IrInstSrc *astgen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6799 | 6799 | |
| 6800 | 6800 | ir_set_cursor_at_end_and_append_block(ag, else_block); |
| 6801 | 6801 | |
| 6802 | IrInstSrc *else_expr_result; | |
| 6802 | Stage1ZirInst *else_expr_result; | |
| 6803 | 6803 | if (else_node) { |
| 6804 | 6804 | Scope *err_var_scope; |
| 6805 | 6805 | if (err_symbol) { |
| ... | ... | @@ -6808,8 +6808,8 @@ static IrInstSrc *astgen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6808 | 6808 | ZigVar *var = ir_create_var(ag, node, subexpr_scope, |
| 6809 | 6809 | err_symbol, is_const, is_const, is_shadowable, is_comptime); |
| 6810 | 6810 | |
| 6811 | IrInstSrc *err_ptr = ir_build_unwrap_err_code_src(ag, subexpr_scope, node, err_val_ptr); | |
| 6812 | IrInstSrc *err_value = ir_build_load_ptr(ag, subexpr_scope, node, err_ptr); | |
| 6811 | Stage1ZirInst *err_ptr = ir_build_unwrap_err_code_src(ag, subexpr_scope, node, err_val_ptr); | |
| 6812 | Stage1ZirInst *err_value = ir_build_load_ptr(ag, subexpr_scope, node, err_ptr); | |
| 6813 | 6813 | build_decl_var_and_init(ag, subexpr_scope, node, var, err_value, buf_ptr(err_symbol), is_comptime); |
| 6814 | 6814 | err_var_scope = var->child_scope; |
| 6815 | 6815 | } else { |
| ... | ... | @@ -6827,22 +6827,22 @@ static IrInstSrc *astgen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6827 | 6827 | ir_build_br(ag, scope, node, endif_block, is_comptime); |
| 6828 | 6828 | |
| 6829 | 6829 | ir_set_cursor_at_end_and_append_block(ag, endif_block); |
| 6830 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | |
| 6830 | Stage1ZirInst **incoming_values = heap::c_allocator.allocate<Stage1ZirInst *>(2); | |
| 6831 | 6831 | incoming_values[0] = then_expr_result; |
| 6832 | 6832 | incoming_values[1] = else_expr_result; |
| 6833 | 6833 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 6834 | 6834 | incoming_blocks[0] = after_then_block; |
| 6835 | 6835 | incoming_blocks[1] = after_else_block; |
| 6836 | 6836 | |
| 6837 | IrInstSrc *phi = ir_build_phi(ag, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | |
| 6837 | Stage1ZirInst *phi = ir_build_phi(ag, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | |
| 6838 | 6838 | return ir_expr_wrap(ag, scope, phi, result_loc); |
| 6839 | 6839 | } |
| 6840 | 6840 | |
| 6841 | 6841 | static bool astgen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *switch_node, AstNode *prong_node, |
| 6842 | Stage1ZirBasicBlock *end_block, IrInstSrc *is_comptime, IrInstSrc *var_is_comptime, | |
| 6843 | IrInstSrc *target_value_ptr, IrInstSrc **prong_values, size_t prong_values_len, | |
| 6844 | ZigList<Stage1ZirBasicBlock *> *incoming_blocks, ZigList<IrInstSrc *> *incoming_values, | |
| 6845 | IrInstSrcSwitchElseVar **out_switch_else_var, LVal lval, ResultLoc *result_loc) | |
| 6842 | Stage1ZirBasicBlock *end_block, Stage1ZirInst *is_comptime, Stage1ZirInst *var_is_comptime, | |
| 6843 | Stage1ZirInst *target_value_ptr, Stage1ZirInst **prong_values, size_t prong_values_len, | |
| 6844 | ZigList<Stage1ZirBasicBlock *> *incoming_blocks, ZigList<Stage1ZirInst *> *incoming_values, | |
| 6845 | Stage1ZirInstSwitchElseVar **out_switch_else_var, LVal lval, ResultLoc *result_loc) | |
| 6846 | 6846 | { |
| 6847 | 6847 | assert(switch_node->type == NodeTypeSwitchExpr); |
| 6848 | 6848 | assert(prong_node->type == NodeTypeSwitchProng); |
| ... | ... | @@ -6860,16 +6860,16 @@ static bool astgen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *sw |
| 6860 | 6860 | ZigVar *var = ir_create_var(ag, var_symbol_node, scope, |
| 6861 | 6861 | var_name, is_const, is_const, is_shadowable, var_is_comptime); |
| 6862 | 6862 | child_scope = var->child_scope; |
| 6863 | IrInstSrc *var_value; | |
| 6863 | Stage1ZirInst *var_value; | |
| 6864 | 6864 | if (out_switch_else_var != nullptr) { |
| 6865 | IrInstSrcSwitchElseVar *switch_else_var = ir_build_switch_else_var(ag, scope, var_symbol_node, | |
| 6865 | Stage1ZirInstSwitchElseVar *switch_else_var = ir_build_switch_else_var(ag, scope, var_symbol_node, | |
| 6866 | 6866 | target_value_ptr); |
| 6867 | 6867 | *out_switch_else_var = switch_else_var; |
| 6868 | IrInstSrc *payload_ptr = &switch_else_var->base; | |
| 6868 | Stage1ZirInst *payload_ptr = &switch_else_var->base; | |
| 6869 | 6869 | var_value = var_is_ptr ? |
| 6870 | 6870 | payload_ptr : ir_build_load_ptr(ag, scope, var_symbol_node, payload_ptr); |
| 6871 | 6871 | } else if (prong_values != nullptr) { |
| 6872 | IrInstSrc *payload_ptr = ir_build_switch_var(ag, scope, var_symbol_node, target_value_ptr, | |
| 6872 | Stage1ZirInst *payload_ptr = ir_build_switch_var(ag, scope, var_symbol_node, target_value_ptr, | |
| 6873 | 6873 | prong_values, prong_values_len); |
| 6874 | 6874 | var_value = var_is_ptr ? |
| 6875 | 6875 | payload_ptr : ir_build_load_ptr(ag, scope, var_symbol_node, payload_ptr); |
| ... | ... | @@ -6882,7 +6882,7 @@ static bool astgen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *sw |
| 6882 | 6882 | child_scope = scope; |
| 6883 | 6883 | } |
| 6884 | 6884 | |
| 6885 | IrInstSrc *expr_result = astgen_node_extra(ag, expr_node, child_scope, lval, result_loc); | |
| 6885 | Stage1ZirInst *expr_result = astgen_node_extra(ag, expr_node, child_scope, lval, result_loc); | |
| 6886 | 6886 | if (expr_result == ag->codegen->invalid_inst_src) |
| 6887 | 6887 | return false; |
| 6888 | 6888 | if (!instr_is_unreachable(expr_result)) |
| ... | ... | @@ -6892,25 +6892,25 @@ static bool astgen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *sw |
| 6892 | 6892 | return true; |
| 6893 | 6893 | } |
| 6894 | 6894 | |
| 6895 | static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 6895 | static Stage1ZirInst *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 6896 | 6896 | ResultLoc *result_loc) |
| 6897 | 6897 | { |
| 6898 | 6898 | assert(node->type == NodeTypeSwitchExpr); |
| 6899 | 6899 | |
| 6900 | 6900 | AstNode *target_node = node->data.switch_expr.expr; |
| 6901 | IrInstSrc *target_value_ptr = astgen_node_extra(ag, target_node, scope, LValPtr, nullptr); | |
| 6901 | Stage1ZirInst *target_value_ptr = astgen_node_extra(ag, target_node, scope, LValPtr, nullptr); | |
| 6902 | 6902 | if (target_value_ptr == ag->codegen->invalid_inst_src) |
| 6903 | 6903 | return target_value_ptr; |
| 6904 | IrInstSrc *target_value = ir_build_switch_target(ag, scope, node, target_value_ptr); | |
| 6904 | Stage1ZirInst *target_value = ir_build_switch_target(ag, scope, node, target_value_ptr); | |
| 6905 | 6905 | |
| 6906 | 6906 | Stage1ZirBasicBlock *else_block = ir_create_basic_block(ag, scope, "SwitchElse"); |
| 6907 | 6907 | Stage1ZirBasicBlock *end_block = ir_create_basic_block(ag, scope, "SwitchEnd"); |
| 6908 | 6908 | |
| 6909 | 6909 | size_t prong_count = node->data.switch_expr.prongs.length; |
| 6910 | ZigList<IrInstSrcSwitchBrCase> cases = {0}; | |
| 6910 | ZigList<Stage1ZirInstSwitchBrCase> cases = {0}; | |
| 6911 | 6911 | |
| 6912 | IrInstSrc *is_comptime; | |
| 6913 | IrInstSrc *var_is_comptime; | |
| 6912 | Stage1ZirInst *is_comptime; | |
| 6913 | Stage1ZirInst *var_is_comptime; | |
| 6914 | 6914 | if (ir_should_inline(ag->exec, scope)) { |
| 6915 | 6915 | is_comptime = ir_build_const_bool(ag, scope, node, true); |
| 6916 | 6916 | var_is_comptime = is_comptime; |
| ... | ... | @@ -6919,11 +6919,11 @@ static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6919 | 6919 | var_is_comptime = ir_build_test_comptime(ag, scope, node, target_value_ptr); |
| 6920 | 6920 | } |
| 6921 | 6921 | |
| 6922 | ZigList<IrInstSrc *> incoming_values = {0}; | |
| 6922 | ZigList<Stage1ZirInst *> incoming_values = {0}; | |
| 6923 | 6923 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 6924 | ZigList<IrInstSrcCheckSwitchProngsRange> check_ranges = {0}; | |
| 6924 | ZigList<Stage1ZirInstCheckSwitchProngsRange> check_ranges = {0}; | |
| 6925 | 6925 | |
| 6926 | IrInstSrcSwitchElseVar *switch_else_var = nullptr; | |
| 6926 | Stage1ZirInstSwitchElseVar *switch_else_var = nullptr; | |
| 6927 | 6927 | |
| 6928 | 6928 | ResultLocPeerParent *peer_parent = heap::c_allocator.create<ResultLocPeerParent>(); |
| 6929 | 6929 | peer_parent->base.id = ResultLocIdPeerParent; |
| ... | ... | @@ -6945,7 +6945,7 @@ static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6945 | 6945 | if (prong_node->data.switch_prong.any_items_are_range) { |
| 6946 | 6946 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); |
| 6947 | 6947 | |
| 6948 | IrInstSrc *ok_bit = nullptr; | |
| 6948 | Stage1ZirInst *ok_bit = nullptr; | |
| 6949 | 6949 | AstNode *last_item_node = nullptr; |
| 6950 | 6950 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { |
| 6951 | 6951 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); |
| ... | ... | @@ -6954,23 +6954,23 @@ static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6954 | 6954 | AstNode *start_node = item_node->data.switch_range.start; |
| 6955 | 6955 | AstNode *end_node = item_node->data.switch_range.end; |
| 6956 | 6956 | |
| 6957 | IrInstSrc *start_value = astgen_node(ag, start_node, comptime_scope); | |
| 6957 | Stage1ZirInst *start_value = astgen_node(ag, start_node, comptime_scope); | |
| 6958 | 6958 | if (start_value == ag->codegen->invalid_inst_src) |
| 6959 | 6959 | return ag->codegen->invalid_inst_src; |
| 6960 | 6960 | |
| 6961 | IrInstSrc *end_value = astgen_node(ag, end_node, comptime_scope); | |
| 6961 | Stage1ZirInst *end_value = astgen_node(ag, end_node, comptime_scope); | |
| 6962 | 6962 | if (end_value == ag->codegen->invalid_inst_src) |
| 6963 | 6963 | return ag->codegen->invalid_inst_src; |
| 6964 | 6964 | |
| 6965 | IrInstSrcCheckSwitchProngsRange *check_range = check_ranges.add_one(); | |
| 6965 | Stage1ZirInstCheckSwitchProngsRange *check_range = check_ranges.add_one(); | |
| 6966 | 6966 | check_range->start = start_value; |
| 6967 | 6967 | check_range->end = end_value; |
| 6968 | 6968 | |
| 6969 | IrInstSrc *lower_range_ok = ir_build_bin_op(ag, scope, item_node, IrBinOpCmpGreaterOrEq, | |
| 6969 | Stage1ZirInst *lower_range_ok = ir_build_bin_op(ag, scope, item_node, IrBinOpCmpGreaterOrEq, | |
| 6970 | 6970 | target_value, start_value, false); |
| 6971 | IrInstSrc *upper_range_ok = ir_build_bin_op(ag, scope, item_node, IrBinOpCmpLessOrEq, | |
| 6971 | Stage1ZirInst *upper_range_ok = ir_build_bin_op(ag, scope, item_node, IrBinOpCmpLessOrEq, | |
| 6972 | 6972 | target_value, end_value, false); |
| 6973 | IrInstSrc *both_ok = ir_build_bin_op(ag, scope, item_node, IrBinOpBoolAnd, | |
| 6973 | Stage1ZirInst *both_ok = ir_build_bin_op(ag, scope, item_node, IrBinOpBoolAnd, | |
| 6974 | 6974 | lower_range_ok, upper_range_ok, false); |
| 6975 | 6975 | if (ok_bit) { |
| 6976 | 6976 | ok_bit = ir_build_bin_op(ag, scope, item_node, IrBinOpBoolOr, both_ok, ok_bit, false); |
| ... | ... | @@ -6978,15 +6978,15 @@ static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6978 | 6978 | ok_bit = both_ok; |
| 6979 | 6979 | } |
| 6980 | 6980 | } else { |
| 6981 | IrInstSrc *item_value = astgen_node(ag, item_node, comptime_scope); | |
| 6981 | Stage1ZirInst *item_value = astgen_node(ag, item_node, comptime_scope); | |
| 6982 | 6982 | if (item_value == ag->codegen->invalid_inst_src) |
| 6983 | 6983 | return ag->codegen->invalid_inst_src; |
| 6984 | 6984 | |
| 6985 | IrInstSrcCheckSwitchProngsRange *check_range = check_ranges.add_one(); | |
| 6985 | Stage1ZirInstCheckSwitchProngsRange *check_range = check_ranges.add_one(); | |
| 6986 | 6986 | check_range->start = item_value; |
| 6987 | 6987 | check_range->end = item_value; |
| 6988 | 6988 | |
| 6989 | IrInstSrc *cmp_ok = ir_build_bin_op(ag, scope, item_node, IrBinOpCmpEq, | |
| 6989 | Stage1ZirInst *cmp_ok = ir_build_bin_op(ag, scope, item_node, IrBinOpCmpEq, | |
| 6990 | 6990 | item_value, target_value, false); |
| 6991 | 6991 | if (ok_bit) { |
| 6992 | 6992 | ok_bit = ir_build_bin_op(ag, scope, item_node, IrBinOpBoolOr, cmp_ok, ok_bit, false); |
| ... | ... | @@ -7001,7 +7001,7 @@ static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7001 | 7001 | |
| 7002 | 7002 | assert(ok_bit); |
| 7003 | 7003 | assert(last_item_node); |
| 7004 | IrInstSrc *br_inst = ir_build_cond_br(ag, scope, last_item_node, ok_bit, | |
| 7004 | Stage1ZirInst *br_inst = ir_build_cond_br(ag, scope, last_item_node, ok_bit, | |
| 7005 | 7005 | range_block_yes, range_block_no, is_comptime); |
| 7006 | 7006 | if (peer_parent->base.source_instruction == nullptr) { |
| 7007 | 7007 | peer_parent->base.source_instruction = br_inst; |
| ... | ... | @@ -7087,21 +7087,21 @@ static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7087 | 7087 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); |
| 7088 | 7088 | |
| 7089 | 7089 | Stage1ZirBasicBlock *prong_block = ir_create_basic_block(ag, scope, "SwitchProng"); |
| 7090 | IrInstSrc **items = heap::c_allocator.allocate<IrInstSrc *>(prong_item_count); | |
| 7090 | Stage1ZirInst **items = heap::c_allocator.allocate<Stage1ZirInst *>(prong_item_count); | |
| 7091 | 7091 | |
| 7092 | 7092 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { |
| 7093 | 7093 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); |
| 7094 | 7094 | assert(item_node->type != NodeTypeSwitchRange); |
| 7095 | 7095 | |
| 7096 | IrInstSrc *item_value = astgen_node(ag, item_node, comptime_scope); | |
| 7096 | Stage1ZirInst *item_value = astgen_node(ag, item_node, comptime_scope); | |
| 7097 | 7097 | if (item_value == ag->codegen->invalid_inst_src) |
| 7098 | 7098 | return ag->codegen->invalid_inst_src; |
| 7099 | 7099 | |
| 7100 | IrInstSrcCheckSwitchProngsRange *check_range = check_ranges.add_one(); | |
| 7100 | Stage1ZirInstCheckSwitchProngsRange *check_range = check_ranges.add_one(); | |
| 7101 | 7101 | check_range->start = item_value; |
| 7102 | 7102 | check_range->end = item_value; |
| 7103 | 7103 | |
| 7104 | IrInstSrcSwitchBrCase *this_case = cases.add_one(); | |
| 7104 | Stage1ZirInstSwitchBrCase *this_case = cases.add_one(); | |
| 7105 | 7105 | this_case->value = item_value; |
| 7106 | 7106 | this_case->block = prong_block; |
| 7107 | 7107 | |
| ... | ... | @@ -7125,14 +7125,14 @@ static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7125 | 7125 | |
| 7126 | 7126 | } |
| 7127 | 7127 | |
| 7128 | IrInstSrc *switch_prongs_void = ir_build_check_switch_prongs(ag, scope, node, target_value, | |
| 7128 | Stage1ZirInst *switch_prongs_void = ir_build_check_switch_prongs(ag, scope, node, target_value, | |
| 7129 | 7129 | check_ranges.items, check_ranges.length, else_prong, underscore_prong != nullptr); |
| 7130 | 7130 | |
| 7131 | IrInstSrc *br_instruction; | |
| 7131 | Stage1ZirInst *br_instruction; | |
| 7132 | 7132 | if (cases.length == 0) { |
| 7133 | 7133 | br_instruction = ir_build_br(ag, scope, node, else_block, is_comptime); |
| 7134 | 7134 | } else { |
| 7135 | IrInstSrcSwitchBr *switch_br = ir_build_switch_br_src(ag, scope, node, target_value, else_block, | |
| 7135 | Stage1ZirInstSwitchBr *switch_br = ir_build_switch_br_src(ag, scope, node, target_value, else_block, | |
| 7136 | 7136 | cases.length, cases.items, is_comptime, switch_prongs_void); |
| 7137 | 7137 | if (switch_else_var != nullptr) { |
| 7138 | 7138 | switch_else_var->switch_br = switch_br; |
| ... | ... | @@ -7160,7 +7160,7 @@ static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7160 | 7160 | |
| 7161 | 7161 | ir_set_cursor_at_end_and_append_block(ag, end_block); |
| 7162 | 7162 | assert(incoming_blocks.length == incoming_values.length); |
| 7163 | IrInstSrc *result_instruction; | |
| 7163 | Stage1ZirInst *result_instruction; | |
| 7164 | 7164 | if (incoming_blocks.length == 0) { |
| 7165 | 7165 | result_instruction = ir_build_const_void(ag, scope, node); |
| 7166 | 7166 | } else { |
| ... | ... | @@ -7170,7 +7170,7 @@ static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7170 | 7170 | return ir_lval_wrap(ag, scope, result_instruction, lval, result_loc); |
| 7171 | 7171 | } |
| 7172 | 7172 | |
| 7173 | static IrInstSrc *astgen_comptime(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) { | |
| 7173 | static Stage1ZirInst *astgen_comptime(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) { | |
| 7174 | 7174 | assert(node->type == NodeTypeCompTime); |
| 7175 | 7175 | |
| 7176 | 7176 | Scope *child_scope = create_comptime_scope(ag->codegen, node, parent_scope); |
| ... | ... | @@ -7178,7 +7178,7 @@ static IrInstSrc *astgen_comptime(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7178 | 7178 | return astgen_node_extra(ag, node->data.comptime_expr.expr, child_scope, lval, nullptr); |
| 7179 | 7179 | } |
| 7180 | 7180 | |
| 7181 | static IrInstSrc *astgen_nosuspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) { | |
| 7181 | static Stage1ZirInst *astgen_nosuspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) { | |
| 7182 | 7182 | assert(node->type == NodeTypeNoSuspend); |
| 7183 | 7183 | |
| 7184 | 7184 | Scope *child_scope = create_nosuspend_scope(ag->codegen, node, parent_scope); |
| ... | ... | @@ -7186,15 +7186,15 @@ static IrInstSrc *astgen_nosuspend(Stage1AstGen *ag, Scope *parent_scope, AstNod |
| 7186 | 7186 | return astgen_node_extra(ag, node->data.nosuspend_expr.expr, child_scope, lval, nullptr); |
| 7187 | 7187 | } |
| 7188 | 7188 | |
| 7189 | static IrInstSrc *astgen_return_from_block(Stage1AstGen *ag, Scope *break_scope, AstNode *node, ScopeBlock *block_scope) { | |
| 7190 | IrInstSrc *is_comptime; | |
| 7189 | static Stage1ZirInst *astgen_return_from_block(Stage1AstGen *ag, Scope *break_scope, AstNode *node, ScopeBlock *block_scope) { | |
| 7190 | Stage1ZirInst *is_comptime; | |
| 7191 | 7191 | if (ir_should_inline(ag->exec, break_scope)) { |
| 7192 | 7192 | is_comptime = ir_build_const_bool(ag, break_scope, node, true); |
| 7193 | 7193 | } else { |
| 7194 | 7194 | is_comptime = block_scope->is_comptime; |
| 7195 | 7195 | } |
| 7196 | 7196 | |
| 7197 | IrInstSrc *result_value; | |
| 7197 | Stage1ZirInst *result_value; | |
| 7198 | 7198 | if (node->data.break_expr.expr) { |
| 7199 | 7199 | ResultLocPeer *peer_result = create_peer_result(block_scope->peer_parent); |
| 7200 | 7200 | block_scope->peer_parent->peers.append(peer_result); |
| ... | ... | @@ -7216,7 +7216,7 @@ static IrInstSrc *astgen_return_from_block(Stage1AstGen *ag, Scope *break_scope, |
| 7216 | 7216 | return ir_build_br(ag, break_scope, node, dest_block, is_comptime); |
| 7217 | 7217 | } |
| 7218 | 7218 | |
| 7219 | static IrInstSrc *astgen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *node) { | |
| 7219 | static Stage1ZirInst *astgen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *node) { | |
| 7220 | 7220 | assert(node->type == NodeTypeBreak); |
| 7221 | 7221 | |
| 7222 | 7222 | // Search up the scope. We'll find one of these things first: |
| ... | ... | @@ -7264,14 +7264,14 @@ static IrInstSrc *astgen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no |
| 7264 | 7264 | search_scope = search_scope->parent; |
| 7265 | 7265 | } |
| 7266 | 7266 | |
| 7267 | IrInstSrc *is_comptime; | |
| 7267 | Stage1ZirInst *is_comptime; | |
| 7268 | 7268 | if (ir_should_inline(ag->exec, break_scope)) { |
| 7269 | 7269 | is_comptime = ir_build_const_bool(ag, break_scope, node, true); |
| 7270 | 7270 | } else { |
| 7271 | 7271 | is_comptime = loop_scope->is_comptime; |
| 7272 | 7272 | } |
| 7273 | 7273 | |
| 7274 | IrInstSrc *result_value; | |
| 7274 | Stage1ZirInst *result_value; | |
| 7275 | 7275 | if (node->data.break_expr.expr) { |
| 7276 | 7276 | ResultLocPeer *peer_result = create_peer_result(loop_scope->peer_parent); |
| 7277 | 7277 | loop_scope->peer_parent->peers.append(peer_result); |
| ... | ... | @@ -7293,7 +7293,7 @@ static IrInstSrc *astgen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no |
| 7293 | 7293 | return ir_build_br(ag, break_scope, node, dest_block, is_comptime); |
| 7294 | 7294 | } |
| 7295 | 7295 | |
| 7296 | static IrInstSrc *astgen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNode *node) { | |
| 7296 | static Stage1ZirInst *astgen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNode *node) { | |
| 7297 | 7297 | assert(node->type == NodeTypeContinue); |
| 7298 | 7298 | |
| 7299 | 7299 | // Search up the scope. We'll find one of these things first: |
| ... | ... | @@ -7333,7 +7333,7 @@ static IrInstSrc *astgen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNo |
| 7333 | 7333 | search_scope = search_scope->parent; |
| 7334 | 7334 | } |
| 7335 | 7335 | |
| 7336 | IrInstSrc *is_comptime; | |
| 7336 | Stage1ZirInst *is_comptime; | |
| 7337 | 7337 | if (ir_should_inline(ag->exec, continue_scope)) { |
| 7338 | 7338 | is_comptime = ir_build_const_bool(ag, continue_scope, node, true); |
| 7339 | 7339 | } else { |
| ... | ... | @@ -7352,12 +7352,12 @@ static IrInstSrc *astgen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNo |
| 7352 | 7352 | return ir_build_br(ag, continue_scope, node, dest_block, is_comptime); |
| 7353 | 7353 | } |
| 7354 | 7354 | |
| 7355 | static IrInstSrc *astgen_error_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 7355 | static Stage1ZirInst *astgen_error_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 7356 | 7356 | assert(node->type == NodeTypeErrorType); |
| 7357 | 7357 | return ir_build_const_type(ag, scope, node, ag->codegen->builtin_types.entry_global_error_set); |
| 7358 | 7358 | } |
| 7359 | 7359 | |
| 7360 | static IrInstSrc *astgen_defer(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 7360 | static Stage1ZirInst *astgen_defer(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 7361 | 7361 | assert(node->type == NodeTypeDefer); |
| 7362 | 7362 | |
| 7363 | 7363 | ScopeDefer *defer_child_scope = create_defer_scope(ag->codegen, node, parent_scope); |
| ... | ... | @@ -7369,7 +7369,7 @@ static IrInstSrc *astgen_defer(Stage1AstGen *ag, Scope *parent_scope, AstNode *n |
| 7369 | 7369 | return ir_build_const_void(ag, parent_scope, node); |
| 7370 | 7370 | } |
| 7371 | 7371 | |
| 7372 | static IrInstSrc *astgen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | |
| 7372 | static Stage1ZirInst *astgen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | |
| 7373 | 7373 | assert(node->type == NodeTypeSliceExpr); |
| 7374 | 7374 | |
| 7375 | 7375 | AstNodeSliceExpr *slice_expr = &node->data.slice_expr; |
| ... | ... | @@ -7378,15 +7378,15 @@ static IrInstSrc *astgen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LV |
| 7378 | 7378 | AstNode *end_node = slice_expr->end; |
| 7379 | 7379 | AstNode *sentinel_node = slice_expr->sentinel; |
| 7380 | 7380 | |
| 7381 | IrInstSrc *ptr_value = astgen_node_extra(ag, array_node, scope, LValPtr, nullptr); | |
| 7381 | Stage1ZirInst *ptr_value = astgen_node_extra(ag, array_node, scope, LValPtr, nullptr); | |
| 7382 | 7382 | if (ptr_value == ag->codegen->invalid_inst_src) |
| 7383 | 7383 | return ag->codegen->invalid_inst_src; |
| 7384 | 7384 | |
| 7385 | IrInstSrc *start_value = astgen_node(ag, start_node, scope); | |
| 7385 | Stage1ZirInst *start_value = astgen_node(ag, start_node, scope); | |
| 7386 | 7386 | if (start_value == ag->codegen->invalid_inst_src) |
| 7387 | 7387 | return ag->codegen->invalid_inst_src; |
| 7388 | 7388 | |
| 7389 | IrInstSrc *end_value; | |
| 7389 | Stage1ZirInst *end_value; | |
| 7390 | 7390 | if (end_node) { |
| 7391 | 7391 | end_value = astgen_node(ag, end_node, scope); |
| 7392 | 7392 | if (end_value == ag->codegen->invalid_inst_src) |
| ... | ... | @@ -7395,7 +7395,7 @@ static IrInstSrc *astgen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LV |
| 7395 | 7395 | end_value = nullptr; |
| 7396 | 7396 | } |
| 7397 | 7397 | |
| 7398 | IrInstSrc *sentinel_value; | |
| 7398 | Stage1ZirInst *sentinel_value; | |
| 7399 | 7399 | if (sentinel_node) { |
| 7400 | 7400 | sentinel_value = astgen_node(ag, sentinel_node, scope); |
| 7401 | 7401 | if (sentinel_value == ag->codegen->invalid_inst_src) |
| ... | ... | @@ -7404,12 +7404,12 @@ static IrInstSrc *astgen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LV |
| 7404 | 7404 | sentinel_value = nullptr; |
| 7405 | 7405 | } |
| 7406 | 7406 | |
| 7407 | IrInstSrc *slice = ir_build_slice_src(ag, scope, node, ptr_value, start_value, end_value, | |
| 7407 | Stage1ZirInst *slice = ir_build_slice_src(ag, scope, node, ptr_value, start_value, end_value, | |
| 7408 | 7408 | sentinel_value, true, result_loc); |
| 7409 | 7409 | return ir_lval_wrap(ag, scope, slice, lval, result_loc); |
| 7410 | 7410 | } |
| 7411 | 7411 | |
| 7412 | static IrInstSrc *astgen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, | |
| 7412 | static Stage1ZirInst *astgen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, | |
| 7413 | 7413 | ResultLoc *result_loc) |
| 7414 | 7414 | { |
| 7415 | 7415 | assert(node->type == NodeTypeCatchExpr); |
| ... | ... | @@ -7432,13 +7432,13 @@ static IrInstSrc *astgen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n |
| 7432 | 7432 | ScopeExpr *spill_scope = create_expr_scope(ag->codegen, op1_node, parent_scope); |
| 7433 | 7433 | spill_scope->spill_harder = true; |
| 7434 | 7434 | |
| 7435 | IrInstSrc *err_union_ptr = astgen_node_extra(ag, op1_node, &spill_scope->base, LValPtr, nullptr); | |
| 7435 | Stage1ZirInst *err_union_ptr = astgen_node_extra(ag, op1_node, &spill_scope->base, LValPtr, nullptr); | |
| 7436 | 7436 | if (err_union_ptr == ag->codegen->invalid_inst_src) |
| 7437 | 7437 | return ag->codegen->invalid_inst_src; |
| 7438 | 7438 | |
| 7439 | IrInstSrc *is_err = ir_build_test_err_src(ag, parent_scope, node, err_union_ptr, true, false); | |
| 7439 | Stage1ZirInst *is_err = ir_build_test_err_src(ag, parent_scope, node, err_union_ptr, true, false); | |
| 7440 | 7440 | |
| 7441 | IrInstSrc *is_comptime; | |
| 7441 | Stage1ZirInst *is_comptime; | |
| 7442 | 7442 | if (ir_should_inline(ag->exec, parent_scope)) { |
| 7443 | 7443 | is_comptime = ir_build_const_bool(ag, parent_scope, node, true); |
| 7444 | 7444 | } else { |
| ... | ... | @@ -7448,7 +7448,7 @@ static IrInstSrc *astgen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n |
| 7448 | 7448 | Stage1ZirBasicBlock *ok_block = ir_create_basic_block(ag, parent_scope, "UnwrapErrOk"); |
| 7449 | 7449 | Stage1ZirBasicBlock *err_block = ir_create_basic_block(ag, parent_scope, "UnwrapErrError"); |
| 7450 | 7450 | Stage1ZirBasicBlock *end_block = ir_create_basic_block(ag, parent_scope, "UnwrapErrEnd"); |
| 7451 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, parent_scope, node, is_err, err_block, ok_block, is_comptime); | |
| 7451 | Stage1ZirInst *cond_br_inst = ir_build_cond_br(ag, parent_scope, node, is_err, err_block, ok_block, is_comptime); | |
| 7452 | 7452 | |
| 7453 | 7453 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(ag, cond_br_inst, ok_block, end_block, result_loc, |
| 7454 | 7454 | is_comptime); |
| ... | ... | @@ -7464,13 +7464,13 @@ static IrInstSrc *astgen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n |
| 7464 | 7464 | ZigVar *var = ir_create_var(ag, node, subexpr_scope, var_name, |
| 7465 | 7465 | is_const, is_const, is_shadowable, is_comptime); |
| 7466 | 7466 | err_scope = var->child_scope; |
| 7467 | IrInstSrc *err_ptr = ir_build_unwrap_err_code_src(ag, err_scope, node, err_union_ptr); | |
| 7468 | IrInstSrc *err_value = ir_build_load_ptr(ag, err_scope, var_node, err_ptr); | |
| 7467 | Stage1ZirInst *err_ptr = ir_build_unwrap_err_code_src(ag, err_scope, node, err_union_ptr); | |
| 7468 | Stage1ZirInst *err_value = ir_build_load_ptr(ag, err_scope, var_node, err_ptr); | |
| 7469 | 7469 | build_decl_var_and_init(ag, err_scope, var_node, var, err_value, buf_ptr(var_name), is_comptime); |
| 7470 | 7470 | } else { |
| 7471 | 7471 | err_scope = subexpr_scope; |
| 7472 | 7472 | } |
| 7473 | IrInstSrc *err_result = astgen_node_extra(ag, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base); | |
| 7473 | Stage1ZirInst *err_result = astgen_node_extra(ag, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base); | |
| 7474 | 7474 | if (err_result == ag->codegen->invalid_inst_src) |
| 7475 | 7475 | return ag->codegen->invalid_inst_src; |
| 7476 | 7476 | Stage1ZirBasicBlock *after_err_block = ag->current_basic_block; |
| ... | ... | @@ -7478,20 +7478,20 @@ static IrInstSrc *astgen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n |
| 7478 | 7478 | ir_build_br(ag, parent_scope, node, end_block, is_comptime); |
| 7479 | 7479 | |
| 7480 | 7480 | ir_set_cursor_at_end_and_append_block(ag, ok_block); |
| 7481 | IrInstSrc *unwrapped_ptr = ir_build_unwrap_err_payload_src(ag, parent_scope, node, err_union_ptr, false, false); | |
| 7482 | IrInstSrc *unwrapped_payload = ir_build_load_ptr(ag, parent_scope, node, unwrapped_ptr); | |
| 7481 | Stage1ZirInst *unwrapped_ptr = ir_build_unwrap_err_payload_src(ag, parent_scope, node, err_union_ptr, false, false); | |
| 7482 | Stage1ZirInst *unwrapped_payload = ir_build_load_ptr(ag, parent_scope, node, unwrapped_ptr); | |
| 7483 | 7483 | ir_build_end_expr(ag, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); |
| 7484 | 7484 | Stage1ZirBasicBlock *after_ok_block = ag->current_basic_block; |
| 7485 | 7485 | ir_build_br(ag, parent_scope, node, end_block, is_comptime); |
| 7486 | 7486 | |
| 7487 | 7487 | ir_set_cursor_at_end_and_append_block(ag, end_block); |
| 7488 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | |
| 7488 | Stage1ZirInst **incoming_values = heap::c_allocator.allocate<Stage1ZirInst *>(2); | |
| 7489 | 7489 | incoming_values[0] = err_result; |
| 7490 | 7490 | incoming_values[1] = unwrapped_payload; |
| 7491 | 7491 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 7492 | 7492 | incoming_blocks[0] = after_err_block; |
| 7493 | 7493 | incoming_blocks[1] = after_ok_block; |
| 7494 | IrInstSrc *phi = ir_build_phi(ag, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | |
| 7494 | Stage1ZirInst *phi = ir_build_phi(ag, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | |
| 7495 | 7495 | return ir_lval_wrap(ag, parent_scope, phi, lval, result_loc); |
| 7496 | 7496 | } |
| 7497 | 7497 | |
| ... | ... | @@ -7540,7 +7540,7 @@ Buf *get_anon_type_name(CodeGen *codegen, Stage1Zir *exec, const char *kind_name |
| 7540 | 7540 | } |
| 7541 | 7541 | } |
| 7542 | 7542 | |
| 7543 | static IrInstSrc *astgen_container_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 7543 | static Stage1ZirInst *astgen_container_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 7544 | 7544 | assert(node->type == NodeTypeContainerDecl); |
| 7545 | 7545 | |
| 7546 | 7546 | ContainerKind kind = node->data.container_decl.kind; |
| ... | ... | @@ -7569,7 +7569,7 @@ static IrInstSrc *astgen_container_decl(Stage1AstGen *ag, Scope *parent_scope, A |
| 7569 | 7569 | return ir_build_const_type(ag, parent_scope, node, container_type); |
| 7570 | 7570 | } |
| 7571 | 7571 | |
| 7572 | static IrInstSrc *astgen_err_set_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 7572 | static Stage1ZirInst *astgen_err_set_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 7573 | 7573 | assert(node->type == NodeTypeErrorSetDecl); |
| 7574 | 7574 | |
| 7575 | 7575 | uint32_t err_count = node->data.err_set_decl.decls.length; |
| ... | ... | @@ -7620,11 +7620,11 @@ static IrInstSrc *astgen_err_set_decl(Stage1AstGen *ag, Scope *parent_scope, Ast |
| 7620 | 7620 | return ir_build_const_type(ag, parent_scope, node, err_set_type); |
| 7621 | 7621 | } |
| 7622 | 7622 | |
| 7623 | static IrInstSrc *astgen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 7623 | static Stage1ZirInst *astgen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 7624 | 7624 | assert(node->type == NodeTypeFnProto); |
| 7625 | 7625 | |
| 7626 | 7626 | size_t param_count = node->data.fn_proto.params.length; |
| 7627 | IrInstSrc **param_types = heap::c_allocator.allocate<IrInstSrc*>(param_count); | |
| 7627 | Stage1ZirInst **param_types = heap::c_allocator.allocate<Stage1ZirInst*>(param_count); | |
| 7628 | 7628 | |
| 7629 | 7629 | bool is_var_args = false; |
| 7630 | 7630 | for (size_t i = 0; i < param_count; i += 1) { |
| ... | ... | @@ -7635,7 +7635,7 @@ static IrInstSrc *astgen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7635 | 7635 | } |
| 7636 | 7636 | if (param_node->data.param_decl.anytype_token == 0) { |
| 7637 | 7637 | AstNode *type_node = param_node->data.param_decl.type; |
| 7638 | IrInstSrc *type_value = astgen_node(ag, type_node, parent_scope); | |
| 7638 | Stage1ZirInst *type_value = astgen_node(ag, type_node, parent_scope); | |
| 7639 | 7639 | if (type_value == ag->codegen->invalid_inst_src) |
| 7640 | 7640 | return ag->codegen->invalid_inst_src; |
| 7641 | 7641 | param_types[i] = type_value; |
| ... | ... | @@ -7644,21 +7644,21 @@ static IrInstSrc *astgen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7644 | 7644 | } |
| 7645 | 7645 | } |
| 7646 | 7646 | |
| 7647 | IrInstSrc *align_value = nullptr; | |
| 7647 | Stage1ZirInst *align_value = nullptr; | |
| 7648 | 7648 | if (node->data.fn_proto.align_expr != nullptr) { |
| 7649 | 7649 | align_value = astgen_node(ag, node->data.fn_proto.align_expr, parent_scope); |
| 7650 | 7650 | if (align_value == ag->codegen->invalid_inst_src) |
| 7651 | 7651 | return ag->codegen->invalid_inst_src; |
| 7652 | 7652 | } |
| 7653 | 7653 | |
| 7654 | IrInstSrc *callconv_value = nullptr; | |
| 7654 | Stage1ZirInst *callconv_value = nullptr; | |
| 7655 | 7655 | if (node->data.fn_proto.callconv_expr != nullptr) { |
| 7656 | 7656 | callconv_value = astgen_node(ag, node->data.fn_proto.callconv_expr, parent_scope); |
| 7657 | 7657 | if (callconv_value == ag->codegen->invalid_inst_src) |
| 7658 | 7658 | return ag->codegen->invalid_inst_src; |
| 7659 | 7659 | } |
| 7660 | 7660 | |
| 7661 | IrInstSrc *return_type; | |
| 7661 | Stage1ZirInst *return_type; | |
| 7662 | 7662 | if (node->data.fn_proto.return_type == nullptr) { |
| 7663 | 7663 | return_type = ir_build_const_type(ag, parent_scope, node, ag->codegen->builtin_types.entry_void); |
| 7664 | 7664 | } else { |
| ... | ... | @@ -7670,17 +7670,17 @@ static IrInstSrc *astgen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7670 | 7670 | return ir_build_fn_proto(ag, parent_scope, node, param_types, align_value, callconv_value, return_type, is_var_args); |
| 7671 | 7671 | } |
| 7672 | 7672 | |
| 7673 | static IrInstSrc *astgen_resume(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 7673 | static Stage1ZirInst *astgen_resume(Stage1AstGen *ag, Scope *scope, AstNode *node) { | |
| 7674 | 7674 | assert(node->type == NodeTypeResume); |
| 7675 | 7675 | |
| 7676 | IrInstSrc *target_inst = astgen_node_extra(ag, node->data.resume_expr.expr, scope, LValPtr, nullptr); | |
| 7676 | Stage1ZirInst *target_inst = astgen_node_extra(ag, node->data.resume_expr.expr, scope, LValPtr, nullptr); | |
| 7677 | 7677 | if (target_inst == ag->codegen->invalid_inst_src) |
| 7678 | 7678 | return ag->codegen->invalid_inst_src; |
| 7679 | 7679 | |
| 7680 | 7680 | return ir_build_resume_src(ag, scope, node, target_inst); |
| 7681 | 7681 | } |
| 7682 | 7682 | |
| 7683 | static IrInstSrc *astgen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 7683 | static Stage1ZirInst *astgen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, | |
| 7684 | 7684 | ResultLoc *result_loc) |
| 7685 | 7685 | { |
| 7686 | 7686 | assert(node->type == NodeTypeAwaitExpr); |
| ... | ... | @@ -7714,15 +7714,15 @@ static IrInstSrc *astgen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 7714 | 7714 | return ag->codegen->invalid_inst_src; |
| 7715 | 7715 | } |
| 7716 | 7716 | |
| 7717 | IrInstSrc *target_inst = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); | |
| 7717 | Stage1ZirInst *target_inst = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); | |
| 7718 | 7718 | if (target_inst == ag->codegen->invalid_inst_src) |
| 7719 | 7719 | return ag->codegen->invalid_inst_src; |
| 7720 | 7720 | |
| 7721 | IrInstSrc *await_inst = ir_build_await_src(ag, scope, node, target_inst, result_loc, is_nosuspend); | |
| 7721 | Stage1ZirInst *await_inst = ir_build_await_src(ag, scope, node, target_inst, result_loc, is_nosuspend); | |
| 7722 | 7722 | return ir_lval_wrap(ag, scope, await_inst, lval, result_loc); |
| 7723 | 7723 | } |
| 7724 | 7724 | |
| 7725 | static IrInstSrc *astgen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 7725 | static Stage1ZirInst *astgen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { | |
| 7726 | 7726 | assert(node->type == NodeTypeSuspend); |
| 7727 | 7727 | |
| 7728 | 7728 | if (!ag->fn) { |
| ... | ... | @@ -7744,10 +7744,10 @@ static IrInstSrc *astgen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7744 | 7744 | return ag->codegen->invalid_inst_src; |
| 7745 | 7745 | } |
| 7746 | 7746 | |
| 7747 | IrInstSrcSuspendBegin *begin = ir_build_suspend_begin_src(ag, parent_scope, node); | |
| 7747 | Stage1ZirInstSuspendBegin *begin = ir_build_suspend_begin_src(ag, parent_scope, node); | |
| 7748 | 7748 | ScopeSuspend *suspend_scope = create_suspend_scope(ag->codegen, node, parent_scope); |
| 7749 | 7749 | Scope *child_scope = &suspend_scope->base; |
| 7750 | IrInstSrc *susp_res = astgen_node(ag, node->data.suspend.block, child_scope); | |
| 7750 | Stage1ZirInst *susp_res = astgen_node(ag, node->data.suspend.block, child_scope); | |
| 7751 | 7751 | if (susp_res == ag->codegen->invalid_inst_src) |
| 7752 | 7752 | return ag->codegen->invalid_inst_src; |
| 7753 | 7753 | ir_build_check_statement_is_void(ag, child_scope, node->data.suspend.block, susp_res); |
| ... | ... | @@ -7755,7 +7755,7 @@ static IrInstSrc *astgen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7755 | 7755 | return ir_build_suspend_finish_src(ag, parent_scope, node, begin); |
| 7756 | 7756 | } |
| 7757 | 7757 | |
| 7758 | static IrInstSrc *astgen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope, | |
| 7758 | static Stage1ZirInst *astgen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope, | |
| 7759 | 7759 | LVal lval, ResultLoc *result_loc) |
| 7760 | 7760 | { |
| 7761 | 7761 | assert(scope); |
| ... | ... | @@ -7804,13 +7804,13 @@ static IrInstSrc *astgen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope, |
| 7804 | 7804 | return astgen_return(ag, scope, node, lval, result_loc); |
| 7805 | 7805 | case NodeTypeFieldAccessExpr: |
| 7806 | 7806 | { |
| 7807 | IrInstSrc *ptr_instruction = astgen_field_access(ag, scope, node); | |
| 7807 | Stage1ZirInst *ptr_instruction = astgen_field_access(ag, scope, node); | |
| 7808 | 7808 | if (ptr_instruction == ag->codegen->invalid_inst_src) |
| 7809 | 7809 | return ptr_instruction; |
| 7810 | 7810 | if (lval == LValPtr || lval == LValAssign) |
| 7811 | 7811 | return ptr_instruction; |
| 7812 | 7812 | |
| 7813 | IrInstSrc *load_ptr = ir_build_load_ptr(ag, scope, node, ptr_instruction); | |
| 7813 | Stage1ZirInst *load_ptr = ir_build_load_ptr(ag, scope, node, ptr_instruction); | |
| 7814 | 7814 | return ir_expr_wrap(ag, scope, load_ptr, result_loc); |
| 7815 | 7815 | } |
| 7816 | 7816 | case NodeTypePtrDeref: { |
| ... | ... | @@ -7820,28 +7820,28 @@ static IrInstSrc *astgen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope, |
| 7820 | 7820 | if (child_lval == LValAssign) |
| 7821 | 7821 | child_lval = LValPtr; |
| 7822 | 7822 | |
| 7823 | IrInstSrc *value = astgen_node_extra(ag, expr_node, scope, child_lval, nullptr); | |
| 7823 | Stage1ZirInst *value = astgen_node_extra(ag, expr_node, scope, child_lval, nullptr); | |
| 7824 | 7824 | if (value == ag->codegen->invalid_inst_src) |
| 7825 | 7825 | return value; |
| 7826 | 7826 | |
| 7827 | 7827 | // We essentially just converted any lvalue from &(x.*) to (&x).*; |
| 7828 | 7828 | // this inhibits checking that x is a pointer later, so we directly |
| 7829 | 7829 | // record whether the pointer check is needed |
| 7830 | IrInstSrc *un_op = ir_build_un_op_lval(ag, scope, node, IrUnOpDereference, value, lval, result_loc); | |
| 7830 | Stage1ZirInst *un_op = ir_build_un_op_lval(ag, scope, node, IrUnOpDereference, value, lval, result_loc); | |
| 7831 | 7831 | return ir_expr_wrap(ag, scope, un_op, result_loc); |
| 7832 | 7832 | } |
| 7833 | 7833 | case NodeTypeUnwrapOptional: { |
| 7834 | 7834 | AstNode *expr_node = node->data.unwrap_optional.expr; |
| 7835 | 7835 | |
| 7836 | IrInstSrc *maybe_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); | |
| 7836 | Stage1ZirInst *maybe_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); | |
| 7837 | 7837 | if (maybe_ptr == ag->codegen->invalid_inst_src) |
| 7838 | 7838 | return ag->codegen->invalid_inst_src; |
| 7839 | 7839 | |
| 7840 | IrInstSrc *unwrapped_ptr = ir_build_optional_unwrap_ptr(ag, scope, node, maybe_ptr, true ); | |
| 7840 | Stage1ZirInst *unwrapped_ptr = ir_build_optional_unwrap_ptr(ag, scope, node, maybe_ptr, true ); | |
| 7841 | 7841 | if (lval == LValPtr || lval == LValAssign) |
| 7842 | 7842 | return unwrapped_ptr; |
| 7843 | 7843 | |
| 7844 | IrInstSrc *load_ptr = ir_build_load_ptr(ag, scope, node, unwrapped_ptr); | |
| 7844 | Stage1ZirInst *load_ptr = ir_build_load_ptr(ag, scope, node, unwrapped_ptr); | |
| 7845 | 7845 | return ir_expr_wrap(ag, scope, load_ptr, result_loc); |
| 7846 | 7846 | } |
| 7847 | 7847 | case NodeTypeBoolLiteral: |
| ... | ... | @@ -7915,7 +7915,7 @@ ResultLoc *no_result_loc(void) { |
| 7915 | 7915 | return &result_loc_none->base; |
| 7916 | 7916 | } |
| 7917 | 7917 | |
| 7918 | static IrInstSrc *astgen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval, | |
| 7918 | static Stage1ZirInst *astgen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval, | |
| 7919 | 7919 | ResultLoc *result_loc) |
| 7920 | 7920 | { |
| 7921 | 7921 | if (lval == LValAssign) { |
| ... | ... | @@ -8023,7 +8023,7 @@ static IrInstSrc *astgen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scop |
| 8023 | 8023 | } else { |
| 8024 | 8024 | child_scope = &create_expr_scope(ag->codegen, node, scope)->base; |
| 8025 | 8025 | } |
| 8026 | IrInstSrc *result = astgen_node_raw(ag, node, child_scope, lval, result_loc); | |
| 8026 | Stage1ZirInst *result = astgen_node_raw(ag, node, child_scope, lval, result_loc); | |
| 8027 | 8027 | if (result == ag->codegen->invalid_inst_src) { |
| 8028 | 8028 | if (ag->exec->first_err_trace_msg == nullptr) { |
| 8029 | 8029 | ag->exec->first_err_trace_msg = ag->codegen->trace_err; |
| ... | ... | @@ -8032,7 +8032,7 @@ static IrInstSrc *astgen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scop |
| 8032 | 8032 | return result; |
| 8033 | 8033 | } |
| 8034 | 8034 | |
| 8035 | static IrInstSrc *astgen_node(Stage1AstGen *ag, AstNode *node, Scope *scope) { | |
| 8035 | static Stage1ZirInst *astgen_node(Stage1AstGen *ag, AstNode *node, Scope *scope) { | |
| 8036 | 8036 | return astgen_node_extra(ag, node, scope, LValNone, nullptr); |
| 8037 | 8037 | } |
| 8038 | 8038 | |
| ... | ... | @@ -8055,7 +8055,7 @@ bool stage1_astgen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *sta |
| 8055 | 8055 | // Entry block gets a reference because we enter it to begin. |
| 8056 | 8056 | ir_ref_bb(ag->current_basic_block); |
| 8057 | 8057 | |
| 8058 | IrInstSrc *result = astgen_node_extra(ag, node, scope, LValNone, nullptr); | |
| 8058 | Stage1ZirInst *result = astgen_node_extra(ag, node, scope, LValNone, nullptr); | |
| 8059 | 8059 | |
| 8060 | 8060 | if (result == ag->codegen->invalid_inst_src) |
| 8061 | 8061 | return false; |
| ... | ... | @@ -8113,8 +8113,8 @@ void ir_add_call_stack_errors_gen(CodeGen *codegen, Stage1Air *exec, ErrorMsg *e |
| 8113 | 8113 | ir_add_call_stack_errors_gen(codegen, exec->parent_exec, err_msg, limit - 1); |
| 8114 | 8114 | } |
| 8115 | 8115 | |
| 8116 | void IrInstSrc::src() { | |
| 8117 | IrInstSrc *inst = this; | |
| 8116 | void Stage1ZirInst::src() { | |
| 8117 | Stage1ZirInst *inst = this; | |
| 8118 | 8118 | if (inst->source_node != nullptr) { |
| 8119 | 8119 | inst->source_node->src(); |
| 8120 | 8120 | } else { |
src/stage1/astgen.hpp+3-3| ... | ... | @@ -14,10 +14,10 @@ bool stage1_astgen(CodeGen *g, AstNode *node, Scope *scope, Stage1Zir *stage1_zi |
| 14 | 14 | ZigFn *fn, bool in_c_import_scope); |
| 15 | 15 | bool stage1_astgen_fn(CodeGen *g, ZigFn *fn_entry); |
| 16 | 16 | |
| 17 | bool ir_inst_src_has_side_effects(IrInstSrc *inst); | |
| 17 | bool ir_inst_src_has_side_effects(Stage1ZirInst *inst); | |
| 18 | 18 | |
| 19 | 19 | ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_scope, |
| 20 | Buf *name, bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstSrc *is_comptime, | |
| 20 | Buf *name, bool src_is_const, bool gen_is_const, bool is_shadowable, Stage1ZirInst *is_comptime, | |
| 21 | 21 | bool skip_name_check); |
| 22 | 22 | |
| 23 | 23 | ResultLoc *no_result_loc(void); |
| ... | ... | @@ -28,7 +28,7 @@ AstNode *ast_field_to_symbol_node(AstNode *err_set_field_node); |
| 28 | 28 | void ir_add_call_stack_errors_gen(CodeGen *codegen, Stage1Air *exec, ErrorMsg *err_msg, |
| 29 | 29 | int limit); |
| 30 | 30 | |
| 31 | void destroy_instruction_src(IrInstSrc *inst); | |
| 31 | void destroy_instruction_src(Stage1ZirInst *inst); | |
| 32 | 32 | |
| 33 | 33 | bool ir_should_inline(Stage1Zir *exec, Scope *scope); |
| 34 | 34 | Buf *get_anon_type_name(CodeGen *codegen, Stage1Zir *exec, const char *kind_name, |
src/stage1/codegen.cpp+301-301| ... | ... | @@ -84,7 +84,7 @@ static void generate_error_name_table(CodeGen *g); |
| 84 | 84 | static bool value_is_all_undef(CodeGen *g, ZigValue *const_val); |
| 85 | 85 | static void gen_undef_init(CodeGen *g, ZigType *ptr_type, ZigType *value_type, LLVMValueRef ptr); |
| 86 | 86 | static LLVMValueRef build_alloca(CodeGen *g, ZigType *type_entry, const char *name, uint32_t alignment); |
| 87 | static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstGen *source_instr, | |
| 87 | static LLVMValueRef gen_await_early_return(CodeGen *g, Stage1AirInst *source_instr, | |
| 88 | 88 | LLVMValueRef target_frame_ptr, ZigType *result_type, ZigType *ptr_result_type, |
| 89 | 89 | LLVMValueRef result_loc, bool non_async); |
| 90 | 90 | |
| ... | ... | @@ -906,14 +906,14 @@ static LLVMValueRef get_handle_value(CodeGen *g, LLVMValueRef ptr, ZigType *type |
| 906 | 906 | } |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | static void ir_assert_impl(bool ok, IrInstGen *source_instruction, const char *file, unsigned int line) { | |
| 909 | static void ir_assert_impl(bool ok, Stage1AirInst *source_instruction, const char *file, unsigned int line) { | |
| 910 | 910 | if (ok) return; |
| 911 | 911 | src_assert_impl(ok, source_instruction->source_node, file, line); |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | #define ir_assert(OK, SOURCE_INSTRUCTION) ir_assert_impl((OK), (SOURCE_INSTRUCTION), __FILE__, __LINE__) |
| 915 | 915 | |
| 916 | static bool ir_want_fast_math(CodeGen *g, IrInstGen *instruction) { | |
| 916 | static bool ir_want_fast_math(CodeGen *g, Stage1AirInst *instruction) { | |
| 917 | 917 | // TODO memoize |
| 918 | 918 | Scope *scope = instruction->scope; |
| 919 | 919 | while (scope) { |
| ... | ... | @@ -950,7 +950,7 @@ static bool ir_want_runtime_safety_scope(CodeGen *g, Scope *scope) { |
| 950 | 950 | g->build_mode != BuildModeSmallRelease); |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | static bool ir_want_runtime_safety(CodeGen *g, IrInstGen *instruction) { | |
| 953 | static bool ir_want_runtime_safety(CodeGen *g, Stage1AirInst *instruction) { | |
| 954 | 954 | return ir_want_runtime_safety_scope(g, instruction->scope); |
| 955 | 955 | } |
| 956 | 956 | |
| ... | ... | @@ -1077,7 +1077,7 @@ static void gen_assertion_scope(CodeGen *g, PanicMsgId msg_id, Scope *source_sco |
| 1077 | 1077 | } |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | static void gen_assertion(CodeGen *g, PanicMsgId msg_id, IrInstGen *source_instruction) { | |
| 1080 | static void gen_assertion(CodeGen *g, PanicMsgId msg_id, Stage1AirInst *source_instruction) { | |
| 1081 | 1081 | return gen_assertion_scope(g, msg_id, source_instruction->scope); |
| 1082 | 1082 | } |
| 1083 | 1083 | |
| ... | ... | @@ -1816,7 +1816,7 @@ static void gen_var_debug_decl(CodeGen *g, ZigVar *var) { |
| 1816 | 1816 | LLVMGetInsertBlock(g->builder)); |
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | static LLVMValueRef ir_llvm_value(CodeGen *g, IrInstGen *instruction) { | |
| 1819 | static LLVMValueRef ir_llvm_value(CodeGen *g, Stage1AirInst *instruction) { | |
| 1820 | 1820 | Error err; |
| 1821 | 1821 | |
| 1822 | 1822 | bool value_has_bits; |
| ... | ... | @@ -1827,8 +1827,8 @@ static LLVMValueRef ir_llvm_value(CodeGen *g, IrInstGen *instruction) { |
| 1827 | 1827 | return nullptr; |
| 1828 | 1828 | |
| 1829 | 1829 | if (!instruction->llvm_value) { |
| 1830 | if (instruction->id == IrInstGenIdAwait) { | |
| 1831 | IrInstGenAwait *await = reinterpret_cast<IrInstGenAwait*>(instruction); | |
| 1830 | if (instruction->id == Stage1AirInstIdAwait) { | |
| 1831 | Stage1AirInstAwait *await = reinterpret_cast<Stage1AirInstAwait*>(instruction); | |
| 1832 | 1832 | if (await->result_loc != nullptr) { |
| 1833 | 1833 | return get_handle_value(g, ir_llvm_value(g, await->result_loc), |
| 1834 | 1834 | await->result_loc->value->type->data.pointer.child_type, await->result_loc->value->type); |
| ... | ... | @@ -1921,7 +1921,7 @@ static bool iter_function_params_c_abi(CodeGen *g, ZigType *fn_type, FnWalk *fn_ |
| 1921 | 1921 | case FnWalkIdCall: { |
| 1922 | 1922 | if (src_i >= fn_walk->data.call.inst->arg_count) |
| 1923 | 1923 | return false; |
| 1924 | IrInstGen *arg = fn_walk->data.call.inst->args[src_i]; | |
| 1924 | Stage1AirInst *arg = fn_walk->data.call.inst->args[src_i]; | |
| 1925 | 1925 | ty = arg->value->type; |
| 1926 | 1926 | source_node = arg->source_node; |
| 1927 | 1927 | val = ir_llvm_value(g, arg); |
| ... | ... | @@ -2228,10 +2228,10 @@ void walk_function_params(CodeGen *g, ZigType *fn_type, FnWalk *fn_walk) { |
| 2228 | 2228 | return; |
| 2229 | 2229 | } |
| 2230 | 2230 | if (fn_walk->id == FnWalkIdCall) { |
| 2231 | IrInstGenCall *instruction = fn_walk->data.call.inst; | |
| 2231 | Stage1AirInstCall *instruction = fn_walk->data.call.inst; | |
| 2232 | 2232 | bool is_var_args = fn_walk->data.call.is_var_args; |
| 2233 | 2233 | for (size_t call_i = 0; call_i < instruction->arg_count; call_i += 1) { |
| 2234 | IrInstGen *param_instruction = instruction->args[call_i]; | |
| 2234 | Stage1AirInst *param_instruction = instruction->args[call_i]; | |
| 2235 | 2235 | ZigType *param_type = param_instruction->value->type; |
| 2236 | 2236 | if (is_var_args || type_has_bits(g, param_type)) { |
| 2237 | 2237 | LLVMValueRef param_value = ir_llvm_value(g, param_instruction); |
| ... | ... | @@ -2445,7 +2445,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) { |
| 2445 | 2445 | |
| 2446 | 2446 | } |
| 2447 | 2447 | static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, Stage1Air *executable, |
| 2448 | IrInstGenSaveErrRetAddr *save_err_ret_addr_instruction) | |
| 2448 | Stage1AirInstSaveErrRetAddr *save_err_ret_addr_instruction) | |
| 2449 | 2449 | { |
| 2450 | 2450 | assert(g->have_err_ret_tracing); |
| 2451 | 2451 | |
| ... | ... | @@ -2466,7 +2466,7 @@ static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, Stage1Air *executabl |
| 2466 | 2466 | return nullptr; |
| 2467 | 2467 | } |
| 2468 | 2468 | |
| 2469 | static void gen_assert_resume_id(CodeGen *g, IrInstGen *source_instr, ResumeId resume_id, PanicMsgId msg_id, | |
| 2469 | static void gen_assert_resume_id(CodeGen *g, Stage1AirInst *source_instr, ResumeId resume_id, PanicMsgId msg_id, | |
| 2470 | 2470 | LLVMBasicBlockRef end_bb) |
| 2471 | 2471 | { |
| 2472 | 2472 | LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type; |
| ... | ... | @@ -2543,7 +2543,7 @@ static LLVMValueRef gen_maybe_atomic_op(CodeGen *g, LLVMAtomicRMWBinOp op, LLVMV |
| 2543 | 2543 | } |
| 2544 | 2544 | } |
| 2545 | 2545 | |
| 2546 | static void gen_async_return(CodeGen *g, IrInstGenReturn *instruction) { | |
| 2546 | static void gen_async_return(CodeGen *g, Stage1AirInstReturn *instruction) { | |
| 2547 | 2547 | LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type; |
| 2548 | 2548 | |
| 2549 | 2549 | ZigType *operand_type = (instruction->operand != nullptr) ? instruction->operand->value->type : nullptr; |
| ... | ... | @@ -2637,7 +2637,7 @@ static void gen_async_return(CodeGen *g, IrInstGenReturn *instruction) { |
| 2637 | 2637 | LLVMBuildRetVoid(g->builder); |
| 2638 | 2638 | } |
| 2639 | 2639 | |
| 2640 | static LLVMValueRef ir_render_return(CodeGen *g, Stage1Air *executable, IrInstGenReturn *instruction) { | |
| 2640 | static LLVMValueRef ir_render_return(CodeGen *g, Stage1Air *executable, Stage1AirInstReturn *instruction) { | |
| 2641 | 2641 | if (fn_is_async(g->cur_fn)) { |
| 2642 | 2642 | gen_async_return(g, instruction); |
| 2643 | 2643 | return nullptr; |
| ... | ... | @@ -3063,11 +3063,11 @@ static void gen_shift_rhs_check(CodeGen *g, ZigType *lhs_type, ZigType *rhs_type |
| 3063 | 3063 | } |
| 3064 | 3064 | |
| 3065 | 3065 | static LLVMValueRef ir_render_bin_op(CodeGen *g, Stage1Air *executable, |
| 3066 | IrInstGenBinOp *bin_op_instruction) | |
| 3066 | Stage1AirInstBinOp *bin_op_instruction) | |
| 3067 | 3067 | { |
| 3068 | 3068 | IrBinOp op_id = bin_op_instruction->op_id; |
| 3069 | IrInstGen *op1 = bin_op_instruction->op1; | |
| 3070 | IrInstGen *op2 = bin_op_instruction->op2; | |
| 3069 | Stage1AirInst *op1 = bin_op_instruction->op1; | |
| 3070 | Stage1AirInst *op2 = bin_op_instruction->op2; | |
| 3071 | 3071 | |
| 3072 | 3072 | ZigType *operand_type = op1->value->type; |
| 3073 | 3073 | ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? operand_type->data.vector.elem_type : operand_type; |
| ... | ... | @@ -3285,7 +3285,7 @@ static void add_error_range_check(CodeGen *g, ZigType *err_set_type, ZigType *in |
| 3285 | 3285 | } |
| 3286 | 3286 | |
| 3287 | 3287 | static LLVMValueRef ir_render_cast(CodeGen *g, Stage1Air *executable, |
| 3288 | IrInstGenCast *cast_instruction) | |
| 3288 | Stage1AirInstCast *cast_instruction) | |
| 3289 | 3289 | { |
| 3290 | 3290 | Error err; |
| 3291 | 3291 | ZigType *actual_type = cast_instruction->value->value->type; |
| ... | ... | @@ -3369,7 +3369,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, Stage1Air *executable, |
| 3369 | 3369 | } |
| 3370 | 3370 | |
| 3371 | 3371 | static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, Stage1Air *executable, |
| 3372 | IrInstGenPtrOfArrayToSlice *instruction) | |
| 3372 | Stage1AirInstPtrOfArrayToSlice *instruction) | |
| 3373 | 3373 | { |
| 3374 | 3374 | ZigType *actual_type = instruction->operand->value->type; |
| 3375 | 3375 | ZigType *slice_type = instruction->base.value->type; |
| ... | ... | @@ -3406,7 +3406,7 @@ static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, Stage1Air *execu |
| 3406 | 3406 | } |
| 3407 | 3407 | |
| 3408 | 3408 | static LLVMValueRef ir_render_ptr_cast(CodeGen *g, Stage1Air *executable, |
| 3409 | IrInstGenPtrCast *instruction) | |
| 3409 | Stage1AirInstPtrCast *instruction) | |
| 3410 | 3410 | { |
| 3411 | 3411 | ZigType *wanted_type = instruction->base.value->type; |
| 3412 | 3412 | if (!type_has_bits(g, wanted_type)) { |
| ... | ... | @@ -3432,7 +3432,7 @@ static LLVMValueRef ir_render_ptr_cast(CodeGen *g, Stage1Air *executable, |
| 3432 | 3432 | } |
| 3433 | 3433 | |
| 3434 | 3434 | static LLVMValueRef ir_render_bit_cast(CodeGen *g, Stage1Air *executable, |
| 3435 | IrInstGenBitCast *instruction) | |
| 3435 | Stage1AirInstBitCast *instruction) | |
| 3436 | 3436 | { |
| 3437 | 3437 | ZigType *wanted_type = instruction->base.value->type; |
| 3438 | 3438 | ZigType *actual_type = instruction->operand->value->type; |
| ... | ... | @@ -3460,7 +3460,7 @@ static LLVMValueRef ir_render_bit_cast(CodeGen *g, Stage1Air *executable, |
| 3460 | 3460 | } |
| 3461 | 3461 | |
| 3462 | 3462 | static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, Stage1Air *executable, |
| 3463 | IrInstGenWidenOrShorten *instruction) | |
| 3463 | Stage1AirInstWidenOrShorten *instruction) | |
| 3464 | 3464 | { |
| 3465 | 3465 | ZigType *actual_type = instruction->target->value->type; |
| 3466 | 3466 | // TODO instead of this logic, use the Noop instruction to change the type from |
| ... | ... | @@ -3476,7 +3476,7 @@ static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, Stage1Air *executable |
| 3476 | 3476 | instruction->base.value->type, target_val); |
| 3477 | 3477 | } |
| 3478 | 3478 | |
| 3479 | static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, Stage1Air *executable, IrInstGenIntToPtr *instruction) { | |
| 3479 | static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, Stage1Air *executable, Stage1AirInstIntToPtr *instruction) { | |
| 3480 | 3480 | ZigType *wanted_type = instruction->base.value->type; |
| 3481 | 3481 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); |
| 3482 | 3482 | const uint32_t align_bytes = get_ptr_align(g, wanted_type); |
| ... | ... | @@ -3514,13 +3514,13 @@ static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, Stage1Air *executable, IrIn |
| 3514 | 3514 | return LLVMBuildIntToPtr(g->builder, target_val, get_llvm_type(g, wanted_type), ""); |
| 3515 | 3515 | } |
| 3516 | 3516 | |
| 3517 | static LLVMValueRef ir_render_ptr_to_int(CodeGen *g, Stage1Air *executable, IrInstGenPtrToInt *instruction) { | |
| 3517 | static LLVMValueRef ir_render_ptr_to_int(CodeGen *g, Stage1Air *executable, Stage1AirInstPtrToInt *instruction) { | |
| 3518 | 3518 | ZigType *wanted_type = instruction->base.value->type; |
| 3519 | 3519 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); |
| 3520 | 3520 | return LLVMBuildPtrToInt(g->builder, target_val, get_llvm_type(g, wanted_type), ""); |
| 3521 | 3521 | } |
| 3522 | 3522 | |
| 3523 | static LLVMValueRef ir_render_int_to_enum(CodeGen *g, Stage1Air *executable, IrInstGenIntToEnum *instruction) { | |
| 3523 | static LLVMValueRef ir_render_int_to_enum(CodeGen *g, Stage1Air *executable, Stage1AirInstIntToEnum *instruction) { | |
| 3524 | 3524 | ZigType *wanted_type = instruction->base.value->type; |
| 3525 | 3525 | assert(wanted_type->id == ZigTypeIdEnum); |
| 3526 | 3526 | ZigType *tag_int_type = wanted_type->data.enumeration.tag_int_type; |
| ... | ... | @@ -3560,7 +3560,7 @@ static LLVMValueRef ir_render_int_to_enum(CodeGen *g, Stage1Air *executable, IrI |
| 3560 | 3560 | return tag_int_value; |
| 3561 | 3561 | } |
| 3562 | 3562 | |
| 3563 | static LLVMValueRef ir_render_int_to_err(CodeGen *g, Stage1Air *executable, IrInstGenIntToErr *instruction) { | |
| 3563 | static LLVMValueRef ir_render_int_to_err(CodeGen *g, Stage1Air *executable, Stage1AirInstIntToErr *instruction) { | |
| 3564 | 3564 | ZigType *wanted_type = instruction->base.value->type; |
| 3565 | 3565 | assert(wanted_type->id == ZigTypeIdErrorSet); |
| 3566 | 3566 | |
| ... | ... | @@ -3577,7 +3577,7 @@ static LLVMValueRef ir_render_int_to_err(CodeGen *g, Stage1Air *executable, IrIn |
| 3577 | 3577 | return gen_widen_or_shorten(g, false, actual_type, g->err_tag_type, target_val); |
| 3578 | 3578 | } |
| 3579 | 3579 | |
| 3580 | static LLVMValueRef ir_render_err_to_int(CodeGen *g, Stage1Air *executable, IrInstGenErrToInt *instruction) { | |
| 3580 | static LLVMValueRef ir_render_err_to_int(CodeGen *g, Stage1Air *executable, Stage1AirInstErrToInt *instruction) { | |
| 3581 | 3581 | ZigType *wanted_type = instruction->base.value->type; |
| 3582 | 3582 | assert(wanted_type->id == ZigTypeIdInt); |
| 3583 | 3583 | assert(!wanted_type->data.integral.is_signed); |
| ... | ... | @@ -3604,7 +3604,7 @@ static LLVMValueRef ir_render_err_to_int(CodeGen *g, Stage1Air *executable, IrIn |
| 3604 | 3604 | } |
| 3605 | 3605 | |
| 3606 | 3606 | static LLVMValueRef ir_render_unreachable(CodeGen *g, Stage1Air *executable, |
| 3607 | IrInstGenUnreachable *unreachable_instruction) | |
| 3607 | Stage1AirInstUnreachable *unreachable_instruction) | |
| 3608 | 3608 | { |
| 3609 | 3609 | if (ir_want_runtime_safety(g, &unreachable_instruction->base)) { |
| 3610 | 3610 | gen_safety_crash(g, PanicMsgIdUnreachable); |
| ... | ... | @@ -3615,7 +3615,7 @@ static LLVMValueRef ir_render_unreachable(CodeGen *g, Stage1Air *executable, |
| 3615 | 3615 | } |
| 3616 | 3616 | |
| 3617 | 3617 | static LLVMValueRef ir_render_cond_br(CodeGen *g, Stage1Air *executable, |
| 3618 | IrInstGenCondBr *cond_br_instruction) | |
| 3618 | Stage1AirInstCondBr *cond_br_instruction) | |
| 3619 | 3619 | { |
| 3620 | 3620 | LLVMBuildCondBr(g->builder, |
| 3621 | 3621 | ir_llvm_value(g, cond_br_instruction->condition), |
| ... | ... | @@ -3624,19 +3624,19 @@ static LLVMValueRef ir_render_cond_br(CodeGen *g, Stage1Air *executable, |
| 3624 | 3624 | return nullptr; |
| 3625 | 3625 | } |
| 3626 | 3626 | |
| 3627 | static LLVMValueRef ir_render_br(CodeGen *g, Stage1Air *executable, IrInstGenBr *br_instruction) { | |
| 3627 | static LLVMValueRef ir_render_br(CodeGen *g, Stage1Air *executable, Stage1AirInstBr *br_instruction) { | |
| 3628 | 3628 | LLVMBuildBr(g->builder, br_instruction->dest_block->llvm_block); |
| 3629 | 3629 | return nullptr; |
| 3630 | 3630 | } |
| 3631 | 3631 | |
| 3632 | 3632 | static LLVMValueRef ir_render_binary_not(CodeGen *g, Stage1Air *executable, |
| 3633 | IrInstGenBinaryNot *inst) | |
| 3633 | Stage1AirInstBinaryNot *inst) | |
| 3634 | 3634 | { |
| 3635 | 3635 | LLVMValueRef operand = ir_llvm_value(g, inst->operand); |
| 3636 | 3636 | return LLVMBuildNot(g->builder, operand, ""); |
| 3637 | 3637 | } |
| 3638 | 3638 | |
| 3639 | static LLVMValueRef ir_gen_negation(CodeGen *g, IrInstGen *inst, IrInstGen *operand, bool wrapping) { | |
| 3639 | static LLVMValueRef ir_gen_negation(CodeGen *g, Stage1AirInst *inst, Stage1AirInst *operand, bool wrapping) { | |
| 3640 | 3640 | LLVMValueRef llvm_operand = ir_llvm_value(g, operand); |
| 3641 | 3641 | ZigType *operand_type = operand->value->type; |
| 3642 | 3642 | ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? |
| ... | ... | @@ -3662,12 +3662,12 @@ static LLVMValueRef ir_gen_negation(CodeGen *g, IrInstGen *inst, IrInstGen *oper |
| 3662 | 3662 | } |
| 3663 | 3663 | |
| 3664 | 3664 | static LLVMValueRef ir_render_negation(CodeGen *g, Stage1Air *executable, |
| 3665 | IrInstGenNegation *inst) | |
| 3665 | Stage1AirInstNegation *inst) | |
| 3666 | 3666 | { |
| 3667 | 3667 | return ir_gen_negation(g, &inst->base, inst->operand, inst->wrapping); |
| 3668 | 3668 | } |
| 3669 | 3669 | |
| 3670 | static LLVMValueRef ir_render_bool_not(CodeGen *g, Stage1Air *executable, IrInstGenBoolNot *instruction) { | |
| 3670 | static LLVMValueRef ir_render_bool_not(CodeGen *g, Stage1Air *executable, Stage1AirInstBoolNot *instruction) { | |
| 3671 | 3671 | LLVMValueRef value = ir_llvm_value(g, instruction->value); |
| 3672 | 3672 | LLVMValueRef zero = LLVMConstNull(LLVMTypeOf(value)); |
| 3673 | 3673 | return LLVMBuildICmp(g->builder, LLVMIntEQ, value, zero, ""); |
| ... | ... | @@ -3681,7 +3681,7 @@ static void render_decl_var(CodeGen *g, ZigVar *var) { |
| 3681 | 3681 | gen_var_debug_decl(g, var); |
| 3682 | 3682 | } |
| 3683 | 3683 | |
| 3684 | static LLVMValueRef ir_render_decl_var(CodeGen *g, Stage1Air *executable, IrInstGenDeclVar *instruction) { | |
| 3684 | static LLVMValueRef ir_render_decl_var(CodeGen *g, Stage1Air *executable, Stage1AirInstDeclVar *instruction) { | |
| 3685 | 3685 | instruction->var->ptr_instruction = instruction->var_ptr; |
| 3686 | 3686 | instruction->var->did_the_decl_codegen = true; |
| 3687 | 3687 | render_decl_var(g, instruction->var); |
| ... | ... | @@ -3689,7 +3689,7 @@ static LLVMValueRef ir_render_decl_var(CodeGen *g, Stage1Air *executable, IrInst |
| 3689 | 3689 | } |
| 3690 | 3690 | |
| 3691 | 3691 | static LLVMValueRef ir_render_load_ptr(CodeGen *g, Stage1Air *executable, |
| 3692 | IrInstGenLoadPtr *instruction) | |
| 3692 | Stage1AirInstLoadPtr *instruction) | |
| 3693 | 3693 | { |
| 3694 | 3694 | ZigType *child_type = instruction->base.value->type; |
| 3695 | 3695 | if (!type_has_bits(g, child_type)) |
| ... | ... | @@ -3896,7 +3896,7 @@ static void gen_undef_init(CodeGen *g, ZigType *ptr_type, ZigType *value_type, L |
| 3896 | 3896 | gen_assign_raw(g, ptr, ptr_type, zero); |
| 3897 | 3897 | } |
| 3898 | 3898 | |
| 3899 | static LLVMValueRef ir_render_store_ptr(CodeGen *g, Stage1Air *executable, IrInstGenStorePtr *instruction) { | |
| 3899 | static LLVMValueRef ir_render_store_ptr(CodeGen *g, Stage1Air *executable, Stage1AirInstStorePtr *instruction) { | |
| 3900 | 3900 | Error err; |
| 3901 | 3901 | |
| 3902 | 3902 | ZigType *ptr_type = instruction->ptr->value->type; |
| ... | ... | @@ -3929,7 +3929,7 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, Stage1Air *executable, IrIns |
| 3929 | 3929 | } |
| 3930 | 3930 | |
| 3931 | 3931 | static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, Stage1Air *executable, |
| 3932 | IrInstGenVectorStoreElem *instruction) | |
| 3932 | Stage1AirInstVectorStoreElem *instruction) | |
| 3933 | 3933 | { |
| 3934 | 3934 | LLVMValueRef vector_ptr = ir_llvm_value(g, instruction->vector_ptr); |
| 3935 | 3935 | LLVMValueRef index = ir_llvm_value(g, instruction->index); |
| ... | ... | @@ -3941,7 +3941,7 @@ static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, Stage1Air *executabl |
| 3941 | 3941 | return nullptr; |
| 3942 | 3942 | } |
| 3943 | 3943 | |
| 3944 | static LLVMValueRef ir_render_var_ptr(CodeGen *g, Stage1Air *executable, IrInstGenVarPtr *instruction) { | |
| 3944 | static LLVMValueRef ir_render_var_ptr(CodeGen *g, Stage1Air *executable, Stage1AirInstVarPtr *instruction) { | |
| 3945 | 3945 | Error err; |
| 3946 | 3946 | |
| 3947 | 3947 | ZigType *ptr_type = instruction->base.value->type; |
| ... | ... | @@ -3969,7 +3969,7 @@ static LLVMValueRef ir_render_var_ptr(CodeGen *g, Stage1Air *executable, IrInstG |
| 3969 | 3969 | } |
| 3970 | 3970 | |
| 3971 | 3971 | static LLVMValueRef ir_render_return_ptr(CodeGen *g, Stage1Air *executable, |
| 3972 | IrInstGenReturnPtr *instruction) | |
| 3972 | Stage1AirInstReturnPtr *instruction) | |
| 3973 | 3973 | { |
| 3974 | 3974 | if (!type_has_bits(g, instruction->base.value->type)) |
| 3975 | 3975 | return nullptr; |
| ... | ... | @@ -3977,7 +3977,7 @@ static LLVMValueRef ir_render_return_ptr(CodeGen *g, Stage1Air *executable, |
| 3977 | 3977 | return g->cur_ret_ptr; |
| 3978 | 3978 | } |
| 3979 | 3979 | |
| 3980 | static LLVMValueRef ir_render_elem_ptr(CodeGen *g, Stage1Air *executable, IrInstGenElemPtr *instruction) { | |
| 3980 | static LLVMValueRef ir_render_elem_ptr(CodeGen *g, Stage1Air *executable, Stage1AirInstElemPtr *instruction) { | |
| 3981 | 3981 | LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->array_ptr); |
| 3982 | 3982 | ZigType *array_ptr_type = instruction->array_ptr->value->type; |
| 3983 | 3983 | assert(array_ptr_type->id == ZigTypeIdPointer); |
| ... | ... | @@ -4152,7 +4152,7 @@ static void render_async_spills(CodeGen *g) { |
| 4152 | 4152 | ZigType *frame_type = g->cur_fn->frame_type->data.frame.locals_struct; |
| 4153 | 4153 | |
| 4154 | 4154 | for (size_t alloca_i = 0; alloca_i < g->cur_fn->alloca_gen_list.length; alloca_i += 1) { |
| 4155 | IrInstGenAlloca *instruction = g->cur_fn->alloca_gen_list.at(alloca_i); | |
| 4155 | Stage1AirInstAlloca *instruction = g->cur_fn->alloca_gen_list.at(alloca_i); | |
| 4156 | 4156 | if (instruction->field_index == SIZE_MAX) |
| 4157 | 4157 | continue; |
| 4158 | 4158 | |
| ... | ... | @@ -4229,7 +4229,7 @@ static void gen_init_stack_trace(CodeGen *g, LLVMValueRef trace_field_ptr, LLVMV |
| 4229 | 4229 | LLVMBuildStore(g->builder, LLVMConstInt(usize_type_ref, stack_trace_ptr_count, false), addrs_len_ptr); |
| 4230 | 4230 | } |
| 4231 | 4231 | |
| 4232 | static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, IrInstGenCall *instruction) { | |
| 4232 | static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, Stage1AirInstCall *instruction) { | |
| 4233 | 4233 | Error err; |
| 4234 | 4234 | |
| 4235 | 4235 | LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type; |
| ... | ... | @@ -4579,7 +4579,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, IrInstGenC |
| 4579 | 4579 | return nullptr; |
| 4580 | 4580 | |
| 4581 | 4581 | if (result_loc != nullptr) { |
| 4582 | if (instruction->result_loc->id == IrInstGenIdReturnPtr) { | |
| 4582 | if (instruction->result_loc->id == Stage1AirInstIdReturnPtr) { | |
| 4583 | 4583 | instruction->base.spill = nullptr; |
| 4584 | 4584 | return g->cur_ret_ptr; |
| 4585 | 4585 | } else { |
| ... | ... | @@ -4650,7 +4650,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, IrInstGenC |
| 4650 | 4650 | } |
| 4651 | 4651 | |
| 4652 | 4652 | static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, Stage1Air *executable, |
| 4653 | IrInstGenStructFieldPtr *instruction) | |
| 4653 | Stage1AirInstStructFieldPtr *instruction) | |
| 4654 | 4654 | { |
| 4655 | 4655 | Error err; |
| 4656 | 4656 | |
| ... | ... | @@ -4701,7 +4701,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, Stage1Air *executable |
| 4701 | 4701 | } |
| 4702 | 4702 | |
| 4703 | 4703 | static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, Stage1Air *executable, |
| 4704 | IrInstGenUnionFieldPtr *instruction) | |
| 4704 | Stage1AirInstUnionFieldPtr *instruction) | |
| 4705 | 4705 | { |
| 4706 | 4706 | if (instruction->base.value->special != ConstValSpecialRuntime) |
| 4707 | 4707 | return nullptr; |
| ... | ... | @@ -4800,7 +4800,7 @@ static size_t find_asm_index(CodeGen *g, AstNode *node, AsmToken *tok, Buf *src_ |
| 4800 | 4800 | return SIZE_MAX; |
| 4801 | 4801 | } |
| 4802 | 4802 | |
| 4803 | static LLVMValueRef ir_render_asm_gen(CodeGen *g, Stage1Air *executable, IrInstGenAsm *instruction) { | |
| 4803 | static LLVMValueRef ir_render_asm_gen(CodeGen *g, Stage1Air *executable, Stage1AirInstAsm *instruction) { | |
| 4804 | 4804 | AstNode *asm_node = instruction->base.source_node; |
| 4805 | 4805 | assert(asm_node->type == NodeTypeAsmExpr); |
| 4806 | 4806 | AstNodeAsmExpr *asm_expr = &asm_node->data.asm_expr; |
| ... | ... | @@ -4885,7 +4885,7 @@ static LLVMValueRef ir_render_asm_gen(CodeGen *g, Stage1Air *executable, IrInstG |
| 4885 | 4885 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1, total_index += 1, param_index += 1) { |
| 4886 | 4886 | AsmInput *asm_input = asm_expr->input_list.at(i); |
| 4887 | 4887 | buf_replace(asm_input->constraint, ',', '|'); |
| 4888 | IrInstGen *ir_input = instruction->input_list[i]; | |
| 4888 | Stage1AirInst *ir_input = instruction->input_list[i]; | |
| 4889 | 4889 | buf_append_buf(&constraint_buf, asm_input->constraint); |
| 4890 | 4890 | if (total_index + 1 < total_constraint_count) { |
| 4891 | 4891 | buf_append_char(&constraint_buf, ','); |
| ... | ... | @@ -4978,13 +4978,13 @@ static LLVMValueRef gen_non_null_bit(CodeGen *g, ZigType *maybe_type, LLVMValueR |
| 4978 | 4978 | } |
| 4979 | 4979 | |
| 4980 | 4980 | static LLVMValueRef ir_render_test_non_null(CodeGen *g, Stage1Air *executable, |
| 4981 | IrInstGenTestNonNull *instruction) | |
| 4981 | Stage1AirInstTestNonNull *instruction) | |
| 4982 | 4982 | { |
| 4983 | 4983 | return gen_non_null_bit(g, instruction->value->value->type, ir_llvm_value(g, instruction->value)); |
| 4984 | 4984 | } |
| 4985 | 4985 | |
| 4986 | 4986 | static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, Stage1Air *executable, |
| 4987 | IrInstGenOptionalUnwrapPtr *instruction) | |
| 4987 | Stage1AirInstOptionalUnwrapPtr *instruction) | |
| 4988 | 4988 | { |
| 4989 | 4989 | if (instruction->base.value->special != ConstValSpecialRuntime) |
| 4990 | 4990 | return nullptr; |
| ... | ... | @@ -5090,7 +5090,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, ZigType *expr_type, BuiltinFn |
| 5090 | 5090 | return fn_val; |
| 5091 | 5091 | } |
| 5092 | 5092 | |
| 5093 | static LLVMValueRef ir_render_clz(CodeGen *g, Stage1Air *executable, IrInstGenClz *instruction) { | |
| 5093 | static LLVMValueRef ir_render_clz(CodeGen *g, Stage1Air *executable, Stage1AirInstClz *instruction) { | |
| 5094 | 5094 | ZigType *int_type = instruction->op->value->type; |
| 5095 | 5095 | LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdClz); |
| 5096 | 5096 | LLVMValueRef operand = ir_llvm_value(g, instruction->op); |
| ... | ... | @@ -5102,7 +5102,7 @@ static LLVMValueRef ir_render_clz(CodeGen *g, Stage1Air *executable, IrInstGenCl |
| 5102 | 5102 | return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int); |
| 5103 | 5103 | } |
| 5104 | 5104 | |
| 5105 | static LLVMValueRef ir_render_ctz(CodeGen *g, Stage1Air *executable, IrInstGenCtz *instruction) { | |
| 5105 | static LLVMValueRef ir_render_ctz(CodeGen *g, Stage1Air *executable, Stage1AirInstCtz *instruction) { | |
| 5106 | 5106 | ZigType *int_type = instruction->op->value->type; |
| 5107 | 5107 | LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdCtz); |
| 5108 | 5108 | LLVMValueRef operand = ir_llvm_value(g, instruction->op); |
| ... | ... | @@ -5114,7 +5114,7 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, Stage1Air *executable, IrInstGenCt |
| 5114 | 5114 | return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int); |
| 5115 | 5115 | } |
| 5116 | 5116 | |
| 5117 | static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, Stage1Air *executable, IrInstGenShuffleVector *instruction) { | |
| 5117 | static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, Stage1Air *executable, Stage1AirInstShuffleVector *instruction) { | |
| 5118 | 5118 | uint64_t len_a = instruction->a->value->type->data.vector.len; |
| 5119 | 5119 | uint64_t len_mask = instruction->mask->value->type->data.vector.len; |
| 5120 | 5120 | |
| ... | ... | @@ -5123,7 +5123,7 @@ static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, Stage1Air *executable, |
| 5123 | 5123 | // when changing code, so Zig uses negative numbers to index the |
| 5124 | 5124 | // second vector. These start at -1 and go down, and are easiest to use |
| 5125 | 5125 | // with the ~ operator. Here we convert between the two formats. |
| 5126 | IrInstGen *mask = instruction->mask; | |
| 5126 | Stage1AirInst *mask = instruction->mask; | |
| 5127 | 5127 | LLVMValueRef *values = heap::c_allocator.allocate<LLVMValueRef>(len_mask); |
| 5128 | 5128 | for (uint64_t i = 0; i < len_mask; i++) { |
| 5129 | 5129 | if (mask->value->data.x_array.data.s_none.elements[i].special == ConstValSpecialUndef) { |
| ... | ... | @@ -5144,7 +5144,7 @@ static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, Stage1Air *executable, |
| 5144 | 5144 | llvm_mask_value, ""); |
| 5145 | 5145 | } |
| 5146 | 5146 | |
| 5147 | static LLVMValueRef ir_render_splat(CodeGen *g, Stage1Air *executable, IrInstGenSplat *instruction) { | |
| 5147 | static LLVMValueRef ir_render_splat(CodeGen *g, Stage1Air *executable, Stage1AirInstSplat *instruction) { | |
| 5148 | 5148 | ZigType *result_type = instruction->base.value->type; |
| 5149 | 5149 | ir_assert(result_type->id == ZigTypeIdVector, &instruction->base); |
| 5150 | 5150 | uint32_t len = result_type->data.vector.len; |
| ... | ... | @@ -5156,7 +5156,7 @@ static LLVMValueRef ir_render_splat(CodeGen *g, Stage1Air *executable, IrInstGen |
| 5156 | 5156 | return LLVMBuildShuffleVector(g->builder, op_vector, undef_vector, LLVMConstNull(mask_llvm_type), ""); |
| 5157 | 5157 | } |
| 5158 | 5158 | |
| 5159 | static LLVMValueRef ir_render_pop_count(CodeGen *g, Stage1Air *executable, IrInstGenPopCount *instruction) { | |
| 5159 | static LLVMValueRef ir_render_pop_count(CodeGen *g, Stage1Air *executable, Stage1AirInstPopCount *instruction) { | |
| 5160 | 5160 | ZigType *int_type = instruction->op->value->type; |
| 5161 | 5161 | LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdPopCount); |
| 5162 | 5162 | LLVMValueRef operand = ir_llvm_value(g, instruction->op); |
| ... | ... | @@ -5164,7 +5164,7 @@ static LLVMValueRef ir_render_pop_count(CodeGen *g, Stage1Air *executable, IrIns |
| 5164 | 5164 | return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int); |
| 5165 | 5165 | } |
| 5166 | 5166 | |
| 5167 | static LLVMValueRef ir_render_switch_br(CodeGen *g, Stage1Air *executable, IrInstGenSwitchBr *instruction) { | |
| 5167 | static LLVMValueRef ir_render_switch_br(CodeGen *g, Stage1Air *executable, Stage1AirInstSwitchBr *instruction) { | |
| 5168 | 5168 | ZigType *target_type = instruction->target_value->value->type; |
| 5169 | 5169 | LLVMBasicBlockRef else_block = instruction->else_block->llvm_block; |
| 5170 | 5170 | |
| ... | ... | @@ -5178,7 +5178,7 @@ static LLVMValueRef ir_render_switch_br(CodeGen *g, Stage1Air *executable, IrIns |
| 5178 | 5178 | (unsigned)instruction->case_count); |
| 5179 | 5179 | |
| 5180 | 5180 | for (size_t i = 0; i < instruction->case_count; i += 1) { |
| 5181 | IrInstGenSwitchBrCase *this_case = &instruction->cases[i]; | |
| 5181 | Stage1AirInstSwitchBrCase *this_case = &instruction->cases[i]; | |
| 5182 | 5182 | |
| 5183 | 5183 | LLVMValueRef case_value = ir_llvm_value(g, this_case->value); |
| 5184 | 5184 | if (target_type->id == ZigTypeIdPointer) { |
| ... | ... | @@ -5192,7 +5192,7 @@ static LLVMValueRef ir_render_switch_br(CodeGen *g, Stage1Air *executable, IrIns |
| 5192 | 5192 | return nullptr; |
| 5193 | 5193 | } |
| 5194 | 5194 | |
| 5195 | static LLVMValueRef ir_render_phi(CodeGen *g, Stage1Air *executable, IrInstGenPhi *instruction) { | |
| 5195 | static LLVMValueRef ir_render_phi(CodeGen *g, Stage1Air *executable, Stage1AirInstPhi *instruction) { | |
| 5196 | 5196 | if (!type_has_bits(g, instruction->base.value->type)) |
| 5197 | 5197 | return nullptr; |
| 5198 | 5198 | |
| ... | ... | @@ -5216,12 +5216,12 @@ static LLVMValueRef ir_render_phi(CodeGen *g, Stage1Air *executable, IrInstGenPh |
| 5216 | 5216 | return phi; |
| 5217 | 5217 | } |
| 5218 | 5218 | |
| 5219 | static LLVMValueRef ir_render_ref(CodeGen *g, Stage1Air *executable, IrInstGenRef *instruction) { | |
| 5219 | static LLVMValueRef ir_render_ref(CodeGen *g, Stage1Air *executable, Stage1AirInstRef *instruction) { | |
| 5220 | 5220 | if (!type_has_bits(g, instruction->base.value->type)) { |
| 5221 | 5221 | return nullptr; |
| 5222 | 5222 | } |
| 5223 | if (instruction->operand->id == IrInstGenIdCall) { | |
| 5224 | IrInstGenCall *call = reinterpret_cast<IrInstGenCall *>(instruction->operand); | |
| 5223 | if (instruction->operand->id == Stage1AirInstIdCall) { | |
| 5224 | Stage1AirInstCall *call = reinterpret_cast<Stage1AirInstCall *>(instruction->operand); | |
| 5225 | 5225 | if (call->result_loc != nullptr) { |
| 5226 | 5226 | return ir_llvm_value(g, call->result_loc); |
| 5227 | 5227 | } |
| ... | ... | @@ -5236,7 +5236,7 @@ static LLVMValueRef ir_render_ref(CodeGen *g, Stage1Air *executable, IrInstGenRe |
| 5236 | 5236 | } |
| 5237 | 5237 | } |
| 5238 | 5238 | |
| 5239 | static LLVMValueRef ir_render_err_name(CodeGen *g, Stage1Air *executable, IrInstGenErrName *instruction) { | |
| 5239 | static LLVMValueRef ir_render_err_name(CodeGen *g, Stage1Air *executable, Stage1AirInstErrName *instruction) { | |
| 5240 | 5240 | assert(g->generate_error_name_table); |
| 5241 | 5241 | assert(g->errors_by_index.length > 0); |
| 5242 | 5242 | |
| ... | ... | @@ -5363,7 +5363,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) { |
| 5363 | 5363 | } |
| 5364 | 5364 | |
| 5365 | 5365 | static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, Stage1Air *executable, |
| 5366 | IrInstGenTagName *instruction) | |
| 5366 | Stage1AirInstTagName *instruction) | |
| 5367 | 5367 | { |
| 5368 | 5368 | ZigType *enum_type = instruction->target->value->type; |
| 5369 | 5369 | assert(enum_type->id == ZigTypeIdEnum); |
| ... | ... | @@ -5376,7 +5376,7 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, Stage1Air *executable, |
| 5376 | 5376 | } |
| 5377 | 5377 | |
| 5378 | 5378 | static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, Stage1Air *executable, |
| 5379 | IrInstGenFieldParentPtr *instruction) | |
| 5379 | Stage1AirInstFieldParentPtr *instruction) | |
| 5380 | 5380 | { |
| 5381 | 5381 | ZigType *container_ptr_type = instruction->base.value->type; |
| 5382 | 5382 | assert(container_ptr_type->id == ZigTypeIdPointer); |
| ... | ... | @@ -5402,7 +5402,7 @@ static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, Stage1Air *executable |
| 5402 | 5402 | } |
| 5403 | 5403 | } |
| 5404 | 5404 | |
| 5405 | static LLVMValueRef ir_render_align_cast(CodeGen *g, Stage1Air *executable, IrInstGenAlignCast *instruction) { | |
| 5405 | static LLVMValueRef ir_render_align_cast(CodeGen *g, Stage1Air *executable, Stage1AirInstAlignCast *instruction) { | |
| 5406 | 5406 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); |
| 5407 | 5407 | assert(target_val); |
| 5408 | 5408 | |
| ... | ... | @@ -5466,7 +5466,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, Stage1Air *executable, IrIn |
| 5466 | 5466 | } |
| 5467 | 5467 | |
| 5468 | 5468 | static LLVMValueRef ir_render_error_return_trace(CodeGen *g, Stage1Air *executable, |
| 5469 | IrInstGenErrorReturnTrace *instruction) | |
| 5469 | Stage1AirInstErrorReturnTrace *instruction) | |
| 5470 | 5470 | { |
| 5471 | 5471 | bool is_llvm_alloca; |
| 5472 | 5472 | LLVMValueRef cur_err_ret_trace_val = get_cur_err_ret_trace_val(g, instruction->base.scope, &is_llvm_alloca); |
| ... | ... | @@ -5507,7 +5507,7 @@ static enum ZigLLVM_AtomicRMWBinOp to_ZigLLVMAtomicRMWBinOp(AtomicRmwOp op, bool |
| 5507 | 5507 | zig_unreachable(); |
| 5508 | 5508 | } |
| 5509 | 5509 | |
| 5510 | static LLVMTypeRef get_atomic_abi_type(CodeGen *g, IrInstGen *instruction, bool RMWXchg) { | |
| 5510 | static LLVMTypeRef get_atomic_abi_type(CodeGen *g, Stage1AirInst *instruction, bool RMWXchg) { | |
| 5511 | 5511 | // If the operand type of an atomic operation is not byte sized we need to |
| 5512 | 5512 | // widen it before using it and then truncate the result. |
| 5513 | 5513 | // RMW exchange of floating-point values is bitcasted to same-sized integer |
| ... | ... | @@ -5538,7 +5538,7 @@ static LLVMTypeRef get_atomic_abi_type(CodeGen *g, IrInstGen *instruction, bool |
| 5538 | 5538 | } |
| 5539 | 5539 | } |
| 5540 | 5540 | |
| 5541 | static LLVMValueRef ir_render_cmpxchg(CodeGen *g, Stage1Air *executable, IrInstGenCmpxchg *instruction) { | |
| 5541 | static LLVMValueRef ir_render_cmpxchg(CodeGen *g, Stage1Air *executable, Stage1AirInstCmpxchg *instruction) { | |
| 5542 | 5542 | LLVMValueRef ptr_val = ir_llvm_value(g, instruction->ptr); |
| 5543 | 5543 | LLVMValueRef cmp_val = ir_llvm_value(g, instruction->cmp_value); |
| 5544 | 5544 | LLVMValueRef new_val = ir_llvm_value(g, instruction->new_value); |
| ... | ... | @@ -5600,7 +5600,7 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, Stage1Air *executable, IrInstG |
| 5600 | 5600 | return result_loc; |
| 5601 | 5601 | } |
| 5602 | 5602 | |
| 5603 | static LLVMValueRef ir_render_reduce(CodeGen *g, Stage1Air *executable, IrInstGenReduce *instruction) { | |
| 5603 | static LLVMValueRef ir_render_reduce(CodeGen *g, Stage1Air *executable, Stage1AirInstReduce *instruction) { | |
| 5604 | 5604 | LLVMValueRef value = ir_llvm_value(g, instruction->value); |
| 5605 | 5605 | |
| 5606 | 5606 | ZigType *value_type = instruction->value->value->type; |
| ... | ... | @@ -5664,13 +5664,13 @@ static LLVMValueRef ir_render_reduce(CodeGen *g, Stage1Air *executable, IrInstGe |
| 5664 | 5664 | return result_val; |
| 5665 | 5665 | } |
| 5666 | 5666 | |
| 5667 | static LLVMValueRef ir_render_fence(CodeGen *g, Stage1Air *executable, IrInstGenFence *instruction) { | |
| 5667 | static LLVMValueRef ir_render_fence(CodeGen *g, Stage1Air *executable, Stage1AirInstFence *instruction) { | |
| 5668 | 5668 | LLVMAtomicOrdering atomic_order = to_LLVMAtomicOrdering(instruction->order); |
| 5669 | 5669 | LLVMBuildFence(g->builder, atomic_order, false, ""); |
| 5670 | 5670 | return nullptr; |
| 5671 | 5671 | } |
| 5672 | 5672 | |
| 5673 | static LLVMValueRef ir_render_truncate(CodeGen *g, Stage1Air *executable, IrInstGenTruncate *instruction) { | |
| 5673 | static LLVMValueRef ir_render_truncate(CodeGen *g, Stage1Air *executable, Stage1AirInstTruncate *instruction) { | |
| 5674 | 5674 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); |
| 5675 | 5675 | ZigType *dest_type = instruction->base.value->type; |
| 5676 | 5676 | ZigType *src_type = instruction->target->value->type; |
| ... | ... | @@ -5685,7 +5685,7 @@ static LLVMValueRef ir_render_truncate(CodeGen *g, Stage1Air *executable, IrInst |
| 5685 | 5685 | } |
| 5686 | 5686 | } |
| 5687 | 5687 | |
| 5688 | static LLVMValueRef ir_render_memset(CodeGen *g, Stage1Air *executable, IrInstGenMemset *instruction) { | |
| 5688 | static LLVMValueRef ir_render_memset(CodeGen *g, Stage1Air *executable, Stage1AirInstMemset *instruction) { | |
| 5689 | 5689 | LLVMValueRef dest_ptr = ir_llvm_value(g, instruction->dest_ptr); |
| 5690 | 5690 | LLVMValueRef len_val = ir_llvm_value(g, instruction->count); |
| 5691 | 5691 | |
| ... | ... | @@ -5715,7 +5715,7 @@ static LLVMValueRef ir_render_memset(CodeGen *g, Stage1Air *executable, IrInstGe |
| 5715 | 5715 | return nullptr; |
| 5716 | 5716 | } |
| 5717 | 5717 | |
| 5718 | static LLVMValueRef ir_render_memcpy(CodeGen *g, Stage1Air *executable, IrInstGenMemcpy *instruction) { | |
| 5718 | static LLVMValueRef ir_render_memcpy(CodeGen *g, Stage1Air *executable, Stage1AirInstMemcpy *instruction) { | |
| 5719 | 5719 | LLVMValueRef dest_ptr = ir_llvm_value(g, instruction->dest_ptr); |
| 5720 | 5720 | LLVMValueRef src_ptr = ir_llvm_value(g, instruction->src_ptr); |
| 5721 | 5721 | LLVMValueRef len_val = ir_llvm_value(g, instruction->count); |
| ... | ... | @@ -5737,14 +5737,14 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, Stage1Air *executable, IrInstGe |
| 5737 | 5737 | return nullptr; |
| 5738 | 5738 | } |
| 5739 | 5739 | |
| 5740 | static LLVMValueRef ir_render_wasm_memory_size(CodeGen *g, Stage1Air *executable, IrInstGenWasmMemorySize *instruction) { | |
| 5740 | static LLVMValueRef ir_render_wasm_memory_size(CodeGen *g, Stage1Air *executable, Stage1AirInstWasmMemorySize *instruction) { | |
| 5741 | 5741 | // TODO adjust for wasm64 |
| 5742 | 5742 | LLVMValueRef param = ir_llvm_value(g, instruction->index); |
| 5743 | 5743 | LLVMValueRef val = LLVMBuildCall(g->builder, gen_wasm_memory_size(g), &param, 1, ""); |
| 5744 | 5744 | return val; |
| 5745 | 5745 | } |
| 5746 | 5746 | |
| 5747 | static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, Stage1Air *executable, IrInstGenWasmMemoryGrow *instruction) { | |
| 5747 | static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, Stage1Air *executable, Stage1AirInstWasmMemoryGrow *instruction) { | |
| 5748 | 5748 | // TODO adjust for wasm64 |
| 5749 | 5749 | LLVMValueRef params[] = { |
| 5750 | 5750 | ir_llvm_value(g, instruction->index), |
| ... | ... | @@ -5754,7 +5754,7 @@ static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, Stage1Air *executable |
| 5754 | 5754 | return val; |
| 5755 | 5755 | } |
| 5756 | 5756 | |
| 5757 | static LLVMValueRef ir_render_slice(CodeGen *g, Stage1Air *executable, IrInstGenSlice *instruction) { | |
| 5757 | static LLVMValueRef ir_render_slice(CodeGen *g, Stage1Air *executable, Stage1AirInstSlice *instruction) { | |
| 5758 | 5758 | Error err; |
| 5759 | 5759 | |
| 5760 | 5760 | LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr); |
| ... | ... | @@ -5991,13 +5991,13 @@ static LLVMValueRef get_trap_fn_val(CodeGen *g) { |
| 5991 | 5991 | } |
| 5992 | 5992 | |
| 5993 | 5993 | |
| 5994 | static LLVMValueRef ir_render_breakpoint(CodeGen *g, Stage1Air *executable, IrInstGenBreakpoint *instruction) { | |
| 5994 | static LLVMValueRef ir_render_breakpoint(CodeGen *g, Stage1Air *executable, Stage1AirInstBreakpoint *instruction) { | |
| 5995 | 5995 | LLVMBuildCall(g->builder, get_trap_fn_val(g), nullptr, 0, ""); |
| 5996 | 5996 | return nullptr; |
| 5997 | 5997 | } |
| 5998 | 5998 | |
| 5999 | 5999 | static LLVMValueRef ir_render_return_address(CodeGen *g, Stage1Air *executable, |
| 6000 | IrInstGenReturnAddress *instruction) | |
| 6000 | Stage1AirInstReturnAddress *instruction) | |
| 6001 | 6001 | { |
| 6002 | 6002 | if (target_is_wasm(g->zig_target) && g->zig_target->os != OsEmscripten) { |
| 6003 | 6003 | // I got this error from LLVM 10: |
| ... | ... | @@ -6025,18 +6025,18 @@ static LLVMValueRef get_frame_address_fn_val(CodeGen *g) { |
| 6025 | 6025 | } |
| 6026 | 6026 | |
| 6027 | 6027 | static LLVMValueRef ir_render_frame_address(CodeGen *g, Stage1Air *executable, |
| 6028 | IrInstGenFrameAddress *instruction) | |
| 6028 | Stage1AirInstFrameAddress *instruction) | |
| 6029 | 6029 | { |
| 6030 | 6030 | LLVMValueRef zero = LLVMConstNull(g->builtin_types.entry_i32->llvm_type); |
| 6031 | 6031 | LLVMValueRef ptr_val = LLVMBuildCall(g->builder, get_frame_address_fn_val(g), &zero, 1, ""); |
| 6032 | 6032 | return LLVMBuildPtrToInt(g->builder, ptr_val, g->builtin_types.entry_usize->llvm_type, ""); |
| 6033 | 6033 | } |
| 6034 | 6034 | |
| 6035 | static LLVMValueRef ir_render_handle(CodeGen *g, Stage1Air *executable, IrInstGenFrameHandle *instruction) { | |
| 6035 | static LLVMValueRef ir_render_handle(CodeGen *g, Stage1Air *executable, Stage1AirInstFrameHandle *instruction) { | |
| 6036 | 6036 | return g->cur_frame_ptr; |
| 6037 | 6037 | } |
| 6038 | 6038 | |
| 6039 | static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstGenOverflowOp *instruction) { | |
| 6039 | static LLVMValueRef render_shl_with_overflow(CodeGen *g, Stage1AirInstOverflowOp *instruction) { | |
| 6040 | 6040 | ZigType *int_type = instruction->result_ptr_type; |
| 6041 | 6041 | assert(int_type->id == ZigTypeIdInt); |
| 6042 | 6042 | |
| ... | ... | @@ -6061,7 +6061,7 @@ static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstGenOverflowOp *in |
| 6061 | 6061 | return overflow_bit; |
| 6062 | 6062 | } |
| 6063 | 6063 | |
| 6064 | static LLVMValueRef ir_render_overflow_op(CodeGen *g, Stage1Air *executable, IrInstGenOverflowOp *instruction) { | |
| 6064 | static LLVMValueRef ir_render_overflow_op(CodeGen *g, Stage1Air *executable, Stage1AirInstOverflowOp *instruction) { | |
| 6065 | 6065 | AddSubMul add_sub_mul; |
| 6066 | 6066 | switch (instruction->op) { |
| 6067 | 6067 | case IrOverflowOpAdd: |
| ... | ... | @@ -6099,7 +6099,7 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, Stage1Air *executable, IrI |
| 6099 | 6099 | return overflow_bit; |
| 6100 | 6100 | } |
| 6101 | 6101 | |
| 6102 | static LLVMValueRef ir_render_test_err(CodeGen *g, Stage1Air *executable, IrInstGenTestErr *instruction) { | |
| 6102 | static LLVMValueRef ir_render_test_err(CodeGen *g, Stage1Air *executable, Stage1AirInstTestErr *instruction) { | |
| 6103 | 6103 | ZigType *err_union_type = instruction->err_union->value->type; |
| 6104 | 6104 | ZigType *payload_type = err_union_type->data.error_union.payload_type; |
| 6105 | 6105 | LLVMValueRef err_union_handle = ir_llvm_value(g, instruction->err_union); |
| ... | ... | @@ -6117,7 +6117,7 @@ static LLVMValueRef ir_render_test_err(CodeGen *g, Stage1Air *executable, IrInst |
| 6117 | 6117 | } |
| 6118 | 6118 | |
| 6119 | 6119 | static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, Stage1Air *executable, |
| 6120 | IrInstGenUnwrapErrCode *instruction) | |
| 6120 | Stage1AirInstUnwrapErrCode *instruction) | |
| 6121 | 6121 | { |
| 6122 | 6122 | if (instruction->base.value->special != ConstValSpecialRuntime) |
| 6123 | 6123 | return nullptr; |
| ... | ... | @@ -6137,7 +6137,7 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, Stage1Air *executable, |
| 6137 | 6137 | } |
| 6138 | 6138 | |
| 6139 | 6139 | static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, Stage1Air *executable, |
| 6140 | IrInstGenUnwrapErrPayload *instruction) | |
| 6140 | Stage1AirInstUnwrapErrPayload *instruction) | |
| 6141 | 6141 | { |
| 6142 | 6142 | Error err; |
| 6143 | 6143 | |
| ... | ... | @@ -6205,7 +6205,7 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, Stage1Air *executab |
| 6205 | 6205 | } |
| 6206 | 6206 | } |
| 6207 | 6207 | |
| 6208 | static LLVMValueRef ir_render_optional_wrap(CodeGen *g, Stage1Air *executable, IrInstGenOptionalWrap *instruction) { | |
| 6208 | static LLVMValueRef ir_render_optional_wrap(CodeGen *g, Stage1Air *executable, Stage1AirInstOptionalWrap *instruction) { | |
| 6209 | 6209 | ZigType *wanted_type = instruction->base.value->type; |
| 6210 | 6210 | |
| 6211 | 6211 | assert(wanted_type->id == ZigTypeIdOptional); |
| ... | ... | @@ -6241,7 +6241,7 @@ static LLVMValueRef ir_render_optional_wrap(CodeGen *g, Stage1Air *executable, I |
| 6241 | 6241 | return result_loc; |
| 6242 | 6242 | } |
| 6243 | 6243 | |
| 6244 | static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, Stage1Air *executable, IrInstGenErrWrapCode *instruction) { | |
| 6244 | static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, Stage1Air *executable, Stage1AirInstErrWrapCode *instruction) { | |
| 6245 | 6245 | ZigType *wanted_type = instruction->base.value->type; |
| 6246 | 6246 | |
| 6247 | 6247 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| ... | ... | @@ -6261,7 +6261,7 @@ static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, Stage1Air *executable, I |
| 6261 | 6261 | return result_loc; |
| 6262 | 6262 | } |
| 6263 | 6263 | |
| 6264 | static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, Stage1Air *executable, IrInstGenErrWrapPayload *instruction) { | |
| 6264 | static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, Stage1Air *executable, Stage1AirInstErrWrapPayload *instruction) { | |
| 6265 | 6265 | ZigType *wanted_type = instruction->base.value->type; |
| 6266 | 6266 | |
| 6267 | 6267 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| ... | ... | @@ -6292,7 +6292,7 @@ static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, Stage1Air *executable |
| 6292 | 6292 | return result_loc; |
| 6293 | 6293 | } |
| 6294 | 6294 | |
| 6295 | static LLVMValueRef ir_render_union_tag(CodeGen *g, Stage1Air *executable, IrInstGenUnionTag *instruction) { | |
| 6295 | static LLVMValueRef ir_render_union_tag(CodeGen *g, Stage1Air *executable, Stage1AirInstUnionTag *instruction) { | |
| 6296 | 6296 | ZigType *union_type = instruction->value->value->type; |
| 6297 | 6297 | |
| 6298 | 6298 | ZigType *tag_type = union_type->data.unionation.tag_type; |
| ... | ... | @@ -6310,7 +6310,7 @@ static LLVMValueRef ir_render_union_tag(CodeGen *g, Stage1Air *executable, IrIns |
| 6310 | 6310 | return get_handle_value(g, tag_field_ptr, tag_type, ptr_type); |
| 6311 | 6311 | } |
| 6312 | 6312 | |
| 6313 | static LLVMValueRef ir_render_panic(CodeGen *g, Stage1Air *executable, IrInstGenPanic *instruction) { | |
| 6313 | static LLVMValueRef ir_render_panic(CodeGen *g, Stage1Air *executable, Stage1AirInstPanic *instruction) { | |
| 6314 | 6314 | bool is_llvm_alloca; |
| 6315 | 6315 | LLVMValueRef err_ret_trace_val = get_cur_err_ret_trace_val(g, instruction->base.scope, &is_llvm_alloca); |
| 6316 | 6316 | gen_panic(g, ir_llvm_value(g, instruction->msg), err_ret_trace_val, is_llvm_alloca); |
| ... | ... | @@ -6318,7 +6318,7 @@ static LLVMValueRef ir_render_panic(CodeGen *g, Stage1Air *executable, IrInstGen |
| 6318 | 6318 | } |
| 6319 | 6319 | |
| 6320 | 6320 | static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, Stage1Air *executable, |
| 6321 | IrInstGenAtomicRmw *instruction) | |
| 6321 | Stage1AirInstAtomicRmw *instruction) | |
| 6322 | 6322 | { |
| 6323 | 6323 | bool is_signed; |
| 6324 | 6324 | ZigType *operand_type = instruction->operand->value->type; |
| ... | ... | @@ -6370,7 +6370,7 @@ static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, Stage1Air *executable, |
| 6370 | 6370 | } |
| 6371 | 6371 | |
| 6372 | 6372 | static LLVMValueRef ir_render_atomic_load(CodeGen *g, Stage1Air *executable, |
| 6373 | IrInstGenAtomicLoad *instruction) | |
| 6373 | Stage1AirInstAtomicLoad *instruction) | |
| 6374 | 6374 | { |
| 6375 | 6375 | LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->ordering); |
| 6376 | 6376 | LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr); |
| ... | ... | @@ -6391,7 +6391,7 @@ static LLVMValueRef ir_render_atomic_load(CodeGen *g, Stage1Air *executable, |
| 6391 | 6391 | } |
| 6392 | 6392 | |
| 6393 | 6393 | static LLVMValueRef ir_render_atomic_store(CodeGen *g, Stage1Air *executable, |
| 6394 | IrInstGenAtomicStore *instruction) | |
| 6394 | Stage1AirInstAtomicStore *instruction) | |
| 6395 | 6395 | { |
| 6396 | 6396 | LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->ordering); |
| 6397 | 6397 | LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr); |
| ... | ... | @@ -6413,13 +6413,13 @@ static LLVMValueRef ir_render_atomic_store(CodeGen *g, Stage1Air *executable, |
| 6413 | 6413 | return nullptr; |
| 6414 | 6414 | } |
| 6415 | 6415 | |
| 6416 | static LLVMValueRef ir_render_float_op(CodeGen *g, Stage1Air *executable, IrInstGenFloatOp *instruction) { | |
| 6416 | static LLVMValueRef ir_render_float_op(CodeGen *g, Stage1Air *executable, Stage1AirInstFloatOp *instruction) { | |
| 6417 | 6417 | LLVMValueRef operand = ir_llvm_value(g, instruction->operand); |
| 6418 | 6418 | LLVMValueRef fn_val = get_float_fn(g, instruction->base.value->type, ZigLLVMFnIdFloatOp, instruction->fn_id); |
| 6419 | 6419 | return LLVMBuildCall(g->builder, fn_val, &operand, 1, ""); |
| 6420 | 6420 | } |
| 6421 | 6421 | |
| 6422 | static LLVMValueRef ir_render_mul_add(CodeGen *g, Stage1Air *executable, IrInstGenMulAdd *instruction) { | |
| 6422 | static LLVMValueRef ir_render_mul_add(CodeGen *g, Stage1Air *executable, Stage1AirInstMulAdd *instruction) { | |
| 6423 | 6423 | LLVMValueRef op1 = ir_llvm_value(g, instruction->op1); |
| 6424 | 6424 | LLVMValueRef op2 = ir_llvm_value(g, instruction->op2); |
| 6425 | 6425 | LLVMValueRef op3 = ir_llvm_value(g, instruction->op3); |
| ... | ... | @@ -6434,7 +6434,7 @@ static LLVMValueRef ir_render_mul_add(CodeGen *g, Stage1Air *executable, IrInstG |
| 6434 | 6434 | return LLVMBuildCall(g->builder, fn_val, args, 3, ""); |
| 6435 | 6435 | } |
| 6436 | 6436 | |
| 6437 | static LLVMValueRef ir_render_bswap(CodeGen *g, Stage1Air *executable, IrInstGenBswap *instruction) { | |
| 6437 | static LLVMValueRef ir_render_bswap(CodeGen *g, Stage1Air *executable, Stage1AirInstBswap *instruction) { | |
| 6438 | 6438 | LLVMValueRef op = ir_llvm_value(g, instruction->op); |
| 6439 | 6439 | ZigType *expr_type = instruction->base.value->type; |
| 6440 | 6440 | bool is_vector = expr_type->id == ZigTypeIdVector; |
| ... | ... | @@ -6469,7 +6469,7 @@ static LLVMValueRef ir_render_bswap(CodeGen *g, Stage1Air *executable, IrInstGen |
| 6469 | 6469 | } |
| 6470 | 6470 | |
| 6471 | 6471 | static LLVMValueRef ir_render_extern(CodeGen *g, Stage1Air *executable, |
| 6472 | IrInstGenExtern *instruction) | |
| 6472 | Stage1AirInstExtern *instruction) | |
| 6473 | 6473 | { |
| 6474 | 6474 | ZigType *expr_type = instruction->base.value->type; |
| 6475 | 6475 | assert(get_src_ptr_type(expr_type)); |
| ... | ... | @@ -6492,7 +6492,7 @@ static LLVMValueRef ir_render_extern(CodeGen *g, Stage1Air *executable, |
| 6492 | 6492 | return LLVMBuildBitCast(g->builder, global_value, get_llvm_type(g, expr_type), ""); |
| 6493 | 6493 | } |
| 6494 | 6494 | |
| 6495 | static LLVMValueRef ir_render_bit_reverse(CodeGen *g, Stage1Air *executable, IrInstGenBitReverse *instruction) { | |
| 6495 | static LLVMValueRef ir_render_bit_reverse(CodeGen *g, Stage1Air *executable, Stage1AirInstBitReverse *instruction) { | |
| 6496 | 6496 | LLVMValueRef op = ir_llvm_value(g, instruction->op); |
| 6497 | 6497 | ZigType *int_type = instruction->base.value->type; |
| 6498 | 6498 | assert(int_type->id == ZigTypeIdInt); |
| ... | ... | @@ -6501,7 +6501,7 @@ static LLVMValueRef ir_render_bit_reverse(CodeGen *g, Stage1Air *executable, IrI |
| 6501 | 6501 | } |
| 6502 | 6502 | |
| 6503 | 6503 | static LLVMValueRef ir_render_vector_to_array(CodeGen *g, Stage1Air *executable, |
| 6504 | IrInstGenVectorToArray *instruction) | |
| 6504 | Stage1AirInstVectorToArray *instruction) | |
| 6505 | 6505 | { |
| 6506 | 6506 | ZigType *array_type = instruction->base.value->type; |
| 6507 | 6507 | assert(array_type->id == ZigTypeIdArray); |
| ... | ... | @@ -6535,7 +6535,7 @@ static LLVMValueRef ir_render_vector_to_array(CodeGen *g, Stage1Air *executable, |
| 6535 | 6535 | } |
| 6536 | 6536 | |
| 6537 | 6537 | static LLVMValueRef ir_render_array_to_vector(CodeGen *g, Stage1Air *executable, |
| 6538 | IrInstGenArrayToVector *instruction) | |
| 6538 | Stage1AirInstArrayToVector *instruction) | |
| 6539 | 6539 | { |
| 6540 | 6540 | ZigType *vector_type = instruction->base.value->type; |
| 6541 | 6541 | assert(vector_type->id == ZigTypeIdVector); |
| ... | ... | @@ -6572,7 +6572,7 @@ static LLVMValueRef ir_render_array_to_vector(CodeGen *g, Stage1Air *executable, |
| 6572 | 6572 | } |
| 6573 | 6573 | |
| 6574 | 6574 | static LLVMValueRef ir_render_assert_zero(CodeGen *g, Stage1Air *executable, |
| 6575 | IrInstGenAssertZero *instruction) | |
| 6575 | Stage1AirInstAssertZero *instruction) | |
| 6576 | 6576 | { |
| 6577 | 6577 | LLVMValueRef target = ir_llvm_value(g, instruction->target); |
| 6578 | 6578 | ZigType *int_type = instruction->target->value->type; |
| ... | ... | @@ -6583,7 +6583,7 @@ static LLVMValueRef ir_render_assert_zero(CodeGen *g, Stage1Air *executable, |
| 6583 | 6583 | } |
| 6584 | 6584 | |
| 6585 | 6585 | static LLVMValueRef ir_render_assert_non_null(CodeGen *g, Stage1Air *executable, |
| 6586 | IrInstGenAssertNonNull *instruction) | |
| 6586 | Stage1AirInstAssertNonNull *instruction) | |
| 6587 | 6587 | { |
| 6588 | 6588 | LLVMValueRef target = ir_llvm_value(g, instruction->target); |
| 6589 | 6589 | ZigType *target_type = instruction->target->value->type; |
| ... | ... | @@ -6608,7 +6608,7 @@ static LLVMValueRef ir_render_assert_non_null(CodeGen *g, Stage1Air *executable, |
| 6608 | 6608 | } |
| 6609 | 6609 | |
| 6610 | 6610 | static LLVMValueRef ir_render_suspend_begin(CodeGen *g, Stage1Air *executable, |
| 6611 | IrInstGenSuspendBegin *instruction) | |
| 6611 | Stage1AirInstSuspendBegin *instruction) | |
| 6612 | 6612 | { |
| 6613 | 6613 | if (fn_is_async(g->cur_fn)) { |
| 6614 | 6614 | instruction->resume_bb = gen_suspend_begin(g, "SuspendResume"); |
| ... | ... | @@ -6617,7 +6617,7 @@ static LLVMValueRef ir_render_suspend_begin(CodeGen *g, Stage1Air *executable, |
| 6617 | 6617 | } |
| 6618 | 6618 | |
| 6619 | 6619 | static LLVMValueRef ir_render_suspend_finish(CodeGen *g, Stage1Air *executable, |
| 6620 | IrInstGenSuspendFinish *instruction) | |
| 6620 | Stage1AirInstSuspendFinish *instruction) | |
| 6621 | 6621 | { |
| 6622 | 6622 | LLVMBuildRetVoid(g->builder); |
| 6623 | 6623 | |
| ... | ... | @@ -6629,7 +6629,7 @@ static LLVMValueRef ir_render_suspend_finish(CodeGen *g, Stage1Air *executable, |
| 6629 | 6629 | return nullptr; |
| 6630 | 6630 | } |
| 6631 | 6631 | |
| 6632 | static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstGen *source_instr, | |
| 6632 | static LLVMValueRef gen_await_early_return(CodeGen *g, Stage1AirInst *source_instr, | |
| 6633 | 6633 | LLVMValueRef target_frame_ptr, ZigType *result_type, ZigType *ptr_result_type, |
| 6634 | 6634 | LLVMValueRef result_loc, bool non_async) |
| 6635 | 6635 | { |
| ... | ... | @@ -6668,7 +6668,7 @@ static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstGen *source_instr, |
| 6668 | 6668 | } |
| 6669 | 6669 | } |
| 6670 | 6670 | |
| 6671 | static LLVMValueRef ir_render_await(CodeGen *g, Stage1Air *executable, IrInstGenAwait *instruction) { | |
| 6671 | static LLVMValueRef ir_render_await(CodeGen *g, Stage1Air *executable, Stage1AirInstAwait *instruction) { | |
| 6672 | 6672 | LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type; |
| 6673 | 6673 | LLVMValueRef zero = LLVMConstNull(usize_type_ref); |
| 6674 | 6674 | LLVMValueRef target_frame_ptr = ir_llvm_value(g, instruction->frame); |
| ... | ... | @@ -6755,7 +6755,7 @@ static LLVMValueRef ir_render_await(CodeGen *g, Stage1Air *executable, IrInstGen |
| 6755 | 6755 | return nullptr; |
| 6756 | 6756 | } |
| 6757 | 6757 | |
| 6758 | static LLVMValueRef ir_render_resume(CodeGen *g, Stage1Air *executable, IrInstGenResume *instruction) { | |
| 6758 | static LLVMValueRef ir_render_resume(CodeGen *g, Stage1Air *executable, Stage1AirInstResume *instruction) { | |
| 6759 | 6759 | LLVMValueRef frame = ir_llvm_value(g, instruction->frame); |
| 6760 | 6760 | ZigType *frame_type = instruction->frame->value->type; |
| 6761 | 6761 | assert(frame_type->id == ZigTypeIdAnyFrame); |
| ... | ... | @@ -6765,14 +6765,14 @@ static LLVMValueRef ir_render_resume(CodeGen *g, Stage1Air *executable, IrInstGe |
| 6765 | 6765 | } |
| 6766 | 6766 | |
| 6767 | 6767 | static LLVMValueRef ir_render_frame_size(CodeGen *g, Stage1Air *executable, |
| 6768 | IrInstGenFrameSize *instruction) | |
| 6768 | Stage1AirInstFrameSize *instruction) | |
| 6769 | 6769 | { |
| 6770 | 6770 | LLVMValueRef fn_val = ir_llvm_value(g, instruction->fn); |
| 6771 | 6771 | return gen_frame_size(g, fn_val); |
| 6772 | 6772 | } |
| 6773 | 6773 | |
| 6774 | 6774 | static LLVMValueRef ir_render_spill_begin(CodeGen *g, Stage1Air *executable, |
| 6775 | IrInstGenSpillBegin *instruction) | |
| 6775 | Stage1AirInstSpillBegin *instruction) | |
| 6776 | 6776 | { |
| 6777 | 6777 | if (!fn_is_async(g->cur_fn)) |
| 6778 | 6778 | return nullptr; |
| ... | ... | @@ -6791,7 +6791,7 @@ static LLVMValueRef ir_render_spill_begin(CodeGen *g, Stage1Air *executable, |
| 6791 | 6791 | zig_unreachable(); |
| 6792 | 6792 | } |
| 6793 | 6793 | |
| 6794 | static LLVMValueRef ir_render_spill_end(CodeGen *g, Stage1Air *executable, IrInstGenSpillEnd *instruction) { | |
| 6794 | static LLVMValueRef ir_render_spill_end(CodeGen *g, Stage1Air *executable, Stage1AirInstSpillEnd *instruction) { | |
| 6795 | 6795 | if (!fn_is_async(g->cur_fn)) |
| 6796 | 6796 | return ir_llvm_value(g, instruction->begin->operand); |
| 6797 | 6797 | |
| ... | ... | @@ -6808,14 +6808,14 @@ static LLVMValueRef ir_render_spill_end(CodeGen *g, Stage1Air *executable, IrIns |
| 6808 | 6808 | } |
| 6809 | 6809 | |
| 6810 | 6810 | static LLVMValueRef ir_render_vector_extract_elem(CodeGen *g, Stage1Air *executable, |
| 6811 | IrInstGenVectorExtractElem *instruction) | |
| 6811 | Stage1AirInstVectorExtractElem *instruction) | |
| 6812 | 6812 | { |
| 6813 | 6813 | LLVMValueRef vector = ir_llvm_value(g, instruction->vector); |
| 6814 | 6814 | LLVMValueRef index = ir_llvm_value(g, instruction->index); |
| 6815 | 6815 | return LLVMBuildExtractElement(g->builder, vector, index, ""); |
| 6816 | 6816 | } |
| 6817 | 6817 | |
| 6818 | static void set_debug_location(CodeGen *g, IrInstGen *instruction) { | |
| 6818 | static void set_debug_location(CodeGen *g, Stage1AirInst *instruction) { | |
| 6819 | 6819 | AstNode *source_node = instruction->source_node; |
| 6820 | 6820 | Scope *scope = instruction->scope; |
| 6821 | 6821 | |
| ... | ... | @@ -6826,187 +6826,187 @@ static void set_debug_location(CodeGen *g, IrInstGen *instruction) { |
| 6826 | 6826 | node_column_onebased(source_node), get_di_scope(g, scope)); |
| 6827 | 6827 | } |
| 6828 | 6828 | |
| 6829 | static LLVMValueRef ir_render_instruction(CodeGen *g, Stage1Air *executable, IrInstGen *instruction) { | |
| 6829 | static LLVMValueRef ir_render_instruction(CodeGen *g, Stage1Air *executable, Stage1AirInst *instruction) { | |
| 6830 | 6830 | switch (instruction->id) { |
| 6831 | case IrInstGenIdInvalid: | |
| 6832 | case IrInstGenIdConst: | |
| 6833 | case IrInstGenIdAlloca: | |
| 6831 | case Stage1AirInstIdInvalid: | |
| 6832 | case Stage1AirInstIdConst: | |
| 6833 | case Stage1AirInstIdAlloca: | |
| 6834 | 6834 | zig_unreachable(); |
| 6835 | 6835 | |
| 6836 | case IrInstGenIdDeclVar: | |
| 6837 | return ir_render_decl_var(g, executable, (IrInstGenDeclVar *)instruction); | |
| 6838 | case IrInstGenIdReturn: | |
| 6839 | return ir_render_return(g, executable, (IrInstGenReturn *)instruction); | |
| 6840 | case IrInstGenIdBinOp: | |
| 6841 | return ir_render_bin_op(g, executable, (IrInstGenBinOp *)instruction); | |
| 6842 | case IrInstGenIdCast: | |
| 6843 | return ir_render_cast(g, executable, (IrInstGenCast *)instruction); | |
| 6844 | case IrInstGenIdUnreachable: | |
| 6845 | return ir_render_unreachable(g, executable, (IrInstGenUnreachable *)instruction); | |
| 6846 | case IrInstGenIdCondBr: | |
| 6847 | return ir_render_cond_br(g, executable, (IrInstGenCondBr *)instruction); | |
| 6848 | case IrInstGenIdBr: | |
| 6849 | return ir_render_br(g, executable, (IrInstGenBr *)instruction); | |
| 6850 | case IrInstGenIdBinaryNot: | |
| 6851 | return ir_render_binary_not(g, executable, (IrInstGenBinaryNot *)instruction); | |
| 6852 | case IrInstGenIdNegation: | |
| 6853 | return ir_render_negation(g, executable, (IrInstGenNegation *)instruction); | |
| 6854 | case IrInstGenIdLoadPtr: | |
| 6855 | return ir_render_load_ptr(g, executable, (IrInstGenLoadPtr *)instruction); | |
| 6856 | case IrInstGenIdStorePtr: | |
| 6857 | return ir_render_store_ptr(g, executable, (IrInstGenStorePtr *)instruction); | |
| 6858 | case IrInstGenIdVectorStoreElem: | |
| 6859 | return ir_render_vector_store_elem(g, executable, (IrInstGenVectorStoreElem *)instruction); | |
| 6860 | case IrInstGenIdVarPtr: | |
| 6861 | return ir_render_var_ptr(g, executable, (IrInstGenVarPtr *)instruction); | |
| 6862 | case IrInstGenIdReturnPtr: | |
| 6863 | return ir_render_return_ptr(g, executable, (IrInstGenReturnPtr *)instruction); | |
| 6864 | case IrInstGenIdElemPtr: | |
| 6865 | return ir_render_elem_ptr(g, executable, (IrInstGenElemPtr *)instruction); | |
| 6866 | case IrInstGenIdCall: | |
| 6867 | return ir_render_call(g, executable, (IrInstGenCall *)instruction); | |
| 6868 | case IrInstGenIdStructFieldPtr: | |
| 6869 | return ir_render_struct_field_ptr(g, executable, (IrInstGenStructFieldPtr *)instruction); | |
| 6870 | case IrInstGenIdUnionFieldPtr: | |
| 6871 | return ir_render_union_field_ptr(g, executable, (IrInstGenUnionFieldPtr *)instruction); | |
| 6872 | case IrInstGenIdAsm: | |
| 6873 | return ir_render_asm_gen(g, executable, (IrInstGenAsm *)instruction); | |
| 6874 | case IrInstGenIdTestNonNull: | |
| 6875 | return ir_render_test_non_null(g, executable, (IrInstGenTestNonNull *)instruction); | |
| 6876 | case IrInstGenIdOptionalUnwrapPtr: | |
| 6877 | return ir_render_optional_unwrap_ptr(g, executable, (IrInstGenOptionalUnwrapPtr *)instruction); | |
| 6878 | case IrInstGenIdClz: | |
| 6879 | return ir_render_clz(g, executable, (IrInstGenClz *)instruction); | |
| 6880 | case IrInstGenIdCtz: | |
| 6881 | return ir_render_ctz(g, executable, (IrInstGenCtz *)instruction); | |
| 6882 | case IrInstGenIdPopCount: | |
| 6883 | return ir_render_pop_count(g, executable, (IrInstGenPopCount *)instruction); | |
| 6884 | case IrInstGenIdSwitchBr: | |
| 6885 | return ir_render_switch_br(g, executable, (IrInstGenSwitchBr *)instruction); | |
| 6886 | case IrInstGenIdBswap: | |
| 6887 | return ir_render_bswap(g, executable, (IrInstGenBswap *)instruction); | |
| 6888 | case IrInstGenIdBitReverse: | |
| 6889 | return ir_render_bit_reverse(g, executable, (IrInstGenBitReverse *)instruction); | |
| 6890 | case IrInstGenIdPhi: | |
| 6891 | return ir_render_phi(g, executable, (IrInstGenPhi *)instruction); | |
| 6892 | case IrInstGenIdRef: | |
| 6893 | return ir_render_ref(g, executable, (IrInstGenRef *)instruction); | |
| 6894 | case IrInstGenIdErrName: | |
| 6895 | return ir_render_err_name(g, executable, (IrInstGenErrName *)instruction); | |
| 6896 | case IrInstGenIdCmpxchg: | |
| 6897 | return ir_render_cmpxchg(g, executable, (IrInstGenCmpxchg *)instruction); | |
| 6898 | case IrInstGenIdFence: | |
| 6899 | return ir_render_fence(g, executable, (IrInstGenFence *)instruction); | |
| 6900 | case IrInstGenIdReduce: | |
| 6901 | return ir_render_reduce(g, executable, (IrInstGenReduce *)instruction); | |
| 6902 | case IrInstGenIdTruncate: | |
| 6903 | return ir_render_truncate(g, executable, (IrInstGenTruncate *)instruction); | |
| 6904 | case IrInstGenIdBoolNot: | |
| 6905 | return ir_render_bool_not(g, executable, (IrInstGenBoolNot *)instruction); | |
| 6906 | case IrInstGenIdMemset: | |
| 6907 | return ir_render_memset(g, executable, (IrInstGenMemset *)instruction); | |
| 6908 | case IrInstGenIdMemcpy: | |
| 6909 | return ir_render_memcpy(g, executable, (IrInstGenMemcpy *)instruction); | |
| 6910 | case IrInstGenIdSlice: | |
| 6911 | return ir_render_slice(g, executable, (IrInstGenSlice *)instruction); | |
| 6912 | case IrInstGenIdBreakpoint: | |
| 6913 | return ir_render_breakpoint(g, executable, (IrInstGenBreakpoint *)instruction); | |
| 6914 | case IrInstGenIdReturnAddress: | |
| 6915 | return ir_render_return_address(g, executable, (IrInstGenReturnAddress *)instruction); | |
| 6916 | case IrInstGenIdFrameAddress: | |
| 6917 | return ir_render_frame_address(g, executable, (IrInstGenFrameAddress *)instruction); | |
| 6918 | case IrInstGenIdFrameHandle: | |
| 6919 | return ir_render_handle(g, executable, (IrInstGenFrameHandle *)instruction); | |
| 6920 | case IrInstGenIdOverflowOp: | |
| 6921 | return ir_render_overflow_op(g, executable, (IrInstGenOverflowOp *)instruction); | |
| 6922 | case IrInstGenIdTestErr: | |
| 6923 | return ir_render_test_err(g, executable, (IrInstGenTestErr *)instruction); | |
| 6924 | case IrInstGenIdUnwrapErrCode: | |
| 6925 | return ir_render_unwrap_err_code(g, executable, (IrInstGenUnwrapErrCode *)instruction); | |
| 6926 | case IrInstGenIdUnwrapErrPayload: | |
| 6927 | return ir_render_unwrap_err_payload(g, executable, (IrInstGenUnwrapErrPayload *)instruction); | |
| 6928 | case IrInstGenIdOptionalWrap: | |
| 6929 | return ir_render_optional_wrap(g, executable, (IrInstGenOptionalWrap *)instruction); | |
| 6930 | case IrInstGenIdErrWrapCode: | |
| 6931 | return ir_render_err_wrap_code(g, executable, (IrInstGenErrWrapCode *)instruction); | |
| 6932 | case IrInstGenIdErrWrapPayload: | |
| 6933 | return ir_render_err_wrap_payload(g, executable, (IrInstGenErrWrapPayload *)instruction); | |
| 6934 | case IrInstGenIdUnionTag: | |
| 6935 | return ir_render_union_tag(g, executable, (IrInstGenUnionTag *)instruction); | |
| 6936 | case IrInstGenIdPtrCast: | |
| 6937 | return ir_render_ptr_cast(g, executable, (IrInstGenPtrCast *)instruction); | |
| 6938 | case IrInstGenIdBitCast: | |
| 6939 | return ir_render_bit_cast(g, executable, (IrInstGenBitCast *)instruction); | |
| 6940 | case IrInstGenIdWidenOrShorten: | |
| 6941 | return ir_render_widen_or_shorten(g, executable, (IrInstGenWidenOrShorten *)instruction); | |
| 6942 | case IrInstGenIdPtrToInt: | |
| 6943 | return ir_render_ptr_to_int(g, executable, (IrInstGenPtrToInt *)instruction); | |
| 6944 | case IrInstGenIdIntToPtr: | |
| 6945 | return ir_render_int_to_ptr(g, executable, (IrInstGenIntToPtr *)instruction); | |
| 6946 | case IrInstGenIdIntToEnum: | |
| 6947 | return ir_render_int_to_enum(g, executable, (IrInstGenIntToEnum *)instruction); | |
| 6948 | case IrInstGenIdIntToErr: | |
| 6949 | return ir_render_int_to_err(g, executable, (IrInstGenIntToErr *)instruction); | |
| 6950 | case IrInstGenIdErrToInt: | |
| 6951 | return ir_render_err_to_int(g, executable, (IrInstGenErrToInt *)instruction); | |
| 6952 | case IrInstGenIdPanic: | |
| 6953 | return ir_render_panic(g, executable, (IrInstGenPanic *)instruction); | |
| 6954 | case IrInstGenIdTagName: | |
| 6955 | return ir_render_enum_tag_name(g, executable, (IrInstGenTagName *)instruction); | |
| 6956 | case IrInstGenIdFieldParentPtr: | |
| 6957 | return ir_render_field_parent_ptr(g, executable, (IrInstGenFieldParentPtr *)instruction); | |
| 6958 | case IrInstGenIdAlignCast: | |
| 6959 | return ir_render_align_cast(g, executable, (IrInstGenAlignCast *)instruction); | |
| 6960 | case IrInstGenIdErrorReturnTrace: | |
| 6961 | return ir_render_error_return_trace(g, executable, (IrInstGenErrorReturnTrace *)instruction); | |
| 6962 | case IrInstGenIdAtomicRmw: | |
| 6963 | return ir_render_atomic_rmw(g, executable, (IrInstGenAtomicRmw *)instruction); | |
| 6964 | case IrInstGenIdAtomicLoad: | |
| 6965 | return ir_render_atomic_load(g, executable, (IrInstGenAtomicLoad *)instruction); | |
| 6966 | case IrInstGenIdAtomicStore: | |
| 6967 | return ir_render_atomic_store(g, executable, (IrInstGenAtomicStore *)instruction); | |
| 6968 | case IrInstGenIdSaveErrRetAddr: | |
| 6969 | return ir_render_save_err_ret_addr(g, executable, (IrInstGenSaveErrRetAddr *)instruction); | |
| 6970 | case IrInstGenIdFloatOp: | |
| 6971 | return ir_render_float_op(g, executable, (IrInstGenFloatOp *)instruction); | |
| 6972 | case IrInstGenIdMulAdd: | |
| 6973 | return ir_render_mul_add(g, executable, (IrInstGenMulAdd *)instruction); | |
| 6974 | case IrInstGenIdArrayToVector: | |
| 6975 | return ir_render_array_to_vector(g, executable, (IrInstGenArrayToVector *)instruction); | |
| 6976 | case IrInstGenIdVectorToArray: | |
| 6977 | return ir_render_vector_to_array(g, executable, (IrInstGenVectorToArray *)instruction); | |
| 6978 | case IrInstGenIdAssertZero: | |
| 6979 | return ir_render_assert_zero(g, executable, (IrInstGenAssertZero *)instruction); | |
| 6980 | case IrInstGenIdAssertNonNull: | |
| 6981 | return ir_render_assert_non_null(g, executable, (IrInstGenAssertNonNull *)instruction); | |
| 6982 | case IrInstGenIdPtrOfArrayToSlice: | |
| 6983 | return ir_render_ptr_of_array_to_slice(g, executable, (IrInstGenPtrOfArrayToSlice *)instruction); | |
| 6984 | case IrInstGenIdSuspendBegin: | |
| 6985 | return ir_render_suspend_begin(g, executable, (IrInstGenSuspendBegin *)instruction); | |
| 6986 | case IrInstGenIdSuspendFinish: | |
| 6987 | return ir_render_suspend_finish(g, executable, (IrInstGenSuspendFinish *)instruction); | |
| 6988 | case IrInstGenIdResume: | |
| 6989 | return ir_render_resume(g, executable, (IrInstGenResume *)instruction); | |
| 6990 | case IrInstGenIdFrameSize: | |
| 6991 | return ir_render_frame_size(g, executable, (IrInstGenFrameSize *)instruction); | |
| 6992 | case IrInstGenIdAwait: | |
| 6993 | return ir_render_await(g, executable, (IrInstGenAwait *)instruction); | |
| 6994 | case IrInstGenIdSpillBegin: | |
| 6995 | return ir_render_spill_begin(g, executable, (IrInstGenSpillBegin *)instruction); | |
| 6996 | case IrInstGenIdSpillEnd: | |
| 6997 | return ir_render_spill_end(g, executable, (IrInstGenSpillEnd *)instruction); | |
| 6998 | case IrInstGenIdShuffleVector: | |
| 6999 | return ir_render_shuffle_vector(g, executable, (IrInstGenShuffleVector *) instruction); | |
| 7000 | case IrInstGenIdSplat: | |
| 7001 | return ir_render_splat(g, executable, (IrInstGenSplat *) instruction); | |
| 7002 | case IrInstGenIdVectorExtractElem: | |
| 7003 | return ir_render_vector_extract_elem(g, executable, (IrInstGenVectorExtractElem *) instruction); | |
| 7004 | case IrInstGenIdWasmMemorySize: | |
| 7005 | return ir_render_wasm_memory_size(g, executable, (IrInstGenWasmMemorySize *) instruction); | |
| 7006 | case IrInstGenIdWasmMemoryGrow: | |
| 7007 | return ir_render_wasm_memory_grow(g, executable, (IrInstGenWasmMemoryGrow *) instruction); | |
| 7008 | case IrInstGenIdExtern: | |
| 7009 | return ir_render_extern(g, executable, (IrInstGenExtern *) instruction); | |
| 6836 | case Stage1AirInstIdDeclVar: | |
| 6837 | return ir_render_decl_var(g, executable, (Stage1AirInstDeclVar *)instruction); | |
| 6838 | case Stage1AirInstIdReturn: | |
| 6839 | return ir_render_return(g, executable, (Stage1AirInstReturn *)instruction); | |
| 6840 | case Stage1AirInstIdBinOp: | |
| 6841 | return ir_render_bin_op(g, executable, (Stage1AirInstBinOp *)instruction); | |
| 6842 | case Stage1AirInstIdCast: | |
| 6843 | return ir_render_cast(g, executable, (Stage1AirInstCast *)instruction); | |
| 6844 | case Stage1AirInstIdUnreachable: | |
| 6845 | return ir_render_unreachable(g, executable, (Stage1AirInstUnreachable *)instruction); | |
| 6846 | case Stage1AirInstIdCondBr: | |
| 6847 | return ir_render_cond_br(g, executable, (Stage1AirInstCondBr *)instruction); | |
| 6848 | case Stage1AirInstIdBr: | |
| 6849 | return ir_render_br(g, executable, (Stage1AirInstBr *)instruction); | |
| 6850 | case Stage1AirInstIdBinaryNot: | |
| 6851 | return ir_render_binary_not(g, executable, (Stage1AirInstBinaryNot *)instruction); | |
| 6852 | case Stage1AirInstIdNegation: | |
| 6853 | return ir_render_negation(g, executable, (Stage1AirInstNegation *)instruction); | |
| 6854 | case Stage1AirInstIdLoadPtr: | |
| 6855 | return ir_render_load_ptr(g, executable, (Stage1AirInstLoadPtr *)instruction); | |
| 6856 | case Stage1AirInstIdStorePtr: | |
| 6857 | return ir_render_store_ptr(g, executable, (Stage1AirInstStorePtr *)instruction); | |
| 6858 | case Stage1AirInstIdVectorStoreElem: | |
| 6859 | return ir_render_vector_store_elem(g, executable, (Stage1AirInstVectorStoreElem *)instruction); | |
| 6860 | case Stage1AirInstIdVarPtr: | |
| 6861 | return ir_render_var_ptr(g, executable, (Stage1AirInstVarPtr *)instruction); | |
| 6862 | case Stage1AirInstIdReturnPtr: | |
| 6863 | return ir_render_return_ptr(g, executable, (Stage1AirInstReturnPtr *)instruction); | |
| 6864 | case Stage1AirInstIdElemPtr: | |
| 6865 | return ir_render_elem_ptr(g, executable, (Stage1AirInstElemPtr *)instruction); | |
| 6866 | case Stage1AirInstIdCall: | |
| 6867 | return ir_render_call(g, executable, (Stage1AirInstCall *)instruction); | |
| 6868 | case Stage1AirInstIdStructFieldPtr: | |
| 6869 | return ir_render_struct_field_ptr(g, executable, (Stage1AirInstStructFieldPtr *)instruction); | |
| 6870 | case Stage1AirInstIdUnionFieldPtr: | |
| 6871 | return ir_render_union_field_ptr(g, executable, (Stage1AirInstUnionFieldPtr *)instruction); | |
| 6872 | case Stage1AirInstIdAsm: | |
| 6873 | return ir_render_asm_gen(g, executable, (Stage1AirInstAsm *)instruction); | |
| 6874 | case Stage1AirInstIdTestNonNull: | |
| 6875 | return ir_render_test_non_null(g, executable, (Stage1AirInstTestNonNull *)instruction); | |
| 6876 | case Stage1AirInstIdOptionalUnwrapPtr: | |
| 6877 | return ir_render_optional_unwrap_ptr(g, executable, (Stage1AirInstOptionalUnwrapPtr *)instruction); | |
| 6878 | case Stage1AirInstIdClz: | |
| 6879 | return ir_render_clz(g, executable, (Stage1AirInstClz *)instruction); | |
| 6880 | case Stage1AirInstIdCtz: | |
| 6881 | return ir_render_ctz(g, executable, (Stage1AirInstCtz *)instruction); | |
| 6882 | case Stage1AirInstIdPopCount: | |
| 6883 | return ir_render_pop_count(g, executable, (Stage1AirInstPopCount *)instruction); | |
| 6884 | case Stage1AirInstIdSwitchBr: | |
| 6885 | return ir_render_switch_br(g, executable, (Stage1AirInstSwitchBr *)instruction); | |
| 6886 | case Stage1AirInstIdBswap: | |
| 6887 | return ir_render_bswap(g, executable, (Stage1AirInstBswap *)instruction); | |
| 6888 | case Stage1AirInstIdBitReverse: | |
| 6889 | return ir_render_bit_reverse(g, executable, (Stage1AirInstBitReverse *)instruction); | |
| 6890 | case Stage1AirInstIdPhi: | |
| 6891 | return ir_render_phi(g, executable, (Stage1AirInstPhi *)instruction); | |
| 6892 | case Stage1AirInstIdRef: | |
| 6893 | return ir_render_ref(g, executable, (Stage1AirInstRef *)instruction); | |
| 6894 | case Stage1AirInstIdErrName: | |
| 6895 | return ir_render_err_name(g, executable, (Stage1AirInstErrName *)instruction); | |
| 6896 | case Stage1AirInstIdCmpxchg: | |
| 6897 | return ir_render_cmpxchg(g, executable, (Stage1AirInstCmpxchg *)instruction); | |
| 6898 | case Stage1AirInstIdFence: | |
| 6899 | return ir_render_fence(g, executable, (Stage1AirInstFence *)instruction); | |
| 6900 | case Stage1AirInstIdReduce: | |
| 6901 | return ir_render_reduce(g, executable, (Stage1AirInstReduce *)instruction); | |
| 6902 | case Stage1AirInstIdTruncate: | |
| 6903 | return ir_render_truncate(g, executable, (Stage1AirInstTruncate *)instruction); | |
| 6904 | case Stage1AirInstIdBoolNot: | |
| 6905 | return ir_render_bool_not(g, executable, (Stage1AirInstBoolNot *)instruction); | |
| 6906 | case Stage1AirInstIdMemset: | |
| 6907 | return ir_render_memset(g, executable, (Stage1AirInstMemset *)instruction); | |
| 6908 | case Stage1AirInstIdMemcpy: | |
| 6909 | return ir_render_memcpy(g, executable, (Stage1AirInstMemcpy *)instruction); | |
| 6910 | case Stage1AirInstIdSlice: | |
| 6911 | return ir_render_slice(g, executable, (Stage1AirInstSlice *)instruction); | |
| 6912 | case Stage1AirInstIdBreakpoint: | |
| 6913 | return ir_render_breakpoint(g, executable, (Stage1AirInstBreakpoint *)instruction); | |
| 6914 | case Stage1AirInstIdReturnAddress: | |
| 6915 | return ir_render_return_address(g, executable, (Stage1AirInstReturnAddress *)instruction); | |
| 6916 | case Stage1AirInstIdFrameAddress: | |
| 6917 | return ir_render_frame_address(g, executable, (Stage1AirInstFrameAddress *)instruction); | |
| 6918 | case Stage1AirInstIdFrameHandle: | |
| 6919 | return ir_render_handle(g, executable, (Stage1AirInstFrameHandle *)instruction); | |
| 6920 | case Stage1AirInstIdOverflowOp: | |
| 6921 | return ir_render_overflow_op(g, executable, (Stage1AirInstOverflowOp *)instruction); | |
| 6922 | case Stage1AirInstIdTestErr: | |
| 6923 | return ir_render_test_err(g, executable, (Stage1AirInstTestErr *)instruction); | |
| 6924 | case Stage1AirInstIdUnwrapErrCode: | |
| 6925 | return ir_render_unwrap_err_code(g, executable, (Stage1AirInstUnwrapErrCode *)instruction); | |
| 6926 | case Stage1AirInstIdUnwrapErrPayload: | |
| 6927 | return ir_render_unwrap_err_payload(g, executable, (Stage1AirInstUnwrapErrPayload *)instruction); | |
| 6928 | case Stage1AirInstIdOptionalWrap: | |
| 6929 | return ir_render_optional_wrap(g, executable, (Stage1AirInstOptionalWrap *)instruction); | |
| 6930 | case Stage1AirInstIdErrWrapCode: | |
| 6931 | return ir_render_err_wrap_code(g, executable, (Stage1AirInstErrWrapCode *)instruction); | |
| 6932 | case Stage1AirInstIdErrWrapPayload: | |
| 6933 | return ir_render_err_wrap_payload(g, executable, (Stage1AirInstErrWrapPayload *)instruction); | |
| 6934 | case Stage1AirInstIdUnionTag: | |
| 6935 | return ir_render_union_tag(g, executable, (Stage1AirInstUnionTag *)instruction); | |
| 6936 | case Stage1AirInstIdPtrCast: | |
| 6937 | return ir_render_ptr_cast(g, executable, (Stage1AirInstPtrCast *)instruction); | |
| 6938 | case Stage1AirInstIdBitCast: | |
| 6939 | return ir_render_bit_cast(g, executable, (Stage1AirInstBitCast *)instruction); | |
| 6940 | case Stage1AirInstIdWidenOrShorten: | |
| 6941 | return ir_render_widen_or_shorten(g, executable, (Stage1AirInstWidenOrShorten *)instruction); | |
| 6942 | case Stage1AirInstIdPtrToInt: | |
| 6943 | return ir_render_ptr_to_int(g, executable, (Stage1AirInstPtrToInt *)instruction); | |
| 6944 | case Stage1AirInstIdIntToPtr: | |
| 6945 | return ir_render_int_to_ptr(g, executable, (Stage1AirInstIntToPtr *)instruction); | |
| 6946 | case Stage1AirInstIdIntToEnum: | |
| 6947 | return ir_render_int_to_enum(g, executable, (Stage1AirInstIntToEnum *)instruction); | |
| 6948 | case Stage1AirInstIdIntToErr: | |
| 6949 | return ir_render_int_to_err(g, executable, (Stage1AirInstIntToErr *)instruction); | |
| 6950 | case Stage1AirInstIdErrToInt: | |
| 6951 | return ir_render_err_to_int(g, executable, (Stage1AirInstErrToInt *)instruction); | |
| 6952 | case Stage1AirInstIdPanic: | |
| 6953 | return ir_render_panic(g, executable, (Stage1AirInstPanic *)instruction); | |
| 6954 | case Stage1AirInstIdTagName: | |
| 6955 | return ir_render_enum_tag_name(g, executable, (Stage1AirInstTagName *)instruction); | |
| 6956 | case Stage1AirInstIdFieldParentPtr: | |
| 6957 | return ir_render_field_parent_ptr(g, executable, (Stage1AirInstFieldParentPtr *)instruction); | |
| 6958 | case Stage1AirInstIdAlignCast: | |
| 6959 | return ir_render_align_cast(g, executable, (Stage1AirInstAlignCast *)instruction); | |
| 6960 | case Stage1AirInstIdErrorReturnTrace: | |
| 6961 | return ir_render_error_return_trace(g, executable, (Stage1AirInstErrorReturnTrace *)instruction); | |
| 6962 | case Stage1AirInstIdAtomicRmw: | |
| 6963 | return ir_render_atomic_rmw(g, executable, (Stage1AirInstAtomicRmw *)instruction); | |
| 6964 | case Stage1AirInstIdAtomicLoad: | |
| 6965 | return ir_render_atomic_load(g, executable, (Stage1AirInstAtomicLoad *)instruction); | |
| 6966 | case Stage1AirInstIdAtomicStore: | |
| 6967 | return ir_render_atomic_store(g, executable, (Stage1AirInstAtomicStore *)instruction); | |
| 6968 | case Stage1AirInstIdSaveErrRetAddr: | |
| 6969 | return ir_render_save_err_ret_addr(g, executable, (Stage1AirInstSaveErrRetAddr *)instruction); | |
| 6970 | case Stage1AirInstIdFloatOp: | |
| 6971 | return ir_render_float_op(g, executable, (Stage1AirInstFloatOp *)instruction); | |
| 6972 | case Stage1AirInstIdMulAdd: | |
| 6973 | return ir_render_mul_add(g, executable, (Stage1AirInstMulAdd *)instruction); | |
| 6974 | case Stage1AirInstIdArrayToVector: | |
| 6975 | return ir_render_array_to_vector(g, executable, (Stage1AirInstArrayToVector *)instruction); | |
| 6976 | case Stage1AirInstIdVectorToArray: | |
| 6977 | return ir_render_vector_to_array(g, executable, (Stage1AirInstVectorToArray *)instruction); | |
| 6978 | case Stage1AirInstIdAssertZero: | |
| 6979 | return ir_render_assert_zero(g, executable, (Stage1AirInstAssertZero *)instruction); | |
| 6980 | case Stage1AirInstIdAssertNonNull: | |
| 6981 | return ir_render_assert_non_null(g, executable, (Stage1AirInstAssertNonNull *)instruction); | |
| 6982 | case Stage1AirInstIdPtrOfArrayToSlice: | |
| 6983 | return ir_render_ptr_of_array_to_slice(g, executable, (Stage1AirInstPtrOfArrayToSlice *)instruction); | |
| 6984 | case Stage1AirInstIdSuspendBegin: | |
| 6985 | return ir_render_suspend_begin(g, executable, (Stage1AirInstSuspendBegin *)instruction); | |
| 6986 | case Stage1AirInstIdSuspendFinish: | |
| 6987 | return ir_render_suspend_finish(g, executable, (Stage1AirInstSuspendFinish *)instruction); | |
| 6988 | case Stage1AirInstIdResume: | |
| 6989 | return ir_render_resume(g, executable, (Stage1AirInstResume *)instruction); | |
| 6990 | case Stage1AirInstIdFrameSize: | |
| 6991 | return ir_render_frame_size(g, executable, (Stage1AirInstFrameSize *)instruction); | |
| 6992 | case Stage1AirInstIdAwait: | |
| 6993 | return ir_render_await(g, executable, (Stage1AirInstAwait *)instruction); | |
| 6994 | case Stage1AirInstIdSpillBegin: | |
| 6995 | return ir_render_spill_begin(g, executable, (Stage1AirInstSpillBegin *)instruction); | |
| 6996 | case Stage1AirInstIdSpillEnd: | |
| 6997 | return ir_render_spill_end(g, executable, (Stage1AirInstSpillEnd *)instruction); | |
| 6998 | case Stage1AirInstIdShuffleVector: | |
| 6999 | return ir_render_shuffle_vector(g, executable, (Stage1AirInstShuffleVector *) instruction); | |
| 7000 | case Stage1AirInstIdSplat: | |
| 7001 | return ir_render_splat(g, executable, (Stage1AirInstSplat *) instruction); | |
| 7002 | case Stage1AirInstIdVectorExtractElem: | |
| 7003 | return ir_render_vector_extract_elem(g, executable, (Stage1AirInstVectorExtractElem *) instruction); | |
| 7004 | case Stage1AirInstIdWasmMemorySize: | |
| 7005 | return ir_render_wasm_memory_size(g, executable, (Stage1AirInstWasmMemorySize *) instruction); | |
| 7006 | case Stage1AirInstIdWasmMemoryGrow: | |
| 7007 | return ir_render_wasm_memory_grow(g, executable, (Stage1AirInstWasmMemoryGrow *) instruction); | |
| 7008 | case Stage1AirInstIdExtern: | |
| 7009 | return ir_render_extern(g, executable, (Stage1AirInstExtern *) instruction); | |
| 7010 | 7010 | } |
| 7011 | 7011 | zig_unreachable(); |
| 7012 | 7012 | } |
| ... | ... | @@ -7018,14 +7018,14 @@ static void ir_render(CodeGen *g, ZigFn *fn_entry) { |
| 7018 | 7018 | assert(executable->basic_block_list.length > 0); |
| 7019 | 7019 | |
| 7020 | 7020 | for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) { |
| 7021 | IrBasicBlockGen *current_block = executable->basic_block_list.at(block_i); | |
| 7021 | Stage1AirBasicBlock *current_block = executable->basic_block_list.at(block_i); | |
| 7022 | 7022 | if (get_scope_typeof(current_block->scope) != nullptr) { |
| 7023 | 7023 | LLVMBuildBr(g->builder, current_block->llvm_block); |
| 7024 | 7024 | } |
| 7025 | 7025 | assert(current_block->llvm_block); |
| 7026 | 7026 | LLVMPositionBuilderAtEnd(g->builder, current_block->llvm_block); |
| 7027 | 7027 | for (size_t instr_i = 0; instr_i < current_block->instruction_list.length; instr_i += 1) { |
| 7028 | IrInstGen *instruction = current_block->instruction_list.at(instr_i); | |
| 7028 | Stage1AirInst *instruction = current_block->instruction_list.at(instr_i); | |
| 7029 | 7029 | if (instruction->ref_count == 0 && !ir_inst_gen_has_side_effects(instruction)) |
| 7030 | 7030 | continue; |
| 7031 | 7031 | if (get_scope_typeof(instruction->scope) != nullptr) |
| ... | ... | @@ -8021,7 +8021,7 @@ static void build_all_basic_blocks(CodeGen *g, ZigFn *fn) { |
| 8021 | 8021 | g->cur_preamble_llvm_block = first_bb; |
| 8022 | 8022 | } |
| 8023 | 8023 | for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) { |
| 8024 | IrBasicBlockGen *bb = executable->basic_block_list.at(block_i); | |
| 8024 | Stage1AirBasicBlock *bb = executable->basic_block_list.at(block_i); | |
| 8025 | 8025 | bb->llvm_block = LLVMAppendBasicBlock(fn_val, bb->name_hint); |
| 8026 | 8026 | } |
| 8027 | 8027 | if (first_bb == nullptr) { |
| ... | ... | @@ -8243,10 +8243,10 @@ static void do_code_gen(CodeGen *g) { |
| 8243 | 8243 | if (!is_async) { |
| 8244 | 8244 | // allocate async frames for nosuspend calls & awaits to async functions |
| 8245 | 8245 | ZigType *largest_call_frame_type = nullptr; |
| 8246 | IrInstGen *all_calls_alloca = ir_create_alloca(g, &fn_table_entry->fndef_scope->base, | |
| 8246 | Stage1AirInst *all_calls_alloca = ir_create_alloca(g, &fn_table_entry->fndef_scope->base, | |
| 8247 | 8247 | fn_table_entry->body_node, fn_table_entry, g->builtin_types.entry_void, "@async_call_frame"); |
| 8248 | 8248 | for (size_t i = 0; i < fn_table_entry->call_list.length; i += 1) { |
| 8249 | IrInstGenCall *call = fn_table_entry->call_list.at(i); | |
| 8249 | Stage1AirInstCall *call = fn_table_entry->call_list.at(i); | |
| 8250 | 8250 | if (call->fn_entry == nullptr) |
| 8251 | 8251 | continue; |
| 8252 | 8252 | if (!fn_is_async(call->fn_entry)) |
| ... | ... | @@ -8268,7 +8268,7 @@ static void do_code_gen(CodeGen *g) { |
| 8268 | 8268 | } |
| 8269 | 8269 | // allocate temporary stack data |
| 8270 | 8270 | for (size_t alloca_i = 0; alloca_i < fn_table_entry->alloca_gen_list.length; alloca_i += 1) { |
| 8271 | IrInstGenAlloca *instruction = fn_table_entry->alloca_gen_list.at(alloca_i); | |
| 8271 | Stage1AirInstAlloca *instruction = fn_table_entry->alloca_gen_list.at(alloca_i); | |
| 8272 | 8272 | ZigType *ptr_type = instruction->base.value->type; |
| 8273 | 8273 | assert(ptr_type->id == ZigTypeIdPointer); |
| 8274 | 8274 | ZigType *child_type = ptr_type->data.pointer.child_type; |
| ... | ... | @@ -8422,7 +8422,7 @@ static void do_code_gen(CodeGen *g) { |
| 8422 | 8422 | g->cur_async_switch_instr = switch_instr; |
| 8423 | 8423 | |
| 8424 | 8424 | LLVMValueRef zero = LLVMConstNull(usize_type_ref); |
| 8425 | IrBasicBlockGen *entry_block = executable->basic_block_list.at(0); | |
| 8425 | Stage1AirBasicBlock *entry_block = executable->basic_block_list.at(0); | |
| 8426 | 8426 | LLVMAddCase(switch_instr, zero, entry_block->llvm_block); |
| 8427 | 8427 | g->cur_resume_block_count += 1; |
| 8428 | 8428 | |
| ... | ... | @@ -9379,7 +9379,7 @@ static void init(CodeGen *g) { |
| 9379 | 9379 | define_builtin_types(g); |
| 9380 | 9380 | define_intern_values(g); |
| 9381 | 9381 | |
| 9382 | IrInstGen *sentinel_instructions = heap::c_allocator.allocate<IrInstGen>(2); | |
| 9382 | Stage1AirInst *sentinel_instructions = heap::c_allocator.allocate<Stage1AirInst>(2); | |
| 9383 | 9383 | g->invalid_inst_gen = &sentinel_instructions[0]; |
| 9384 | 9384 | g->invalid_inst_gen->value = g->pass1_arena->create<ZigValue>(); |
| 9385 | 9385 | g->invalid_inst_gen->value->type = g->builtin_types.entry_invalid; |
| ... | ... | @@ -9388,7 +9388,7 @@ static void init(CodeGen *g) { |
| 9388 | 9388 | g->unreach_instruction->value = g->pass1_arena->create<ZigValue>(); |
| 9389 | 9389 | g->unreach_instruction->value->type = g->builtin_types.entry_unreachable; |
| 9390 | 9390 | |
| 9391 | g->invalid_inst_src = heap::c_allocator.create<IrInstSrc>(); | |
| 9391 | g->invalid_inst_src = heap::c_allocator.create<Stage1ZirInst>(); | |
| 9392 | 9392 | |
| 9393 | 9393 | define_builtin_fns(g); |
| 9394 | 9394 | Error err; |
src/stage1/ir.cpp+2246-2246| ... | ... | @@ -25,10 +25,10 @@ |
| 25 | 25 | struct IrBuilderGen { |
| 26 | 26 | CodeGen *codegen; |
| 27 | 27 | Stage1Air *exec; |
| 28 | IrBasicBlockGen *current_basic_block; | |
| 28 | Stage1AirBasicBlock *current_basic_block; | |
| 29 | 29 | |
| 30 | 30 | // track for immediate post-analysis destruction |
| 31 | mem::List<IrInstGenConst *> constants; | |
| 31 | mem::List<Stage1AirInstConst *> constants; | |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | 34 | struct IrAnalyze { |
| ... | ... | @@ -40,17 +40,17 @@ struct IrAnalyze { |
| 40 | 40 | size_t instruction_index; |
| 41 | 41 | ZigType *explicit_return_type; |
| 42 | 42 | AstNode *explicit_return_type_source_node; |
| 43 | ZigList<IrInstGen *> src_implicit_return_type_list; | |
| 43 | ZigList<Stage1AirInst *> src_implicit_return_type_list; | |
| 44 | 44 | ZigList<IrSuspendPosition> resume_stack; |
| 45 | 45 | Stage1ZirBasicBlock *const_predecessor_bb; |
| 46 | 46 | size_t ref_count; |
| 47 | 47 | size_t break_debug_id; // for debugging purposes |
| 48 | IrInstGen *return_ptr; | |
| 48 | Stage1AirInst *return_ptr; | |
| 49 | 49 | Stage1Air *parent_exec; |
| 50 | 50 | size_t *backward_branch_count; |
| 51 | 51 | size_t *backward_branch_quota; |
| 52 | 52 | ZigFn *fn; |
| 53 | IrInstSrc *suspend_source_instr; | |
| 53 | Stage1ZirInst *suspend_source_instr; | |
| 54 | 54 | |
| 55 | 55 | // For the purpose of using in a debugger |
| 56 | 56 | void dump(); |
| ... | ... | @@ -216,16 +216,16 @@ struct DbgIrBreakPoint { |
| 216 | 216 | uint32_t line; |
| 217 | 217 | }; |
| 218 | 218 | |
| 219 | static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *expected_type); | |
| 220 | static IrInstGen *ir_implicit_cast2(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 221 | IrInstGen *value, ZigType *expected_type); | |
| 222 | static IrInstGen *ir_get_deref(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *ptr, | |
| 219 | static Stage1AirInst *ir_implicit_cast(IrAnalyze *ira, Stage1AirInst *value, ZigType *expected_type); | |
| 220 | static Stage1AirInst *ir_implicit_cast2(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 221 | Stage1AirInst *value, ZigType *expected_type); | |
| 222 | static Stage1AirInst *ir_get_deref(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *ptr, | |
| 223 | 223 | ResultLoc *result_loc); |
| 224 | static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, | |
| 225 | Scope *scope, AstNode *source_node, IrInstGen *container_ptr, AstNode *container_ptr_src, | |
| 224 | static Stage1AirInst *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, | |
| 225 | Scope *scope, AstNode *source_node, Stage1AirInst *container_ptr, AstNode *container_ptr_src, | |
| 226 | 226 | ZigType *container_type, bool initializing); |
| 227 | static IrInstGen *ir_get_var_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigVar *var); | |
| 228 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstGen *op); | |
| 227 | static Stage1AirInst *ir_get_var_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigVar *var); | |
| 228 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, Stage1AirInst *op); | |
| 229 | 229 | static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align); |
| 230 | 230 | static ZigType *adjust_ptr_const(CodeGen *g, ZigType *ptr_type, bool is_const); |
| 231 | 231 | static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align); |
| ... | ... | @@ -233,40 +233,40 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 233 | 233 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ZigValue *val); |
| 234 | 234 | static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, |
| 235 | 235 | ZigValue *out_val, ZigValue *ptr_val); |
| 236 | static IrInstGen *ir_analyze_ptr_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 237 | IrInstGen *ptr, AstNode *ptr_src, ZigType *dest_type, AstNode *dest_type_src, | |
| 236 | static Stage1AirInst *ir_analyze_ptr_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 237 | Stage1AirInst *ptr, AstNode *ptr_src, ZigType *dest_type, AstNode *dest_type_src, | |
| 238 | 238 | bool safety_check_on, bool keep_bigger_alignment); |
| 239 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstGen *value, UndefAllowed undef_allowed); | |
| 239 | static ZigValue *ir_resolve_const(IrAnalyze *ira, Stage1AirInst *value, UndefAllowed undef_allowed); | |
| 240 | 240 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align); |
| 241 | static IrInstGen *ir_analyze_int_to_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, | |
| 241 | static Stage1AirInst *ir_analyze_int_to_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target, | |
| 242 | 242 | ZigType *ptr_type); |
| 243 | static IrInstGen *ir_analyze_bit_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value, | |
| 243 | static Stage1AirInst *ir_analyze_bit_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value, | |
| 244 | 244 | ZigType *dest_type); |
| 245 | static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_source_instr, | |
| 246 | ResultLoc *result_loc, ZigType *value_type, IrInstGen *value, bool force_runtime, bool allow_discard); | |
| 247 | static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInstSrc *suspend_source_instr, | |
| 248 | ResultLoc *result_loc, ZigType *value_type, IrInstGen *value, bool force_runtime, bool allow_discard); | |
| 249 | static IrInstGen *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 250 | IrInstGen *base_ptr, bool safety_check_on, bool initializing); | |
| 251 | static IrInstGen *ir_analyze_unwrap_error_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 252 | IrInstGen *base_ptr, bool safety_check_on, bool initializing); | |
| 253 | static IrInstGen *ir_analyze_unwrap_err_code(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 254 | IrInstGen *base_ptr, bool initializing); | |
| 255 | static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 256 | IrInstGen *ptr, IrInstGen *uncasted_value, bool allow_write_through_const); | |
| 245 | static Stage1AirInst *ir_resolve_result_raw(IrAnalyze *ira, Stage1ZirInst *suspend_source_instr, | |
| 246 | ResultLoc *result_loc, ZigType *value_type, Stage1AirInst *value, bool force_runtime, bool allow_discard); | |
| 247 | static Stage1AirInst *ir_resolve_result(IrAnalyze *ira, Stage1ZirInst *suspend_source_instr, | |
| 248 | ResultLoc *result_loc, ZigType *value_type, Stage1AirInst *value, bool force_runtime, bool allow_discard); | |
| 249 | static Stage1AirInst *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 250 | Stage1AirInst *base_ptr, bool safety_check_on, bool initializing); | |
| 251 | static Stage1AirInst *ir_analyze_unwrap_error_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 252 | Stage1AirInst *base_ptr, bool safety_check_on, bool initializing); | |
| 253 | static Stage1AirInst *ir_analyze_unwrap_err_code(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 254 | Stage1AirInst *base_ptr, bool initializing); | |
| 255 | static Stage1AirInst *ir_analyze_store_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 256 | Stage1AirInst *ptr, Stage1AirInst *uncasted_value, bool allow_write_through_const); | |
| 257 | 257 | static void ir_reset_result(ResultLoc *result_loc); |
| 258 | static IrInstGen *ir_analyze_struct_field_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 259 | TypeStructField *field, IrInstGen *struct_ptr, ZigType *struct_type, bool initializing); | |
| 260 | static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, | |
| 261 | Scope *scope, AstNode *source_node, IrInstGen *container_ptr, ZigType *container_type); | |
| 262 | static IrInstGen *ir_analyze_test_non_null(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value); | |
| 263 | static IrInstGen *ir_error_dependency_loop(IrAnalyze *ira, AstNode *source_node); | |
| 264 | static IrInstGen *ir_const_undef(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty); | |
| 265 | static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 266 | AstNode *field_source_node, ZigType *union_type, Buf *field_name, IrInstGen *field_result_loc, | |
| 267 | IrInstGen *result_loc); | |
| 268 | static IrInstGen *ir_analyze_struct_value_field_value(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 269 | IrInstGen *struct_operand, TypeStructField *field); | |
| 258 | static Stage1AirInst *ir_analyze_struct_field_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 259 | TypeStructField *field, Stage1AirInst *struct_ptr, ZigType *struct_type, bool initializing); | |
| 260 | static Stage1AirInst *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, | |
| 261 | Scope *scope, AstNode *source_node, Stage1AirInst *container_ptr, ZigType *container_type); | |
| 262 | static Stage1AirInst *ir_analyze_test_non_null(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value); | |
| 263 | static Stage1AirInst *ir_error_dependency_loop(IrAnalyze *ira, AstNode *source_node); | |
| 264 | static Stage1AirInst *ir_const_undef(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty); | |
| 265 | static Stage1AirInst *ir_analyze_union_init(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 266 | AstNode *field_source_node, ZigType *union_type, Buf *field_name, Stage1AirInst *field_result_loc, | |
| 267 | Stage1AirInst *result_loc); | |
| 268 | static Stage1AirInst *ir_analyze_struct_value_field_value(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 269 | Stage1AirInst *struct_operand, TypeStructField *field); | |
| 270 | 270 | static bool value_cmp_numeric_val_any(ZigValue *left, Cmp predicate, ZigValue *right); |
| 271 | 271 | static bool value_cmp_numeric_val_all(ZigValue *left, Cmp predicate, ZigValue *right); |
| 272 | 272 | static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, TypeStructField *field); |
| ... | ... | @@ -276,195 +276,195 @@ static Error ir_resolve_lazy_recurse(AstNode *source_node, ZigValue *val); |
| 276 | 276 | static Error ir_resolve_lazy_recurse_array(AstNode *source_node, ZigValue *val, size_t len); |
| 277 | 277 | |
| 278 | 278 | |
| 279 | static void ir_assert_impl(bool ok, IrInstGen *source_instruction, char const *file, unsigned int line) { | |
| 279 | static void ir_assert_impl(bool ok, Stage1AirInst *source_instruction, char const *file, unsigned int line) { | |
| 280 | 280 | if (ok) return; |
| 281 | 281 | src_assert_impl(ok, source_instruction->source_node, file, line); |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | #define ir_assert(OK, SOURCE_INSTRUCTION) ir_assert_impl((OK), (SOURCE_INSTRUCTION), __FILE__, __LINE__) |
| 285 | 285 | |
| 286 | void destroy_instruction_gen(IrInstGen *inst) { | |
| 286 | void destroy_instruction_gen(Stage1AirInst *inst) { | |
| 287 | 287 | switch (inst->id) { |
| 288 | case IrInstGenIdInvalid: | |
| 288 | case Stage1AirInstIdInvalid: | |
| 289 | 289 | zig_unreachable(); |
| 290 | case IrInstGenIdReturn: | |
| 291 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenReturn *>(inst)); | |
| 292 | case IrInstGenIdConst: | |
| 293 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenConst *>(inst)); | |
| 294 | case IrInstGenIdBinOp: | |
| 295 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBinOp *>(inst)); | |
| 296 | case IrInstGenIdCast: | |
| 297 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenCast *>(inst)); | |
| 298 | case IrInstGenIdCall: | |
| 299 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenCall *>(inst)); | |
| 300 | case IrInstGenIdCondBr: | |
| 301 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenCondBr *>(inst)); | |
| 302 | case IrInstGenIdBr: | |
| 303 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBr *>(inst)); | |
| 304 | case IrInstGenIdPhi: | |
| 305 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPhi *>(inst)); | |
| 306 | case IrInstGenIdUnreachable: | |
| 307 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenUnreachable *>(inst)); | |
| 308 | case IrInstGenIdElemPtr: | |
| 309 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenElemPtr *>(inst)); | |
| 310 | case IrInstGenIdVarPtr: | |
| 311 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenVarPtr *>(inst)); | |
| 312 | case IrInstGenIdReturnPtr: | |
| 313 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenReturnPtr *>(inst)); | |
| 314 | case IrInstGenIdLoadPtr: | |
| 315 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenLoadPtr *>(inst)); | |
| 316 | case IrInstGenIdStorePtr: | |
| 317 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenStorePtr *>(inst)); | |
| 318 | case IrInstGenIdVectorStoreElem: | |
| 319 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenVectorStoreElem *>(inst)); | |
| 320 | case IrInstGenIdStructFieldPtr: | |
| 321 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenStructFieldPtr *>(inst)); | |
| 322 | case IrInstGenIdUnionFieldPtr: | |
| 323 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenUnionFieldPtr *>(inst)); | |
| 324 | case IrInstGenIdAsm: | |
| 325 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAsm *>(inst)); | |
| 326 | case IrInstGenIdTestNonNull: | |
| 327 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenTestNonNull *>(inst)); | |
| 328 | case IrInstGenIdOptionalUnwrapPtr: | |
| 329 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenOptionalUnwrapPtr *>(inst)); | |
| 330 | case IrInstGenIdPopCount: | |
| 331 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPopCount *>(inst)); | |
| 332 | case IrInstGenIdClz: | |
| 333 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenClz *>(inst)); | |
| 334 | case IrInstGenIdCtz: | |
| 335 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenCtz *>(inst)); | |
| 336 | case IrInstGenIdBswap: | |
| 337 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBswap *>(inst)); | |
| 338 | case IrInstGenIdBitReverse: | |
| 339 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBitReverse *>(inst)); | |
| 340 | case IrInstGenIdSwitchBr: | |
| 341 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSwitchBr *>(inst)); | |
| 342 | case IrInstGenIdUnionTag: | |
| 343 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenUnionTag *>(inst)); | |
| 344 | case IrInstGenIdRef: | |
| 345 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenRef *>(inst)); | |
| 346 | case IrInstGenIdErrName: | |
| 347 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenErrName *>(inst)); | |
| 348 | case IrInstGenIdCmpxchg: | |
| 349 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenCmpxchg *>(inst)); | |
| 350 | case IrInstGenIdFence: | |
| 351 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFence *>(inst)); | |
| 352 | case IrInstGenIdReduce: | |
| 353 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenReduce *>(inst)); | |
| 354 | case IrInstGenIdTruncate: | |
| 355 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenTruncate *>(inst)); | |
| 356 | case IrInstGenIdShuffleVector: | |
| 357 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenShuffleVector *>(inst)); | |
| 358 | case IrInstGenIdSplat: | |
| 359 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSplat *>(inst)); | |
| 360 | case IrInstGenIdBoolNot: | |
| 361 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBoolNot *>(inst)); | |
| 362 | case IrInstGenIdMemset: | |
| 363 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenMemset *>(inst)); | |
| 364 | case IrInstGenIdMemcpy: | |
| 365 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenMemcpy *>(inst)); | |
| 366 | case IrInstGenIdSlice: | |
| 367 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSlice *>(inst)); | |
| 368 | case IrInstGenIdBreakpoint: | |
| 369 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBreakpoint *>(inst)); | |
| 370 | case IrInstGenIdReturnAddress: | |
| 371 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenReturnAddress *>(inst)); | |
| 372 | case IrInstGenIdFrameAddress: | |
| 373 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFrameAddress *>(inst)); | |
| 374 | case IrInstGenIdFrameHandle: | |
| 375 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFrameHandle *>(inst)); | |
| 376 | case IrInstGenIdFrameSize: | |
| 377 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFrameSize *>(inst)); | |
| 378 | case IrInstGenIdOverflowOp: | |
| 379 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenOverflowOp *>(inst)); | |
| 380 | case IrInstGenIdTestErr: | |
| 381 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenTestErr *>(inst)); | |
| 382 | case IrInstGenIdUnwrapErrCode: | |
| 383 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenUnwrapErrCode *>(inst)); | |
| 384 | case IrInstGenIdUnwrapErrPayload: | |
| 385 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenUnwrapErrPayload *>(inst)); | |
| 386 | case IrInstGenIdOptionalWrap: | |
| 387 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenOptionalWrap *>(inst)); | |
| 388 | case IrInstGenIdErrWrapCode: | |
| 389 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenErrWrapCode *>(inst)); | |
| 390 | case IrInstGenIdErrWrapPayload: | |
| 391 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenErrWrapPayload *>(inst)); | |
| 392 | case IrInstGenIdPtrCast: | |
| 393 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPtrCast *>(inst)); | |
| 394 | case IrInstGenIdBitCast: | |
| 395 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBitCast *>(inst)); | |
| 396 | case IrInstGenIdWidenOrShorten: | |
| 397 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenWidenOrShorten *>(inst)); | |
| 398 | case IrInstGenIdPtrToInt: | |
| 399 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPtrToInt *>(inst)); | |
| 400 | case IrInstGenIdIntToPtr: | |
| 401 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenIntToPtr *>(inst)); | |
| 402 | case IrInstGenIdIntToEnum: | |
| 403 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenIntToEnum *>(inst)); | |
| 404 | case IrInstGenIdIntToErr: | |
| 405 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenIntToErr *>(inst)); | |
| 406 | case IrInstGenIdErrToInt: | |
| 407 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenErrToInt *>(inst)); | |
| 408 | case IrInstGenIdTagName: | |
| 409 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenTagName *>(inst)); | |
| 410 | case IrInstGenIdPanic: | |
| 411 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPanic *>(inst)); | |
| 412 | case IrInstGenIdFieldParentPtr: | |
| 413 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFieldParentPtr *>(inst)); | |
| 414 | case IrInstGenIdAlignCast: | |
| 415 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAlignCast *>(inst)); | |
| 416 | case IrInstGenIdErrorReturnTrace: | |
| 417 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenErrorReturnTrace *>(inst)); | |
| 418 | case IrInstGenIdAtomicRmw: | |
| 419 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAtomicRmw *>(inst)); | |
| 420 | case IrInstGenIdSaveErrRetAddr: | |
| 421 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSaveErrRetAddr *>(inst)); | |
| 422 | case IrInstGenIdFloatOp: | |
| 423 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenFloatOp *>(inst)); | |
| 424 | case IrInstGenIdMulAdd: | |
| 425 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenMulAdd *>(inst)); | |
| 426 | case IrInstGenIdAtomicLoad: | |
| 427 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAtomicLoad *>(inst)); | |
| 428 | case IrInstGenIdAtomicStore: | |
| 429 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAtomicStore *>(inst)); | |
| 430 | case IrInstGenIdDeclVar: | |
| 431 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenDeclVar *>(inst)); | |
| 432 | case IrInstGenIdArrayToVector: | |
| 433 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenArrayToVector *>(inst)); | |
| 434 | case IrInstGenIdVectorToArray: | |
| 435 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenVectorToArray *>(inst)); | |
| 436 | case IrInstGenIdPtrOfArrayToSlice: | |
| 437 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenPtrOfArrayToSlice *>(inst)); | |
| 438 | case IrInstGenIdAssertZero: | |
| 439 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAssertZero *>(inst)); | |
| 440 | case IrInstGenIdAssertNonNull: | |
| 441 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAssertNonNull *>(inst)); | |
| 442 | case IrInstGenIdAlloca: | |
| 443 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAlloca *>(inst)); | |
| 444 | case IrInstGenIdSuspendBegin: | |
| 445 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSuspendBegin *>(inst)); | |
| 446 | case IrInstGenIdSuspendFinish: | |
| 447 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSuspendFinish *>(inst)); | |
| 448 | case IrInstGenIdResume: | |
| 449 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenResume *>(inst)); | |
| 450 | case IrInstGenIdAwait: | |
| 451 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenAwait *>(inst)); | |
| 452 | case IrInstGenIdSpillBegin: | |
| 453 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSpillBegin *>(inst)); | |
| 454 | case IrInstGenIdSpillEnd: | |
| 455 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenSpillEnd *>(inst)); | |
| 456 | case IrInstGenIdVectorExtractElem: | |
| 457 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenVectorExtractElem *>(inst)); | |
| 458 | case IrInstGenIdBinaryNot: | |
| 459 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenBinaryNot *>(inst)); | |
| 460 | case IrInstGenIdNegation: | |
| 461 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenNegation *>(inst)); | |
| 462 | case IrInstGenIdWasmMemorySize: | |
| 463 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenWasmMemorySize *>(inst)); | |
| 464 | case IrInstGenIdWasmMemoryGrow: | |
| 465 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenWasmMemoryGrow *>(inst)); | |
| 466 | case IrInstGenIdExtern: | |
| 467 | return heap::c_allocator.destroy(reinterpret_cast<IrInstGenExtern *>(inst)); | |
| 290 | case Stage1AirInstIdReturn: | |
| 291 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstReturn *>(inst)); | |
| 292 | case Stage1AirInstIdConst: | |
| 293 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstConst *>(inst)); | |
| 294 | case Stage1AirInstIdBinOp: | |
| 295 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstBinOp *>(inst)); | |
| 296 | case Stage1AirInstIdCast: | |
| 297 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstCast *>(inst)); | |
| 298 | case Stage1AirInstIdCall: | |
| 299 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstCall *>(inst)); | |
| 300 | case Stage1AirInstIdCondBr: | |
| 301 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstCondBr *>(inst)); | |
| 302 | case Stage1AirInstIdBr: | |
| 303 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstBr *>(inst)); | |
| 304 | case Stage1AirInstIdPhi: | |
| 305 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstPhi *>(inst)); | |
| 306 | case Stage1AirInstIdUnreachable: | |
| 307 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstUnreachable *>(inst)); | |
| 308 | case Stage1AirInstIdElemPtr: | |
| 309 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstElemPtr *>(inst)); | |
| 310 | case Stage1AirInstIdVarPtr: | |
| 311 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstVarPtr *>(inst)); | |
| 312 | case Stage1AirInstIdReturnPtr: | |
| 313 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstReturnPtr *>(inst)); | |
| 314 | case Stage1AirInstIdLoadPtr: | |
| 315 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstLoadPtr *>(inst)); | |
| 316 | case Stage1AirInstIdStorePtr: | |
| 317 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstStorePtr *>(inst)); | |
| 318 | case Stage1AirInstIdVectorStoreElem: | |
| 319 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstVectorStoreElem *>(inst)); | |
| 320 | case Stage1AirInstIdStructFieldPtr: | |
| 321 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstStructFieldPtr *>(inst)); | |
| 322 | case Stage1AirInstIdUnionFieldPtr: | |
| 323 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstUnionFieldPtr *>(inst)); | |
| 324 | case Stage1AirInstIdAsm: | |
| 325 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstAsm *>(inst)); | |
| 326 | case Stage1AirInstIdTestNonNull: | |
| 327 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstTestNonNull *>(inst)); | |
| 328 | case Stage1AirInstIdOptionalUnwrapPtr: | |
| 329 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstOptionalUnwrapPtr *>(inst)); | |
| 330 | case Stage1AirInstIdPopCount: | |
| 331 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstPopCount *>(inst)); | |
| 332 | case Stage1AirInstIdClz: | |
| 333 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstClz *>(inst)); | |
| 334 | case Stage1AirInstIdCtz: | |
| 335 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstCtz *>(inst)); | |
| 336 | case Stage1AirInstIdBswap: | |
| 337 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstBswap *>(inst)); | |
| 338 | case Stage1AirInstIdBitReverse: | |
| 339 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstBitReverse *>(inst)); | |
| 340 | case Stage1AirInstIdSwitchBr: | |
| 341 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstSwitchBr *>(inst)); | |
| 342 | case Stage1AirInstIdUnionTag: | |
| 343 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstUnionTag *>(inst)); | |
| 344 | case Stage1AirInstIdRef: | |
| 345 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstRef *>(inst)); | |
| 346 | case Stage1AirInstIdErrName: | |
| 347 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstErrName *>(inst)); | |
| 348 | case Stage1AirInstIdCmpxchg: | |
| 349 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstCmpxchg *>(inst)); | |
| 350 | case Stage1AirInstIdFence: | |
| 351 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstFence *>(inst)); | |
| 352 | case Stage1AirInstIdReduce: | |
| 353 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstReduce *>(inst)); | |
| 354 | case Stage1AirInstIdTruncate: | |
| 355 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstTruncate *>(inst)); | |
| 356 | case Stage1AirInstIdShuffleVector: | |
| 357 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstShuffleVector *>(inst)); | |
| 358 | case Stage1AirInstIdSplat: | |
| 359 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstSplat *>(inst)); | |
| 360 | case Stage1AirInstIdBoolNot: | |
| 361 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstBoolNot *>(inst)); | |
| 362 | case Stage1AirInstIdMemset: | |
| 363 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstMemset *>(inst)); | |
| 364 | case Stage1AirInstIdMemcpy: | |
| 365 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstMemcpy *>(inst)); | |
| 366 | case Stage1AirInstIdSlice: | |
| 367 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstSlice *>(inst)); | |
| 368 | case Stage1AirInstIdBreakpoint: | |
| 369 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstBreakpoint *>(inst)); | |
| 370 | case Stage1AirInstIdReturnAddress: | |
| 371 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstReturnAddress *>(inst)); | |
| 372 | case Stage1AirInstIdFrameAddress: | |
| 373 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstFrameAddress *>(inst)); | |
| 374 | case Stage1AirInstIdFrameHandle: | |
| 375 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstFrameHandle *>(inst)); | |
| 376 | case Stage1AirInstIdFrameSize: | |
| 377 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstFrameSize *>(inst)); | |
| 378 | case Stage1AirInstIdOverflowOp: | |
| 379 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstOverflowOp *>(inst)); | |
| 380 | case Stage1AirInstIdTestErr: | |
| 381 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstTestErr *>(inst)); | |
| 382 | case Stage1AirInstIdUnwrapErrCode: | |
| 383 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstUnwrapErrCode *>(inst)); | |
| 384 | case Stage1AirInstIdUnwrapErrPayload: | |
| 385 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstUnwrapErrPayload *>(inst)); | |
| 386 | case Stage1AirInstIdOptionalWrap: | |
| 387 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstOptionalWrap *>(inst)); | |
| 388 | case Stage1AirInstIdErrWrapCode: | |
| 389 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstErrWrapCode *>(inst)); | |
| 390 | case Stage1AirInstIdErrWrapPayload: | |
| 391 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstErrWrapPayload *>(inst)); | |
| 392 | case Stage1AirInstIdPtrCast: | |
| 393 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstPtrCast *>(inst)); | |
| 394 | case Stage1AirInstIdBitCast: | |
| 395 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstBitCast *>(inst)); | |
| 396 | case Stage1AirInstIdWidenOrShorten: | |
| 397 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstWidenOrShorten *>(inst)); | |
| 398 | case Stage1AirInstIdPtrToInt: | |
| 399 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstPtrToInt *>(inst)); | |
| 400 | case Stage1AirInstIdIntToPtr: | |
| 401 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstIntToPtr *>(inst)); | |
| 402 | case Stage1AirInstIdIntToEnum: | |
| 403 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstIntToEnum *>(inst)); | |
| 404 | case Stage1AirInstIdIntToErr: | |
| 405 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstIntToErr *>(inst)); | |
| 406 | case Stage1AirInstIdErrToInt: | |
| 407 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstErrToInt *>(inst)); | |
| 408 | case Stage1AirInstIdTagName: | |
| 409 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstTagName *>(inst)); | |
| 410 | case Stage1AirInstIdPanic: | |
| 411 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstPanic *>(inst)); | |
| 412 | case Stage1AirInstIdFieldParentPtr: | |
| 413 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstFieldParentPtr *>(inst)); | |
| 414 | case Stage1AirInstIdAlignCast: | |
| 415 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstAlignCast *>(inst)); | |
| 416 | case Stage1AirInstIdErrorReturnTrace: | |
| 417 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstErrorReturnTrace *>(inst)); | |
| 418 | case Stage1AirInstIdAtomicRmw: | |
| 419 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstAtomicRmw *>(inst)); | |
| 420 | case Stage1AirInstIdSaveErrRetAddr: | |
| 421 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstSaveErrRetAddr *>(inst)); | |
| 422 | case Stage1AirInstIdFloatOp: | |
| 423 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstFloatOp *>(inst)); | |
| 424 | case Stage1AirInstIdMulAdd: | |
| 425 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstMulAdd *>(inst)); | |
| 426 | case Stage1AirInstIdAtomicLoad: | |
| 427 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstAtomicLoad *>(inst)); | |
| 428 | case Stage1AirInstIdAtomicStore: | |
| 429 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstAtomicStore *>(inst)); | |
| 430 | case Stage1AirInstIdDeclVar: | |
| 431 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstDeclVar *>(inst)); | |
| 432 | case Stage1AirInstIdArrayToVector: | |
| 433 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstArrayToVector *>(inst)); | |
| 434 | case Stage1AirInstIdVectorToArray: | |
| 435 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstVectorToArray *>(inst)); | |
| 436 | case Stage1AirInstIdPtrOfArrayToSlice: | |
| 437 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstPtrOfArrayToSlice *>(inst)); | |
| 438 | case Stage1AirInstIdAssertZero: | |
| 439 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstAssertZero *>(inst)); | |
| 440 | case Stage1AirInstIdAssertNonNull: | |
| 441 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstAssertNonNull *>(inst)); | |
| 442 | case Stage1AirInstIdAlloca: | |
| 443 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstAlloca *>(inst)); | |
| 444 | case Stage1AirInstIdSuspendBegin: | |
| 445 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstSuspendBegin *>(inst)); | |
| 446 | case Stage1AirInstIdSuspendFinish: | |
| 447 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstSuspendFinish *>(inst)); | |
| 448 | case Stage1AirInstIdResume: | |
| 449 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstResume *>(inst)); | |
| 450 | case Stage1AirInstIdAwait: | |
| 451 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstAwait *>(inst)); | |
| 452 | case Stage1AirInstIdSpillBegin: | |
| 453 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstSpillBegin *>(inst)); | |
| 454 | case Stage1AirInstIdSpillEnd: | |
| 455 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstSpillEnd *>(inst)); | |
| 456 | case Stage1AirInstIdVectorExtractElem: | |
| 457 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstVectorExtractElem *>(inst)); | |
| 458 | case Stage1AirInstIdBinaryNot: | |
| 459 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstBinaryNot *>(inst)); | |
| 460 | case Stage1AirInstIdNegation: | |
| 461 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstNegation *>(inst)); | |
| 462 | case Stage1AirInstIdWasmMemorySize: | |
| 463 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstWasmMemorySize *>(inst)); | |
| 464 | case Stage1AirInstIdWasmMemoryGrow: | |
| 465 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstWasmMemoryGrow *>(inst)); | |
| 466 | case Stage1AirInstIdExtern: | |
| 467 | return heap::c_allocator.destroy(reinterpret_cast<Stage1AirInstExtern *>(inst)); | |
| 468 | 468 | } |
| 469 | 469 | zig_unreachable(); |
| 470 | 470 | } |
| ... | ... | @@ -476,7 +476,7 @@ static void ira_deref(IrAnalyze *ira) { |
| 476 | 476 | if (ira->ref_count > 1) { |
| 477 | 477 | ira->ref_count -= 1; |
| 478 | 478 | |
| 479 | // immediate destruction of dangling IrInstGenConst is not possible | |
| 479 | // immediate destruction of dangling Stage1AirInstConst is not possible | |
| 480 | 480 | // free tracking memory because it will never be used |
| 481 | 481 | ira->new_irb.constants.deinit(&heap::c_allocator); |
| 482 | 482 | return; |
| ... | ... | @@ -486,7 +486,7 @@ static void ira_deref(IrAnalyze *ira) { |
| 486 | 486 | for (size_t bb_i = 0; bb_i < ira->zir->basic_block_list.length; bb_i += 1) { |
| 487 | 487 | Stage1ZirBasicBlock *pass1_bb = ira->zir->basic_block_list.items[bb_i]; |
| 488 | 488 | for (size_t inst_i = 0; inst_i < pass1_bb->instruction_list.length; inst_i += 1) { |
| 489 | IrInstSrc *pass1_inst = pass1_bb->instruction_list.items[inst_i]; | |
| 489 | Stage1ZirInst *pass1_inst = pass1_bb->instruction_list.items[inst_i]; | |
| 490 | 490 | destroy_instruction_src(pass1_inst); |
| 491 | 491 | } |
| 492 | 492 | heap::c_allocator.destroy(pass1_bb); |
| ... | ... | @@ -497,7 +497,7 @@ static void ira_deref(IrAnalyze *ira) { |
| 497 | 497 | ira->src_implicit_return_type_list.deinit(); |
| 498 | 498 | ira->resume_stack.deinit(); |
| 499 | 499 | |
| 500 | // destroy dangling IrInstGenConst | |
| 500 | // destroy dangling Stage1AirInstConst | |
| 501 | 501 | for (size_t i = 0; i < ira->new_irb.constants.length; i += 1) { |
| 502 | 502 | auto constant = ira->new_irb.constants.items[i]; |
| 503 | 503 | if (constant->base.ref_count == 0 && !ir_inst_gen_has_side_effects(&constant->base)) |
| ... | ... | @@ -675,7 +675,7 @@ static bool types_have_same_zig_comptime_repr(CodeGen *codegen, ZigType *expecte |
| 675 | 675 | zig_unreachable(); |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | static void ir_inst_gen_append(IrBasicBlockGen *basic_block, IrInstGen *instruction) { | |
| 678 | static void ir_inst_gen_append(Stage1AirBasicBlock *basic_block, Stage1AirInst *instruction) { | |
| 679 | 679 | assert(basic_block); |
| 680 | 680 | assert(instruction); |
| 681 | 681 | basic_block->instruction_list.append(instruction); |
| ... | ... | @@ -691,12 +691,12 @@ static bool value_is_comptime(ZigValue *const_val) { |
| 691 | 691 | return const_val->special != ConstValSpecialRuntime; |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | static bool instr_is_comptime(IrInstGen *instruction) { | |
| 694 | static bool instr_is_comptime(Stage1AirInst *instruction) { | |
| 695 | 695 | return value_is_comptime(instruction->value); |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | static void ir_ref_inst_gen(IrInstGen *instruction) { | |
| 699 | assert(instruction->id != IrInstGenIdInvalid); | |
| 698 | static void ir_ref_inst_gen(Stage1AirInst *instruction) { | |
| 699 | assert(instruction->id != Stage1AirInstIdInvalid); | |
| 700 | 700 | instruction->ref_count += 1; |
| 701 | 701 | } |
| 702 | 702 | |
| ... | ... | @@ -739,374 +739,374 @@ ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) { |
| 739 | 739 | return res_type; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | static IrBasicBlockGen *ir_create_basic_block_gen(IrAnalyze *ira, Scope *scope, const char *name_hint) { | |
| 743 | IrBasicBlockGen *result = heap::c_allocator.create<IrBasicBlockGen>(); | |
| 742 | static Stage1AirBasicBlock *ir_create_basic_block_gen(IrAnalyze *ira, Scope *scope, const char *name_hint) { | |
| 743 | Stage1AirBasicBlock *result = heap::c_allocator.create<Stage1AirBasicBlock>(); | |
| 744 | 744 | result->scope = scope; |
| 745 | 745 | result->name_hint = name_hint; |
| 746 | 746 | result->debug_id = exec_next_debug_id_gen(ira->new_irb.exec); |
| 747 | 747 | return result; |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | static IrBasicBlockGen *ir_build_bb_from(IrAnalyze *ira, Stage1ZirBasicBlock *other_bb) { | |
| 751 | IrBasicBlockGen *new_bb = ir_create_basic_block_gen(ira, other_bb->scope, other_bb->name_hint); | |
| 750 | static Stage1AirBasicBlock *ir_build_bb_from(IrAnalyze *ira, Stage1ZirBasicBlock *other_bb) { | |
| 751 | Stage1AirBasicBlock *new_bb = ir_create_basic_block_gen(ira, other_bb->scope, other_bb->name_hint); | |
| 752 | 752 | other_bb->child = new_bb; |
| 753 | 753 | return new_bb; |
| 754 | 754 | } |
| 755 | 755 | |
| 756 | static constexpr IrInstGenId ir_inst_id(IrInstGenDeclVar *) { | |
| 757 | return IrInstGenIdDeclVar; | |
| 756 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstDeclVar *) { | |
| 757 | return Stage1AirInstIdDeclVar; | |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | static constexpr IrInstGenId ir_inst_id(IrInstGenBr *) { | |
| 761 | return IrInstGenIdBr; | |
| 760 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstBr *) { | |
| 761 | return Stage1AirInstIdBr; | |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | static constexpr IrInstGenId ir_inst_id(IrInstGenCondBr *) { | |
| 765 | return IrInstGenIdCondBr; | |
| 764 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstCondBr *) { | |
| 765 | return Stage1AirInstIdCondBr; | |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | static constexpr IrInstGenId ir_inst_id(IrInstGenSwitchBr *) { | |
| 769 | return IrInstGenIdSwitchBr; | |
| 768 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstSwitchBr *) { | |
| 769 | return Stage1AirInstIdSwitchBr; | |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | static constexpr IrInstGenId ir_inst_id(IrInstGenPhi *) { | |
| 773 | return IrInstGenIdPhi; | |
| 772 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstPhi *) { | |
| 773 | return Stage1AirInstIdPhi; | |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | static constexpr IrInstGenId ir_inst_id(IrInstGenBinaryNot *) { | |
| 777 | return IrInstGenIdBinaryNot; | |
| 776 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstBinaryNot *) { | |
| 777 | return Stage1AirInstIdBinaryNot; | |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | static constexpr IrInstGenId ir_inst_id(IrInstGenNegation *) { | |
| 781 | return IrInstGenIdNegation; | |
| 780 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstNegation *) { | |
| 781 | return Stage1AirInstIdNegation; | |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | static constexpr IrInstGenId ir_inst_id(IrInstGenBinOp *) { | |
| 785 | return IrInstGenIdBinOp; | |
| 784 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstBinOp *) { | |
| 785 | return Stage1AirInstIdBinOp; | |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | static constexpr IrInstGenId ir_inst_id(IrInstGenLoadPtr *) { | |
| 789 | return IrInstGenIdLoadPtr; | |
| 788 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstLoadPtr *) { | |
| 789 | return Stage1AirInstIdLoadPtr; | |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | static constexpr IrInstGenId ir_inst_id(IrInstGenStorePtr *) { | |
| 793 | return IrInstGenIdStorePtr; | |
| 792 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstStorePtr *) { | |
| 793 | return Stage1AirInstIdStorePtr; | |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | static constexpr IrInstGenId ir_inst_id(IrInstGenVectorStoreElem *) { | |
| 797 | return IrInstGenIdVectorStoreElem; | |
| 796 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstVectorStoreElem *) { | |
| 797 | return Stage1AirInstIdVectorStoreElem; | |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | static constexpr IrInstGenId ir_inst_id(IrInstGenStructFieldPtr *) { | |
| 801 | return IrInstGenIdStructFieldPtr; | |
| 800 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstStructFieldPtr *) { | |
| 801 | return Stage1AirInstIdStructFieldPtr; | |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnionFieldPtr *) { | |
| 805 | return IrInstGenIdUnionFieldPtr; | |
| 804 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstUnionFieldPtr *) { | |
| 805 | return Stage1AirInstIdUnionFieldPtr; | |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | static constexpr IrInstGenId ir_inst_id(IrInstGenElemPtr *) { | |
| 809 | return IrInstGenIdElemPtr; | |
| 808 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstElemPtr *) { | |
| 809 | return Stage1AirInstIdElemPtr; | |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | static constexpr IrInstGenId ir_inst_id(IrInstGenVarPtr *) { | |
| 813 | return IrInstGenIdVarPtr; | |
| 812 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstVarPtr *) { | |
| 813 | return Stage1AirInstIdVarPtr; | |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | static constexpr IrInstGenId ir_inst_id(IrInstGenReturnPtr *) { | |
| 817 | return IrInstGenIdReturnPtr; | |
| 816 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstReturnPtr *) { | |
| 817 | return Stage1AirInstIdReturnPtr; | |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | static constexpr IrInstGenId ir_inst_id(IrInstGenCall *) { | |
| 821 | return IrInstGenIdCall; | |
| 820 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstCall *) { | |
| 821 | return Stage1AirInstIdCall; | |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | static constexpr IrInstGenId ir_inst_id(IrInstGenReturn *) { | |
| 825 | return IrInstGenIdReturn; | |
| 824 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstReturn *) { | |
| 825 | return Stage1AirInstIdReturn; | |
| 826 | 826 | } |
| 827 | 827 | |
| 828 | static constexpr IrInstGenId ir_inst_id(IrInstGenCast *) { | |
| 829 | return IrInstGenIdCast; | |
| 828 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstCast *) { | |
| 829 | return Stage1AirInstIdCast; | |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnreachable *) { | |
| 833 | return IrInstGenIdUnreachable; | |
| 832 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstUnreachable *) { | |
| 833 | return Stage1AirInstIdUnreachable; | |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | static constexpr IrInstGenId ir_inst_id(IrInstGenAsm *) { | |
| 837 | return IrInstGenIdAsm; | |
| 836 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstAsm *) { | |
| 837 | return Stage1AirInstIdAsm; | |
| 838 | 838 | } |
| 839 | 839 | |
| 840 | static constexpr IrInstGenId ir_inst_id(IrInstGenTestNonNull *) { | |
| 841 | return IrInstGenIdTestNonNull; | |
| 840 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstTestNonNull *) { | |
| 841 | return Stage1AirInstIdTestNonNull; | |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | static constexpr IrInstGenId ir_inst_id(IrInstGenOptionalUnwrapPtr *) { | |
| 845 | return IrInstGenIdOptionalUnwrapPtr; | |
| 844 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstOptionalUnwrapPtr *) { | |
| 845 | return Stage1AirInstIdOptionalUnwrapPtr; | |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | static constexpr IrInstGenId ir_inst_id(IrInstGenOptionalWrap *) { | |
| 849 | return IrInstGenIdOptionalWrap; | |
| 848 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstOptionalWrap *) { | |
| 849 | return Stage1AirInstIdOptionalWrap; | |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnionTag *) { | |
| 853 | return IrInstGenIdUnionTag; | |
| 852 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstUnionTag *) { | |
| 853 | return Stage1AirInstIdUnionTag; | |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | static constexpr IrInstGenId ir_inst_id(IrInstGenClz *) { | |
| 857 | return IrInstGenIdClz; | |
| 856 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstClz *) { | |
| 857 | return Stage1AirInstIdClz; | |
| 858 | 858 | } |
| 859 | 859 | |
| 860 | static constexpr IrInstGenId ir_inst_id(IrInstGenCtz *) { | |
| 861 | return IrInstGenIdCtz; | |
| 860 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstCtz *) { | |
| 861 | return Stage1AirInstIdCtz; | |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | static constexpr IrInstGenId ir_inst_id(IrInstGenPopCount *) { | |
| 865 | return IrInstGenIdPopCount; | |
| 864 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstPopCount *) { | |
| 865 | return Stage1AirInstIdPopCount; | |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | static constexpr IrInstGenId ir_inst_id(IrInstGenBswap *) { | |
| 869 | return IrInstGenIdBswap; | |
| 868 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstBswap *) { | |
| 869 | return Stage1AirInstIdBswap; | |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | static constexpr IrInstGenId ir_inst_id(IrInstGenBitReverse *) { | |
| 873 | return IrInstGenIdBitReverse; | |
| 872 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstBitReverse *) { | |
| 873 | return Stage1AirInstIdBitReverse; | |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | static constexpr IrInstGenId ir_inst_id(IrInstGenRef *) { | |
| 877 | return IrInstGenIdRef; | |
| 876 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstRef *) { | |
| 877 | return Stage1AirInstIdRef; | |
| 878 | 878 | } |
| 879 | 879 | |
| 880 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrName *) { | |
| 881 | return IrInstGenIdErrName; | |
| 880 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstErrName *) { | |
| 881 | return Stage1AirInstIdErrName; | |
| 882 | 882 | } |
| 883 | 883 | |
| 884 | static constexpr IrInstGenId ir_inst_id(IrInstGenCmpxchg *) { | |
| 885 | return IrInstGenIdCmpxchg; | |
| 884 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstCmpxchg *) { | |
| 885 | return Stage1AirInstIdCmpxchg; | |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | static constexpr IrInstGenId ir_inst_id(IrInstGenFence *) { | |
| 889 | return IrInstGenIdFence; | |
| 888 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstFence *) { | |
| 889 | return Stage1AirInstIdFence; | |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | static constexpr IrInstGenId ir_inst_id(IrInstGenReduce *) { | |
| 893 | return IrInstGenIdReduce; | |
| 892 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstReduce *) { | |
| 893 | return Stage1AirInstIdReduce; | |
| 894 | 894 | } |
| 895 | 895 | |
| 896 | static constexpr IrInstGenId ir_inst_id(IrInstGenTruncate *) { | |
| 897 | return IrInstGenIdTruncate; | |
| 896 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstTruncate *) { | |
| 897 | return Stage1AirInstIdTruncate; | |
| 898 | 898 | } |
| 899 | 899 | |
| 900 | static constexpr IrInstGenId ir_inst_id(IrInstGenShuffleVector *) { | |
| 901 | return IrInstGenIdShuffleVector; | |
| 900 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstShuffleVector *) { | |
| 901 | return Stage1AirInstIdShuffleVector; | |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | static constexpr IrInstGenId ir_inst_id(IrInstGenSplat *) { | |
| 905 | return IrInstGenIdSplat; | |
| 904 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstSplat *) { | |
| 905 | return Stage1AirInstIdSplat; | |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | static constexpr IrInstGenId ir_inst_id(IrInstGenBoolNot *) { | |
| 909 | return IrInstGenIdBoolNot; | |
| 908 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstBoolNot *) { | |
| 909 | return Stage1AirInstIdBoolNot; | |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | static constexpr IrInstGenId ir_inst_id(IrInstGenMemset *) { | |
| 913 | return IrInstGenIdMemset; | |
| 912 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstMemset *) { | |
| 913 | return Stage1AirInstIdMemset; | |
| 914 | 914 | } |
| 915 | 915 | |
| 916 | static constexpr IrInstGenId ir_inst_id(IrInstGenMemcpy *) { | |
| 917 | return IrInstGenIdMemcpy; | |
| 916 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstMemcpy *) { | |
| 917 | return Stage1AirInstIdMemcpy; | |
| 918 | 918 | } |
| 919 | 919 | |
| 920 | static constexpr IrInstGenId ir_inst_id(IrInstGenSlice *) { | |
| 921 | return IrInstGenIdSlice; | |
| 920 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstSlice *) { | |
| 921 | return Stage1AirInstIdSlice; | |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | static constexpr IrInstGenId ir_inst_id(IrInstGenBreakpoint *) { | |
| 925 | return IrInstGenIdBreakpoint; | |
| 924 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstBreakpoint *) { | |
| 925 | return Stage1AirInstIdBreakpoint; | |
| 926 | 926 | } |
| 927 | 927 | |
| 928 | static constexpr IrInstGenId ir_inst_id(IrInstGenReturnAddress *) { | |
| 929 | return IrInstGenIdReturnAddress; | |
| 928 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstReturnAddress *) { | |
| 929 | return Stage1AirInstIdReturnAddress; | |
| 930 | 930 | } |
| 931 | 931 | |
| 932 | static constexpr IrInstGenId ir_inst_id(IrInstGenFrameAddress *) { | |
| 933 | return IrInstGenIdFrameAddress; | |
| 932 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstFrameAddress *) { | |
| 933 | return Stage1AirInstIdFrameAddress; | |
| 934 | 934 | } |
| 935 | 935 | |
| 936 | static constexpr IrInstGenId ir_inst_id(IrInstGenFrameHandle *) { | |
| 937 | return IrInstGenIdFrameHandle; | |
| 936 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstFrameHandle *) { | |
| 937 | return Stage1AirInstIdFrameHandle; | |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | static constexpr IrInstGenId ir_inst_id(IrInstGenFrameSize *) { | |
| 941 | return IrInstGenIdFrameSize; | |
| 940 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstFrameSize *) { | |
| 941 | return Stage1AirInstIdFrameSize; | |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | static constexpr IrInstGenId ir_inst_id(IrInstGenOverflowOp *) { | |
| 945 | return IrInstGenIdOverflowOp; | |
| 944 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstOverflowOp *) { | |
| 945 | return Stage1AirInstIdOverflowOp; | |
| 946 | 946 | } |
| 947 | 947 | |
| 948 | static constexpr IrInstGenId ir_inst_id(IrInstGenTestErr *) { | |
| 949 | return IrInstGenIdTestErr; | |
| 948 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstTestErr *) { | |
| 949 | return Stage1AirInstIdTestErr; | |
| 950 | 950 | } |
| 951 | 951 | |
| 952 | static constexpr IrInstGenId ir_inst_id(IrInstGenMulAdd *) { | |
| 953 | return IrInstGenIdMulAdd; | |
| 952 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstMulAdd *) { | |
| 953 | return Stage1AirInstIdMulAdd; | |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | static constexpr IrInstGenId ir_inst_id(IrInstGenFloatOp *) { | |
| 957 | return IrInstGenIdFloatOp; | |
| 956 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstFloatOp *) { | |
| 957 | return Stage1AirInstIdFloatOp; | |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnwrapErrCode *) { | |
| 961 | return IrInstGenIdUnwrapErrCode; | |
| 960 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstUnwrapErrCode *) { | |
| 961 | return Stage1AirInstIdUnwrapErrCode; | |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnwrapErrPayload *) { | |
| 965 | return IrInstGenIdUnwrapErrPayload; | |
| 964 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstUnwrapErrPayload *) { | |
| 965 | return Stage1AirInstIdUnwrapErrPayload; | |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrWrapCode *) { | |
| 969 | return IrInstGenIdErrWrapCode; | |
| 968 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstErrWrapCode *) { | |
| 969 | return Stage1AirInstIdErrWrapCode; | |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrWrapPayload *) { | |
| 973 | return IrInstGenIdErrWrapPayload; | |
| 972 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstErrWrapPayload *) { | |
| 973 | return Stage1AirInstIdErrWrapPayload; | |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | static constexpr IrInstGenId ir_inst_id(IrInstGenPtrCast *) { | |
| 977 | return IrInstGenIdPtrCast; | |
| 976 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstPtrCast *) { | |
| 977 | return Stage1AirInstIdPtrCast; | |
| 978 | 978 | } |
| 979 | 979 | |
| 980 | static constexpr IrInstGenId ir_inst_id(IrInstGenBitCast *) { | |
| 981 | return IrInstGenIdBitCast; | |
| 980 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstBitCast *) { | |
| 981 | return Stage1AirInstIdBitCast; | |
| 982 | 982 | } |
| 983 | 983 | |
| 984 | static constexpr IrInstGenId ir_inst_id(IrInstGenWidenOrShorten *) { | |
| 985 | return IrInstGenIdWidenOrShorten; | |
| 984 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstWidenOrShorten *) { | |
| 985 | return Stage1AirInstIdWidenOrShorten; | |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | static constexpr IrInstGenId ir_inst_id(IrInstGenIntToPtr *) { | |
| 989 | return IrInstGenIdIntToPtr; | |
| 988 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstIntToPtr *) { | |
| 989 | return Stage1AirInstIdIntToPtr; | |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | static constexpr IrInstGenId ir_inst_id(IrInstGenPtrToInt *) { | |
| 993 | return IrInstGenIdPtrToInt; | |
| 992 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstPtrToInt *) { | |
| 993 | return Stage1AirInstIdPtrToInt; | |
| 994 | 994 | } |
| 995 | 995 | |
| 996 | static constexpr IrInstGenId ir_inst_id(IrInstGenIntToEnum *) { | |
| 997 | return IrInstGenIdIntToEnum; | |
| 996 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstIntToEnum *) { | |
| 997 | return Stage1AirInstIdIntToEnum; | |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | static constexpr IrInstGenId ir_inst_id(IrInstGenIntToErr *) { | |
| 1001 | return IrInstGenIdIntToErr; | |
| 1000 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstIntToErr *) { | |
| 1001 | return Stage1AirInstIdIntToErr; | |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrToInt *) { | |
| 1005 | return IrInstGenIdErrToInt; | |
| 1004 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstErrToInt *) { | |
| 1005 | return Stage1AirInstIdErrToInt; | |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | static constexpr IrInstGenId ir_inst_id(IrInstGenPanic *) { | |
| 1009 | return IrInstGenIdPanic; | |
| 1008 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstPanic *) { | |
| 1009 | return Stage1AirInstIdPanic; | |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | static constexpr IrInstGenId ir_inst_id(IrInstGenTagName *) { | |
| 1013 | return IrInstGenIdTagName; | |
| 1012 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstTagName *) { | |
| 1013 | return Stage1AirInstIdTagName; | |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | static constexpr IrInstGenId ir_inst_id(IrInstGenFieldParentPtr *) { | |
| 1017 | return IrInstGenIdFieldParentPtr; | |
| 1016 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstFieldParentPtr *) { | |
| 1017 | return Stage1AirInstIdFieldParentPtr; | |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | static constexpr IrInstGenId ir_inst_id(IrInstGenAlignCast *) { | |
| 1021 | return IrInstGenIdAlignCast; | |
| 1020 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstAlignCast *) { | |
| 1021 | return Stage1AirInstIdAlignCast; | |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrorReturnTrace *) { | |
| 1025 | return IrInstGenIdErrorReturnTrace; | |
| 1024 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstErrorReturnTrace *) { | |
| 1025 | return Stage1AirInstIdErrorReturnTrace; | |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | static constexpr IrInstGenId ir_inst_id(IrInstGenAtomicRmw *) { | |
| 1029 | return IrInstGenIdAtomicRmw; | |
| 1028 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstAtomicRmw *) { | |
| 1029 | return Stage1AirInstIdAtomicRmw; | |
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | static constexpr IrInstGenId ir_inst_id(IrInstGenAtomicLoad *) { | |
| 1033 | return IrInstGenIdAtomicLoad; | |
| 1032 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstAtomicLoad *) { | |
| 1033 | return Stage1AirInstIdAtomicLoad; | |
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | static constexpr IrInstGenId ir_inst_id(IrInstGenAtomicStore *) { | |
| 1037 | return IrInstGenIdAtomicStore; | |
| 1036 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstAtomicStore *) { | |
| 1037 | return Stage1AirInstIdAtomicStore; | |
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | static constexpr IrInstGenId ir_inst_id(IrInstGenSaveErrRetAddr *) { | |
| 1041 | return IrInstGenIdSaveErrRetAddr; | |
| 1040 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstSaveErrRetAddr *) { | |
| 1041 | return Stage1AirInstIdSaveErrRetAddr; | |
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | static constexpr IrInstGenId ir_inst_id(IrInstGenVectorToArray *) { | |
| 1045 | return IrInstGenIdVectorToArray; | |
| 1044 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstVectorToArray *) { | |
| 1045 | return Stage1AirInstIdVectorToArray; | |
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | static constexpr IrInstGenId ir_inst_id(IrInstGenArrayToVector *) { | |
| 1049 | return IrInstGenIdArrayToVector; | |
| 1048 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstArrayToVector *) { | |
| 1049 | return Stage1AirInstIdArrayToVector; | |
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | static constexpr IrInstGenId ir_inst_id(IrInstGenAssertZero *) { | |
| 1053 | return IrInstGenIdAssertZero; | |
| 1052 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstAssertZero *) { | |
| 1053 | return Stage1AirInstIdAssertZero; | |
| 1054 | 1054 | } |
| 1055 | 1055 | |
| 1056 | static constexpr IrInstGenId ir_inst_id(IrInstGenAssertNonNull *) { | |
| 1057 | return IrInstGenIdAssertNonNull; | |
| 1056 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstAssertNonNull *) { | |
| 1057 | return Stage1AirInstIdAssertNonNull; | |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | static constexpr IrInstGenId ir_inst_id(IrInstGenPtrOfArrayToSlice *) { | |
| 1061 | return IrInstGenIdPtrOfArrayToSlice; | |
| 1060 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstPtrOfArrayToSlice *) { | |
| 1061 | return Stage1AirInstIdPtrOfArrayToSlice; | |
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | static constexpr IrInstGenId ir_inst_id(IrInstGenSuspendBegin *) { | |
| 1065 | return IrInstGenIdSuspendBegin; | |
| 1064 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstSuspendBegin *) { | |
| 1065 | return Stage1AirInstIdSuspendBegin; | |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | static constexpr IrInstGenId ir_inst_id(IrInstGenSuspendFinish *) { | |
| 1069 | return IrInstGenIdSuspendFinish; | |
| 1068 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstSuspendFinish *) { | |
| 1069 | return Stage1AirInstIdSuspendFinish; | |
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | static constexpr IrInstGenId ir_inst_id(IrInstGenAwait *) { | |
| 1073 | return IrInstGenIdAwait; | |
| 1072 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstAwait *) { | |
| 1073 | return Stage1AirInstIdAwait; | |
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | static constexpr IrInstGenId ir_inst_id(IrInstGenResume *) { | |
| 1077 | return IrInstGenIdResume; | |
| 1076 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstResume *) { | |
| 1077 | return Stage1AirInstIdResume; | |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | static constexpr IrInstGenId ir_inst_id(IrInstGenSpillBegin *) { | |
| 1081 | return IrInstGenIdSpillBegin; | |
| 1080 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstSpillBegin *) { | |
| 1081 | return Stage1AirInstIdSpillBegin; | |
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | static constexpr IrInstGenId ir_inst_id(IrInstGenSpillEnd *) { | |
| 1085 | return IrInstGenIdSpillEnd; | |
| 1084 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstSpillEnd *) { | |
| 1085 | return Stage1AirInstIdSpillEnd; | |
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | static constexpr IrInstGenId ir_inst_id(IrInstGenVectorExtractElem *) { | |
| 1089 | return IrInstGenIdVectorExtractElem; | |
| 1088 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstVectorExtractElem *) { | |
| 1089 | return Stage1AirInstIdVectorExtractElem; | |
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | static constexpr IrInstGenId ir_inst_id(IrInstGenAlloca *) { | |
| 1093 | return IrInstGenIdAlloca; | |
| 1092 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstAlloca *) { | |
| 1093 | return Stage1AirInstIdAlloca; | |
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | static constexpr IrInstGenId ir_inst_id(IrInstGenConst *) { | |
| 1097 | return IrInstGenIdConst; | |
| 1096 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstConst *) { | |
| 1097 | return Stage1AirInstIdConst; | |
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | static constexpr IrInstGenId ir_inst_id(IrInstGenWasmMemorySize *) { | |
| 1101 | return IrInstGenIdWasmMemorySize; | |
| 1100 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstWasmMemorySize *) { | |
| 1101 | return Stage1AirInstIdWasmMemorySize; | |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | static constexpr IrInstGenId ir_inst_id(IrInstGenWasmMemoryGrow *) { | |
| 1105 | return IrInstGenIdWasmMemoryGrow; | |
| 1104 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstWasmMemoryGrow *) { | |
| 1105 | return Stage1AirInstIdWasmMemoryGrow; | |
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | static constexpr IrInstGenId ir_inst_id(IrInstGenExtern *) { | |
| 1109 | return IrInstGenIdExtern; | |
| 1108 | static constexpr Stage1AirInstId ir_inst_id(Stage1AirInstExtern *) { | |
| 1109 | return Stage1AirInstIdExtern; | |
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | template<typename T> |
| ... | ... | @@ -1155,11 +1155,11 @@ static T *ir_build_inst_void(IrBuilderGen *irb, Scope *scope, AstNode *source_no |
| 1155 | 1155 | return special_instruction; |
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | IrInstGen *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigFn *fn, | |
| 1158 | Stage1AirInst *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigFn *fn, | |
| 1159 | 1159 | ZigType *var_type, const char *name_hint) |
| 1160 | 1160 | { |
| 1161 | IrInstGenAlloca *alloca_gen = heap::c_allocator.create<IrInstGenAlloca>(); | |
| 1162 | alloca_gen->base.id = IrInstGenIdAlloca; | |
| 1161 | Stage1AirInstAlloca *alloca_gen = heap::c_allocator.create<Stage1AirInstAlloca>(); | |
| 1162 | alloca_gen->base.id = Stage1AirInstIdAlloca; | |
| 1163 | 1163 | alloca_gen->base.source_node = source_node; |
| 1164 | 1164 | alloca_gen->base.scope = scope; |
| 1165 | 1165 | alloca_gen->base.value = g->pass1_arena->create<ZigValue>(); |
| ... | ... | @@ -1170,10 +1170,10 @@ IrInstGen *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigF |
| 1170 | 1170 | return &alloca_gen->base; |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | static IrInstGen *ir_build_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1174 | ZigType *dest_type, IrInstGen *value, CastOp cast_op) | |
| 1173 | static Stage1AirInst *ir_build_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1174 | ZigType *dest_type, Stage1AirInst *value, CastOp cast_op) | |
| 1175 | 1175 | { |
| 1176 | IrInstGenCast *inst = ir_build_inst_gen<IrInstGenCast>(&ira->new_irb, scope, source_node); | |
| 1176 | Stage1AirInstCast *inst = ir_build_inst_gen<Stage1AirInstCast>(&ira->new_irb, scope, source_node); | |
| 1177 | 1177 | inst->base.value->type = dest_type; |
| 1178 | 1178 | inst->value = value; |
| 1179 | 1179 | inst->cast_op = cast_op; |
| ... | ... | @@ -1183,10 +1183,10 @@ static IrInstGen *ir_build_cast(IrAnalyze *ira, Scope *scope, AstNode *source_no |
| 1183 | 1183 | return &inst->base; |
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | static IrInstGen *ir_build_cond_br_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *condition, | |
| 1187 | IrBasicBlockGen *then_block, IrBasicBlockGen *else_block) | |
| 1186 | static Stage1AirInst *ir_build_cond_br_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *condition, | |
| 1187 | Stage1AirBasicBlock *then_block, Stage1AirBasicBlock *else_block) | |
| 1188 | 1188 | { |
| 1189 | IrInstGenCondBr *inst = ir_build_inst_noreturn<IrInstGenCondBr>(&ira->new_irb, scope, source_node); | |
| 1189 | Stage1AirInstCondBr *inst = ir_build_inst_noreturn<Stage1AirInstCondBr>(&ira->new_irb, scope, source_node); | |
| 1190 | 1190 | inst->condition = condition; |
| 1191 | 1191 | inst->then_block = then_block; |
| 1192 | 1192 | inst->else_block = else_block; |
| ... | ... | @@ -1196,8 +1196,8 @@ static IrInstGen *ir_build_cond_br_gen(IrAnalyze *ira, Scope *scope, AstNode *so |
| 1196 | 1196 | return &inst->base; |
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | static IrInstGen *ir_build_return_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *operand) { | |
| 1200 | IrInstGenReturn *inst = ir_build_inst_noreturn<IrInstGenReturn>(&ira->new_irb, scope, source_node); | |
| 1199 | static Stage1AirInst *ir_build_return_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *operand) { | |
| 1200 | Stage1AirInstReturn *inst = ir_build_inst_noreturn<Stage1AirInstReturn>(&ira->new_irb, scope, source_node); | |
| 1201 | 1201 | inst->operand = operand; |
| 1202 | 1202 | |
| 1203 | 1203 | if (operand != nullptr) ir_ref_inst_gen(operand); |
| ... | ... | @@ -1205,10 +1205,10 @@ static IrInstGen *ir_build_return_gen(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 1205 | 1205 | return &inst->base; |
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | static IrInstGen *ir_build_bin_op_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *res_type, | |
| 1209 | IrBinOp op_id, IrInstGen *op1, IrInstGen *op2, bool safety_check_on) | |
| 1208 | static Stage1AirInst *ir_build_bin_op_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *res_type, | |
| 1209 | IrBinOp op_id, Stage1AirInst *op1, Stage1AirInst *op2, bool safety_check_on) | |
| 1210 | 1210 | { |
| 1211 | IrInstGenBinOp *inst = ir_build_inst_gen<IrInstGenBinOp>(&ira->new_irb, | |
| 1211 | Stage1AirInstBinOp *inst = ir_build_inst_gen<Stage1AirInstBinOp>(&ira->new_irb, | |
| 1212 | 1212 | scope, source_node); |
| 1213 | 1213 | inst->base.value->type = res_type; |
| 1214 | 1214 | inst->op_id = op_id; |
| ... | ... | @@ -1223,8 +1223,8 @@ static IrInstGen *ir_build_bin_op_gen(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | 1225 | |
| 1226 | static IrInstGen *ir_build_var_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigVar *var) { | |
| 1227 | IrInstGenVarPtr *instruction = ir_build_inst_gen<IrInstGenVarPtr>(&ira->new_irb, scope, source_node); | |
| 1226 | static Stage1AirInst *ir_build_var_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigVar *var) { | |
| 1227 | Stage1AirInstVarPtr *instruction = ir_build_inst_gen<Stage1AirInstVarPtr>(&ira->new_irb, scope, source_node); | |
| 1228 | 1228 | instruction->var = var; |
| 1229 | 1229 | |
| 1230 | 1230 | var->ref_count += 1; |
| ... | ... | @@ -1232,16 +1232,16 @@ static IrInstGen *ir_build_var_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *so |
| 1232 | 1232 | return &instruction->base; |
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | static IrInstGen *ir_build_return_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty) { | |
| 1236 | IrInstGenReturnPtr *instruction = ir_build_inst_gen<IrInstGenReturnPtr>(&ira->new_irb, scope, source_node); | |
| 1235 | static Stage1AirInst *ir_build_return_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty) { | |
| 1236 | Stage1AirInstReturnPtr *instruction = ir_build_inst_gen<Stage1AirInstReturnPtr>(&ira->new_irb, scope, source_node); | |
| 1237 | 1237 | instruction->base.value->type = ty; |
| 1238 | 1238 | return &instruction->base; |
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | static IrInstGen *ir_build_elem_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1242 | IrInstGen *array_ptr, IrInstGen *elem_index, bool safety_check_on, ZigType *return_type) | |
| 1241 | static Stage1AirInst *ir_build_elem_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1242 | Stage1AirInst *array_ptr, Stage1AirInst *elem_index, bool safety_check_on, ZigType *return_type) | |
| 1243 | 1243 | { |
| 1244 | IrInstGenElemPtr *instruction = ir_build_inst_gen<IrInstGenElemPtr>(&ira->new_irb, scope, source_node); | |
| 1244 | Stage1AirInstElemPtr *instruction = ir_build_inst_gen<Stage1AirInstElemPtr>(&ira->new_irb, scope, source_node); | |
| 1245 | 1245 | instruction->base.value->type = return_type; |
| 1246 | 1246 | instruction->array_ptr = array_ptr; |
| 1247 | 1247 | instruction->elem_index = elem_index; |
| ... | ... | @@ -1253,10 +1253,10 @@ static IrInstGen *ir_build_elem_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 1253 | 1253 | return &instruction->base; |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | static IrInstGen *ir_build_struct_field_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1257 | IrInstGen *struct_ptr, TypeStructField *field, ZigType *ptr_type) | |
| 1256 | static Stage1AirInst *ir_build_struct_field_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1257 | Stage1AirInst *struct_ptr, TypeStructField *field, ZigType *ptr_type) | |
| 1258 | 1258 | { |
| 1259 | IrInstGenStructFieldPtr *inst = ir_build_inst_gen<IrInstGenStructFieldPtr>(&ira->new_irb, scope, source_node); | |
| 1259 | Stage1AirInstStructFieldPtr *inst = ir_build_inst_gen<Stage1AirInstStructFieldPtr>(&ira->new_irb, scope, source_node); | |
| 1260 | 1260 | inst->base.value->type = ptr_type; |
| 1261 | 1261 | inst->struct_ptr = struct_ptr; |
| 1262 | 1262 | inst->field = field; |
| ... | ... | @@ -1266,10 +1266,10 @@ static IrInstGen *ir_build_struct_field_ptr(IrAnalyze *ira, Scope *scope, AstNod |
| 1266 | 1266 | return &inst->base; |
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | static IrInstGen *ir_build_union_field_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1270 | IrInstGen *union_ptr, TypeUnionField *field, bool safety_check_on, bool initializing, ZigType *ptr_type) | |
| 1269 | static Stage1AirInst *ir_build_union_field_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1270 | Stage1AirInst *union_ptr, TypeUnionField *field, bool safety_check_on, bool initializing, ZigType *ptr_type) | |
| 1271 | 1271 | { |
| 1272 | IrInstGenUnionFieldPtr *inst = ir_build_inst_gen<IrInstGenUnionFieldPtr>(&ira->new_irb, | |
| 1272 | Stage1AirInstUnionFieldPtr *inst = ir_build_inst_gen<Stage1AirInstUnionFieldPtr>(&ira->new_irb, | |
| 1273 | 1273 | scope, source_node); |
| 1274 | 1274 | inst->base.value->type = ptr_type; |
| 1275 | 1275 | inst->initializing = initializing; |
| ... | ... | @@ -1282,12 +1282,12 @@ static IrInstGen *ir_build_union_field_ptr(IrAnalyze *ira, Scope *scope, AstNode |
| 1282 | 1282 | return &inst->base; |
| 1283 | 1283 | } |
| 1284 | 1284 | |
| 1285 | static IrInstGenCall *ir_build_call_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1286 | ZigFn *fn_entry, IrInstGen *fn_ref, size_t arg_count, IrInstGen **args, | |
| 1287 | CallModifier modifier, IrInstGen *new_stack, bool is_async_call_builtin, | |
| 1288 | IrInstGen *result_loc, ZigType *return_type) | |
| 1285 | static Stage1AirInstCall *ir_build_call_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1286 | ZigFn *fn_entry, Stage1AirInst *fn_ref, size_t arg_count, Stage1AirInst **args, | |
| 1287 | CallModifier modifier, Stage1AirInst *new_stack, bool is_async_call_builtin, | |
| 1288 | Stage1AirInst *result_loc, ZigType *return_type) | |
| 1289 | 1289 | { |
| 1290 | IrInstGenCall *call_instruction = ir_build_inst_gen<IrInstGenCall>(&ira->new_irb, | |
| 1290 | Stage1AirInstCall *call_instruction = ir_build_inst_gen<Stage1AirInstCall>(&ira->new_irb, | |
| 1291 | 1291 | scope, source_node); |
| 1292 | 1292 | call_instruction->base.value->type = return_type; |
| 1293 | 1293 | call_instruction->fn_entry = fn_entry; |
| ... | ... | @@ -1308,13 +1308,13 @@ static IrInstGenCall *ir_build_call_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 1308 | 1308 | return call_instruction; |
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | static IrInstGen *ir_build_phi_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, size_t incoming_count, | |
| 1312 | IrBasicBlockGen **incoming_blocks, IrInstGen **incoming_values, ZigType *result_type) | |
| 1311 | static Stage1AirInst *ir_build_phi_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, size_t incoming_count, | |
| 1312 | Stage1AirBasicBlock **incoming_blocks, Stage1AirInst **incoming_values, ZigType *result_type) | |
| 1313 | 1313 | { |
| 1314 | 1314 | assert(incoming_count != 0); |
| 1315 | 1315 | assert(incoming_count != SIZE_MAX); |
| 1316 | 1316 | |
| 1317 | IrInstGenPhi *phi_instruction = ir_build_inst_gen<IrInstGenPhi>(&ira->new_irb, | |
| 1317 | Stage1AirInstPhi *phi_instruction = ir_build_inst_gen<Stage1AirInstPhi>(&ira->new_irb, | |
| 1318 | 1318 | scope, source_node); |
| 1319 | 1319 | phi_instruction->base.value->type = result_type; |
| 1320 | 1320 | phi_instruction->incoming_count = incoming_count; |
| ... | ... | @@ -1328,15 +1328,15 @@ static IrInstGen *ir_build_phi_gen(IrAnalyze *ira, Scope *scope, AstNode *source |
| 1328 | 1328 | return &phi_instruction->base; |
| 1329 | 1329 | } |
| 1330 | 1330 | |
| 1331 | static IrInstGen *ir_build_br_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrBasicBlockGen *dest_block) { | |
| 1332 | IrInstGenBr *inst = ir_build_inst_noreturn<IrInstGenBr>(&ira->new_irb, scope, source_node); | |
| 1331 | static Stage1AirInst *ir_build_br_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirBasicBlock *dest_block) { | |
| 1332 | Stage1AirInstBr *inst = ir_build_inst_noreturn<Stage1AirInstBr>(&ira->new_irb, scope, source_node); | |
| 1333 | 1333 | inst->dest_block = dest_block; |
| 1334 | 1334 | |
| 1335 | 1335 | return &inst->base; |
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | static IrInstGen *ir_build_negation(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *operand, ZigType *expr_type, bool wrapping) { | |
| 1339 | IrInstGenNegation *instruction = ir_build_inst_gen<IrInstGenNegation>(&ira->new_irb, | |
| 1338 | static Stage1AirInst *ir_build_negation(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *operand, ZigType *expr_type, bool wrapping) { | |
| 1339 | Stage1AirInstNegation *instruction = ir_build_inst_gen<Stage1AirInstNegation>(&ira->new_irb, | |
| 1340 | 1340 | scope, source_node); |
| 1341 | 1341 | instruction->base.value->type = expr_type; |
| 1342 | 1342 | instruction->operand = operand; |
| ... | ... | @@ -1347,10 +1347,10 @@ static IrInstGen *ir_build_negation(IrAnalyze *ira, Scope *scope, AstNode *sourc |
| 1347 | 1347 | return &instruction->base; |
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | static IrInstGen *ir_build_binary_not(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *operand, | |
| 1350 | static Stage1AirInst *ir_build_binary_not(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *operand, | |
| 1351 | 1351 | ZigType *expr_type) |
| 1352 | 1352 | { |
| 1353 | IrInstGenBinaryNot *instruction = ir_build_inst_gen<IrInstGenBinaryNot>(&ira->new_irb, | |
| 1353 | Stage1AirInstBinaryNot *instruction = ir_build_inst_gen<Stage1AirInstBinaryNot>(&ira->new_irb, | |
| 1354 | 1354 | scope, source_node); |
| 1355 | 1355 | instruction->base.value->type = expr_type; |
| 1356 | 1356 | instruction->operand = operand; |
| ... | ... | @@ -1360,13 +1360,13 @@ static IrInstGen *ir_build_binary_not(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 1360 | 1360 | return &instruction->base; |
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | static IrInstGen *ir_build_unreachable_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1364 | IrInstGenUnreachable *inst = ir_build_inst_noreturn<IrInstGenUnreachable>(&ira->new_irb, scope, source_node); | |
| 1363 | static Stage1AirInst *ir_build_unreachable_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1364 | Stage1AirInstUnreachable *inst = ir_build_inst_noreturn<Stage1AirInstUnreachable>(&ira->new_irb, scope, source_node); | |
| 1365 | 1365 | return &inst->base; |
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | static IrInstGen *ir_build_store_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *ptr, IrInstGen *value) { | |
| 1369 | IrInstGenStorePtr *instruction = ir_build_inst_void<IrInstGenStorePtr>(&ira->new_irb, | |
| 1368 | static Stage1AirInst *ir_build_store_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *ptr, Stage1AirInst *value) { | |
| 1369 | Stage1AirInstStorePtr *instruction = ir_build_inst_void<Stage1AirInstStorePtr>(&ira->new_irb, | |
| 1370 | 1370 | scope, source_node); |
| 1371 | 1371 | instruction->ptr = ptr; |
| 1372 | 1372 | instruction->value = value; |
| ... | ... | @@ -1377,10 +1377,10 @@ static IrInstGen *ir_build_store_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode * |
| 1377 | 1377 | return &instruction->base; |
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | static IrInstGen *ir_build_vector_store_elem(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1381 | IrInstGen *vector_ptr, IrInstGen *index, IrInstGen *value) | |
| 1380 | static Stage1AirInst *ir_build_vector_store_elem(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1381 | Stage1AirInst *vector_ptr, Stage1AirInst *index, Stage1AirInst *value) | |
| 1382 | 1382 | { |
| 1383 | IrInstGenVectorStoreElem *inst = ir_build_inst_void<IrInstGenVectorStoreElem>( | |
| 1383 | Stage1AirInstVectorStoreElem *inst = ir_build_inst_void<Stage1AirInstVectorStoreElem>( | |
| 1384 | 1384 | &ira->new_irb, scope, source_node); |
| 1385 | 1385 | inst->vector_ptr = vector_ptr; |
| 1386 | 1386 | inst->index = index; |
| ... | ... | @@ -1393,10 +1393,10 @@ static IrInstGen *ir_build_vector_store_elem(IrAnalyze *ira, Scope *scope, AstNo |
| 1393 | 1393 | return &inst->base; |
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | static IrInstGen *ir_build_var_decl_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1397 | ZigVar *var, IrInstGen *var_ptr) | |
| 1396 | static Stage1AirInst *ir_build_var_decl_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1397 | ZigVar *var, Stage1AirInst *var_ptr) | |
| 1398 | 1398 | { |
| 1399 | IrInstGenDeclVar *inst = ir_build_inst_gen<IrInstGenDeclVar>(&ira->new_irb, | |
| 1399 | Stage1AirInstDeclVar *inst = ir_build_inst_gen<Stage1AirInstDeclVar>(&ira->new_irb, | |
| 1400 | 1400 | scope, source_node); |
| 1401 | 1401 | inst->base.value->special = ConstValSpecialStatic; |
| 1402 | 1402 | inst->base.value->type = ira->codegen->builtin_types.entry_void; |
| ... | ... | @@ -1408,10 +1408,10 @@ static IrInstGen *ir_build_var_decl_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 1408 | 1408 | return &inst->base; |
| 1409 | 1409 | } |
| 1410 | 1410 | |
| 1411 | static IrInstGen *ir_build_extern_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Buf *name, | |
| 1411 | static Stage1AirInst *ir_build_extern_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Buf *name, | |
| 1412 | 1412 | GlobalLinkageId linkage, bool is_thread_local, ZigType *expr_type) |
| 1413 | 1413 | { |
| 1414 | IrInstGenExtern *instruction = ir_build_inst_gen<IrInstGenExtern>(&ira->new_irb, | |
| 1414 | Stage1AirInstExtern *instruction = ir_build_inst_gen<Stage1AirInstExtern>(&ira->new_irb, | |
| 1415 | 1415 | scope, source_node); |
| 1416 | 1416 | instruction->base.value->type = expr_type; |
| 1417 | 1417 | instruction->name = name; |
| ... | ... | @@ -1421,10 +1421,10 @@ static IrInstGen *ir_build_extern_gen(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 1421 | 1421 | return &instruction->base; |
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | static IrInstGen *ir_build_load_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1425 | IrInstGen *ptr, ZigType *ty, IrInstGen *result_loc) | |
| 1424 | static Stage1AirInst *ir_build_load_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1425 | Stage1AirInst *ptr, ZigType *ty, Stage1AirInst *result_loc) | |
| 1426 | 1426 | { |
| 1427 | IrInstGenLoadPtr *instruction = ir_build_inst_gen<IrInstGenLoadPtr>( | |
| 1427 | Stage1AirInstLoadPtr *instruction = ir_build_inst_gen<Stage1AirInstLoadPtr>( | |
| 1428 | 1428 | &ira->new_irb, scope, source_node); |
| 1429 | 1429 | instruction->base.value->type = ty; |
| 1430 | 1430 | instruction->ptr = ptr; |
| ... | ... | @@ -1436,12 +1436,12 @@ static IrInstGen *ir_build_load_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 1436 | 1436 | return &instruction->base; |
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | static IrInstGen *ir_build_asm_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1439 | static Stage1AirInst *ir_build_asm_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1440 | 1440 | Buf *asm_template, AsmToken *token_list, size_t token_list_len, |
| 1441 | IrInstGen **input_list, IrInstGen **output_types, ZigVar **output_vars, size_t return_count, | |
| 1441 | Stage1AirInst **input_list, Stage1AirInst **output_types, ZigVar **output_vars, size_t return_count, | |
| 1442 | 1442 | bool has_side_effects, ZigType *return_type) |
| 1443 | 1443 | { |
| 1444 | IrInstGenAsm *instruction = ir_build_inst_gen<IrInstGenAsm>(&ira->new_irb, scope, source_node); | |
| 1444 | Stage1AirInstAsm *instruction = ir_build_inst_gen<Stage1AirInstAsm>(&ira->new_irb, scope, source_node); | |
| 1445 | 1445 | instruction->base.value->type = return_type; |
| 1446 | 1446 | instruction->asm_template = asm_template; |
| 1447 | 1447 | instruction->token_list = token_list; |
| ... | ... | @@ -1454,20 +1454,20 @@ static IrInstGen *ir_build_asm_gen(IrAnalyze *ira, Scope *scope, AstNode *source |
| 1454 | 1454 | |
| 1455 | 1455 | assert(source_node->type == NodeTypeAsmExpr); |
| 1456 | 1456 | for (size_t i = 0; i < source_node->data.asm_expr.output_list.length; i += 1) { |
| 1457 | IrInstGen *output_type = output_types[i]; | |
| 1457 | Stage1AirInst *output_type = output_types[i]; | |
| 1458 | 1458 | if (output_type) ir_ref_inst_gen(output_type); |
| 1459 | 1459 | } |
| 1460 | 1460 | |
| 1461 | 1461 | for (size_t i = 0; i < source_node->data.asm_expr.input_list.length; i += 1) { |
| 1462 | IrInstGen *input_value = input_list[i]; | |
| 1462 | Stage1AirInst *input_value = input_list[i]; | |
| 1463 | 1463 | ir_ref_inst_gen(input_value); |
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | 1466 | return &instruction->base; |
| 1467 | 1467 | } |
| 1468 | 1468 | |
| 1469 | static IrInstGen *ir_build_test_non_null_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value) { | |
| 1470 | IrInstGenTestNonNull *inst = ir_build_inst_gen<IrInstGenTestNonNull>(&ira->new_irb, | |
| 1469 | static Stage1AirInst *ir_build_test_non_null_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value) { | |
| 1470 | Stage1AirInstTestNonNull *inst = ir_build_inst_gen<Stage1AirInstTestNonNull>(&ira->new_irb, | |
| 1471 | 1471 | scope, source_node); |
| 1472 | 1472 | inst->base.value->type = ira->codegen->builtin_types.entry_bool; |
| 1473 | 1473 | inst->value = value; |
| ... | ... | @@ -1477,10 +1477,10 @@ static IrInstGen *ir_build_test_non_null_gen(IrAnalyze *ira, Scope *scope, AstNo |
| 1477 | 1477 | return &inst->base; |
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | static IrInstGen *ir_build_optional_unwrap_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1481 | IrInstGen *base_ptr, bool safety_check_on, bool initializing, ZigType *result_type) | |
| 1480 | static Stage1AirInst *ir_build_optional_unwrap_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1481 | Stage1AirInst *base_ptr, bool safety_check_on, bool initializing, ZigType *result_type) | |
| 1482 | 1482 | { |
| 1483 | IrInstGenOptionalUnwrapPtr *inst = ir_build_inst_gen<IrInstGenOptionalUnwrapPtr>(&ira->new_irb, | |
| 1483 | Stage1AirInstOptionalUnwrapPtr *inst = ir_build_inst_gen<Stage1AirInstOptionalUnwrapPtr>(&ira->new_irb, | |
| 1484 | 1484 | scope, source_node); |
| 1485 | 1485 | inst->base.value->type = result_type; |
| 1486 | 1486 | inst->base_ptr = base_ptr; |
| ... | ... | @@ -1492,10 +1492,10 @@ static IrInstGen *ir_build_optional_unwrap_ptr_gen(IrAnalyze *ira, Scope *scope, |
| 1492 | 1492 | return &inst->base; |
| 1493 | 1493 | } |
| 1494 | 1494 | |
| 1495 | static IrInstGen *ir_build_optional_wrap(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_ty, | |
| 1496 | IrInstGen *operand, IrInstGen *result_loc) | |
| 1495 | static Stage1AirInst *ir_build_optional_wrap(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_ty, | |
| 1496 | Stage1AirInst *operand, Stage1AirInst *result_loc) | |
| 1497 | 1497 | { |
| 1498 | IrInstGenOptionalWrap *instruction = ir_build_inst_gen<IrInstGenOptionalWrap>( | |
| 1498 | Stage1AirInstOptionalWrap *instruction = ir_build_inst_gen<Stage1AirInstOptionalWrap>( | |
| 1499 | 1499 | &ira->new_irb, scope, source_node); |
| 1500 | 1500 | instruction->base.value->type = result_ty; |
| 1501 | 1501 | instruction->operand = operand; |
| ... | ... | @@ -1507,10 +1507,10 @@ static IrInstGen *ir_build_optional_wrap(IrAnalyze *ira, Scope *scope, AstNode * |
| 1507 | 1507 | return &instruction->base; |
| 1508 | 1508 | } |
| 1509 | 1509 | |
| 1510 | static IrInstGen *ir_build_err_wrap_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1511 | ZigType *result_type, IrInstGen *operand, IrInstGen *result_loc) | |
| 1510 | static Stage1AirInst *ir_build_err_wrap_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1511 | ZigType *result_type, Stage1AirInst *operand, Stage1AirInst *result_loc) | |
| 1512 | 1512 | { |
| 1513 | IrInstGenErrWrapPayload *instruction = ir_build_inst_gen<IrInstGenErrWrapPayload>( | |
| 1513 | Stage1AirInstErrWrapPayload *instruction = ir_build_inst_gen<Stage1AirInstErrWrapPayload>( | |
| 1514 | 1514 | &ira->new_irb, scope, source_node); |
| 1515 | 1515 | instruction->base.value->type = result_type; |
| 1516 | 1516 | instruction->operand = operand; |
| ... | ... | @@ -1522,10 +1522,10 @@ static IrInstGen *ir_build_err_wrap_payload(IrAnalyze *ira, Scope *scope, AstNod |
| 1522 | 1522 | return &instruction->base; |
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | static IrInstGen *ir_build_err_wrap_code(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1526 | ZigType *result_type, IrInstGen *operand, IrInstGen *result_loc) | |
| 1525 | static Stage1AirInst *ir_build_err_wrap_code(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1526 | ZigType *result_type, Stage1AirInst *operand, Stage1AirInst *result_loc) | |
| 1527 | 1527 | { |
| 1528 | IrInstGenErrWrapCode *instruction = ir_build_inst_gen<IrInstGenErrWrapCode>( | |
| 1528 | Stage1AirInstErrWrapCode *instruction = ir_build_inst_gen<Stage1AirInstErrWrapCode>( | |
| 1529 | 1529 | &ira->new_irb, scope, source_node); |
| 1530 | 1530 | instruction->base.value->type = result_type; |
| 1531 | 1531 | instruction->operand = operand; |
| ... | ... | @@ -1537,8 +1537,8 @@ static IrInstGen *ir_build_err_wrap_code(IrAnalyze *ira, Scope *scope, AstNode * |
| 1537 | 1537 | return &instruction->base; |
| 1538 | 1538 | } |
| 1539 | 1539 | |
| 1540 | static IrInstGen *ir_build_clz_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, IrInstGen *op) { | |
| 1541 | IrInstGenClz *instruction = ir_build_inst_gen<IrInstGenClz>(&ira->new_irb, | |
| 1540 | static Stage1AirInst *ir_build_clz_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, Stage1AirInst *op) { | |
| 1541 | Stage1AirInstClz *instruction = ir_build_inst_gen<Stage1AirInstClz>(&ira->new_irb, | |
| 1542 | 1542 | scope, source_node); |
| 1543 | 1543 | instruction->base.value->type = result_type; |
| 1544 | 1544 | instruction->op = op; |
| ... | ... | @@ -1548,8 +1548,8 @@ static IrInstGen *ir_build_clz_gen(IrAnalyze *ira, Scope *scope, AstNode *source |
| 1548 | 1548 | return &instruction->base; |
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | static IrInstGen *ir_build_ctz_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, IrInstGen *op) { | |
| 1552 | IrInstGenCtz *instruction = ir_build_inst_gen<IrInstGenCtz>(&ira->new_irb, | |
| 1551 | static Stage1AirInst *ir_build_ctz_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, Stage1AirInst *op) { | |
| 1552 | Stage1AirInstCtz *instruction = ir_build_inst_gen<Stage1AirInstCtz>(&ira->new_irb, | |
| 1553 | 1553 | scope, source_node); |
| 1554 | 1554 | instruction->base.value->type = result_type; |
| 1555 | 1555 | instruction->op = op; |
| ... | ... | @@ -1559,10 +1559,10 @@ static IrInstGen *ir_build_ctz_gen(IrAnalyze *ira, Scope *scope, AstNode *source |
| 1559 | 1559 | return &instruction->base; |
| 1560 | 1560 | } |
| 1561 | 1561 | |
| 1562 | static IrInstGen *ir_build_pop_count_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, | |
| 1563 | IrInstGen *op) | |
| 1562 | static Stage1AirInst *ir_build_pop_count_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, | |
| 1563 | Stage1AirInst *op) | |
| 1564 | 1564 | { |
| 1565 | IrInstGenPopCount *instruction = ir_build_inst_gen<IrInstGenPopCount>(&ira->new_irb, | |
| 1565 | Stage1AirInstPopCount *instruction = ir_build_inst_gen<Stage1AirInstPopCount>(&ira->new_irb, | |
| 1566 | 1566 | scope, source_node); |
| 1567 | 1567 | instruction->base.value->type = result_type; |
| 1568 | 1568 | instruction->op = op; |
| ... | ... | @@ -1572,10 +1572,10 @@ static IrInstGen *ir_build_pop_count_gen(IrAnalyze *ira, Scope *scope, AstNode * |
| 1572 | 1572 | return &instruction->base; |
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | static IrInstGen *ir_build_bswap_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *op_type, | |
| 1576 | IrInstGen *op) | |
| 1575 | static Stage1AirInst *ir_build_bswap_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *op_type, | |
| 1576 | Stage1AirInst *op) | |
| 1577 | 1577 | { |
| 1578 | IrInstGenBswap *instruction = ir_build_inst_gen<IrInstGenBswap>(&ira->new_irb, | |
| 1578 | Stage1AirInstBswap *instruction = ir_build_inst_gen<Stage1AirInstBswap>(&ira->new_irb, | |
| 1579 | 1579 | scope, source_node); |
| 1580 | 1580 | instruction->base.value->type = op_type; |
| 1581 | 1581 | instruction->op = op; |
| ... | ... | @@ -1585,10 +1585,10 @@ static IrInstGen *ir_build_bswap_gen(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 1585 | 1585 | return &instruction->base; |
| 1586 | 1586 | } |
| 1587 | 1587 | |
| 1588 | static IrInstGen *ir_build_bit_reverse_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *int_type, | |
| 1589 | IrInstGen *op) | |
| 1588 | static Stage1AirInst *ir_build_bit_reverse_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *int_type, | |
| 1589 | Stage1AirInst *op) | |
| 1590 | 1590 | { |
| 1591 | IrInstGenBitReverse *instruction = ir_build_inst_gen<IrInstGenBitReverse>(&ira->new_irb, | |
| 1591 | Stage1AirInstBitReverse *instruction = ir_build_inst_gen<Stage1AirInstBitReverse>(&ira->new_irb, | |
| 1592 | 1592 | scope, source_node); |
| 1593 | 1593 | instruction->base.value->type = int_type; |
| 1594 | 1594 | instruction->op = op; |
| ... | ... | @@ -1598,10 +1598,10 @@ static IrInstGen *ir_build_bit_reverse_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 1598 | 1598 | return &instruction->base; |
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | static IrInstGenSwitchBr *ir_build_switch_br_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1602 | IrInstGen *target_value, IrBasicBlockGen *else_block, size_t case_count, IrInstGenSwitchBrCase *cases) | |
| 1601 | static Stage1AirInstSwitchBr *ir_build_switch_br_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1602 | Stage1AirInst *target_value, Stage1AirBasicBlock *else_block, size_t case_count, Stage1AirInstSwitchBrCase *cases) | |
| 1603 | 1603 | { |
| 1604 | IrInstGenSwitchBr *instruction = ir_build_inst_noreturn<IrInstGenSwitchBr>(&ira->new_irb, | |
| 1604 | Stage1AirInstSwitchBr *instruction = ir_build_inst_noreturn<Stage1AirInstSwitchBr>(&ira->new_irb, | |
| 1605 | 1605 | scope, source_node); |
| 1606 | 1606 | instruction->target_value = target_value; |
| 1607 | 1607 | instruction->else_block = else_block; |
| ... | ... | @@ -1617,10 +1617,10 @@ static IrInstGenSwitchBr *ir_build_switch_br_gen(IrAnalyze *ira, Scope *scope, A |
| 1617 | 1617 | return instruction; |
| 1618 | 1618 | } |
| 1619 | 1619 | |
| 1620 | static IrInstGen *ir_build_union_tag(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value, | |
| 1620 | static Stage1AirInst *ir_build_union_tag(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value, | |
| 1621 | 1621 | ZigType *tag_type) |
| 1622 | 1622 | { |
| 1623 | IrInstGenUnionTag *instruction = ir_build_inst_gen<IrInstGenUnionTag>(&ira->new_irb, | |
| 1623 | Stage1AirInstUnionTag *instruction = ir_build_inst_gen<Stage1AirInstUnionTag>(&ira->new_irb, | |
| 1624 | 1624 | scope, source_node); |
| 1625 | 1625 | instruction->value = value; |
| 1626 | 1626 | instruction->base.value->type = tag_type; |
| ... | ... | @@ -1630,10 +1630,10 @@ static IrInstGen *ir_build_union_tag(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 1630 | 1630 | return &instruction->base; |
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | static IrInstGen *ir_build_ref_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, | |
| 1634 | IrInstGen *operand, IrInstGen *result_loc) | |
| 1633 | static Stage1AirInst *ir_build_ref_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, | |
| 1634 | Stage1AirInst *operand, Stage1AirInst *result_loc) | |
| 1635 | 1635 | { |
| 1636 | IrInstGenRef *instruction = ir_build_inst_gen<IrInstGenRef>(&ira->new_irb, | |
| 1636 | Stage1AirInstRef *instruction = ir_build_inst_gen<Stage1AirInstRef>(&ira->new_irb, | |
| 1637 | 1637 | scope, source_node); |
| 1638 | 1638 | instruction->base.value->type = result_type; |
| 1639 | 1639 | instruction->operand = operand; |
| ... | ... | @@ -1645,10 +1645,10 @@ static IrInstGen *ir_build_ref_gen(IrAnalyze *ira, Scope *scope, AstNode *source |
| 1645 | 1645 | return &instruction->base; |
| 1646 | 1646 | } |
| 1647 | 1647 | |
| 1648 | static IrInstGen *ir_build_err_name_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value, | |
| 1648 | static Stage1AirInst *ir_build_err_name_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value, | |
| 1649 | 1649 | ZigType *str_type) |
| 1650 | 1650 | { |
| 1651 | IrInstGenErrName *instruction = ir_build_inst_gen<IrInstGenErrName>(&ira->new_irb, | |
| 1651 | Stage1AirInstErrName *instruction = ir_build_inst_gen<Stage1AirInstErrName>(&ira->new_irb, | |
| 1652 | 1652 | scope, source_node); |
| 1653 | 1653 | instruction->base.value->type = str_type; |
| 1654 | 1654 | instruction->value = value; |
| ... | ... | @@ -1658,11 +1658,11 @@ static IrInstGen *ir_build_err_name_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 1658 | 1658 | return &instruction->base; |
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | static IrInstGen *ir_build_cmpxchg_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, | |
| 1662 | IrInstGen *ptr, IrInstGen *cmp_value, IrInstGen *new_value, | |
| 1663 | AtomicOrder success_order, AtomicOrder failure_order, bool is_weak, IrInstGen *result_loc) | |
| 1661 | static Stage1AirInst *ir_build_cmpxchg_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, | |
| 1662 | Stage1AirInst *ptr, Stage1AirInst *cmp_value, Stage1AirInst *new_value, | |
| 1663 | AtomicOrder success_order, AtomicOrder failure_order, bool is_weak, Stage1AirInst *result_loc) | |
| 1664 | 1664 | { |
| 1665 | IrInstGenCmpxchg *instruction = ir_build_inst_gen<IrInstGenCmpxchg>(&ira->new_irb, | |
| 1665 | Stage1AirInstCmpxchg *instruction = ir_build_inst_gen<Stage1AirInstCmpxchg>(&ira->new_irb, | |
| 1666 | 1666 | scope, source_node); |
| 1667 | 1667 | instruction->base.value->type = result_type; |
| 1668 | 1668 | instruction->ptr = ptr; |
| ... | ... | @@ -1681,16 +1681,16 @@ static IrInstGen *ir_build_cmpxchg_gen(IrAnalyze *ira, Scope *scope, AstNode *so |
| 1681 | 1681 | return &instruction->base; |
| 1682 | 1682 | } |
| 1683 | 1683 | |
| 1684 | static IrInstGen *ir_build_fence_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, AtomicOrder order) { | |
| 1685 | IrInstGenFence *instruction = ir_build_inst_void<IrInstGenFence>(&ira->new_irb, | |
| 1684 | static Stage1AirInst *ir_build_fence_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, AtomicOrder order) { | |
| 1685 | Stage1AirInstFence *instruction = ir_build_inst_void<Stage1AirInstFence>(&ira->new_irb, | |
| 1686 | 1686 | scope, source_node); |
| 1687 | 1687 | instruction->order = order; |
| 1688 | 1688 | |
| 1689 | 1689 | return &instruction->base; |
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | static IrInstGen *ir_build_reduce_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ReduceOp op, IrInstGen *value, ZigType *result_type) { | |
| 1693 | IrInstGenReduce *instruction = ir_build_inst_gen<IrInstGenReduce>(&ira->new_irb, | |
| 1692 | static Stage1AirInst *ir_build_reduce_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ReduceOp op, Stage1AirInst *value, ZigType *result_type) { | |
| 1693 | Stage1AirInstReduce *instruction = ir_build_inst_gen<Stage1AirInstReduce>(&ira->new_irb, | |
| 1694 | 1694 | scope, source_node); |
| 1695 | 1695 | instruction->base.value->type = result_type; |
| 1696 | 1696 | instruction->op = op; |
| ... | ... | @@ -1701,38 +1701,38 @@ static IrInstGen *ir_build_reduce_gen(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 1701 | 1701 | return &instruction->base; |
| 1702 | 1702 | } |
| 1703 | 1703 | |
| 1704 | static void ir_set_cursor_at_end_gen(IrBuilderGen *irb, IrBasicBlockGen *basic_block) { | |
| 1704 | static void ir_set_cursor_at_end_gen(IrBuilderGen *irb, Stage1AirBasicBlock *basic_block) { | |
| 1705 | 1705 | assert(basic_block); |
| 1706 | 1706 | irb->current_basic_block = basic_block; |
| 1707 | 1707 | } |
| 1708 | 1708 | |
| 1709 | static void ir_append_basic_block_gen(IrBuilderGen *irb, IrBasicBlockGen *bb) { | |
| 1709 | static void ir_append_basic_block_gen(IrBuilderGen *irb, Stage1AirBasicBlock *bb) { | |
| 1710 | 1710 | assert(!bb->already_appended); |
| 1711 | 1711 | bb->already_appended = true; |
| 1712 | 1712 | irb->exec->basic_block_list.append(bb); |
| 1713 | 1713 | } |
| 1714 | 1714 | |
| 1715 | static void ir_set_cursor_at_end_and_append_block_gen(IrBuilderGen *irb, IrBasicBlockGen *basic_block) { | |
| 1715 | static void ir_set_cursor_at_end_and_append_block_gen(IrBuilderGen *irb, Stage1AirBasicBlock *basic_block) { | |
| 1716 | 1716 | ir_append_basic_block_gen(irb, basic_block); |
| 1717 | 1717 | ir_set_cursor_at_end_gen(irb, basic_block); |
| 1718 | 1718 | } |
| 1719 | 1719 | |
| 1720 | static IrInstGen *ir_build_suspend_begin_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1721 | IrInstGenSuspendBegin *inst = ir_build_inst_void<IrInstGenSuspendBegin>(&ira->new_irb, | |
| 1720 | static Stage1AirInst *ir_build_suspend_begin_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1721 | Stage1AirInstSuspendBegin *inst = ir_build_inst_void<Stage1AirInstSuspendBegin>(&ira->new_irb, | |
| 1722 | 1722 | scope, source_node); |
| 1723 | 1723 | return &inst->base; |
| 1724 | 1724 | } |
| 1725 | 1725 | |
| 1726 | static IrInstGen *ir_build_save_err_ret_addr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1727 | IrInstGenSaveErrRetAddr *inst = ir_build_inst_void<IrInstGenSaveErrRetAddr>(&ira->new_irb, | |
| 1726 | static Stage1AirInst *ir_build_save_err_ret_addr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1727 | Stage1AirInstSaveErrRetAddr *inst = ir_build_inst_void<Stage1AirInstSaveErrRetAddr>(&ira->new_irb, | |
| 1728 | 1728 | scope, source_node); |
| 1729 | 1729 | return &inst->base; |
| 1730 | 1730 | } |
| 1731 | 1731 | |
| 1732 | static IrInstGen *ir_build_truncate_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *dest_type, | |
| 1733 | IrInstGen *target) | |
| 1732 | static Stage1AirInst *ir_build_truncate_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *dest_type, | |
| 1733 | Stage1AirInst *target) | |
| 1734 | 1734 | { |
| 1735 | IrInstGenTruncate *instruction = ir_build_inst_gen<IrInstGenTruncate>(&ira->new_irb, | |
| 1735 | Stage1AirInstTruncate *instruction = ir_build_inst_gen<Stage1AirInstTruncate>(&ira->new_irb, | |
| 1736 | 1736 | scope, source_node); |
| 1737 | 1737 | instruction->base.value->type = dest_type; |
| 1738 | 1738 | instruction->target = target; |
| ... | ... | @@ -1742,10 +1742,10 @@ static IrInstGen *ir_build_truncate_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 1742 | 1742 | return &instruction->base; |
| 1743 | 1743 | } |
| 1744 | 1744 | |
| 1745 | static IrInstGen *ir_build_shuffle_vector_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1746 | ZigType *result_type, IrInstGen *a, IrInstGen *b, IrInstGen *mask) | |
| 1745 | static Stage1AirInst *ir_build_shuffle_vector_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1746 | ZigType *result_type, Stage1AirInst *a, Stage1AirInst *b, Stage1AirInst *mask) | |
| 1747 | 1747 | { |
| 1748 | IrInstGenShuffleVector *inst = ir_build_inst_gen<IrInstGenShuffleVector>(&ira->new_irb, scope, source_node); | |
| 1748 | Stage1AirInstShuffleVector *inst = ir_build_inst_gen<Stage1AirInstShuffleVector>(&ira->new_irb, scope, source_node); | |
| 1749 | 1749 | inst->base.value->type = result_type; |
| 1750 | 1750 | inst->a = a; |
| 1751 | 1751 | inst->b = b; |
| ... | ... | @@ -1758,10 +1758,10 @@ static IrInstGen *ir_build_shuffle_vector_gen(IrAnalyze *ira, Scope *scope, AstN |
| 1758 | 1758 | return &inst->base; |
| 1759 | 1759 | } |
| 1760 | 1760 | |
| 1761 | static IrInstGen *ir_build_splat_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, | |
| 1762 | IrInstGen *scalar) | |
| 1761 | static Stage1AirInst *ir_build_splat_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *result_type, | |
| 1762 | Stage1AirInst *scalar) | |
| 1763 | 1763 | { |
| 1764 | IrInstGenSplat *instruction = ir_build_inst_gen<IrInstGenSplat>( | |
| 1764 | Stage1AirInstSplat *instruction = ir_build_inst_gen<Stage1AirInstSplat>( | |
| 1765 | 1765 | &ira->new_irb, scope, source_node); |
| 1766 | 1766 | instruction->base.value->type = result_type; |
| 1767 | 1767 | instruction->scalar = scalar; |
| ... | ... | @@ -1771,8 +1771,8 @@ static IrInstGen *ir_build_splat_gen(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 1771 | 1771 | return &instruction->base; |
| 1772 | 1772 | } |
| 1773 | 1773 | |
| 1774 | static IrInstGen *ir_build_bool_not_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value) { | |
| 1775 | IrInstGenBoolNot *instruction = ir_build_inst_gen<IrInstGenBoolNot>(&ira->new_irb, | |
| 1774 | static Stage1AirInst *ir_build_bool_not_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value) { | |
| 1775 | Stage1AirInstBoolNot *instruction = ir_build_inst_gen<Stage1AirInstBoolNot>(&ira->new_irb, | |
| 1776 | 1776 | scope, source_node); |
| 1777 | 1777 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; |
| 1778 | 1778 | instruction->value = value; |
| ... | ... | @@ -1782,10 +1782,10 @@ static IrInstGen *ir_build_bool_not_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 1782 | 1782 | return &instruction->base; |
| 1783 | 1783 | } |
| 1784 | 1784 | |
| 1785 | static IrInstGen *ir_build_memset_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1786 | IrInstGen *dest_ptr, IrInstGen *byte, IrInstGen *count) | |
| 1785 | static Stage1AirInst *ir_build_memset_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1786 | Stage1AirInst *dest_ptr, Stage1AirInst *byte, Stage1AirInst *count) | |
| 1787 | 1787 | { |
| 1788 | IrInstGenMemset *instruction = ir_build_inst_void<IrInstGenMemset>(&ira->new_irb, | |
| 1788 | Stage1AirInstMemset *instruction = ir_build_inst_void<Stage1AirInstMemset>(&ira->new_irb, | |
| 1789 | 1789 | scope, source_node); |
| 1790 | 1790 | instruction->dest_ptr = dest_ptr; |
| 1791 | 1791 | instruction->byte = byte; |
| ... | ... | @@ -1798,10 +1798,10 @@ static IrInstGen *ir_build_memset_gen(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 1798 | 1798 | return &instruction->base; |
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | static IrInstGen *ir_build_memcpy_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1802 | IrInstGen *dest_ptr, IrInstGen *src_ptr, IrInstGen *count) | |
| 1801 | static Stage1AirInst *ir_build_memcpy_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1802 | Stage1AirInst *dest_ptr, Stage1AirInst *src_ptr, Stage1AirInst *count) | |
| 1803 | 1803 | { |
| 1804 | IrInstGenMemcpy *instruction = ir_build_inst_void<IrInstGenMemcpy>(&ira->new_irb, | |
| 1804 | Stage1AirInstMemcpy *instruction = ir_build_inst_void<Stage1AirInstMemcpy>(&ira->new_irb, | |
| 1805 | 1805 | scope, source_node); |
| 1806 | 1806 | instruction->dest_ptr = dest_ptr; |
| 1807 | 1807 | instruction->src_ptr = src_ptr; |
| ... | ... | @@ -1814,11 +1814,11 @@ static IrInstGen *ir_build_memcpy_gen(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 1814 | 1814 | return &instruction->base; |
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | static IrInstGen *ir_build_slice_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *slice_type, | |
| 1818 | IrInstGen *ptr, IrInstGen *start, IrInstGen *end, bool safety_check_on, IrInstGen *result_loc, | |
| 1817 | static Stage1AirInst *ir_build_slice_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *slice_type, | |
| 1818 | Stage1AirInst *ptr, Stage1AirInst *start, Stage1AirInst *end, bool safety_check_on, Stage1AirInst *result_loc, | |
| 1819 | 1819 | ZigValue *sentinel) |
| 1820 | 1820 | { |
| 1821 | IrInstGenSlice *instruction = ir_build_inst_gen<IrInstGenSlice>( | |
| 1821 | Stage1AirInstSlice *instruction = ir_build_inst_gen<Stage1AirInstSlice>( | |
| 1822 | 1822 | &ira->new_irb, scope, source_node); |
| 1823 | 1823 | instruction->base.value->type = slice_type; |
| 1824 | 1824 | instruction->ptr = ptr; |
| ... | ... | @@ -1836,33 +1836,33 @@ static IrInstGen *ir_build_slice_gen(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 1836 | 1836 | return &instruction->base; |
| 1837 | 1837 | } |
| 1838 | 1838 | |
| 1839 | static IrInstGen *ir_build_breakpoint_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1840 | IrInstGenBreakpoint *instruction = ir_build_inst_void<IrInstGenBreakpoint>(&ira->new_irb, | |
| 1839 | static Stage1AirInst *ir_build_breakpoint_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1840 | Stage1AirInstBreakpoint *instruction = ir_build_inst_void<Stage1AirInstBreakpoint>(&ira->new_irb, | |
| 1841 | 1841 | scope, source_node); |
| 1842 | 1842 | return &instruction->base; |
| 1843 | 1843 | } |
| 1844 | 1844 | |
| 1845 | static IrInstGen *ir_build_return_address_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1846 | IrInstGenReturnAddress *inst = ir_build_inst_gen<IrInstGenReturnAddress>(&ira->new_irb, scope, source_node); | |
| 1845 | static Stage1AirInst *ir_build_return_address_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1846 | Stage1AirInstReturnAddress *inst = ir_build_inst_gen<Stage1AirInstReturnAddress>(&ira->new_irb, scope, source_node); | |
| 1847 | 1847 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| 1848 | 1848 | return &inst->base; |
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | static IrInstGen *ir_build_frame_address_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1852 | IrInstGenFrameAddress *inst = ir_build_inst_gen<IrInstGenFrameAddress>(&ira->new_irb, scope, source_node); | |
| 1851 | static Stage1AirInst *ir_build_frame_address_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 1852 | Stage1AirInstFrameAddress *inst = ir_build_inst_gen<Stage1AirInstFrameAddress>(&ira->new_irb, scope, source_node); | |
| 1853 | 1853 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| 1854 | 1854 | return &inst->base; |
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | static IrInstGen *ir_build_handle_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty) { | |
| 1858 | IrInstGenFrameHandle *inst = ir_build_inst_gen<IrInstGenFrameHandle>(&ira->new_irb, scope, source_node); | |
| 1857 | static Stage1AirInst *ir_build_handle_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty) { | |
| 1858 | Stage1AirInstFrameHandle *inst = ir_build_inst_gen<Stage1AirInstFrameHandle>(&ira->new_irb, scope, source_node); | |
| 1859 | 1859 | inst->base.value->type = ty; |
| 1860 | 1860 | return &inst->base; |
| 1861 | 1861 | } |
| 1862 | 1862 | |
| 1863 | static IrInstGen *ir_build_frame_size_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *fn) | |
| 1863 | static Stage1AirInst *ir_build_frame_size_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *fn) | |
| 1864 | 1864 | { |
| 1865 | IrInstGenFrameSize *inst = ir_build_inst_gen<IrInstGenFrameSize>(&ira->new_irb, scope, source_node); | |
| 1865 | Stage1AirInstFrameSize *inst = ir_build_inst_gen<Stage1AirInstFrameSize>(&ira->new_irb, scope, source_node); | |
| 1866 | 1866 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| 1867 | 1867 | inst->fn = fn; |
| 1868 | 1868 | |
| ... | ... | @@ -1871,11 +1871,11 @@ static IrInstGen *ir_build_frame_size_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 1871 | 1871 | return &inst->base; |
| 1872 | 1872 | } |
| 1873 | 1873 | |
| 1874 | static IrInstGen *ir_build_overflow_op_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1875 | IrOverflowOp op, IrInstGen *op1, IrInstGen *op2, IrInstGen *result_ptr, | |
| 1874 | static Stage1AirInst *ir_build_overflow_op_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1875 | IrOverflowOp op, Stage1AirInst *op1, Stage1AirInst *op2, Stage1AirInst *result_ptr, | |
| 1876 | 1876 | ZigType *result_ptr_type) |
| 1877 | 1877 | { |
| 1878 | IrInstGenOverflowOp *instruction = ir_build_inst_gen<IrInstGenOverflowOp>(&ira->new_irb, | |
| 1878 | Stage1AirInstOverflowOp *instruction = ir_build_inst_gen<Stage1AirInstOverflowOp>(&ira->new_irb, | |
| 1879 | 1879 | scope, source_node); |
| 1880 | 1880 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; |
| 1881 | 1881 | instruction->op = op; |
| ... | ... | @@ -1891,10 +1891,10 @@ static IrInstGen *ir_build_overflow_op_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 1891 | 1891 | return &instruction->base; |
| 1892 | 1892 | } |
| 1893 | 1893 | |
| 1894 | static IrInstGen *ir_build_float_op_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *operand, | |
| 1894 | static Stage1AirInst *ir_build_float_op_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *operand, | |
| 1895 | 1895 | BuiltinFnId fn_id, ZigType *operand_type) |
| 1896 | 1896 | { |
| 1897 | IrInstGenFloatOp *instruction = ir_build_inst_gen<IrInstGenFloatOp>(&ira->new_irb, | |
| 1897 | Stage1AirInstFloatOp *instruction = ir_build_inst_gen<Stage1AirInstFloatOp>(&ira->new_irb, | |
| 1898 | 1898 | scope, source_node); |
| 1899 | 1899 | instruction->base.value->type = operand_type; |
| 1900 | 1900 | instruction->operand = operand; |
| ... | ... | @@ -1905,10 +1905,10 @@ static IrInstGen *ir_build_float_op_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 1905 | 1905 | return &instruction->base; |
| 1906 | 1906 | } |
| 1907 | 1907 | |
| 1908 | static IrInstGen *ir_build_mul_add_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *op1, IrInstGen *op2, | |
| 1909 | IrInstGen *op3, ZigType *expr_type) | |
| 1908 | static Stage1AirInst *ir_build_mul_add_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *op1, Stage1AirInst *op2, | |
| 1909 | Stage1AirInst *op3, ZigType *expr_type) | |
| 1910 | 1910 | { |
| 1911 | IrInstGenMulAdd *instruction = ir_build_inst_gen<IrInstGenMulAdd>(&ira->new_irb, | |
| 1911 | Stage1AirInstMulAdd *instruction = ir_build_inst_gen<Stage1AirInstMulAdd>(&ira->new_irb, | |
| 1912 | 1912 | scope, source_node); |
| 1913 | 1913 | instruction->base.value->type = expr_type; |
| 1914 | 1914 | instruction->op1 = op1; |
| ... | ... | @@ -1922,8 +1922,8 @@ static IrInstGen *ir_build_mul_add_gen(IrAnalyze *ira, Scope *scope, AstNode *so |
| 1922 | 1922 | return &instruction->base; |
| 1923 | 1923 | } |
| 1924 | 1924 | |
| 1925 | static IrInstGen *ir_build_test_err_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *err_union) { | |
| 1926 | IrInstGenTestErr *instruction = ir_build_inst_gen<IrInstGenTestErr>( | |
| 1925 | static Stage1AirInst *ir_build_test_err_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *err_union) { | |
| 1926 | Stage1AirInstTestErr *instruction = ir_build_inst_gen<Stage1AirInstTestErr>( | |
| 1927 | 1927 | &ira->new_irb, scope, source_node); |
| 1928 | 1928 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; |
| 1929 | 1929 | instruction->err_union = err_union; |
| ... | ... | @@ -1933,10 +1933,10 @@ static IrInstGen *ir_build_test_err_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 1933 | 1933 | return &instruction->base; |
| 1934 | 1934 | } |
| 1935 | 1935 | |
| 1936 | static IrInstGen *ir_build_unwrap_err_code_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1937 | IrInstGen *err_union_ptr, ZigType *result_type) | |
| 1936 | static Stage1AirInst *ir_build_unwrap_err_code_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1937 | Stage1AirInst *err_union_ptr, ZigType *result_type) | |
| 1938 | 1938 | { |
| 1939 | IrInstGenUnwrapErrCode *inst = ir_build_inst_gen<IrInstGenUnwrapErrCode>(&ira->new_irb, scope, source_node); | |
| 1939 | Stage1AirInstUnwrapErrCode *inst = ir_build_inst_gen<Stage1AirInstUnwrapErrCode>(&ira->new_irb, scope, source_node); | |
| 1940 | 1940 | inst->base.value->type = result_type; |
| 1941 | 1941 | inst->err_union_ptr = err_union_ptr; |
| 1942 | 1942 | |
| ... | ... | @@ -1945,10 +1945,10 @@ static IrInstGen *ir_build_unwrap_err_code_gen(IrAnalyze *ira, Scope *scope, Ast |
| 1945 | 1945 | return &inst->base; |
| 1946 | 1946 | } |
| 1947 | 1947 | |
| 1948 | static IrInstGen *ir_build_unwrap_err_payload_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1949 | IrInstGen *value, bool safety_check_on, bool initializing, ZigType *result_type) | |
| 1948 | static Stage1AirInst *ir_build_unwrap_err_payload_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1949 | Stage1AirInst *value, bool safety_check_on, bool initializing, ZigType *result_type) | |
| 1950 | 1950 | { |
| 1951 | IrInstGenUnwrapErrPayload *inst = ir_build_inst_gen<IrInstGenUnwrapErrPayload>(&ira->new_irb, scope, source_node); | |
| 1951 | Stage1AirInstUnwrapErrPayload *inst = ir_build_inst_gen<Stage1AirInstUnwrapErrPayload>(&ira->new_irb, scope, source_node); | |
| 1952 | 1952 | inst->base.value->type = result_type; |
| 1953 | 1953 | inst->value = value; |
| 1954 | 1954 | inst->safety_check_on = safety_check_on; |
| ... | ... | @@ -1959,10 +1959,10 @@ static IrInstGen *ir_build_unwrap_err_payload_gen(IrAnalyze *ira, Scope *scope, |
| 1959 | 1959 | return &inst->base; |
| 1960 | 1960 | } |
| 1961 | 1961 | |
| 1962 | static IrInstGen *ir_build_ptr_cast_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1963 | ZigType *ptr_type, IrInstGen *ptr, bool safety_check_on) | |
| 1962 | static Stage1AirInst *ir_build_ptr_cast_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1963 | ZigType *ptr_type, Stage1AirInst *ptr, bool safety_check_on) | |
| 1964 | 1964 | { |
| 1965 | IrInstGenPtrCast *instruction = ir_build_inst_gen<IrInstGenPtrCast>( | |
| 1965 | Stage1AirInstPtrCast *instruction = ir_build_inst_gen<Stage1AirInstPtrCast>( | |
| 1966 | 1966 | &ira->new_irb, scope, source_node); |
| 1967 | 1967 | instruction->base.value->type = ptr_type; |
| 1968 | 1968 | instruction->ptr = ptr; |
| ... | ... | @@ -1973,10 +1973,10 @@ static IrInstGen *ir_build_ptr_cast_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 1973 | 1973 | return &instruction->base; |
| 1974 | 1974 | } |
| 1975 | 1975 | |
| 1976 | static IrInstGen *ir_build_bit_cast_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1977 | IrInstGen *operand, ZigType *ty) | |
| 1976 | static Stage1AirInst *ir_build_bit_cast_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 1977 | Stage1AirInst *operand, ZigType *ty) | |
| 1978 | 1978 | { |
| 1979 | IrInstGenBitCast *instruction = ir_build_inst_gen<IrInstGenBitCast>( | |
| 1979 | Stage1AirInstBitCast *instruction = ir_build_inst_gen<Stage1AirInstBitCast>( | |
| 1980 | 1980 | &ira->new_irb, scope, source_node); |
| 1981 | 1981 | instruction->base.value->type = ty; |
| 1982 | 1982 | instruction->operand = operand; |
| ... | ... | @@ -1986,10 +1986,10 @@ static IrInstGen *ir_build_bit_cast_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 1986 | 1986 | return &instruction->base; |
| 1987 | 1987 | } |
| 1988 | 1988 | |
| 1989 | static IrInstGen *ir_build_widen_or_shorten(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, | |
| 1989 | static Stage1AirInst *ir_build_widen_or_shorten(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target, | |
| 1990 | 1990 | ZigType *result_type) |
| 1991 | 1991 | { |
| 1992 | IrInstGenWidenOrShorten *inst = ir_build_inst_gen<IrInstGenWidenOrShorten>(&ira->new_irb, scope, source_node); | |
| 1992 | Stage1AirInstWidenOrShorten *inst = ir_build_inst_gen<Stage1AirInstWidenOrShorten>(&ira->new_irb, scope, source_node); | |
| 1993 | 1993 | inst->base.value->type = result_type; |
| 1994 | 1994 | inst->target = target; |
| 1995 | 1995 | |
| ... | ... | @@ -1998,10 +1998,10 @@ static IrInstGen *ir_build_widen_or_shorten(IrAnalyze *ira, Scope *scope, AstNod |
| 1998 | 1998 | return &inst->base; |
| 1999 | 1999 | } |
| 2000 | 2000 | |
| 2001 | static IrInstGen *ir_build_int_to_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2002 | IrInstGen *target, ZigType *ptr_type) | |
| 2001 | static Stage1AirInst *ir_build_int_to_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2002 | Stage1AirInst *target, ZigType *ptr_type) | |
| 2003 | 2003 | { |
| 2004 | IrInstGenIntToPtr *instruction = ir_build_inst_gen<IrInstGenIntToPtr>(&ira->new_irb, scope, source_node); | |
| 2004 | Stage1AirInstIntToPtr *instruction = ir_build_inst_gen<Stage1AirInstIntToPtr>(&ira->new_irb, scope, source_node); | |
| 2005 | 2005 | instruction->base.value->type = ptr_type; |
| 2006 | 2006 | instruction->target = target; |
| 2007 | 2007 | |
| ... | ... | @@ -2010,8 +2010,8 @@ static IrInstGen *ir_build_int_to_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 2010 | 2010 | return &instruction->base; |
| 2011 | 2011 | } |
| 2012 | 2012 | |
| 2013 | static IrInstGen *ir_build_ptr_to_int_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target) { | |
| 2014 | IrInstGenPtrToInt *inst = ir_build_inst_gen<IrInstGenPtrToInt>(&ira->new_irb, scope, source_node); | |
| 2013 | static Stage1AirInst *ir_build_ptr_to_int_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target) { | |
| 2014 | Stage1AirInstPtrToInt *inst = ir_build_inst_gen<Stage1AirInstPtrToInt>(&ira->new_irb, scope, source_node); | |
| 2015 | 2015 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| 2016 | 2016 | inst->target = target; |
| 2017 | 2017 | |
| ... | ... | @@ -2020,10 +2020,10 @@ static IrInstGen *ir_build_ptr_to_int_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 2020 | 2020 | return &inst->base; |
| 2021 | 2021 | } |
| 2022 | 2022 | |
| 2023 | static IrInstGen *ir_build_int_to_enum_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2024 | ZigType *dest_type, IrInstGen *target) | |
| 2023 | static Stage1AirInst *ir_build_int_to_enum_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2024 | ZigType *dest_type, Stage1AirInst *target) | |
| 2025 | 2025 | { |
| 2026 | IrInstGenIntToEnum *instruction = ir_build_inst_gen<IrInstGenIntToEnum>(&ira->new_irb, scope, source_node); | |
| 2026 | Stage1AirInstIntToEnum *instruction = ir_build_inst_gen<Stage1AirInstIntToEnum>(&ira->new_irb, scope, source_node); | |
| 2027 | 2027 | instruction->base.value->type = dest_type; |
| 2028 | 2028 | instruction->target = target; |
| 2029 | 2029 | |
| ... | ... | @@ -2032,10 +2032,10 @@ static IrInstGen *ir_build_int_to_enum_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 2032 | 2032 | return &instruction->base; |
| 2033 | 2033 | } |
| 2034 | 2034 | |
| 2035 | static IrInstGen *ir_build_int_to_err_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, | |
| 2035 | static Stage1AirInst *ir_build_int_to_err_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target, | |
| 2036 | 2036 | ZigType *wanted_type) |
| 2037 | 2037 | { |
| 2038 | IrInstGenIntToErr *instruction = ir_build_inst_gen<IrInstGenIntToErr>(&ira->new_irb, scope, source_node); | |
| 2038 | Stage1AirInstIntToErr *instruction = ir_build_inst_gen<Stage1AirInstIntToErr>(&ira->new_irb, scope, source_node); | |
| 2039 | 2039 | instruction->base.value->type = wanted_type; |
| 2040 | 2040 | instruction->target = target; |
| 2041 | 2041 | |
| ... | ... | @@ -2044,10 +2044,10 @@ static IrInstGen *ir_build_int_to_err_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 2044 | 2044 | return &instruction->base; |
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | static IrInstGen *ir_build_err_to_int_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, | |
| 2047 | static Stage1AirInst *ir_build_err_to_int_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target, | |
| 2048 | 2048 | ZigType *wanted_type) |
| 2049 | 2049 | { |
| 2050 | IrInstGenErrToInt *instruction = ir_build_inst_gen<IrInstGenErrToInt>(&ira->new_irb, scope, source_node); | |
| 2050 | Stage1AirInstErrToInt *instruction = ir_build_inst_gen<Stage1AirInstErrToInt>(&ira->new_irb, scope, source_node); | |
| 2051 | 2051 | instruction->base.value->type = wanted_type; |
| 2052 | 2052 | instruction->target = target; |
| 2053 | 2053 | |
| ... | ... | @@ -2056,8 +2056,8 @@ static IrInstGen *ir_build_err_to_int_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 2056 | 2056 | return &instruction->base; |
| 2057 | 2057 | } |
| 2058 | 2058 | |
| 2059 | static IrInstGen *ir_build_panic_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *msg) { | |
| 2060 | IrInstGenPanic *instruction = ir_build_inst_noreturn<IrInstGenPanic>(&ira->new_irb, | |
| 2059 | static Stage1AirInst *ir_build_panic_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *msg) { | |
| 2060 | Stage1AirInstPanic *instruction = ir_build_inst_noreturn<Stage1AirInstPanic>(&ira->new_irb, | |
| 2061 | 2061 | scope, source_node); |
| 2062 | 2062 | instruction->msg = msg; |
| 2063 | 2063 | |
| ... | ... | @@ -2066,10 +2066,10 @@ static IrInstGen *ir_build_panic_gen(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 2066 | 2066 | return &instruction->base; |
| 2067 | 2067 | } |
| 2068 | 2068 | |
| 2069 | static IrInstGen *ir_build_tag_name_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, | |
| 2069 | static Stage1AirInst *ir_build_tag_name_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target, | |
| 2070 | 2070 | ZigType *result_type) |
| 2071 | 2071 | { |
| 2072 | IrInstGenTagName *instruction = ir_build_inst_gen<IrInstGenTagName>(&ira->new_irb, | |
| 2072 | Stage1AirInstTagName *instruction = ir_build_inst_gen<Stage1AirInstTagName>(&ira->new_irb, | |
| 2073 | 2073 | scope, source_node); |
| 2074 | 2074 | instruction->base.value->type = result_type; |
| 2075 | 2075 | instruction->target = target; |
| ... | ... | @@ -2079,10 +2079,10 @@ static IrInstGen *ir_build_tag_name_gen(IrAnalyze *ira, Scope *scope, AstNode *s |
| 2079 | 2079 | return &instruction->base; |
| 2080 | 2080 | } |
| 2081 | 2081 | |
| 2082 | static IrInstGen *ir_build_field_parent_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2083 | IrInstGen *field_ptr, TypeStructField *field, ZigType *result_type) | |
| 2082 | static Stage1AirInst *ir_build_field_parent_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2083 | Stage1AirInst *field_ptr, TypeStructField *field, ZigType *result_type) | |
| 2084 | 2084 | { |
| 2085 | IrInstGenFieldParentPtr *inst = ir_build_inst_gen<IrInstGenFieldParentPtr>(&ira->new_irb, | |
| 2085 | Stage1AirInstFieldParentPtr *inst = ir_build_inst_gen<Stage1AirInstFieldParentPtr>(&ira->new_irb, | |
| 2086 | 2086 | scope, source_node); |
| 2087 | 2087 | inst->base.value->type = result_type; |
| 2088 | 2088 | inst->field_ptr = field_ptr; |
| ... | ... | @@ -2093,10 +2093,10 @@ static IrInstGen *ir_build_field_parent_ptr_gen(IrAnalyze *ira, Scope *scope, As |
| 2093 | 2093 | return &inst->base; |
| 2094 | 2094 | } |
| 2095 | 2095 | |
| 2096 | static IrInstGen *ir_build_align_cast_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, | |
| 2096 | static Stage1AirInst *ir_build_align_cast_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target, | |
| 2097 | 2097 | ZigType *result_type) |
| 2098 | 2098 | { |
| 2099 | IrInstGenAlignCast *instruction = ir_build_inst_gen<IrInstGenAlignCast>(&ira->new_irb, scope, source_node); | |
| 2099 | Stage1AirInstAlignCast *instruction = ir_build_inst_gen<Stage1AirInstAlignCast>(&ira->new_irb, scope, source_node); | |
| 2100 | 2100 | instruction->base.value->type = result_type; |
| 2101 | 2101 | instruction->target = target; |
| 2102 | 2102 | |
| ... | ... | @@ -2105,20 +2105,20 @@ static IrInstGen *ir_build_align_cast_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 2105 | 2105 | return &instruction->base; |
| 2106 | 2106 | } |
| 2107 | 2107 | |
| 2108 | static IrInstGen *ir_build_error_return_trace_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2108 | static Stage1AirInst *ir_build_error_return_trace_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2109 | 2109 | IrInstErrorReturnTraceOptional optional, ZigType *result_type) |
| 2110 | 2110 | { |
| 2111 | IrInstGenErrorReturnTrace *inst = ir_build_inst_gen<IrInstGenErrorReturnTrace>(&ira->new_irb, scope, source_node); | |
| 2111 | Stage1AirInstErrorReturnTrace *inst = ir_build_inst_gen<Stage1AirInstErrorReturnTrace>(&ira->new_irb, scope, source_node); | |
| 2112 | 2112 | inst->base.value->type = result_type; |
| 2113 | 2113 | inst->optional = optional; |
| 2114 | 2114 | |
| 2115 | 2115 | return &inst->base; |
| 2116 | 2116 | } |
| 2117 | 2117 | |
| 2118 | static IrInstGen *ir_build_atomic_rmw_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2119 | IrInstGen *ptr, IrInstGen *operand, AtomicRmwOp op, AtomicOrder ordering, ZigType *operand_type) | |
| 2118 | static Stage1AirInst *ir_build_atomic_rmw_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2119 | Stage1AirInst *ptr, Stage1AirInst *operand, AtomicRmwOp op, AtomicOrder ordering, ZigType *operand_type) | |
| 2120 | 2120 | { |
| 2121 | IrInstGenAtomicRmw *instruction = ir_build_inst_gen<IrInstGenAtomicRmw>(&ira->new_irb, scope, source_node); | |
| 2121 | Stage1AirInstAtomicRmw *instruction = ir_build_inst_gen<Stage1AirInstAtomicRmw>(&ira->new_irb, scope, source_node); | |
| 2122 | 2122 | instruction->base.value->type = operand_type; |
| 2123 | 2123 | instruction->ptr = ptr; |
| 2124 | 2124 | instruction->op = op; |
| ... | ... | @@ -2131,10 +2131,10 @@ static IrInstGen *ir_build_atomic_rmw_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 2131 | 2131 | return &instruction->base; |
| 2132 | 2132 | } |
| 2133 | 2133 | |
| 2134 | static IrInstGen *ir_build_atomic_load_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2135 | IrInstGen *ptr, AtomicOrder ordering, ZigType *operand_type) | |
| 2134 | static Stage1AirInst *ir_build_atomic_load_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2135 | Stage1AirInst *ptr, AtomicOrder ordering, ZigType *operand_type) | |
| 2136 | 2136 | { |
| 2137 | IrInstGenAtomicLoad *instruction = ir_build_inst_gen<IrInstGenAtomicLoad>(&ira->new_irb, | |
| 2137 | Stage1AirInstAtomicLoad *instruction = ir_build_inst_gen<Stage1AirInstAtomicLoad>(&ira->new_irb, | |
| 2138 | 2138 | scope, source_node); |
| 2139 | 2139 | instruction->base.value->type = operand_type; |
| 2140 | 2140 | instruction->ptr = ptr; |
| ... | ... | @@ -2145,10 +2145,10 @@ static IrInstGen *ir_build_atomic_load_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 2145 | 2145 | return &instruction->base; |
| 2146 | 2146 | } |
| 2147 | 2147 | |
| 2148 | static IrInstGen *ir_build_atomic_store_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2149 | IrInstGen *ptr, IrInstGen *value, AtomicOrder ordering) | |
| 2148 | static Stage1AirInst *ir_build_atomic_store_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2149 | Stage1AirInst *ptr, Stage1AirInst *value, AtomicOrder ordering) | |
| 2150 | 2150 | { |
| 2151 | IrInstGenAtomicStore *instruction = ir_build_inst_void<IrInstGenAtomicStore>(&ira->new_irb, | |
| 2151 | Stage1AirInstAtomicStore *instruction = ir_build_inst_void<Stage1AirInstAtomicStore>(&ira->new_irb, | |
| 2152 | 2152 | scope, source_node); |
| 2153 | 2153 | instruction->ptr = ptr; |
| 2154 | 2154 | instruction->value = value; |
| ... | ... | @@ -2161,10 +2161,10 @@ static IrInstGen *ir_build_atomic_store_gen(IrAnalyze *ira, Scope *scope, AstNod |
| 2161 | 2161 | } |
| 2162 | 2162 | |
| 2163 | 2163 | |
| 2164 | static IrInstGen *ir_build_vector_to_array(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2165 | ZigType *result_type, IrInstGen *vector, IrInstGen *result_loc) | |
| 2164 | static Stage1AirInst *ir_build_vector_to_array(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2165 | ZigType *result_type, Stage1AirInst *vector, Stage1AirInst *result_loc) | |
| 2166 | 2166 | { |
| 2167 | IrInstGenVectorToArray *instruction = ir_build_inst_gen<IrInstGenVectorToArray>(&ira->new_irb, | |
| 2167 | Stage1AirInstVectorToArray *instruction = ir_build_inst_gen<Stage1AirInstVectorToArray>(&ira->new_irb, | |
| 2168 | 2168 | scope, source_node); |
| 2169 | 2169 | instruction->base.value->type = result_type; |
| 2170 | 2170 | instruction->vector = vector; |
| ... | ... | @@ -2176,10 +2176,10 @@ static IrInstGen *ir_build_vector_to_array(IrAnalyze *ira, Scope *scope, AstNode |
| 2176 | 2176 | return &instruction->base; |
| 2177 | 2177 | } |
| 2178 | 2178 | |
| 2179 | static IrInstGen *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2180 | ZigType *result_type, IrInstGen *operand, IrInstGen *result_loc) | |
| 2179 | static Stage1AirInst *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2180 | ZigType *result_type, Stage1AirInst *operand, Stage1AirInst *result_loc) | |
| 2181 | 2181 | { |
| 2182 | IrInstGenPtrOfArrayToSlice *instruction = ir_build_inst_gen<IrInstGenPtrOfArrayToSlice>(&ira->new_irb, | |
| 2182 | Stage1AirInstPtrOfArrayToSlice *instruction = ir_build_inst_gen<Stage1AirInstPtrOfArrayToSlice>(&ira->new_irb, | |
| 2183 | 2183 | scope, source_node); |
| 2184 | 2184 | instruction->base.value->type = result_type; |
| 2185 | 2185 | instruction->operand = operand; |
| ... | ... | @@ -2191,10 +2191,10 @@ static IrInstGen *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, Scope *scope, A |
| 2191 | 2191 | return &instruction->base; |
| 2192 | 2192 | } |
| 2193 | 2193 | |
| 2194 | static IrInstGen *ir_build_array_to_vector(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2195 | IrInstGen *array, ZigType *result_type) | |
| 2194 | static Stage1AirInst *ir_build_array_to_vector(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2195 | Stage1AirInst *array, ZigType *result_type) | |
| 2196 | 2196 | { |
| 2197 | IrInstGenArrayToVector *instruction = ir_build_inst_gen<IrInstGenArrayToVector>(&ira->new_irb, | |
| 2197 | Stage1AirInstArrayToVector *instruction = ir_build_inst_gen<Stage1AirInstArrayToVector>(&ira->new_irb, | |
| 2198 | 2198 | scope, source_node); |
| 2199 | 2199 | instruction->base.value->type = result_type; |
| 2200 | 2200 | instruction->array = array; |
| ... | ... | @@ -2204,10 +2204,10 @@ static IrInstGen *ir_build_array_to_vector(IrAnalyze *ira, Scope *scope, AstNode |
| 2204 | 2204 | return &instruction->base; |
| 2205 | 2205 | } |
| 2206 | 2206 | |
| 2207 | static IrInstGen *ir_build_assert_zero(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2208 | IrInstGen *target) | |
| 2207 | static Stage1AirInst *ir_build_assert_zero(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2208 | Stage1AirInst *target) | |
| 2209 | 2209 | { |
| 2210 | IrInstGenAssertZero *instruction = ir_build_inst_gen<IrInstGenAssertZero>(&ira->new_irb, | |
| 2210 | Stage1AirInstAssertZero *instruction = ir_build_inst_gen<Stage1AirInstAssertZero>(&ira->new_irb, | |
| 2211 | 2211 | scope, source_node); |
| 2212 | 2212 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 2213 | 2213 | instruction->target = target; |
| ... | ... | @@ -2217,10 +2217,10 @@ static IrInstGen *ir_build_assert_zero(IrAnalyze *ira, Scope *scope, AstNode *so |
| 2217 | 2217 | return &instruction->base; |
| 2218 | 2218 | } |
| 2219 | 2219 | |
| 2220 | static IrInstGen *ir_build_assert_non_null(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2221 | IrInstGen *target) | |
| 2220 | static Stage1AirInst *ir_build_assert_non_null(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2221 | Stage1AirInst *target) | |
| 2222 | 2222 | { |
| 2223 | IrInstGenAssertNonNull *instruction = ir_build_inst_gen<IrInstGenAssertNonNull>(&ira->new_irb, | |
| 2223 | Stage1AirInstAssertNonNull *instruction = ir_build_inst_gen<Stage1AirInstAssertNonNull>(&ira->new_irb, | |
| 2224 | 2224 | scope, source_node); |
| 2225 | 2225 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 2226 | 2226 | instruction->target = target; |
| ... | ... | @@ -2230,10 +2230,10 @@ static IrInstGen *ir_build_assert_non_null(IrAnalyze *ira, Scope *scope, AstNode |
| 2230 | 2230 | return &instruction->base; |
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | static IrInstGenAlloca *ir_build_alloca_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2233 | static Stage1AirInstAlloca *ir_build_alloca_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2234 | 2234 | uint32_t align, const char *name_hint) |
| 2235 | 2235 | { |
| 2236 | IrInstGenAlloca *instruction = ir_create_inst_gen<IrInstGenAlloca>(&ira->new_irb, | |
| 2236 | Stage1AirInstAlloca *instruction = ir_create_inst_gen<Stage1AirInstAlloca>(&ira->new_irb, | |
| 2237 | 2237 | scope, source_node); |
| 2238 | 2238 | instruction->align = align; |
| 2239 | 2239 | instruction->name_hint = name_hint; |
| ... | ... | @@ -2241,8 +2241,8 @@ static IrInstGenAlloca *ir_build_alloca_gen(IrAnalyze *ira, Scope *scope, AstNod |
| 2241 | 2241 | return instruction; |
| 2242 | 2242 | } |
| 2243 | 2243 | |
| 2244 | static IrInstGen *ir_build_suspend_finish_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGenSuspendBegin *begin) { | |
| 2245 | IrInstGenSuspendFinish *inst = ir_build_inst_void<IrInstGenSuspendFinish>(&ira->new_irb, | |
| 2244 | static Stage1AirInst *ir_build_suspend_finish_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInstSuspendBegin *begin) { | |
| 2245 | Stage1AirInstSuspendFinish *inst = ir_build_inst_void<Stage1AirInstSuspendFinish>(&ira->new_irb, | |
| 2246 | 2246 | scope, source_node); |
| 2247 | 2247 | inst->begin = begin; |
| 2248 | 2248 | |
| ... | ... | @@ -2251,10 +2251,10 @@ static IrInstGen *ir_build_suspend_finish_gen(IrAnalyze *ira, Scope *scope, AstN |
| 2251 | 2251 | return &inst->base; |
| 2252 | 2252 | } |
| 2253 | 2253 | |
| 2254 | static IrInstGenAwait *ir_build_await_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2255 | IrInstGen *frame, ZigType *result_type, IrInstGen *result_loc, bool is_nosuspend) | |
| 2254 | static Stage1AirInstAwait *ir_build_await_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2255 | Stage1AirInst *frame, ZigType *result_type, Stage1AirInst *result_loc, bool is_nosuspend) | |
| 2256 | 2256 | { |
| 2257 | IrInstGenAwait *instruction = ir_build_inst_gen<IrInstGenAwait>(&ira->new_irb, | |
| 2257 | Stage1AirInstAwait *instruction = ir_build_inst_gen<Stage1AirInstAwait>(&ira->new_irb, | |
| 2258 | 2258 | scope, source_node); |
| 2259 | 2259 | instruction->base.value->type = result_type; |
| 2260 | 2260 | instruction->frame = frame; |
| ... | ... | @@ -2267,8 +2267,8 @@ static IrInstGenAwait *ir_build_await_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 2267 | 2267 | return instruction; |
| 2268 | 2268 | } |
| 2269 | 2269 | |
| 2270 | static IrInstGen *ir_build_resume_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *frame) { | |
| 2271 | IrInstGenResume *instruction = ir_build_inst_void<IrInstGenResume>(&ira->new_irb, | |
| 2270 | static Stage1AirInst *ir_build_resume_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *frame) { | |
| 2271 | Stage1AirInstResume *instruction = ir_build_inst_void<Stage1AirInstResume>(&ira->new_irb, | |
| 2272 | 2272 | scope, source_node); |
| 2273 | 2273 | instruction->frame = frame; |
| 2274 | 2274 | |
| ... | ... | @@ -2277,10 +2277,10 @@ static IrInstGen *ir_build_resume_gen(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 2277 | 2277 | return &instruction->base; |
| 2278 | 2278 | } |
| 2279 | 2279 | |
| 2280 | static IrInstGen *ir_build_spill_begin_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *operand, | |
| 2280 | static Stage1AirInst *ir_build_spill_begin_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *operand, | |
| 2281 | 2281 | SpillId spill_id) |
| 2282 | 2282 | { |
| 2283 | IrInstGenSpillBegin *instruction = ir_build_inst_void<IrInstGenSpillBegin>(&ira->new_irb, | |
| 2283 | Stage1AirInstSpillBegin *instruction = ir_build_inst_void<Stage1AirInstSpillBegin>(&ira->new_irb, | |
| 2284 | 2284 | scope, source_node); |
| 2285 | 2285 | instruction->operand = operand; |
| 2286 | 2286 | instruction->spill_id = spill_id; |
| ... | ... | @@ -2290,10 +2290,10 @@ static IrInstGen *ir_build_spill_begin_gen(IrAnalyze *ira, Scope *scope, AstNode |
| 2290 | 2290 | return &instruction->base; |
| 2291 | 2291 | } |
| 2292 | 2292 | |
| 2293 | static IrInstGen *ir_build_spill_end_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGenSpillBegin *begin, | |
| 2293 | static Stage1AirInst *ir_build_spill_end_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInstSpillBegin *begin, | |
| 2294 | 2294 | ZigType *result_type) |
| 2295 | 2295 | { |
| 2296 | IrInstGenSpillEnd *instruction = ir_build_inst_gen<IrInstGenSpillEnd>(&ira->new_irb, | |
| 2296 | Stage1AirInstSpillEnd *instruction = ir_build_inst_gen<Stage1AirInstSpillEnd>(&ira->new_irb, | |
| 2297 | 2297 | scope, source_node); |
| 2298 | 2298 | instruction->base.value->type = result_type; |
| 2299 | 2299 | instruction->begin = begin; |
| ... | ... | @@ -2303,10 +2303,10 @@ static IrInstGen *ir_build_spill_end_gen(IrAnalyze *ira, Scope *scope, AstNode * |
| 2303 | 2303 | return &instruction->base; |
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | static IrInstGen *ir_build_vector_extract_elem(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2307 | IrInstGen *vector, IrInstGen *index) | |
| 2306 | static Stage1AirInst *ir_build_vector_extract_elem(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 2307 | Stage1AirInst *vector, Stage1AirInst *index) | |
| 2308 | 2308 | { |
| 2309 | IrInstGenVectorExtractElem *instruction = ir_build_inst_gen<IrInstGenVectorExtractElem>( | |
| 2309 | Stage1AirInstVectorExtractElem *instruction = ir_build_inst_gen<Stage1AirInstVectorExtractElem>( | |
| 2310 | 2310 | &ira->new_irb, scope, source_node); |
| 2311 | 2311 | instruction->base.value->type = vector->value->type->data.vector.elem_type; |
| 2312 | 2312 | instruction->vector = vector; |
| ... | ... | @@ -2318,8 +2318,8 @@ static IrInstGen *ir_build_vector_extract_elem(IrAnalyze *ira, Scope *scope, Ast |
| 2318 | 2318 | return &instruction->base; |
| 2319 | 2319 | } |
| 2320 | 2320 | |
| 2321 | static IrInstGen *ir_build_wasm_memory_size_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *index) { | |
| 2322 | IrInstGenWasmMemorySize *instruction = ir_build_inst_gen<IrInstGenWasmMemorySize>(&ira->new_irb, | |
| 2321 | static Stage1AirInst *ir_build_wasm_memory_size_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *index) { | |
| 2322 | Stage1AirInstWasmMemorySize *instruction = ir_build_inst_gen<Stage1AirInstWasmMemorySize>(&ira->new_irb, | |
| 2323 | 2323 | scope, source_node); |
| 2324 | 2324 | instruction->base.value->type = ira->codegen->builtin_types.entry_u32; |
| 2325 | 2325 | instruction->index = index; |
| ... | ... | @@ -2329,8 +2329,8 @@ static IrInstGen *ir_build_wasm_memory_size_gen(IrAnalyze *ira, Scope *scope, As |
| 2329 | 2329 | return &instruction->base; |
| 2330 | 2330 | } |
| 2331 | 2331 | |
| 2332 | static IrInstGen *ir_build_wasm_memory_grow_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *index, IrInstGen *delta) { | |
| 2333 | IrInstGenWasmMemoryGrow *instruction = ir_build_inst_gen<IrInstGenWasmMemoryGrow>(&ira->new_irb, | |
| 2332 | static Stage1AirInst *ir_build_wasm_memory_grow_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *index, Stage1AirInst *delta) { | |
| 2333 | Stage1AirInstWasmMemoryGrow *instruction = ir_build_inst_gen<Stage1AirInstWasmMemoryGrow>(&ira->new_irb, | |
| 2334 | 2334 | scope, source_node); |
| 2335 | 2335 | instruction->base.value->type = ira->codegen->builtin_types.entry_i32; |
| 2336 | 2336 | instruction->index = index; |
| ... | ... | @@ -2555,7 +2555,7 @@ static ErrorMsg *opt_ir_add_error_node(IrAnalyze *ira, CodeGen *codegen, AstNode |
| 2555 | 2555 | return add_node_error(codegen, source_node, msg); |
| 2556 | 2556 | } |
| 2557 | 2557 | |
| 2558 | static ErrorMsg *ir_add_error(IrAnalyze *ira, IrInstGen *source_instruction, Buf *msg) { | |
| 2558 | static ErrorMsg *ir_add_error(IrAnalyze *ira, Stage1AirInst *source_instruction, Buf *msg) { | |
| 2559 | 2559 | return ir_add_error_node(ira, source_instruction->source_node, msg); |
| 2560 | 2560 | } |
| 2561 | 2561 | |
| ... | ... | @@ -2605,17 +2605,17 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va |
| 2605 | 2605 | } |
| 2606 | 2606 | |
| 2607 | 2607 | static Error ir_exec_scan_for_side_effects(CodeGen *codegen, Stage1Air *exec) { |
| 2608 | IrBasicBlockGen *bb = exec->basic_block_list.at(0); | |
| 2608 | Stage1AirBasicBlock *bb = exec->basic_block_list.at(0); | |
| 2609 | 2609 | for (size_t i = 0; i < bb->instruction_list.length; i += 1) { |
| 2610 | IrInstGen *instruction = bb->instruction_list.at(i); | |
| 2611 | if (instruction->id == IrInstGenIdReturn) { | |
| 2610 | Stage1AirInst *instruction = bb->instruction_list.at(i); | |
| 2611 | if (instruction->id == Stage1AirInstIdReturn) { | |
| 2612 | 2612 | return ErrorNone; |
| 2613 | 2613 | } else if (ir_inst_gen_has_side_effects(instruction)) { |
| 2614 | 2614 | if (instr_is_comptime(instruction)) { |
| 2615 | 2615 | switch (instruction->id) { |
| 2616 | case IrInstGenIdUnwrapErrPayload: | |
| 2617 | case IrInstGenIdOptionalUnwrapPtr: | |
| 2618 | case IrInstGenIdUnionFieldPtr: | |
| 2616 | case Stage1AirInstIdUnwrapErrPayload: | |
| 2617 | case Stage1AirInstIdOptionalUnwrapPtr: | |
| 2618 | case Stage1AirInstIdUnionFieldPtr: | |
| 2619 | 2619 | continue; |
| 2620 | 2620 | default: |
| 2621 | 2621 | break; |
| ... | ... | @@ -2633,7 +2633,7 @@ static Error ir_exec_scan_for_side_effects(CodeGen *codegen, Stage1Air *exec) { |
| 2633 | 2633 | zig_unreachable(); |
| 2634 | 2634 | } |
| 2635 | 2635 | |
| 2636 | static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstSrc* source_instruction) { | |
| 2636 | static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, Stage1ZirInst* source_instruction) { | |
| 2637 | 2637 | if (ir_should_inline(ira->zir, source_instruction->scope)) { |
| 2638 | 2638 | ir_add_error_node(ira, source_instruction->source_node, buf_sprintf("unable to evaluate constant expression")); |
| 2639 | 2639 | return false; |
| ... | ... | @@ -3423,7 +3423,7 @@ static void value_to_bigfloat(BigFloat *out, ZigValue *val) { |
| 3423 | 3423 | } |
| 3424 | 3424 | } |
| 3425 | 3425 | |
| 3426 | static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstGen *instruction, ZigType *other_type, | |
| 3426 | static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, Stage1AirInst *instruction, ZigType *other_type, | |
| 3427 | 3427 | bool explicit_cast) |
| 3428 | 3428 | { |
| 3429 | 3429 | if (type_is_invalid(other_type)) { |
| ... | ... | @@ -4185,11 +4185,11 @@ static void update_errors_helper(CodeGen *g, ErrorTableEntry ***errors, size_t * |
| 4185 | 4185 | } |
| 4186 | 4186 | |
| 4187 | 4187 | static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigType *expected_type, |
| 4188 | IrInstGen **instructions, size_t instruction_count) | |
| 4188 | Stage1AirInst **instructions, size_t instruction_count) | |
| 4189 | 4189 | { |
| 4190 | 4190 | Error err; |
| 4191 | 4191 | assert(instruction_count >= 1); |
| 4192 | IrInstGen *prev_inst; | |
| 4192 | Stage1AirInst *prev_inst; | |
| 4193 | 4193 | size_t i = 0; |
| 4194 | 4194 | for (;;) { |
| 4195 | 4195 | prev_inst = instructions[i]; |
| ... | ... | @@ -4231,7 +4231,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 4231 | 4231 | bool make_the_slice_const = false; |
| 4232 | 4232 | bool make_the_pointer_const = false; |
| 4233 | 4233 | for (; i < instruction_count; i += 1) { |
| 4234 | IrInstGen *cur_inst = instructions[i]; | |
| 4234 | Stage1AirInst *cur_inst = instructions[i]; | |
| 4235 | 4235 | ZigType *cur_type = cur_inst->value->type; |
| 4236 | 4236 | ZigType *prev_type = prev_inst->value->type; |
| 4237 | 4237 | |
| ... | ... | @@ -5085,36 +5085,36 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, Scope *scope, AstNode |
| 5085 | 5085 | return true; |
| 5086 | 5086 | } |
| 5087 | 5087 | |
| 5088 | static IrInstGen *ir_const(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty) { | |
| 5089 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, | |
| 5088 | static Stage1AirInst *ir_const(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty) { | |
| 5089 | Stage1AirInstConst *const_instruction = ir_create_inst_gen<Stage1AirInstConst>(&ira->new_irb, | |
| 5090 | 5090 | scope, source_node); |
| 5091 | IrInstGen *new_instruction = &const_instruction->base; | |
| 5091 | Stage1AirInst *new_instruction = &const_instruction->base; | |
| 5092 | 5092 | new_instruction->value->type = ty; |
| 5093 | 5093 | new_instruction->value->special = ConstValSpecialStatic; |
| 5094 | 5094 | ira->new_irb.constants.append(&heap::c_allocator, const_instruction); |
| 5095 | 5095 | return new_instruction; |
| 5096 | 5096 | } |
| 5097 | 5097 | |
| 5098 | static IrInstGen *ir_const_noval(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 5099 | IrInstGenConst *const_instruction = ir_create_inst_noval<IrInstGenConst>(&ira->new_irb, | |
| 5098 | static Stage1AirInst *ir_const_noval(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 5099 | Stage1AirInstConst *const_instruction = ir_create_inst_noval<Stage1AirInstConst>(&ira->new_irb, | |
| 5100 | 5100 | scope, source_node); |
| 5101 | 5101 | ira->new_irb.constants.append(&heap::c_allocator, const_instruction); |
| 5102 | 5102 | return &const_instruction->base; |
| 5103 | 5103 | } |
| 5104 | 5104 | |
| 5105 | // This function initializes the new IrInstGen with the provided ZigValue, | |
| 5105 | // This function initializes the new Stage1AirInst with the provided ZigValue, | |
| 5106 | 5106 | // rather than creating a new one. |
| 5107 | static IrInstGen *ir_const_move(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigValue *val) { | |
| 5108 | IrInstGen *result = ir_const_noval(ira, scope, source_node); | |
| 5107 | static Stage1AirInst *ir_const_move(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigValue *val) { | |
| 5108 | Stage1AirInst *result = ir_const_noval(ira, scope, source_node); | |
| 5109 | 5109 | result->value = val; |
| 5110 | 5110 | return result; |
| 5111 | 5111 | } |
| 5112 | 5112 | |
| 5113 | static IrInstGen *ir_resolve_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value, | |
| 5113 | static Stage1AirInst *ir_resolve_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value, | |
| 5114 | 5114 | ZigType *wanted_type, CastOp cast_op) |
| 5115 | 5115 | { |
| 5116 | 5116 | if (instr_is_comptime(value) || !type_has_bits(ira->codegen, wanted_type)) { |
| 5117 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5117 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5118 | 5118 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 5119 | 5119 | if (val == nullptr) |
| 5120 | 5120 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -5131,8 +5131,8 @@ static IrInstGen *ir_resolve_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 5131 | 5131 | } |
| 5132 | 5132 | } |
| 5133 | 5133 | |
| 5134 | static IrInstGen *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, | |
| 5135 | Scope *scope, AstNode *source_node, IrInstGen *value, ZigType *wanted_type) | |
| 5134 | static Stage1AirInst *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, | |
| 5135 | Scope *scope, AstNode *source_node, Stage1AirInst *value, ZigType *wanted_type) | |
| 5136 | 5136 | { |
| 5137 | 5137 | src_assert(value->value->type->id == ZigTypeIdPointer, source_node); |
| 5138 | 5138 | |
| ... | ... | @@ -5157,7 +5157,7 @@ static IrInstGen *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, |
| 5157 | 5157 | if (pointee == nullptr) |
| 5158 | 5158 | return ira->codegen->invalid_inst_gen; |
| 5159 | 5159 | if (pointee->special != ConstValSpecialRuntime) { |
| 5160 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5160 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5161 | 5161 | result->value->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 5162 | 5162 | result->value->data.x_ptr.mut = val->data.x_ptr.mut; |
| 5163 | 5163 | result->value->data.x_ptr.data.base_array.array_val = pointee; |
| ... | ... | @@ -5170,8 +5170,8 @@ static IrInstGen *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, |
| 5170 | 5170 | wanted_type, value, CastOpBitCast); |
| 5171 | 5171 | } |
| 5172 | 5172 | |
| 5173 | static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5174 | IrInstGen *array_ptr, ZigType *wanted_type, ResultLoc *result_loc) | |
| 5173 | static Stage1AirInst *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5174 | Stage1AirInst *array_ptr, ZigType *wanted_type, ResultLoc *result_loc) | |
| 5175 | 5175 | { |
| 5176 | 5176 | Error err; |
| 5177 | 5177 | |
| ... | ... | @@ -5190,7 +5190,7 @@ static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, Scope *scope, |
| 5190 | 5190 | // undef_array->special = ConstValSpecialUndef; |
| 5191 | 5191 | // undef_array->type = array_type; |
| 5192 | 5192 | |
| 5193 | // IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5193 | // Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5194 | 5194 | // init_const_slice(ira->codegen, result->value, undef_array, 0, 0, false, nullptr); |
| 5195 | 5195 | // result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 5196 | 5196 | // result->value->type = wanted_type; |
| ... | ... | @@ -5217,7 +5217,7 @@ static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, Scope *scope, |
| 5217 | 5217 | undef_array->special = ConstValSpecialUndef; |
| 5218 | 5218 | undef_array->type = array_type; |
| 5219 | 5219 | |
| 5220 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5220 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5221 | 5221 | init_const_slice(ira->codegen, result->value, undef_array, 0, 0, false, nullptr); |
| 5222 | 5222 | result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 5223 | 5223 | result->value->type = wanted_type; |
| ... | ... | @@ -5228,7 +5228,7 @@ static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, Scope *scope, |
| 5228 | 5228 | if (array_ptr_val->data.x_ptr.special == ConstPtrSpecialSubArray) { |
| 5229 | 5229 | ZigValue *array_val = array_ptr_val->data.x_ptr.data.base_array.array_val; |
| 5230 | 5230 | if (array_val->special != ConstValSpecialRuntime) { |
| 5231 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5231 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5232 | 5232 | init_const_slice(ira->codegen, result->value, array_val, |
| 5233 | 5233 | array_ptr_val->data.x_ptr.data.base_array.elem_index, |
| 5234 | 5234 | array_type->data.array.len, wanted_const, nullptr); |
| ... | ... | @@ -5243,7 +5243,7 @@ static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, Scope *scope, |
| 5243 | 5243 | if (pointee->special != ConstValSpecialRuntime) { |
| 5244 | 5244 | assert(array_ptr_val->type->id == ZigTypeIdPointer); |
| 5245 | 5245 | |
| 5246 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5246 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 5247 | 5247 | init_const_slice(ira->codegen, result->value, pointee, 0, array_type->data.array.len, wanted_const, nullptr); |
| 5248 | 5248 | result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; |
| 5249 | 5249 | result->value->type = wanted_type; |
| ... | ... | @@ -5253,7 +5253,7 @@ static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, Scope *scope, |
| 5253 | 5253 | } |
| 5254 | 5254 | |
| 5255 | 5255 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 5256 | IrInstGen *result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, | |
| 5256 | Stage1AirInst *result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, | |
| 5257 | 5257 | result_loc, wanted_type, nullptr, true, true); |
| 5258 | 5258 | if (type_is_invalid(result_loc_inst->value->type) || |
| 5259 | 5259 | result_loc_inst->value->type->id == ZigTypeIdUnreachable) |
| ... | ... | @@ -5263,7 +5263,7 @@ static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, Scope *scope, |
| 5263 | 5263 | return ir_build_ptr_of_array_to_slice(ira, scope, source_node, wanted_type, array_ptr, result_loc_inst); |
| 5264 | 5264 | } |
| 5265 | 5265 | |
| 5266 | static IrBasicBlockGen *ir_get_new_bb(IrAnalyze *ira, Stage1ZirBasicBlock *old_bb, IrInstSrc *ref_old_instruction) { | |
| 5266 | static Stage1AirBasicBlock *ir_get_new_bb(IrAnalyze *ira, Stage1ZirBasicBlock *old_bb, Stage1ZirInst *ref_old_instruction) { | |
| 5267 | 5267 | assert(old_bb); |
| 5268 | 5268 | |
| 5269 | 5269 | if (old_bb->child) { |
| ... | ... | @@ -5272,15 +5272,15 @@ static IrBasicBlockGen *ir_get_new_bb(IrAnalyze *ira, Stage1ZirBasicBlock *old_b |
| 5272 | 5272 | } |
| 5273 | 5273 | } |
| 5274 | 5274 | |
| 5275 | IrBasicBlockGen *new_bb = ir_build_bb_from(ira, old_bb); | |
| 5275 | Stage1AirBasicBlock *new_bb = ir_build_bb_from(ira, old_bb); | |
| 5276 | 5276 | new_bb->ref_instruction = ref_old_instruction; |
| 5277 | 5277 | |
| 5278 | 5278 | return new_bb; |
| 5279 | 5279 | } |
| 5280 | 5280 | |
| 5281 | static IrBasicBlockGen *ir_get_new_bb_runtime(IrAnalyze *ira, Stage1ZirBasicBlock *old_bb, IrInstSrc *ref_old_instruction) { | |
| 5281 | static Stage1AirBasicBlock *ir_get_new_bb_runtime(IrAnalyze *ira, Stage1ZirBasicBlock *old_bb, Stage1ZirInst *ref_old_instruction) { | |
| 5282 | 5282 | assert(ref_old_instruction != nullptr); |
| 5283 | IrBasicBlockGen *new_bb = ir_get_new_bb(ira, old_bb, ref_old_instruction); | |
| 5283 | Stage1AirBasicBlock *new_bb = ir_get_new_bb(ira, old_bb, ref_old_instruction); | |
| 5284 | 5284 | if (new_bb->must_be_comptime_source_node != nullptr) { |
| 5285 | 5285 | ErrorMsg *msg = ir_add_error_node(ira, ref_old_instruction->source_node, |
| 5286 | 5286 | buf_sprintf("control flow attempts to use compile-time variable at runtime")); |
| ... | ... | @@ -5301,7 +5301,7 @@ static void ir_start_bb(IrAnalyze *ira, Stage1ZirBasicBlock *old_bb, Stage1ZirBa |
| 5301 | 5301 | ira->old_bb_index = old_bb->index; |
| 5302 | 5302 | } |
| 5303 | 5303 | |
| 5304 | static IrInstGen *ira_suspend(IrAnalyze *ira, IrInstSrc *old_instruction, Stage1ZirBasicBlock *next_bb, | |
| 5304 | static Stage1AirInst *ira_suspend(IrAnalyze *ira, Stage1ZirInst *old_instruction, Stage1ZirBasicBlock *next_bb, | |
| 5305 | 5305 | IrSuspendPosition *suspend_pos) |
| 5306 | 5306 | { |
| 5307 | 5307 | if (ira->codegen->verbose_ir) { |
| ... | ... | @@ -5331,7 +5331,7 @@ static IrInstGen *ira_suspend(IrAnalyze *ira, IrInstSrc *old_instruction, Stage1 |
| 5331 | 5331 | return ira->codegen->unreach_instruction; |
| 5332 | 5332 | } |
| 5333 | 5333 | |
| 5334 | static IrInstGen *ira_resume(IrAnalyze *ira) { | |
| 5334 | static Stage1AirInst *ira_resume(IrAnalyze *ira) { | |
| 5335 | 5335 | IrSuspendPosition pos = ira->resume_stack.pop(); |
| 5336 | 5336 | if (ira->codegen->verbose_ir) { |
| 5337 | 5337 | fprintf(stderr, "resume (%zu,%zu) ", pos.basic_block_index, pos.instruction_index); |
| ... | ... | @@ -5414,7 +5414,7 @@ static void ir_finish_bb(IrAnalyze *ira) { |
| 5414 | 5414 | ir_start_next_bb(ira); |
| 5415 | 5415 | } |
| 5416 | 5416 | |
| 5417 | static IrInstGen *ir_unreach_error(IrAnalyze *ira) { | |
| 5417 | static Stage1AirInst *ir_unreach_error(IrAnalyze *ira) { | |
| 5418 | 5418 | ira->old_bb_index = SIZE_MAX; |
| 5419 | 5419 | if (ira->new_irb.exec->first_err_trace_msg == nullptr) { |
| 5420 | 5420 | ira->new_irb.exec->first_err_trace_msg = ira->codegen->trace_err; |
| ... | ... | @@ -5441,7 +5441,7 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, AstNode* source_node) { |
| 5441 | 5441 | return true; |
| 5442 | 5442 | } |
| 5443 | 5443 | |
| 5444 | static IrInstGen *ir_inline_bb(IrAnalyze *ira, AstNode* source_node, Stage1ZirBasicBlock *old_bb) { | |
| 5444 | static Stage1AirInst *ir_inline_bb(IrAnalyze *ira, AstNode* source_node, Stage1ZirBasicBlock *old_bb) { | |
| 5445 | 5445 | if (old_bb->debug_id <= ira->zir_current_basic_block->debug_id) { |
| 5446 | 5446 | if (!ir_emit_backward_branch(ira, source_node)) |
| 5447 | 5447 | return ir_unreach_error(ira); |
| ... | ... | @@ -5452,14 +5452,14 @@ static IrInstGen *ir_inline_bb(IrAnalyze *ira, AstNode* source_node, Stage1ZirBa |
| 5452 | 5452 | return ira->codegen->unreach_instruction; |
| 5453 | 5453 | } |
| 5454 | 5454 | |
| 5455 | static IrInstGen *ir_finish_anal(IrAnalyze *ira, IrInstGen *instruction) { | |
| 5455 | static Stage1AirInst *ir_finish_anal(IrAnalyze *ira, Stage1AirInst *instruction) { | |
| 5456 | 5456 | if (instruction->value->type->id == ZigTypeIdUnreachable) |
| 5457 | 5457 | ir_finish_bb(ira); |
| 5458 | 5458 | return instruction; |
| 5459 | 5459 | } |
| 5460 | 5460 | |
| 5461 | static IrInstGen *ir_const_fn(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { | |
| 5462 | IrInstGen *result = ir_const(ira, scope, source_node, fn_entry->type_entry); | |
| 5461 | static Stage1AirInst *ir_const_fn(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { | |
| 5462 | Stage1AirInst *result = ir_const(ira, scope, source_node, fn_entry->type_entry); | |
| 5463 | 5463 | result->value->special = ConstValSpecialStatic; |
| 5464 | 5464 | result->value->data.x_ptr.data.fn.fn_entry = fn_entry; |
| 5465 | 5465 | result->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| ... | ... | @@ -5467,62 +5467,62 @@ static IrInstGen *ir_const_fn(IrAnalyze *ira, Scope *scope, AstNode *source_node |
| 5467 | 5467 | return result; |
| 5468 | 5468 | } |
| 5469 | 5469 | |
| 5470 | static IrInstGen *ir_const_bound_fn(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5471 | ZigFn *fn_entry, IrInstGen *first_arg, AstNode *first_arg_src) | |
| 5470 | static Stage1AirInst *ir_const_bound_fn(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5471 | ZigFn *fn_entry, Stage1AirInst *first_arg, AstNode *first_arg_src) | |
| 5472 | 5472 | { |
| 5473 | 5473 | // This is unfortunately required to avoid improperly freeing first_arg_src |
| 5474 | 5474 | ira_ref(ira); |
| 5475 | 5475 | |
| 5476 | IrInstGen *result = ir_const(ira, scope, source_node, get_bound_fn_type(ira->codegen, fn_entry)); | |
| 5476 | Stage1AirInst *result = ir_const(ira, scope, source_node, get_bound_fn_type(ira->codegen, fn_entry)); | |
| 5477 | 5477 | result->value->data.x_bound_fn.fn = fn_entry; |
| 5478 | 5478 | result->value->data.x_bound_fn.first_arg = first_arg; |
| 5479 | 5479 | result->value->data.x_bound_fn.first_arg_src = first_arg_src; |
| 5480 | 5480 | return result; |
| 5481 | 5481 | } |
| 5482 | 5482 | |
| 5483 | static IrInstGen *ir_const_type(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty) { | |
| 5484 | IrInstGen *result = ir_const(ira, scope, source_node, ira->codegen->builtin_types.entry_type); | |
| 5483 | static Stage1AirInst *ir_const_type(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty) { | |
| 5484 | Stage1AirInst *result = ir_const(ira, scope, source_node, ira->codegen->builtin_types.entry_type); | |
| 5485 | 5485 | result->value->data.x_type = ty; |
| 5486 | 5486 | return result; |
| 5487 | 5487 | } |
| 5488 | 5488 | |
| 5489 | static IrInstGen *ir_const_bool(IrAnalyze *ira, Scope *scope, AstNode *source_node, bool value) { | |
| 5490 | IrInstGen *result = ir_const(ira, scope, source_node, ira->codegen->builtin_types.entry_bool); | |
| 5489 | static Stage1AirInst *ir_const_bool(IrAnalyze *ira, Scope *scope, AstNode *source_node, bool value) { | |
| 5490 | Stage1AirInst *result = ir_const(ira, scope, source_node, ira->codegen->builtin_types.entry_bool); | |
| 5491 | 5491 | result->value->data.x_bool = value; |
| 5492 | 5492 | return result; |
| 5493 | 5493 | } |
| 5494 | 5494 | |
| 5495 | static IrInstGen *ir_const_undef(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty) { | |
| 5496 | IrInstGen *result = ir_const(ira, scope, source_node, ty); | |
| 5495 | static Stage1AirInst *ir_const_undef(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty) { | |
| 5496 | Stage1AirInst *result = ir_const(ira, scope, source_node, ty); | |
| 5497 | 5497 | result->value->special = ConstValSpecialUndef; |
| 5498 | 5498 | return result; |
| 5499 | 5499 | } |
| 5500 | 5500 | |
| 5501 | static IrInstGen *ir_const_unreachable(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 5502 | IrInstGen *result = ir_const_noval(ira, scope, source_node); | |
| 5501 | static Stage1AirInst *ir_const_unreachable(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 5502 | Stage1AirInst *result = ir_const_noval(ira, scope, source_node); | |
| 5503 | 5503 | result->value = ira->codegen->intern.for_unreachable(); |
| 5504 | 5504 | return result; |
| 5505 | 5505 | } |
| 5506 | 5506 | |
| 5507 | static IrInstGen *ir_const_void(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 5508 | IrInstGen *result = ir_const_noval(ira, scope, source_node); | |
| 5507 | static Stage1AirInst *ir_const_void(IrAnalyze *ira, Scope *scope, AstNode *source_node) { | |
| 5508 | Stage1AirInst *result = ir_const_noval(ira, scope, source_node); | |
| 5509 | 5509 | result->value = ira->codegen->intern.for_void(); |
| 5510 | 5510 | return result; |
| 5511 | 5511 | } |
| 5512 | 5512 | |
| 5513 | static IrInstGen *ir_const_unsigned(IrAnalyze *ira, Scope *scope, AstNode *source_node, uint64_t value) { | |
| 5514 | IrInstGen *result = ir_const(ira, scope, source_node, ira->codegen->builtin_types.entry_num_lit_int); | |
| 5513 | static Stage1AirInst *ir_const_unsigned(IrAnalyze *ira, Scope *scope, AstNode *source_node, uint64_t value) { | |
| 5514 | Stage1AirInst *result = ir_const(ira, scope, source_node, ira->codegen->builtin_types.entry_num_lit_int); | |
| 5515 | 5515 | bigint_init_unsigned(&result->value->data.x_bigint, value); |
| 5516 | 5516 | return result; |
| 5517 | 5517 | } |
| 5518 | 5518 | |
| 5519 | static IrInstGen *ir_get_const_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5519 | static Stage1AirInst *ir_get_const_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5520 | 5520 | ZigValue *pointee, ZigType *pointee_type, |
| 5521 | 5521 | ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align) |
| 5522 | 5522 | { |
| 5523 | 5523 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type, |
| 5524 | 5524 | ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false); |
| 5525 | IrInstGen *const_instr = ir_const(ira, scope, source_node, ptr_type); | |
| 5525 | Stage1AirInst *const_instr = ir_const(ira, scope, source_node, ptr_type); | |
| 5526 | 5526 | ZigValue *const_val = const_instr->value; |
| 5527 | 5527 | const_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 5528 | 5528 | const_val->data.x_ptr.mut = ptr_mut; |
| ... | ... | @@ -5564,7 +5564,7 @@ static Error ir_resolve_const_val(CodeGen *codegen, Stage1Air *exec, AstNode *so |
| 5564 | 5564 | } |
| 5565 | 5565 | } |
| 5566 | 5566 | |
| 5567 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstGen *value, UndefAllowed undef_allowed) { | |
| 5567 | static ZigValue *ir_resolve_const(IrAnalyze *ira, Stage1AirInst *value, UndefAllowed undef_allowed) { | |
| 5568 | 5568 | Error err; |
| 5569 | 5569 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->source_node, |
| 5570 | 5570 | value->value, undef_allowed))) |
| ... | ... | @@ -5640,7 +5640,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 5640 | 5640 | return ErrorNone; |
| 5641 | 5641 | } |
| 5642 | 5642 | |
| 5643 | static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstGen *err_value) { | |
| 5643 | static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, Stage1AirInst *err_value) { | |
| 5644 | 5644 | if (type_is_invalid(err_value->value->type)) |
| 5645 | 5645 | return nullptr; |
| 5646 | 5646 | |
| ... | ... | @@ -5669,7 +5669,7 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, Stage1Air *exec, AstNode |
| 5669 | 5669 | return val->data.x_type; |
| 5670 | 5670 | } |
| 5671 | 5671 | |
| 5672 | static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstGen *type_value) { | |
| 5672 | static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, Stage1AirInst *type_value) { | |
| 5673 | 5673 | if (type_is_invalid(type_value->value->type)) |
| 5674 | 5674 | return nullptr; |
| 5675 | 5675 | |
| ... | ... | @@ -5689,7 +5689,7 @@ static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstGen *type_value) { |
| 5689 | 5689 | return type_value->value; |
| 5690 | 5690 | } |
| 5691 | 5691 | |
| 5692 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstGen *type_value) { | |
| 5692 | static ZigType *ir_resolve_type(IrAnalyze *ira, Stage1AirInst *type_value) { | |
| 5693 | 5693 | ZigValue *val = ir_resolve_type_lazy(ira, type_value); |
| 5694 | 5694 | if (val == nullptr) |
| 5695 | 5695 | return ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -5711,7 +5711,7 @@ static Error ir_validate_vector_elem_type(IrAnalyze *ira, AstNode *source_node, |
| 5711 | 5711 | return ErrorNone; |
| 5712 | 5712 | } |
| 5713 | 5713 | |
| 5714 | static ZigType *ir_resolve_vector_elem_type(IrAnalyze *ira, IrInstGen *elem_type_value) { | |
| 5714 | static ZigType *ir_resolve_vector_elem_type(IrAnalyze *ira, Stage1AirInst *elem_type_value) { | |
| 5715 | 5715 | Error err; |
| 5716 | 5716 | ZigType *elem_type = ir_resolve_type(ira, elem_type_value); |
| 5717 | 5717 | if (type_is_invalid(elem_type)) |
| ... | ... | @@ -5721,7 +5721,7 @@ static ZigType *ir_resolve_vector_elem_type(IrAnalyze *ira, IrInstGen *elem_type |
| 5721 | 5721 | return elem_type; |
| 5722 | 5722 | } |
| 5723 | 5723 | |
| 5724 | static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstGen *type_value) { | |
| 5724 | static ZigType *ir_resolve_int_type(IrAnalyze *ira, Stage1AirInst *type_value) { | |
| 5725 | 5725 | ZigType *ty = ir_resolve_type(ira, type_value); |
| 5726 | 5726 | if (type_is_invalid(ty)) |
| 5727 | 5727 | return ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -5742,7 +5742,7 @@ static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstGen *type_value) { |
| 5742 | 5742 | return ty; |
| 5743 | 5743 | } |
| 5744 | 5744 | |
| 5745 | static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, AstNode *op_source, IrInstGen *type_value) { | |
| 5745 | static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, AstNode *op_source, Stage1AirInst *type_value) { | |
| 5746 | 5746 | if (type_is_invalid(type_value->value->type)) |
| 5747 | 5747 | return ira->codegen->builtin_types.entry_invalid; |
| 5748 | 5748 | |
| ... | ... | @@ -5770,7 +5770,7 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, AstNode *op_source, Ir |
| 5770 | 5770 | return result_type; |
| 5771 | 5771 | } |
| 5772 | 5772 | |
| 5773 | static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstGen *fn_value) { | |
| 5773 | static ZigFn *ir_resolve_fn(IrAnalyze *ira, Stage1AirInst *fn_value) { | |
| 5774 | 5774 | if (type_is_invalid(fn_value->value->type)) |
| 5775 | 5775 | return nullptr; |
| 5776 | 5776 | |
| ... | ... | @@ -5791,14 +5791,14 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstGen *fn_value) { |
| 5791 | 5791 | return const_val->data.x_ptr.data.fn.fn_entry; |
| 5792 | 5792 | } |
| 5793 | 5793 | |
| 5794 | static IrInstGen *ir_analyze_optional_wrap(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5795 | IrInstGen *value, ZigType *wanted_type, ResultLoc *result_loc) | |
| 5794 | static Stage1AirInst *ir_analyze_optional_wrap(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5795 | Stage1AirInst *value, ZigType *wanted_type, ResultLoc *result_loc) | |
| 5796 | 5796 | { |
| 5797 | 5797 | assert(wanted_type->id == ZigTypeIdOptional); |
| 5798 | 5798 | |
| 5799 | 5799 | if (instr_is_comptime(value)) { |
| 5800 | 5800 | ZigType *payload_type = wanted_type->data.maybe.child_type; |
| 5801 | IrInstGen *casted_payload = ir_implicit_cast(ira, value, payload_type); | |
| 5801 | Stage1AirInst *casted_payload = ir_implicit_cast(ira, value, payload_type); | |
| 5802 | 5802 | if (type_is_invalid(casted_payload->value->type)) |
| 5803 | 5803 | return ira->codegen->invalid_inst_gen; |
| 5804 | 5804 | |
| ... | ... | @@ -5806,7 +5806,7 @@ static IrInstGen *ir_analyze_optional_wrap(IrAnalyze *ira, Scope *scope, AstNode |
| 5806 | 5806 | if (!val) |
| 5807 | 5807 | return ira->codegen->invalid_inst_gen; |
| 5808 | 5808 | |
| 5809 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, | |
| 5809 | Stage1AirInstConst *const_instruction = ir_create_inst_gen<Stage1AirInstConst>(&ira->new_irb, | |
| 5810 | 5810 | scope, source_node); |
| 5811 | 5811 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 5812 | 5812 | if (types_have_same_zig_comptime_repr(ira->codegen, wanted_type, payload_type)) { |
| ... | ... | @@ -5821,7 +5821,7 @@ static IrInstGen *ir_analyze_optional_wrap(IrAnalyze *ira, Scope *scope, AstNode |
| 5821 | 5821 | if (result_loc == nullptr && handle_is_ptr(ira->codegen, wanted_type)) { |
| 5822 | 5822 | result_loc = no_result_loc(); |
| 5823 | 5823 | } |
| 5824 | IrInstGen *result_loc_inst = nullptr; | |
| 5824 | Stage1AirInst *result_loc_inst = nullptr; | |
| 5825 | 5825 | if (result_loc != nullptr) { |
| 5826 | 5826 | result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, result_loc, wanted_type, nullptr, true, true); |
| 5827 | 5827 | if (type_is_invalid(result_loc_inst->value->type) || |
| ... | ... | @@ -5830,20 +5830,20 @@ static IrInstGen *ir_analyze_optional_wrap(IrAnalyze *ira, Scope *scope, AstNode |
| 5830 | 5830 | return result_loc_inst; |
| 5831 | 5831 | } |
| 5832 | 5832 | } |
| 5833 | IrInstGen *result = ir_build_optional_wrap(ira, scope, source_node, wanted_type, value, result_loc_inst); | |
| 5833 | Stage1AirInst *result = ir_build_optional_wrap(ira, scope, source_node, wanted_type, value, result_loc_inst); | |
| 5834 | 5834 | result->value->data.rh_maybe = RuntimeHintOptionalNonNull; |
| 5835 | 5835 | return result; |
| 5836 | 5836 | } |
| 5837 | 5837 | |
| 5838 | static IrInstGen *ir_analyze_err_wrap_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5839 | IrInstGen *value, ZigType *wanted_type, ResultLoc *result_loc) | |
| 5838 | static Stage1AirInst *ir_analyze_err_wrap_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5839 | Stage1AirInst *value, ZigType *wanted_type, ResultLoc *result_loc) | |
| 5840 | 5840 | { |
| 5841 | 5841 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| 5842 | 5842 | |
| 5843 | 5843 | ZigType *payload_type = wanted_type->data.error_union.payload_type; |
| 5844 | 5844 | ZigType *err_set_type = wanted_type->data.error_union.err_set_type; |
| 5845 | 5845 | if (instr_is_comptime(value)) { |
| 5846 | IrInstGen *casted_payload = ir_implicit_cast(ira, value, payload_type); | |
| 5846 | Stage1AirInst *casted_payload = ir_implicit_cast(ira, value, payload_type); | |
| 5847 | 5847 | if (type_is_invalid(casted_payload->value->type)) |
| 5848 | 5848 | return ira->codegen->invalid_inst_gen; |
| 5849 | 5849 | |
| ... | ... | @@ -5856,7 +5856,7 @@ static IrInstGen *ir_analyze_err_wrap_payload(IrAnalyze *ira, Scope *scope, AstN |
| 5856 | 5856 | err_set_val->special = ConstValSpecialStatic; |
| 5857 | 5857 | err_set_val->data.x_err_set = nullptr; |
| 5858 | 5858 | |
| 5859 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, | |
| 5859 | Stage1AirInstConst *const_instruction = ir_create_inst_gen<Stage1AirInstConst>(&ira->new_irb, | |
| 5860 | 5860 | scope, source_node); |
| 5861 | 5861 | const_instruction->base.value->type = wanted_type; |
| 5862 | 5862 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | ... | @@ -5865,7 +5865,7 @@ static IrInstGen *ir_analyze_err_wrap_payload(IrAnalyze *ira, Scope *scope, AstN |
| 5865 | 5865 | return &const_instruction->base; |
| 5866 | 5866 | } |
| 5867 | 5867 | |
| 5868 | IrInstGen *result_loc_inst; | |
| 5868 | Stage1AirInst *result_loc_inst; | |
| 5869 | 5869 | if (handle_is_ptr(ira->codegen, wanted_type)) { |
| 5870 | 5870 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 5871 | 5871 | result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, result_loc, wanted_type, nullptr, true, true); |
| ... | ... | @@ -5877,12 +5877,12 @@ static IrInstGen *ir_analyze_err_wrap_payload(IrAnalyze *ira, Scope *scope, AstN |
| 5877 | 5877 | result_loc_inst = nullptr; |
| 5878 | 5878 | } |
| 5879 | 5879 | |
| 5880 | IrInstGen *result = ir_build_err_wrap_payload(ira, scope, source_node, wanted_type, value, result_loc_inst); | |
| 5880 | Stage1AirInst *result = ir_build_err_wrap_payload(ira, scope, source_node, wanted_type, value, result_loc_inst); | |
| 5881 | 5881 | result->value->data.rh_error_union = RuntimeHintErrorUnionNonError; |
| 5882 | 5882 | return result; |
| 5883 | 5883 | } |
| 5884 | 5884 | |
| 5885 | static IrInstGen *ir_analyze_err_set_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value, | |
| 5885 | static Stage1AirInst *ir_analyze_err_set_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value, | |
| 5886 | 5886 | ZigType *wanted_type) |
| 5887 | 5887 | { |
| 5888 | 5888 | assert(value->value->type->id == ZigTypeIdErrorSet); |
| ... | ... | @@ -5912,7 +5912,7 @@ static IrInstGen *ir_analyze_err_set_cast(IrAnalyze *ira, Scope *scope, AstNode |
| 5912 | 5912 | } |
| 5913 | 5913 | } |
| 5914 | 5914 | |
| 5915 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, | |
| 5915 | Stage1AirInstConst *const_instruction = ir_create_inst_gen<Stage1AirInstConst>(&ira->new_irb, | |
| 5916 | 5916 | scope, source_node); |
| 5917 | 5917 | const_instruction->base.value->type = wanted_type; |
| 5918 | 5918 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | ... | @@ -5923,8 +5923,8 @@ static IrInstGen *ir_analyze_err_set_cast(IrAnalyze *ira, Scope *scope, AstNode |
| 5923 | 5923 | return ir_build_cast(ira, scope, source_node, wanted_type, value, CastOpErrSet); |
| 5924 | 5924 | } |
| 5925 | 5925 | |
| 5926 | static IrInstGen *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5927 | IrInstGen *frame_ptr, ZigType *wanted_type) | |
| 5926 | static Stage1AirInst *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5927 | Stage1AirInst *frame_ptr, ZigType *wanted_type) | |
| 5928 | 5928 | { |
| 5929 | 5929 | if (instr_is_comptime(frame_ptr)) { |
| 5930 | 5930 | ZigValue *ptr_val = ir_resolve_const(ira, frame_ptr, UndefBad); |
| ... | ... | @@ -5940,8 +5940,8 @@ static IrInstGen *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, Scope *scope, |
| 5940 | 5940 | return ir_build_cast(ira, scope, source_node, wanted_type, frame_ptr, CastOpBitCast); |
| 5941 | 5941 | } |
| 5942 | 5942 | |
| 5943 | static IrInstGen *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5944 | IrInstGen *value, ZigType *wanted_type) | |
| 5943 | static Stage1AirInst *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 5944 | Stage1AirInst *value, ZigType *wanted_type) | |
| 5945 | 5945 | { |
| 5946 | 5946 | if (instr_is_comptime(value)) { |
| 5947 | 5947 | zig_panic("TODO comptime anyframe->T to anyframe"); |
| ... | ... | @@ -5951,12 +5951,12 @@ static IrInstGen *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, Scope *scope, |
| 5951 | 5951 | } |
| 5952 | 5952 | |
| 5953 | 5953 | |
| 5954 | static IrInstGen *ir_analyze_err_wrap_code(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value, | |
| 5954 | static Stage1AirInst *ir_analyze_err_wrap_code(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value, | |
| 5955 | 5955 | ZigType *wanted_type, ResultLoc *result_loc) |
| 5956 | 5956 | { |
| 5957 | 5957 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| 5958 | 5958 | |
| 5959 | IrInstGen *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); | |
| 5959 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); | |
| 5960 | 5960 | |
| 5961 | 5961 | if (instr_is_comptime(casted_value)) { |
| 5962 | 5962 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | ... | @@ -5968,7 +5968,7 @@ static IrInstGen *ir_analyze_err_wrap_code(IrAnalyze *ira, Scope *scope, AstNode |
| 5968 | 5968 | err_set_val->type = wanted_type->data.error_union.err_set_type; |
| 5969 | 5969 | err_set_val->data.x_err_set = val->data.x_err_set; |
| 5970 | 5970 | |
| 5971 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, | |
| 5971 | Stage1AirInstConst *const_instruction = ir_create_inst_gen<Stage1AirInstConst>(&ira->new_irb, | |
| 5972 | 5972 | scope, source_node); |
| 5973 | 5973 | const_instruction->base.value->type = wanted_type; |
| 5974 | 5974 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | ... | @@ -5977,7 +5977,7 @@ static IrInstGen *ir_analyze_err_wrap_code(IrAnalyze *ira, Scope *scope, AstNode |
| 5977 | 5977 | return &const_instruction->base; |
| 5978 | 5978 | } |
| 5979 | 5979 | |
| 5980 | IrInstGen *result_loc_inst; | |
| 5980 | Stage1AirInst *result_loc_inst; | |
| 5981 | 5981 | if (handle_is_ptr(ira->codegen, wanted_type)) { |
| 5982 | 5982 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 5983 | 5983 | result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, result_loc, wanted_type, nullptr, true, true); |
| ... | ... | @@ -5991,19 +5991,19 @@ static IrInstGen *ir_analyze_err_wrap_code(IrAnalyze *ira, Scope *scope, AstNode |
| 5991 | 5991 | } |
| 5992 | 5992 | |
| 5993 | 5993 | |
| 5994 | IrInstGen *result = ir_build_err_wrap_code(ira, scope, source_node, wanted_type, value, result_loc_inst); | |
| 5994 | Stage1AirInst *result = ir_build_err_wrap_code(ira, scope, source_node, wanted_type, value, result_loc_inst); | |
| 5995 | 5995 | result->value->data.rh_error_union = RuntimeHintErrorUnionError; |
| 5996 | 5996 | return result; |
| 5997 | 5997 | } |
| 5998 | 5998 | |
| 5999 | static IrInstGen *ir_analyze_null_to_maybe(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value, ZigType *wanted_type) { | |
| 5999 | static Stage1AirInst *ir_analyze_null_to_maybe(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value, ZigType *wanted_type) { | |
| 6000 | 6000 | assert(wanted_type->id == ZigTypeIdOptional); |
| 6001 | 6001 | assert(instr_is_comptime(value)); |
| 6002 | 6002 | |
| 6003 | 6003 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 6004 | 6004 | assert(val != nullptr); |
| 6005 | 6005 | |
| 6006 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6006 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6007 | 6007 | result->value->special = ConstValSpecialStatic; |
| 6008 | 6008 | |
| 6009 | 6009 | if (get_src_ptr_type(wanted_type) != nullptr) { |
| ... | ... | @@ -6016,8 +6016,8 @@ static IrInstGen *ir_analyze_null_to_maybe(IrAnalyze *ira, Scope *scope, AstNode |
| 6016 | 6016 | return result; |
| 6017 | 6017 | } |
| 6018 | 6018 | |
| 6019 | static IrInstGen *ir_analyze_null_to_c_pointer(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6020 | IrInstGen *value, ZigType *wanted_type) | |
| 6019 | static Stage1AirInst *ir_analyze_null_to_c_pointer(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6020 | Stage1AirInst *value, ZigType *wanted_type) | |
| 6021 | 6021 | { |
| 6022 | 6022 | assert(wanted_type->id == ZigTypeIdPointer); |
| 6023 | 6023 | assert(wanted_type->data.pointer.ptr_len == PtrLenC); |
| ... | ... | @@ -6026,13 +6026,13 @@ static IrInstGen *ir_analyze_null_to_c_pointer(IrAnalyze *ira, Scope *scope, Ast |
| 6026 | 6026 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 6027 | 6027 | assert(val != nullptr); |
| 6028 | 6028 | |
| 6029 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6029 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6030 | 6030 | result->value->data.x_ptr.special = ConstPtrSpecialNull; |
| 6031 | 6031 | result->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 6032 | 6032 | return result; |
| 6033 | 6033 | } |
| 6034 | 6034 | |
| 6035 | static IrInstGen *ir_get_ref2(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value, | |
| 6035 | static Stage1AirInst *ir_get_ref2(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value, | |
| 6036 | 6036 | ZigType *elem_type, bool is_const, bool is_volatile) |
| 6037 | 6037 | { |
| 6038 | 6038 | Error err; |
| ... | ... | @@ -6054,19 +6054,19 @@ static IrInstGen *ir_get_ref2(IrAnalyze *ira, Scope *scope, AstNode *source_node |
| 6054 | 6054 | if ((err = type_resolve(ira->codegen, ptr_type, ResolveStatusZeroBitsKnown))) |
| 6055 | 6055 | return ira->codegen->invalid_inst_gen; |
| 6056 | 6056 | |
| 6057 | IrInstGen *result_loc; | |
| 6057 | Stage1AirInst *result_loc; | |
| 6058 | 6058 | if (type_has_bits(ira->codegen, ptr_type) && !handle_is_ptr(ira->codegen, elem_type)) { |
| 6059 | 6059 | result_loc = ir_resolve_result(ira, ira->suspend_source_instr, no_result_loc(), elem_type, nullptr, true, true); |
| 6060 | 6060 | } else { |
| 6061 | 6061 | result_loc = nullptr; |
| 6062 | 6062 | } |
| 6063 | 6063 | |
| 6064 | IrInstGen *new_instruction = ir_build_ref_gen(ira, scope, source_node, ptr_type, value, result_loc); | |
| 6064 | Stage1AirInst *new_instruction = ir_build_ref_gen(ira, scope, source_node, ptr_type, value, result_loc); | |
| 6065 | 6065 | new_instruction->value->data.rh_ptr = RuntimeHintPtrStack; |
| 6066 | 6066 | return new_instruction; |
| 6067 | 6067 | } |
| 6068 | 6068 | |
| 6069 | static IrInstGen *ir_get_ref(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value, | |
| 6069 | static Stage1AirInst *ir_get_ref(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value, | |
| 6070 | 6070 | bool is_const, bool is_volatile) |
| 6071 | 6071 | { |
| 6072 | 6072 | return ir_get_ref2(ira, scope, source_node, value, value->value->type, is_const, is_volatile); |
| ... | ... | @@ -6103,10 +6103,10 @@ static bool can_fold_enum_type(ZigType *ty) { |
| 6103 | 6103 | (tag_int_type->id == ZigTypeIdInt && tag_int_type->data.integral.bit_count == 0); |
| 6104 | 6104 | } |
| 6105 | 6105 | |
| 6106 | static IrInstGen *ir_analyze_enum_to_int(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target) { | |
| 6106 | static Stage1AirInst *ir_analyze_enum_to_int(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target) { | |
| 6107 | 6107 | Error err; |
| 6108 | 6108 | |
| 6109 | IrInstGen *enum_target; | |
| 6109 | Stage1AirInst *enum_target; | |
| 6110 | 6110 | ZigType *enum_type; |
| 6111 | 6111 | if (target->value->type->id == ZigTypeIdUnion) { |
| 6112 | 6112 | enum_type = ir_resolve_union_tag_type(ira, target->source_node, target->value->type); |
| ... | ... | @@ -6132,7 +6132,7 @@ static IrInstGen *ir_analyze_enum_to_int(IrAnalyze *ira, Scope *scope, AstNode * |
| 6132 | 6132 | |
| 6133 | 6133 | // If there is only one possible tag, then we know at comptime what it is. |
| 6134 | 6134 | if (can_fold_enum_type(enum_type)) { |
| 6135 | IrInstGen *result = ir_const(ira, scope, source_node, tag_type); | |
| 6135 | Stage1AirInst *result = ir_const(ira, scope, source_node, tag_type); | |
| 6136 | 6136 | init_const_bigint(result->value, tag_type, |
| 6137 | 6137 | &enum_type->data.enumeration.fields[0].value); |
| 6138 | 6138 | return result; |
| ... | ... | @@ -6142,7 +6142,7 @@ static IrInstGen *ir_analyze_enum_to_int(IrAnalyze *ira, Scope *scope, AstNode * |
| 6142 | 6142 | ZigValue *val = ir_resolve_const(ira, enum_target, UndefBad); |
| 6143 | 6143 | if (!val) |
| 6144 | 6144 | return ira->codegen->invalid_inst_gen; |
| 6145 | IrInstGen *result = ir_const(ira, scope, source_node, tag_type); | |
| 6145 | Stage1AirInst *result = ir_const(ira, scope, source_node, tag_type); | |
| 6146 | 6146 | init_const_bigint(result->value, tag_type, &val->data.x_enum_tag); |
| 6147 | 6147 | return result; |
| 6148 | 6148 | } |
| ... | ... | @@ -6150,8 +6150,8 @@ static IrInstGen *ir_analyze_enum_to_int(IrAnalyze *ira, Scope *scope, AstNode * |
| 6150 | 6150 | return ir_build_widen_or_shorten(ira, scope, source_node, enum_target, tag_type); |
| 6151 | 6151 | } |
| 6152 | 6152 | |
| 6153 | static IrInstGen *ir_analyze_union_to_tag(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6154 | IrInstGen *target, ZigType *wanted_type) | |
| 6153 | static Stage1AirInst *ir_analyze_union_to_tag(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6154 | Stage1AirInst *target, ZigType *wanted_type) | |
| 6155 | 6155 | { |
| 6156 | 6156 | assert(target->value->type->id == ZigTypeIdUnion); |
| 6157 | 6157 | assert(wanted_type->id == ZigTypeIdEnum); |
| ... | ... | @@ -6161,7 +6161,7 @@ static IrInstGen *ir_analyze_union_to_tag(IrAnalyze *ira, Scope *scope, AstNode |
| 6161 | 6161 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 6162 | 6162 | if (!val) |
| 6163 | 6163 | return ira->codegen->invalid_inst_gen; |
| 6164 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6164 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6165 | 6165 | result->value->special = ConstValSpecialStatic; |
| 6166 | 6166 | result->value->type = wanted_type; |
| 6167 | 6167 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_union.tag); |
| ... | ... | @@ -6170,7 +6170,7 @@ static IrInstGen *ir_analyze_union_to_tag(IrAnalyze *ira, Scope *scope, AstNode |
| 6170 | 6170 | |
| 6171 | 6171 | // If there is only 1 possible tag, then we know at comptime what it is. |
| 6172 | 6172 | if (can_fold_enum_type(wanted_type)) { |
| 6173 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6173 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6174 | 6174 | result->value->special = ConstValSpecialStatic; |
| 6175 | 6175 | result->value->type = wanted_type; |
| 6176 | 6176 | TypeEnumField *enum_field = target->value->type->data.unionation.fields[0].enum_field; |
| ... | ... | @@ -6181,16 +6181,16 @@ static IrInstGen *ir_analyze_union_to_tag(IrAnalyze *ira, Scope *scope, AstNode |
| 6181 | 6181 | return ir_build_union_tag(ira, scope, source_node, target, wanted_type); |
| 6182 | 6182 | } |
| 6183 | 6183 | |
| 6184 | static IrInstGen *ir_analyze_undefined_to_anything(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6185 | IrInstGen *target, ZigType *wanted_type) | |
| 6184 | static Stage1AirInst *ir_analyze_undefined_to_anything(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6185 | Stage1AirInst *target, ZigType *wanted_type) | |
| 6186 | 6186 | { |
| 6187 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6187 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6188 | 6188 | result->value->special = ConstValSpecialUndef; |
| 6189 | 6189 | return result; |
| 6190 | 6190 | } |
| 6191 | 6191 | |
| 6192 | static IrInstGen *ir_analyze_enum_to_union(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6193 | IrInstGen *uncasted_target, ZigType *wanted_type) | |
| 6192 | static Stage1AirInst *ir_analyze_enum_to_union(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6193 | Stage1AirInst *uncasted_target, ZigType *wanted_type) | |
| 6194 | 6194 | { |
| 6195 | 6195 | Error err; |
| 6196 | 6196 | assert(wanted_type->id == ZigTypeIdUnion); |
| ... | ... | @@ -6198,7 +6198,7 @@ static IrInstGen *ir_analyze_enum_to_union(IrAnalyze *ira, Scope *scope, AstNode |
| 6198 | 6198 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusZeroBitsKnown))) |
| 6199 | 6199 | return ira->codegen->invalid_inst_gen; |
| 6200 | 6200 | |
| 6201 | IrInstGen *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type); | |
| 6201 | Stage1AirInst *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type); | |
| 6202 | 6202 | if (type_is_invalid(target->value->type)) |
| 6203 | 6203 | return ira->codegen->invalid_inst_gen; |
| 6204 | 6204 | |
| ... | ... | @@ -6240,7 +6240,7 @@ static IrInstGen *ir_analyze_enum_to_union(IrAnalyze *ira, Scope *scope, AstNode |
| 6240 | 6240 | break; |
| 6241 | 6241 | } |
| 6242 | 6242 | |
| 6243 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6243 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6244 | 6244 | result->value->special = ConstValSpecialStatic; |
| 6245 | 6245 | result->value->type = wanted_type; |
| 6246 | 6246 | bigint_init_bigint(&result->value->data.x_union.tag, &val->data.x_enum_tag); |
| ... | ... | @@ -6287,8 +6287,8 @@ static IrInstGen *ir_analyze_enum_to_union(IrAnalyze *ira, Scope *scope, AstNode |
| 6287 | 6287 | |
| 6288 | 6288 | static bool value_numeric_fits_in_type(ZigValue *value, ZigType *type_entry); |
| 6289 | 6289 | |
| 6290 | static IrInstGen *ir_analyze_widen_or_shorten(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6291 | IrInstGen *target, ZigType *wanted_type) | |
| 6290 | static Stage1AirInst *ir_analyze_widen_or_shorten(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6291 | Stage1AirInst *target, ZigType *wanted_type) | |
| 6292 | 6292 | { |
| 6293 | 6293 | ZigType *wanted_scalar_type = (target->value->type->id == ZigTypeIdVector) ? |
| 6294 | 6294 | wanted_type->data.vector.elem_type : wanted_type; |
| ... | ... | @@ -6314,7 +6314,7 @@ static IrInstGen *ir_analyze_widen_or_shorten(IrAnalyze *ira, Scope *scope, AstN |
| 6314 | 6314 | } |
| 6315 | 6315 | } |
| 6316 | 6316 | |
| 6317 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6317 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6318 | 6318 | result->value->type = wanted_type; |
| 6319 | 6319 | |
| 6320 | 6320 | if (wanted_type->id == ZigTypeIdVector) { |
| ... | ... | @@ -6351,7 +6351,7 @@ static IrInstGen *ir_analyze_widen_or_shorten(IrAnalyze *ira, Scope *scope, AstN |
| 6351 | 6351 | assert(wanted_type->id == ZigTypeIdInt); |
| 6352 | 6352 | assert(type_has_bits(ira->codegen, target->value->type)); |
| 6353 | 6353 | ir_build_assert_zero(ira, scope, source_node, target); |
| 6354 | IrInstGen *result = ir_const_unsigned(ira, scope, source_node, 0); | |
| 6354 | Stage1AirInst *result = ir_const_unsigned(ira, scope, source_node, 0); | |
| 6355 | 6355 | result->value->type = wanted_type; |
| 6356 | 6356 | return result; |
| 6357 | 6357 | } |
| ... | ... | @@ -6359,8 +6359,8 @@ static IrInstGen *ir_analyze_widen_or_shorten(IrAnalyze *ira, Scope *scope, AstN |
| 6359 | 6359 | return ir_build_widen_or_shorten(ira, scope, source_node, target, wanted_type); |
| 6360 | 6360 | } |
| 6361 | 6361 | |
| 6362 | static IrInstGen *ir_analyze_int_to_enum(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6363 | IrInstGen *target, ZigType *wanted_type) | |
| 6362 | static Stage1AirInst *ir_analyze_int_to_enum(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6363 | Stage1AirInst *target, ZigType *wanted_type) | |
| 6364 | 6364 | { |
| 6365 | 6365 | Error err; |
| 6366 | 6366 | assert(wanted_type->id == ZigTypeIdEnum); |
| ... | ... | @@ -6397,7 +6397,7 @@ static IrInstGen *ir_analyze_int_to_enum(IrAnalyze *ira, Scope *scope, AstNode * |
| 6397 | 6397 | return ira->codegen->invalid_inst_gen; |
| 6398 | 6398 | } |
| 6399 | 6399 | |
| 6400 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6400 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6401 | 6401 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_bigint); |
| 6402 | 6402 | return result; |
| 6403 | 6403 | } |
| ... | ... | @@ -6405,14 +6405,14 @@ static IrInstGen *ir_analyze_int_to_enum(IrAnalyze *ira, Scope *scope, AstNode * |
| 6405 | 6405 | return ir_build_int_to_enum_gen(ira, scope, source_node, wanted_type, target); |
| 6406 | 6406 | } |
| 6407 | 6407 | |
| 6408 | static IrInstGen *ir_analyze_number_to_literal(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6409 | IrInstGen *target, ZigType *wanted_type) | |
| 6408 | static Stage1AirInst *ir_analyze_number_to_literal(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6409 | Stage1AirInst *target, ZigType *wanted_type) | |
| 6410 | 6410 | { |
| 6411 | 6411 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 6412 | 6412 | if (!val) |
| 6413 | 6413 | return ira->codegen->invalid_inst_gen; |
| 6414 | 6414 | |
| 6415 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6415 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6416 | 6416 | if (wanted_type->id == ZigTypeIdComptimeFloat) { |
| 6417 | 6417 | float_init_float(result->value, val); |
| 6418 | 6418 | } else if (wanted_type->id == ZigTypeIdComptimeInt) { |
| ... | ... | @@ -6423,7 +6423,7 @@ static IrInstGen *ir_analyze_number_to_literal(IrAnalyze *ira, Scope *scope, Ast |
| 6423 | 6423 | return result; |
| 6424 | 6424 | } |
| 6425 | 6425 | |
| 6426 | static IrInstGen *ir_analyze_int_to_err(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, | |
| 6426 | static Stage1AirInst *ir_analyze_int_to_err(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target, | |
| 6427 | 6427 | ZigType *wanted_type) |
| 6428 | 6428 | { |
| 6429 | 6429 | assert(target->value->type->id == ZigTypeIdInt); |
| ... | ... | @@ -6435,7 +6435,7 @@ static IrInstGen *ir_analyze_int_to_err(IrAnalyze *ira, Scope *scope, AstNode *s |
| 6435 | 6435 | if (!val) |
| 6436 | 6436 | return ira->codegen->invalid_inst_gen; |
| 6437 | 6437 | |
| 6438 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6438 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6439 | 6439 | |
| 6440 | 6440 | if (!resolve_inferred_error_set(ira->codegen, wanted_type, source_node)) { |
| 6441 | 6441 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -6485,7 +6485,7 @@ static IrInstGen *ir_analyze_int_to_err(IrAnalyze *ira, Scope *scope, AstNode *s |
| 6485 | 6485 | return ir_build_int_to_err_gen(ira, scope, source_node, target, wanted_type); |
| 6486 | 6486 | } |
| 6487 | 6487 | |
| 6488 | static IrInstGen *ir_analyze_err_to_int(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, | |
| 6488 | static Stage1AirInst *ir_analyze_err_to_int(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target, | |
| 6489 | 6489 | ZigType *wanted_type) |
| 6490 | 6490 | { |
| 6491 | 6491 | assert(wanted_type->id == ZigTypeIdInt); |
| ... | ... | @@ -6497,7 +6497,7 @@ static IrInstGen *ir_analyze_err_to_int(IrAnalyze *ira, Scope *scope, AstNode *s |
| 6497 | 6497 | if (!val) |
| 6498 | 6498 | return ira->codegen->invalid_inst_gen; |
| 6499 | 6499 | |
| 6500 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6500 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6501 | 6501 | |
| 6502 | 6502 | ErrorTableEntry *err; |
| 6503 | 6503 | if (err_type->id == ZigTypeIdErrorUnion) { |
| ... | ... | @@ -6536,11 +6536,11 @@ static IrInstGen *ir_analyze_err_to_int(IrAnalyze *ira, Scope *scope, AstNode *s |
| 6536 | 6536 | return ira->codegen->invalid_inst_gen; |
| 6537 | 6537 | } |
| 6538 | 6538 | if (err_set_type->data.error_set.err_count == 0) { |
| 6539 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6539 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6540 | 6540 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 6541 | 6541 | return result; |
| 6542 | 6542 | } else if (err_set_type->data.error_set.err_count == 1) { |
| 6543 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6543 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 6544 | 6544 | ErrorTableEntry *err = err_set_type->data.error_set.errors[0]; |
| 6545 | 6545 | bigint_init_unsigned(&result->value->data.x_bigint, err->value); |
| 6546 | 6546 | return result; |
| ... | ... | @@ -6558,7 +6558,7 @@ static IrInstGen *ir_analyze_err_to_int(IrAnalyze *ira, Scope *scope, AstNode *s |
| 6558 | 6558 | return ir_build_err_to_int_gen(ira, scope, source_node, target, wanted_type); |
| 6559 | 6559 | } |
| 6560 | 6560 | |
| 6561 | static IrInstGen *ir_analyze_ptr_to_array(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, | |
| 6561 | static Stage1AirInst *ir_analyze_ptr_to_array(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target, | |
| 6562 | 6562 | ZigType *wanted_type) |
| 6563 | 6563 | { |
| 6564 | 6564 | assert(wanted_type->id == ZigTypeIdPointer); |
| ... | ... | @@ -6589,7 +6589,7 @@ static IrInstGen *ir_analyze_ptr_to_array(IrAnalyze *ira, Scope *scope, AstNode |
| 6589 | 6589 | array_val->parent.id = ConstParentIdScalar; |
| 6590 | 6590 | array_val->parent.data.p_scalar.scalar_val = pointee; |
| 6591 | 6591 | |
| 6592 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, | |
| 6592 | Stage1AirInstConst *const_instruction = ir_create_inst_gen<Stage1AirInstConst>(&ira->new_irb, | |
| 6593 | 6593 | scope, source_node); |
| 6594 | 6594 | const_instruction->base.value->type = wanted_type; |
| 6595 | 6595 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | ... | @@ -6798,12 +6798,12 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa |
| 6798 | 6798 | } |
| 6799 | 6799 | } |
| 6800 | 6800 | |
| 6801 | static IrInstGen *ir_analyze_array_to_vector(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6802 | IrInstGen *array, ZigType *vector_type) | |
| 6801 | static Stage1AirInst *ir_analyze_array_to_vector(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6802 | Stage1AirInst *array, ZigType *vector_type) | |
| 6803 | 6803 | { |
| 6804 | 6804 | if (instr_is_comptime(array)) { |
| 6805 | 6805 | // arrays and vectors have the same ZigValue representation |
| 6806 | IrInstGen *result = ir_const(ira, scope, source_node, vector_type); | |
| 6806 | Stage1AirInst *result = ir_const(ira, scope, source_node, vector_type); | |
| 6807 | 6807 | copy_const_val(ira->codegen, result->value, array->value); |
| 6808 | 6808 | result->value->type = vector_type; |
| 6809 | 6809 | return result; |
| ... | ... | @@ -6811,12 +6811,12 @@ static IrInstGen *ir_analyze_array_to_vector(IrAnalyze *ira, Scope *scope, AstNo |
| 6811 | 6811 | return ir_build_array_to_vector(ira, scope, source_node, array, vector_type); |
| 6812 | 6812 | } |
| 6813 | 6813 | |
| 6814 | static IrInstGen *ir_analyze_vector_to_array(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6815 | IrInstGen *vector, ZigType *array_type, ResultLoc *result_loc) | |
| 6814 | static Stage1AirInst *ir_analyze_vector_to_array(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6815 | Stage1AirInst *vector, ZigType *array_type, ResultLoc *result_loc) | |
| 6816 | 6816 | { |
| 6817 | 6817 | if (instr_is_comptime(vector)) { |
| 6818 | 6818 | // arrays and vectors have the same ZigValue representation |
| 6819 | IrInstGen *result = ir_const(ira, scope, source_node, array_type); | |
| 6819 | Stage1AirInst *result = ir_const(ira, scope, source_node, array_type); | |
| 6820 | 6820 | copy_const_val(ira->codegen, result->value, vector->value); |
| 6821 | 6821 | result->value->type = array_type; |
| 6822 | 6822 | return result; |
| ... | ... | @@ -6824,17 +6824,17 @@ static IrInstGen *ir_analyze_vector_to_array(IrAnalyze *ira, Scope *scope, AstNo |
| 6824 | 6824 | if (result_loc == nullptr) { |
| 6825 | 6825 | result_loc = no_result_loc(); |
| 6826 | 6826 | } |
| 6827 | IrInstGen *result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, result_loc, array_type, nullptr, true, true); | |
| 6827 | Stage1AirInst *result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, result_loc, array_type, nullptr, true, true); | |
| 6828 | 6828 | if (type_is_invalid(result_loc_inst->value->type) || result_loc_inst->value->type->id == ZigTypeIdUnreachable) { |
| 6829 | 6829 | return result_loc_inst; |
| 6830 | 6830 | } |
| 6831 | 6831 | return ir_build_vector_to_array(ira, scope, source_node, array_type, vector, result_loc_inst); |
| 6832 | 6832 | } |
| 6833 | 6833 | |
| 6834 | static IrInstGen *ir_analyze_int_to_c_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6835 | IrInstGen *integer, ZigType *dest_type) | |
| 6834 | static Stage1AirInst *ir_analyze_int_to_c_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6835 | Stage1AirInst *integer, ZigType *dest_type) | |
| 6836 | 6836 | { |
| 6837 | IrInstGen *unsigned_integer; | |
| 6837 | Stage1AirInst *unsigned_integer; | |
| 6838 | 6838 | if (instr_is_comptime(integer)) { |
| 6839 | 6839 | unsigned_integer = integer; |
| 6840 | 6840 | } else { |
| ... | ... | @@ -6875,7 +6875,7 @@ static bool is_pointery_and_elem_is_not_pointery(ZigType *ty) { |
| 6875 | 6875 | return false; |
| 6876 | 6876 | } |
| 6877 | 6877 | |
| 6878 | static IrInstGen *ir_analyze_enum_literal(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value, | |
| 6878 | static Stage1AirInst *ir_analyze_enum_literal(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value, | |
| 6879 | 6879 | ZigType *enum_type) |
| 6880 | 6880 | { |
| 6881 | 6881 | assert(enum_type->id == ZigTypeIdEnum); |
| ... | ... | @@ -6892,14 +6892,14 @@ static IrInstGen *ir_analyze_enum_literal(IrAnalyze *ira, Scope *scope, AstNode |
| 6892 | 6892 | buf_sprintf("'%s' declared here", buf_ptr(&enum_type->name))); |
| 6893 | 6893 | return ira->codegen->invalid_inst_gen; |
| 6894 | 6894 | } |
| 6895 | IrInstGen *result = ir_const(ira, scope, source_node, enum_type); | |
| 6895 | Stage1AirInst *result = ir_const(ira, scope, source_node, enum_type); | |
| 6896 | 6896 | bigint_init_bigint(&result->value->data.x_enum_tag, &field->value); |
| 6897 | 6897 | |
| 6898 | 6898 | return result; |
| 6899 | 6899 | } |
| 6900 | 6900 | |
| 6901 | static IrInstGen *ir_analyze_struct_literal_to_array(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6902 | IrInstGen *struct_ptr, ZigType *actual_type, ZigType *wanted_type) | |
| 6901 | static Stage1AirInst *ir_analyze_struct_literal_to_array(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6902 | Stage1AirInst *struct_ptr, ZigType *actual_type, ZigType *wanted_type) | |
| 6903 | 6903 | { |
| 6904 | 6904 | Error err; |
| 6905 | 6905 | |
| ... | ... | @@ -6918,20 +6918,20 @@ static IrInstGen *ir_analyze_struct_literal_to_array(IrAnalyze *ira, Scope *scop |
| 6918 | 6918 | |
| 6919 | 6919 | // Determine if the struct_operand will be comptime. |
| 6920 | 6920 | ZigValue *elem_values = heap::c_allocator.allocate<ZigValue>(array_len); |
| 6921 | IrInstGen **casted_fields = heap::c_allocator.allocate<IrInstGen *>(array_len); | |
| 6922 | IrInstGen *const_result = ir_const(ira, scope, source_node, wanted_type); | |
| 6921 | Stage1AirInst **casted_fields = heap::c_allocator.allocate<Stage1AirInst *>(array_len); | |
| 6922 | Stage1AirInst *const_result = ir_const(ira, scope, source_node, wanted_type); | |
| 6923 | 6923 | |
| 6924 | 6924 | for (size_t i = 0; i < array_len; i += 1) { |
| 6925 | 6925 | TypeStructField *src_field = actual_type->data.structure.fields[i]; |
| 6926 | 6926 | |
| 6927 | IrInstGen *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, src_field, struct_ptr, | |
| 6927 | Stage1AirInst *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, src_field, struct_ptr, | |
| 6928 | 6928 | actual_type, false); |
| 6929 | 6929 | if (type_is_invalid(field_ptr->value->type)) |
| 6930 | 6930 | return ira->codegen->invalid_inst_gen; |
| 6931 | IrInstGen *field_value = ir_get_deref(ira, scope, source_node, field_ptr, nullptr); | |
| 6931 | Stage1AirInst *field_value = ir_get_deref(ira, scope, source_node, field_ptr, nullptr); | |
| 6932 | 6932 | if (type_is_invalid(field_value->value->type)) |
| 6933 | 6933 | return ira->codegen->invalid_inst_gen; |
| 6934 | IrInstGen *casted_value = ir_implicit_cast(ira, field_value, elem_type); | |
| 6934 | Stage1AirInst *casted_value = ir_implicit_cast(ira, field_value, elem_type); | |
| 6935 | 6935 | if (type_is_invalid(casted_value->value->type)) |
| 6936 | 6936 | return ira->codegen->invalid_inst_gen; |
| 6937 | 6937 | |
| ... | ... | @@ -6954,13 +6954,13 @@ static IrInstGen *ir_analyze_struct_literal_to_array(IrAnalyze *ira, Scope *scop |
| 6954 | 6954 | } |
| 6955 | 6955 | |
| 6956 | 6956 | if (is_comptime) { |
| 6957 | IrInstGen *const_result = ir_const(ira, scope, source_node, wanted_type); | |
| 6957 | Stage1AirInst *const_result = ir_const(ira, scope, source_node, wanted_type); | |
| 6958 | 6958 | const_result->value->data.x_array.special = ConstArraySpecialNone; |
| 6959 | 6959 | const_result->value->data.x_array.data.s_none.elements = elem_values; |
| 6960 | 6960 | return const_result; |
| 6961 | 6961 | } |
| 6962 | 6962 | |
| 6963 | IrInstGen *result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, no_result_loc(), | |
| 6963 | Stage1AirInst *result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, no_result_loc(), | |
| 6964 | 6964 | wanted_type, nullptr, true, true); |
| 6965 | 6965 | if (type_is_invalid(result_loc_inst->value->type) || result_loc_inst->value->type->id == ZigTypeIdUnreachable) { |
| 6966 | 6966 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -6968,12 +6968,12 @@ static IrInstGen *ir_analyze_struct_literal_to_array(IrAnalyze *ira, Scope *scop |
| 6968 | 6968 | |
| 6969 | 6969 | ZigType *elem_type_ptr = get_pointer_to_type(ira->codegen, elem_type, false); |
| 6970 | 6970 | for (size_t i = 0; i < array_len; i += 1) { |
| 6971 | IrInstGen *index_val = ir_const(ira, scope, source_node, ira->codegen->builtin_types.entry_usize); | |
| 6971 | Stage1AirInst *index_val = ir_const(ira, scope, source_node, ira->codegen->builtin_types.entry_usize); | |
| 6972 | 6972 | bigint_init_unsigned(&index_val->value->data.x_bigint, i); |
| 6973 | 6973 | |
| 6974 | IrInstGen *elem_ptr = ir_build_elem_ptr_gen(ira, scope, source_node, | |
| 6974 | Stage1AirInst *elem_ptr = ir_build_elem_ptr_gen(ira, scope, source_node, | |
| 6975 | 6975 | result_loc_inst, index_val, false, elem_type_ptr); |
| 6976 | IrInstGen *store_ptr_inst = ir_analyze_store_ptr(ira, scope, source_node, elem_ptr, casted_fields[i], true); | |
| 6976 | Stage1AirInst *store_ptr_inst = ir_analyze_store_ptr(ira, scope, source_node, elem_ptr, casted_fields[i], true); | |
| 6977 | 6977 | if (type_is_invalid(store_ptr_inst->value->type)) |
| 6978 | 6978 | return ira->codegen->invalid_inst_gen; |
| 6979 | 6979 | } |
| ... | ... | @@ -6984,8 +6984,8 @@ static IrInstGen *ir_analyze_struct_literal_to_array(IrAnalyze *ira, Scope *scop |
| 6984 | 6984 | return result_loc_inst; |
| 6985 | 6985 | } |
| 6986 | 6986 | |
| 6987 | static IrInstGen *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6988 | IrInstGen *struct_ptr, ZigType *actual_type, ZigType *wanted_type) | |
| 6987 | static Stage1AirInst *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 6988 | Stage1AirInst *struct_ptr, ZigType *actual_type, ZigType *wanted_type) | |
| 6989 | 6989 | { |
| 6990 | 6990 | Error err; |
| 6991 | 6991 | |
| ... | ... | @@ -7008,8 +7008,8 @@ static IrInstGen *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, Scope *sco |
| 7008 | 7008 | // Also emit compile errors for missing fields and duplicate fields. |
| 7009 | 7009 | AstNode **field_assign_nodes = heap::c_allocator.allocate<AstNode *>(actual_field_count); |
| 7010 | 7010 | ZigValue **field_values = heap::c_allocator.allocate<ZigValue *>(actual_field_count); |
| 7011 | IrInstGen **casted_fields = heap::c_allocator.allocate<IrInstGen *>(actual_field_count); | |
| 7012 | IrInstGen *const_result = ir_const(ira, scope, source_node, wanted_type); | |
| 7011 | Stage1AirInst **casted_fields = heap::c_allocator.allocate<Stage1AirInst *>(actual_field_count); | |
| 7012 | Stage1AirInst *const_result = ir_const(ira, scope, source_node, wanted_type); | |
| 7013 | 7013 | |
| 7014 | 7014 | for (size_t i = 0; i < instr_field_count; i += 1) { |
| 7015 | 7015 | TypeStructField *src_field = actual_type->data.structure.fields[i]; |
| ... | ... | @@ -7046,14 +7046,14 @@ static IrInstGen *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, Scope *sco |
| 7046 | 7046 | } |
| 7047 | 7047 | field_assign_nodes[dst_field->src_index] = src_field->decl_node; |
| 7048 | 7048 | |
| 7049 | IrInstGen *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, src_field, struct_ptr, | |
| 7049 | Stage1AirInst *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, src_field, struct_ptr, | |
| 7050 | 7050 | actual_type, false); |
| 7051 | 7051 | if (type_is_invalid(field_ptr->value->type)) |
| 7052 | 7052 | return ira->codegen->invalid_inst_gen; |
| 7053 | IrInstGen *field_value = ir_get_deref(ira, scope, source_node, field_ptr, nullptr); | |
| 7053 | Stage1AirInst *field_value = ir_get_deref(ira, scope, source_node, field_ptr, nullptr); | |
| 7054 | 7054 | if (type_is_invalid(field_value->value->type)) |
| 7055 | 7055 | return ira->codegen->invalid_inst_gen; |
| 7056 | IrInstGen *casted_value = ir_implicit_cast(ira, field_value, dst_field->type_entry); | |
| 7056 | Stage1AirInst *casted_value = ir_implicit_cast(ira, field_value, dst_field->type_entry); | |
| 7057 | 7057 | if (type_is_invalid(casted_value->value->type)) |
| 7058 | 7058 | return ira->codegen->invalid_inst_gen; |
| 7059 | 7059 | |
| ... | ... | @@ -7103,12 +7103,12 @@ static IrInstGen *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, Scope *sco |
| 7103 | 7103 | |
| 7104 | 7104 | if (is_comptime) { |
| 7105 | 7105 | heap::c_allocator.deallocate(field_assign_nodes, actual_field_count); |
| 7106 | IrInstGen *const_result = ir_const(ira, scope, source_node, wanted_type); | |
| 7106 | Stage1AirInst *const_result = ir_const(ira, scope, source_node, wanted_type); | |
| 7107 | 7107 | const_result->value->data.x_struct.fields = field_values; |
| 7108 | 7108 | return const_result; |
| 7109 | 7109 | } |
| 7110 | 7110 | |
| 7111 | IrInstGen *result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, no_result_loc(), | |
| 7111 | Stage1AirInst *result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, no_result_loc(), | |
| 7112 | 7112 | wanted_type, nullptr, true, true); |
| 7113 | 7113 | if (type_is_invalid(result_loc_inst->value->type) || result_loc_inst->value->type->id == ZigTypeIdUnreachable) { |
| 7114 | 7114 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -7119,10 +7119,10 @@ static IrInstGen *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, Scope *sco |
| 7119 | 7119 | if (field->is_comptime) |
| 7120 | 7120 | continue; |
| 7121 | 7121 | |
| 7122 | IrInstGen *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, field, result_loc_inst, wanted_type, true); | |
| 7122 | Stage1AirInst *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, field, result_loc_inst, wanted_type, true); | |
| 7123 | 7123 | if (type_is_invalid(field_ptr->value->type)) |
| 7124 | 7124 | return ira->codegen->invalid_inst_gen; |
| 7125 | IrInstGen *store_ptr_inst = ir_analyze_store_ptr(ira, scope, source_node, field_ptr, casted_fields[i], true); | |
| 7125 | Stage1AirInst *store_ptr_inst = ir_analyze_store_ptr(ira, scope, source_node, field_ptr, casted_fields[i], true); | |
| 7126 | 7126 | if (type_is_invalid(store_ptr_inst->value->type)) |
| 7127 | 7127 | return ira->codegen->invalid_inst_gen; |
| 7128 | 7128 | } |
| ... | ... | @@ -7134,8 +7134,8 @@ static IrInstGen *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, Scope *sco |
| 7134 | 7134 | return result_loc_inst; |
| 7135 | 7135 | } |
| 7136 | 7136 | |
| 7137 | static IrInstGen *ir_analyze_struct_literal_to_union(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 7138 | IrInstGen *struct_ptr, ZigType *struct_type, ZigType *union_type) | |
| 7137 | static Stage1AirInst *ir_analyze_struct_literal_to_union(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 7138 | Stage1AirInst *struct_ptr, ZigType *struct_type, ZigType *union_type) | |
| 7139 | 7139 | { |
| 7140 | 7140 | Error err; |
| 7141 | 7141 | |
| ... | ... | @@ -7160,15 +7160,15 @@ static IrInstGen *ir_analyze_struct_literal_to_union(IrAnalyze *ira, Scope *scop |
| 7160 | 7160 | if (payload_type == nullptr) |
| 7161 | 7161 | return ira->codegen->invalid_inst_gen; |
| 7162 | 7162 | |
| 7163 | IrInstGen *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, only_field, struct_ptr, | |
| 7163 | Stage1AirInst *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, only_field, struct_ptr, | |
| 7164 | 7164 | struct_type, false); |
| 7165 | 7165 | if (type_is_invalid(field_ptr->value->type)) |
| 7166 | 7166 | return ira->codegen->invalid_inst_gen; |
| 7167 | IrInstGen *field_value = ir_get_deref(ira, scope, source_node, field_ptr, nullptr); | |
| 7167 | Stage1AirInst *field_value = ir_get_deref(ira, scope, source_node, field_ptr, nullptr); | |
| 7168 | 7168 | if (type_is_invalid(field_value->value->type)) |
| 7169 | 7169 | return ira->codegen->invalid_inst_gen; |
| 7170 | 7170 | |
| 7171 | IrInstGen *casted_value = ir_implicit_cast(ira, field_value, payload_type); | |
| 7171 | Stage1AirInst *casted_value = ir_implicit_cast(ira, field_value, payload_type); | |
| 7172 | 7172 | if (type_is_invalid(casted_value->value->type)) |
| 7173 | 7173 | return ira->codegen->invalid_inst_gen; |
| 7174 | 7174 | |
| ... | ... | @@ -7177,7 +7177,7 @@ static IrInstGen *ir_analyze_struct_literal_to_union(IrAnalyze *ira, Scope *scop |
| 7177 | 7177 | if (val == nullptr) |
| 7178 | 7178 | return ira->codegen->invalid_inst_gen; |
| 7179 | 7179 | |
| 7180 | IrInstGen *result = ir_const(ira, scope, source_node, union_type); | |
| 7180 | Stage1AirInst *result = ir_const(ira, scope, source_node, union_type); | |
| 7181 | 7181 | bigint_init_bigint(&result->value->data.x_union.tag, &union_field->enum_field->value); |
| 7182 | 7182 | result->value->data.x_union.payload = val; |
| 7183 | 7183 | |
| ... | ... | @@ -7187,18 +7187,18 @@ static IrInstGen *ir_analyze_struct_literal_to_union(IrAnalyze *ira, Scope *scop |
| 7187 | 7187 | return result; |
| 7188 | 7188 | } |
| 7189 | 7189 | |
| 7190 | IrInstGen *result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, no_result_loc(), | |
| 7190 | Stage1AirInst *result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, no_result_loc(), | |
| 7191 | 7191 | union_type, nullptr, true, true); |
| 7192 | 7192 | if (type_is_invalid(result_loc_inst->value->type) || result_loc_inst->value->type->id == ZigTypeIdUnreachable) { |
| 7193 | 7193 | return ira->codegen->invalid_inst_gen; |
| 7194 | 7194 | } |
| 7195 | 7195 | |
| 7196 | IrInstGen *payload_ptr = ir_analyze_container_field_ptr(ira, only_field->name, | |
| 7196 | Stage1AirInst *payload_ptr = ir_analyze_container_field_ptr(ira, only_field->name, | |
| 7197 | 7197 | scope, source_node, result_loc_inst, source_node, union_type, true); |
| 7198 | 7198 | if (type_is_invalid(payload_ptr->value->type)) |
| 7199 | 7199 | return ira->codegen->invalid_inst_gen; |
| 7200 | 7200 | |
| 7201 | IrInstGen *store_ptr_inst = ir_analyze_store_ptr(ira, scope, source_node, payload_ptr, casted_value, false); | |
| 7201 | Stage1AirInst *store_ptr_inst = ir_analyze_store_ptr(ira, scope, source_node, payload_ptr, casted_value, false); | |
| 7202 | 7202 | if (type_is_invalid(store_ptr_inst->value->type)) |
| 7203 | 7203 | return ira->codegen->invalid_inst_gen; |
| 7204 | 7204 | |
| ... | ... | @@ -7243,30 +7243,30 @@ static Error ir_cast_ptr_align(IrAnalyze *ira, Scope *scope, AstNode *source_nod |
| 7243 | 7243 | return ErrorNone; |
| 7244 | 7244 | } |
| 7245 | 7245 | |
| 7246 | static IrInstGen *ir_analyze_struct_value_field_value(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 7247 | IrInstGen *struct_operand, TypeStructField *field) | |
| 7246 | static Stage1AirInst *ir_analyze_struct_value_field_value(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 7247 | Stage1AirInst *struct_operand, TypeStructField *field) | |
| 7248 | 7248 | { |
| 7249 | IrInstGen *struct_ptr = ir_get_ref(ira, scope, source_node, struct_operand, true, false); | |
| 7249 | Stage1AirInst *struct_ptr = ir_get_ref(ira, scope, source_node, struct_operand, true, false); | |
| 7250 | 7250 | if (type_is_invalid(struct_ptr->value->type)) |
| 7251 | 7251 | return ira->codegen->invalid_inst_gen; |
| 7252 | IrInstGen *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, field, struct_ptr, | |
| 7252 | Stage1AirInst *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, field, struct_ptr, | |
| 7253 | 7253 | struct_operand->value->type, false); |
| 7254 | 7254 | if (type_is_invalid(field_ptr->value->type)) |
| 7255 | 7255 | return ira->codegen->invalid_inst_gen; |
| 7256 | 7256 | return ir_get_deref(ira, scope, source_node, field_ptr, nullptr); |
| 7257 | 7257 | } |
| 7258 | 7258 | |
| 7259 | static IrInstGen *ir_analyze_optional_value_payload_value(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 7260 | IrInstGen *optional_operand, bool safety_check_on) | |
| 7259 | static Stage1AirInst *ir_analyze_optional_value_payload_value(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 7260 | Stage1AirInst *optional_operand, bool safety_check_on) | |
| 7261 | 7261 | { |
| 7262 | IrInstGen *opt_ptr = ir_get_ref(ira, scope, source_node, optional_operand, true, false); | |
| 7263 | IrInstGen *payload_ptr = ir_analyze_unwrap_optional_payload(ira, scope, source_node, opt_ptr, | |
| 7262 | Stage1AirInst *opt_ptr = ir_get_ref(ira, scope, source_node, optional_operand, true, false); | |
| 7263 | Stage1AirInst *payload_ptr = ir_analyze_unwrap_optional_payload(ira, scope, source_node, opt_ptr, | |
| 7264 | 7264 | safety_check_on, false); |
| 7265 | 7265 | return ir_get_deref(ira, scope, source_node, payload_ptr, nullptr); |
| 7266 | 7266 | } |
| 7267 | 7267 | |
| 7268 | static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 7269 | ZigType *wanted_type, IrInstGen *value) | |
| 7268 | static Stage1AirInst *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 7269 | ZigType *wanted_type, Stage1AirInst *value) | |
| 7270 | 7270 | { |
| 7271 | 7271 | Error err; |
| 7272 | 7272 | ZigType *actual_type = value->value->type; |
| ... | ... | @@ -7336,7 +7336,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7336 | 7336 | actual_type->data.pointer.child_type->data.array.child_type, source_node, |
| 7337 | 7337 | !wanted_child_type->data.pointer.is_const).id == ConstCastResultIdOk) |
| 7338 | 7338 | { |
| 7339 | IrInstGen *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, scope, source_node, value, | |
| 7339 | Stage1AirInst *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, scope, source_node, value, | |
| 7340 | 7340 | wanted_child_type); |
| 7341 | 7341 | if (type_is_invalid(cast1->value->type)) |
| 7342 | 7342 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -7373,11 +7373,11 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7373 | 7373 | actual_type->id == ZigTypeIdComptimeInt || |
| 7374 | 7374 | actual_type->id == ZigTypeIdComptimeFloat) |
| 7375 | 7375 | { |
| 7376 | IrInstGen *cast1 = ir_analyze_cast(ira, scope, source_node, wanted_type->data.error_union.payload_type, value); | |
| 7376 | Stage1AirInst *cast1 = ir_analyze_cast(ira, scope, source_node, wanted_type->data.error_union.payload_type, value); | |
| 7377 | 7377 | if (type_is_invalid(cast1->value->type)) |
| 7378 | 7378 | return ira->codegen->invalid_inst_gen; |
| 7379 | 7379 | |
| 7380 | IrInstGen *cast2 = ir_analyze_cast(ira, scope, source_node, wanted_type, cast1); | |
| 7380 | Stage1AirInst *cast2 = ir_analyze_cast(ira, scope, source_node, wanted_type, cast1); | |
| 7381 | 7381 | if (type_is_invalid(cast2->value->type)) |
| 7382 | 7382 | return ira->codegen->invalid_inst_gen; |
| 7383 | 7383 | |
| ... | ... | @@ -7394,13 +7394,13 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7394 | 7394 | wanted_type->id == ZigTypeIdFloat || wanted_type->id == ZigTypeIdComptimeFloat)) |
| 7395 | 7395 | { |
| 7396 | 7396 | if (value->value->special == ConstValSpecialUndef) { |
| 7397 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 7397 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 7398 | 7398 | result->value->special = ConstValSpecialUndef; |
| 7399 | 7399 | return result; |
| 7400 | 7400 | } |
| 7401 | 7401 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { |
| 7402 | 7402 | if (wanted_type->id == ZigTypeIdComptimeInt || wanted_type->id == ZigTypeIdInt) { |
| 7403 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 7403 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 7404 | 7404 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { |
| 7405 | 7405 | copy_const_val(ira->codegen, result->value, value->value); |
| 7406 | 7406 | result->value->type = wanted_type; |
| ... | ... | @@ -7409,7 +7409,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7409 | 7409 | } |
| 7410 | 7410 | return result; |
| 7411 | 7411 | } else if (wanted_type->id == ZigTypeIdComptimeFloat || wanted_type->id == ZigTypeIdFloat) { |
| 7412 | IrInstGen *result = ir_const(ira, scope, source_node, wanted_type); | |
| 7412 | Stage1AirInst *result = ir_const(ira, scope, source_node, wanted_type); | |
| 7413 | 7413 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { |
| 7414 | 7414 | BigFloat bf; |
| 7415 | 7415 | bigfloat_init_bigint(&bf, &value->value->data.x_bigint); |
| ... | ... | @@ -7457,11 +7457,11 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7457 | 7457 | actual_type->data.pointer.ptr_len == PtrLenSingle && |
| 7458 | 7458 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 7459 | 7459 | { |
| 7460 | IrInstGen *cast1 = ir_analyze_cast(ira, scope, source_node, wanted_type->data.maybe.child_type, value); | |
| 7460 | Stage1AirInst *cast1 = ir_analyze_cast(ira, scope, source_node, wanted_type->data.maybe.child_type, value); | |
| 7461 | 7461 | if (type_is_invalid(cast1->value->type)) |
| 7462 | 7462 | return ira->codegen->invalid_inst_gen; |
| 7463 | 7463 | |
| 7464 | IrInstGen *cast2 = ir_analyze_cast(ira, scope, source_node, wanted_type, cast1); | |
| 7464 | Stage1AirInst *cast2 = ir_analyze_cast(ira, scope, source_node, wanted_type, cast1); | |
| 7465 | 7465 | if (type_is_invalid(cast2->value->type)) |
| 7466 | 7466 | return ira->codegen->invalid_inst_gen; |
| 7467 | 7467 | |
| ... | ... | @@ -7543,11 +7543,11 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7543 | 7543 | } |
| 7544 | 7544 | if (ok_align) { |
| 7545 | 7545 | if (wanted_type->id == ZigTypeIdErrorUnion) { |
| 7546 | IrInstGen *cast1 = ir_analyze_cast(ira, scope, source_node, slice_type, value); | |
| 7546 | Stage1AirInst *cast1 = ir_analyze_cast(ira, scope, source_node, slice_type, value); | |
| 7547 | 7547 | if (type_is_invalid(cast1->value->type)) |
| 7548 | 7548 | return ira->codegen->invalid_inst_gen; |
| 7549 | 7549 | |
| 7550 | IrInstGen *cast2 = ir_analyze_cast(ira, scope, source_node, wanted_type, cast1); | |
| 7550 | Stage1AirInst *cast2 = ir_analyze_cast(ira, scope, source_node, wanted_type, cast1); | |
| 7551 | 7551 | if (type_is_invalid(cast2->value->type)) |
| 7552 | 7552 | return ira->codegen->invalid_inst_gen; |
| 7553 | 7553 | |
| ... | ... | @@ -7623,7 +7623,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7623 | 7623 | } |
| 7624 | 7624 | } |
| 7625 | 7625 | if (ok) { |
| 7626 | IrInstGen *cast1 = ir_analyze_frame_ptr_to_anyframe(ira, scope, source_node, value, anyframe_type); | |
| 7626 | Stage1AirInst *cast1 = ir_analyze_frame_ptr_to_anyframe(ira, scope, source_node, value, anyframe_type); | |
| 7627 | 7627 | if (anyframe_type == wanted_type) |
| 7628 | 7628 | return cast1; |
| 7629 | 7629 | return ir_analyze_cast(ira, scope, source_node, wanted_type, cast1); |
| ... | ... | @@ -7678,7 +7678,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7678 | 7678 | if (actual_type->id == ZigTypeIdEnumLiteral && |
| 7679 | 7679 | (wanted_type->id == ZigTypeIdOptional && wanted_type->data.maybe.child_type->id == ZigTypeIdEnum)) |
| 7680 | 7680 | { |
| 7681 | IrInstGen *result = ir_analyze_enum_literal(ira, scope, source_node, value, wanted_type->data.maybe.child_type); | |
| 7681 | Stage1AirInst *result = ir_analyze_enum_literal(ira, scope, source_node, value, wanted_type->data.maybe.child_type); | |
| 7682 | 7682 | if (type_is_invalid(result->value->type)) |
| 7683 | 7683 | return result; |
| 7684 | 7684 | |
| ... | ... | @@ -7689,7 +7689,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7689 | 7689 | if (actual_type->id == ZigTypeIdEnumLiteral && |
| 7690 | 7690 | (wanted_type->id == ZigTypeIdErrorUnion && wanted_type->data.error_union.payload_type->id == ZigTypeIdEnum)) |
| 7691 | 7691 | { |
| 7692 | IrInstGen *result = ir_analyze_enum_literal(ira, scope, source_node, value, wanted_type->data.error_union.payload_type); | |
| 7692 | Stage1AirInst *result = ir_analyze_enum_literal(ira, scope, source_node, value, wanted_type->data.error_union.payload_type); | |
| 7693 | 7693 | if (type_is_invalid(result->value->type)) |
| 7694 | 7694 | return result; |
| 7695 | 7695 | |
| ... | ... | @@ -7751,7 +7751,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7751 | 7751 | slice_ptr_type->data.pointer.sentinel)))) |
| 7752 | 7752 | { |
| 7753 | 7753 | TypeStructField *ptr_field = actual_type->data.structure.fields[slice_ptr_index]; |
| 7754 | IrInstGen *slice_ptr = ir_analyze_struct_value_field_value(ira, scope, source_node, value, ptr_field); | |
| 7754 | Stage1AirInst *slice_ptr = ir_analyze_struct_value_field_value(ira, scope, source_node, value, ptr_field); | |
| 7755 | 7755 | return ir_implicit_cast2(ira, scope, source_node, slice_ptr, wanted_type); |
| 7756 | 7756 | } |
| 7757 | 7757 | } |
| ... | ... | @@ -7835,31 +7835,31 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7835 | 7835 | if (wanted_type->id == ZigTypeIdArray && (is_array_init || field_count == 0) && |
| 7836 | 7836 | wanted_type->data.array.len == field_count) |
| 7837 | 7837 | { |
| 7838 | IrInstGen *struct_ptr = ir_get_ref(ira, scope, source_node, value, true, false); | |
| 7838 | Stage1AirInst *struct_ptr = ir_get_ref(ira, scope, source_node, value, true, false); | |
| 7839 | 7839 | if (type_is_invalid(struct_ptr->value->type)) |
| 7840 | 7840 | return ira->codegen->invalid_inst_gen; |
| 7841 | 7841 | |
| 7842 | IrInstGen *ptr = ir_analyze_struct_literal_to_array(ira, scope, source_node, struct_ptr, actual_type, wanted_type); | |
| 7842 | Stage1AirInst *ptr = ir_analyze_struct_literal_to_array(ira, scope, source_node, struct_ptr, actual_type, wanted_type); | |
| 7843 | 7843 | if (ptr->value->type->id != ZigTypeIdPointer) |
| 7844 | 7844 | return ptr; |
| 7845 | 7845 | return ir_get_deref(ira, scope, source_node, ptr, nullptr); |
| 7846 | 7846 | } else if (wanted_type->id == ZigTypeIdStruct && !is_slice(wanted_type) && |
| 7847 | 7847 | (!is_array_init || field_count == 0)) |
| 7848 | 7848 | { |
| 7849 | IrInstGen *struct_ptr = ir_get_ref(ira, scope, source_node, value, true, false); | |
| 7849 | Stage1AirInst *struct_ptr = ir_get_ref(ira, scope, source_node, value, true, false); | |
| 7850 | 7850 | if (type_is_invalid(struct_ptr->value->type)) |
| 7851 | 7851 | return ira->codegen->invalid_inst_gen; |
| 7852 | 7852 | |
| 7853 | IrInstGen *ptr = ir_analyze_struct_literal_to_struct(ira, scope, source_node, struct_ptr, actual_type, wanted_type); | |
| 7853 | Stage1AirInst *ptr = ir_analyze_struct_literal_to_struct(ira, scope, source_node, struct_ptr, actual_type, wanted_type); | |
| 7854 | 7854 | if (ptr->value->type->id != ZigTypeIdPointer) |
| 7855 | 7855 | return ptr; |
| 7856 | 7856 | return ir_get_deref(ira, scope, source_node, ptr, nullptr); |
| 7857 | 7857 | } else if (wanted_type->id == ZigTypeIdUnion && !is_array_init && field_count == 1) { |
| 7858 | IrInstGen *struct_ptr = ir_get_ref(ira, scope, source_node, value, true, false); | |
| 7858 | Stage1AirInst *struct_ptr = ir_get_ref(ira, scope, source_node, value, true, false); | |
| 7859 | 7859 | if (type_is_invalid(struct_ptr->value->type)) |
| 7860 | 7860 | return ira->codegen->invalid_inst_gen; |
| 7861 | 7861 | |
| 7862 | IrInstGen *ptr = ir_analyze_struct_literal_to_union(ira, scope, source_node, struct_ptr, actual_type, wanted_type); | |
| 7862 | Stage1AirInst *ptr = ir_analyze_struct_literal_to_union(ira, scope, source_node, struct_ptr, actual_type, wanted_type); | |
| 7863 | 7863 | if (ptr->value->type->id != ZigTypeIdPointer) |
| 7864 | 7864 | return ptr; |
| 7865 | 7865 | return ir_get_deref(ira, scope, source_node, ptr, nullptr); |
| ... | ... | @@ -7881,19 +7881,19 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7881 | 7881 | if (wanted_child->id == ZigTypeIdArray && (is_array_init || field_count == 0) && |
| 7882 | 7882 | wanted_child->data.array.len == field_count && (const_ok || field_count == 0)) |
| 7883 | 7883 | { |
| 7884 | IrInstGen *res = ir_analyze_struct_literal_to_array(ira, scope, source_node, value, anon_type, wanted_child); | |
| 7884 | Stage1AirInst *res = ir_analyze_struct_literal_to_array(ira, scope, source_node, value, anon_type, wanted_child); | |
| 7885 | 7885 | if (res->value->type->id == ZigTypeIdPointer) |
| 7886 | 7886 | return res; |
| 7887 | 7887 | return ir_get_ref(ira, scope, source_node, res, actual_type->data.pointer.is_const, actual_type->data.pointer.is_volatile); |
| 7888 | 7888 | } else if (wanted_child->id == ZigTypeIdStruct && !is_slice(wanted_type) && |
| 7889 | 7889 | (!is_array_init || field_count == 0) && const_ok) |
| 7890 | 7890 | { |
| 7891 | IrInstGen *res = ir_analyze_struct_literal_to_struct(ira, scope, source_node, value, anon_type, wanted_child); | |
| 7891 | Stage1AirInst *res = ir_analyze_struct_literal_to_struct(ira, scope, source_node, value, anon_type, wanted_child); | |
| 7892 | 7892 | if (res->value->type->id == ZigTypeIdPointer) |
| 7893 | 7893 | return res; |
| 7894 | 7894 | return ir_get_ref(ira, scope, source_node, res, actual_type->data.pointer.is_const, actual_type->data.pointer.is_volatile); |
| 7895 | 7895 | } else if (wanted_child->id == ZigTypeIdUnion && !is_array_init && field_count == 1 && const_ok) { |
| 7896 | IrInstGen *res = ir_analyze_struct_literal_to_union(ira, scope, source_node, value, anon_type, wanted_child); | |
| 7896 | Stage1AirInst *res = ir_analyze_struct_literal_to_union(ira, scope, source_node, value, anon_type, wanted_child); | |
| 7897 | 7897 | if (res->value->type->id == ZigTypeIdPointer) |
| 7898 | 7898 | return res; |
| 7899 | 7899 | return ir_get_ref(ira, scope, source_node, res, actual_type->data.pointer.is_const, actual_type->data.pointer.is_volatile); |
| ... | ... | @@ -7905,7 +7905,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7905 | 7905 | { |
| 7906 | 7906 | ZigType *slice_child_type = slice_type->data.pointer.child_type; |
| 7907 | 7907 | ZigType *slice_array_type = get_array_type(ira->codegen, slice_child_type, field_count, nullptr); |
| 7908 | IrInstGen *res = ir_analyze_struct_literal_to_array(ira, scope, source_node, value, anon_type, slice_array_type); | |
| 7908 | Stage1AirInst *res = ir_analyze_struct_literal_to_array(ira, scope, source_node, value, anon_type, slice_array_type); | |
| 7909 | 7909 | if (type_is_invalid(res->value->type)) |
| 7910 | 7910 | return ira->codegen->invalid_inst_gen; |
| 7911 | 7911 | if (res->value->type->id != ZigTypeIdPointer) |
| ... | ... | @@ -7923,7 +7923,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7923 | 7923 | |
| 7924 | 7924 | // T to ?U, where T implicitly casts to U |
| 7925 | 7925 | if (wanted_type->id == ZigTypeIdOptional && actual_type->id != ZigTypeIdOptional) { |
| 7926 | IrInstGen *cast1 = ir_implicit_cast2(ira, scope, source_node, value, wanted_type->data.maybe.child_type); | |
| 7926 | Stage1AirInst *cast1 = ir_implicit_cast2(ira, scope, source_node, value, wanted_type->data.maybe.child_type); | |
| 7927 | 7927 | if (type_is_invalid(cast1->value->type)) |
| 7928 | 7928 | return ira->codegen->invalid_inst_gen; |
| 7929 | 7929 | return ir_implicit_cast2(ira, scope, source_node, cast1, wanted_type); |
| ... | ... | @@ -7933,7 +7933,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7933 | 7933 | if (wanted_type->id == ZigTypeIdErrorUnion && actual_type->id != ZigTypeIdErrorUnion && |
| 7934 | 7934 | actual_type->id != ZigTypeIdErrorSet) |
| 7935 | 7935 | { |
| 7936 | IrInstGen *cast1 = ir_implicit_cast2(ira, scope, source_node, value, wanted_type->data.error_union.payload_type); | |
| 7936 | Stage1AirInst *cast1 = ir_implicit_cast2(ira, scope, source_node, value, wanted_type->data.error_union.payload_type); | |
| 7937 | 7937 | if (type_is_invalid(cast1->value->type)) |
| 7938 | 7938 | return ira->codegen->invalid_inst_gen; |
| 7939 | 7939 | return ir_implicit_cast2(ira, scope, source_node, cast1, wanted_type); |
| ... | ... | @@ -7947,8 +7947,8 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 7947 | 7947 | return ira->codegen->invalid_inst_gen; |
| 7948 | 7948 | } |
| 7949 | 7949 | |
| 7950 | static IrInstGen *ir_implicit_cast2(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 7951 | IrInstGen *value, ZigType *expected_type) | |
| 7950 | static Stage1AirInst *ir_implicit_cast2(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 7951 | Stage1AirInst *value, ZigType *expected_type) | |
| 7952 | 7952 | { |
| 7953 | 7953 | assert(value); |
| 7954 | 7954 | assert(!expected_type || !type_is_invalid(expected_type)); |
| ... | ... | @@ -7964,11 +7964,11 @@ static IrInstGen *ir_implicit_cast2(IrAnalyze *ira, Scope *scope, AstNode *sourc |
| 7964 | 7964 | return ir_analyze_cast(ira, scope, source_node, expected_type, value); |
| 7965 | 7965 | } |
| 7966 | 7966 | |
| 7967 | static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *expected_type) { | |
| 7967 | static Stage1AirInst *ir_implicit_cast(IrAnalyze *ira, Stage1AirInst *value, ZigType *expected_type) { | |
| 7968 | 7968 | return ir_implicit_cast2(ira, value->scope, value->source_node, value, expected_type); |
| 7969 | 7969 | } |
| 7970 | 7970 | |
| 7971 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstGen *ptr) { | |
| 7971 | static ZigType *get_ptr_elem_type(CodeGen *g, Stage1AirInst *ptr) { | |
| 7972 | 7972 | ir_assert(ptr->value->type->id == ZigTypeIdPointer, ptr); |
| 7973 | 7973 | ZigType *elem_type = ptr->value->type->data.pointer.child_type; |
| 7974 | 7974 | if (elem_type != g->builtin_types.entry_anytype) |
| ... | ... | @@ -7982,7 +7982,7 @@ static ZigType *get_ptr_elem_type(CodeGen *g, IrInstGen *ptr) { |
| 7982 | 7982 | return pointee->type; |
| 7983 | 7983 | } |
| 7984 | 7984 | |
| 7985 | static IrInstGen *ir_get_deref(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *ptr, | |
| 7985 | static Stage1AirInst *ir_get_deref(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *ptr, | |
| 7986 | 7986 | ResultLoc *result_loc) |
| 7987 | 7987 | { |
| 7988 | 7988 | Error err; |
| ... | ... | @@ -8027,7 +8027,7 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, Scope *scope, AstNode *source_nod |
| 8027 | 8027 | child_type = pointee->type; |
| 8028 | 8028 | } |
| 8029 | 8029 | if (pointee->special != ConstValSpecialRuntime) { |
| 8030 | IrInstGen *result = ir_const(ira, scope, source_node, child_type); | |
| 8030 | Stage1AirInst *result = ir_const(ira, scope, source_node, child_type); | |
| 8031 | 8031 | |
| 8032 | 8032 | if ((err = ir_read_const_ptr(ira, ira->codegen, source_node, result->value, |
| 8033 | 8033 | ptr->value))) |
| ... | ... | @@ -8041,25 +8041,25 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, Scope *scope, AstNode *source_nod |
| 8041 | 8041 | } |
| 8042 | 8042 | |
| 8043 | 8043 | // if the instruction is a const ref instruction we can skip it |
| 8044 | if (ptr->id == IrInstGenIdRef) { | |
| 8045 | IrInstGenRef *ref_inst = reinterpret_cast<IrInstGenRef *>(ptr); | |
| 8044 | if (ptr->id == Stage1AirInstIdRef) { | |
| 8045 | Stage1AirInstRef *ref_inst = reinterpret_cast<Stage1AirInstRef *>(ptr); | |
| 8046 | 8046 | return ref_inst->operand; |
| 8047 | 8047 | } |
| 8048 | 8048 | |
| 8049 | 8049 | // If the instruction is a element pointer instruction to a vector, we emit |
| 8050 | 8050 | // vector element extract instruction rather than load pointer. If the |
| 8051 | 8051 | // pointer type has non-VECTOR_INDEX_RUNTIME value, it would have been |
| 8052 | // possible to implement this in the codegen for IrInstGenLoadPtr. | |
| 8052 | // possible to implement this in the codegen for Stage1AirInstLoadPtr. | |
| 8053 | 8053 | // However if it has VECTOR_INDEX_RUNTIME then we must emit a compile error |
| 8054 | 8054 | // if the vector index cannot be determined right here, right now, because |
| 8055 | 8055 | // the type information does not contain enough information to actually |
| 8056 | 8056 | // perform a dereference. |
| 8057 | 8057 | if (ptr_type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { |
| 8058 | if (ptr->id == IrInstGenIdElemPtr) { | |
| 8059 | IrInstGenElemPtr *elem_ptr = (IrInstGenElemPtr *)ptr; | |
| 8060 | IrInstGen *vector_loaded = ir_get_deref(ira, elem_ptr->array_ptr->scope, | |
| 8058 | if (ptr->id == Stage1AirInstIdElemPtr) { | |
| 8059 | Stage1AirInstElemPtr *elem_ptr = (Stage1AirInstElemPtr *)ptr; | |
| 8060 | Stage1AirInst *vector_loaded = ir_get_deref(ira, elem_ptr->array_ptr->scope, | |
| 8061 | 8061 | elem_ptr->array_ptr->source_node, elem_ptr->array_ptr, nullptr); |
| 8062 | IrInstGen *elem_index = elem_ptr->elem_index; | |
| 8062 | Stage1AirInst *elem_index = elem_ptr->elem_index; | |
| 8063 | 8063 | return ir_build_vector_extract_elem(ira, scope, source_node, vector_loaded, elem_index); |
| 8064 | 8064 | } |
| 8065 | 8065 | ir_add_error(ira, ptr, |
| ... | ... | @@ -8067,7 +8067,7 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, Scope *scope, AstNode *source_nod |
| 8067 | 8067 | return ira->codegen->invalid_inst_gen; |
| 8068 | 8068 | } |
| 8069 | 8069 | |
| 8070 | IrInstGen *result_loc_inst; | |
| 8070 | Stage1AirInst *result_loc_inst; | |
| 8071 | 8071 | if (ptr_type->data.pointer.host_int_bytes != 0 && handle_is_ptr(ira->codegen, child_type)) { |
| 8072 | 8072 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 8073 | 8073 | result_loc_inst = ir_resolve_result(ira, ira->suspend_source_instr, result_loc, child_type, nullptr, true, true); |
| ... | ... | @@ -8104,7 +8104,7 @@ static bool ir_resolve_const_align(CodeGen *codegen, Stage1Air *exec, AstNode *s |
| 8104 | 8104 | return true; |
| 8105 | 8105 | } |
| 8106 | 8106 | |
| 8107 | static bool ir_resolve_align(IrAnalyze *ira, IrInstGen *value, ZigType *elem_type, uint32_t *out) { | |
| 8107 | static bool ir_resolve_align(IrAnalyze *ira, Stage1AirInst *value, ZigType *elem_type, uint32_t *out) { | |
| 8108 | 8108 | if (type_is_invalid(value->value->type)) |
| 8109 | 8109 | return false; |
| 8110 | 8110 | |
| ... | ... | @@ -8125,7 +8125,7 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstGen *value, ZigType *elem_typ |
| 8125 | 8125 | } |
| 8126 | 8126 | } |
| 8127 | 8127 | |
| 8128 | IrInstGen *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen)); | |
| 8128 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen)); | |
| 8129 | 8129 | if (type_is_invalid(casted_value->value->type)) |
| 8130 | 8130 | return false; |
| 8131 | 8131 | |
| ... | ... | @@ -8133,11 +8133,11 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstGen *value, ZigType *elem_typ |
| 8133 | 8133 | casted_value->value, out); |
| 8134 | 8134 | } |
| 8135 | 8135 | |
| 8136 | static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstGen *value, ZigType *int_type, uint64_t *out) { | |
| 8136 | static bool ir_resolve_unsigned(IrAnalyze *ira, Stage1AirInst *value, ZigType *int_type, uint64_t *out) { | |
| 8137 | 8137 | if (type_is_invalid(value->value->type)) |
| 8138 | 8138 | return false; |
| 8139 | 8139 | |
| 8140 | IrInstGen *casted_value = ir_implicit_cast(ira, value, int_type); | |
| 8140 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, int_type); | |
| 8141 | 8141 | if (type_is_invalid(casted_value->value->type)) |
| 8142 | 8142 | return false; |
| 8143 | 8143 | |
| ... | ... | @@ -8149,15 +8149,15 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstGen *value, ZigType *int_t |
| 8149 | 8149 | return true; |
| 8150 | 8150 | } |
| 8151 | 8151 | |
| 8152 | static bool ir_resolve_usize(IrAnalyze *ira, IrInstGen *value, uint64_t *out) { | |
| 8152 | static bool ir_resolve_usize(IrAnalyze *ira, Stage1AirInst *value, uint64_t *out) { | |
| 8153 | 8153 | return ir_resolve_unsigned(ira, value, ira->codegen->builtin_types.entry_usize, out); |
| 8154 | 8154 | } |
| 8155 | 8155 | |
| 8156 | static bool ir_resolve_bool(IrAnalyze *ira, IrInstGen *value, bool *out) { | |
| 8156 | static bool ir_resolve_bool(IrAnalyze *ira, Stage1AirInst *value, bool *out) { | |
| 8157 | 8157 | if (type_is_invalid(value->value->type)) |
| 8158 | 8158 | return false; |
| 8159 | 8159 | |
| 8160 | IrInstGen *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); | |
| 8160 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); | |
| 8161 | 8161 | if (type_is_invalid(casted_value->value->type)) |
| 8162 | 8162 | return false; |
| 8163 | 8163 | |
| ... | ... | @@ -8169,7 +8169,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstGen *value, bool *out) { |
| 8169 | 8169 | return true; |
| 8170 | 8170 | } |
| 8171 | 8171 | |
| 8172 | static bool ir_resolve_comptime(IrAnalyze *ira, IrInstGen *value, bool *out) { | |
| 8172 | static bool ir_resolve_comptime(IrAnalyze *ira, Stage1AirInst *value, bool *out) { | |
| 8173 | 8173 | if (!value) { |
| 8174 | 8174 | *out = false; |
| 8175 | 8175 | return true; |
| ... | ... | @@ -8177,13 +8177,13 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstGen *value, bool *out) { |
| 8177 | 8177 | return ir_resolve_bool(ira, value, out); |
| 8178 | 8178 | } |
| 8179 | 8179 | |
| 8180 | static bool ir_resolve_reduce_op(IrAnalyze *ira, IrInstGen *value, ReduceOp *out) { | |
| 8180 | static bool ir_resolve_reduce_op(IrAnalyze *ira, Stage1AirInst *value, ReduceOp *out) { | |
| 8181 | 8181 | if (type_is_invalid(value->value->type)) |
| 8182 | 8182 | return false; |
| 8183 | 8183 | |
| 8184 | 8184 | ZigType *reduce_op_type = get_builtin_type(ira->codegen, "ReduceOp"); |
| 8185 | 8185 | |
| 8186 | IrInstGen *casted_value = ir_implicit_cast(ira, value, reduce_op_type); | |
| 8186 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, reduce_op_type); | |
| 8187 | 8187 | if (type_is_invalid(casted_value->value->type)) |
| 8188 | 8188 | return false; |
| 8189 | 8189 | |
| ... | ... | @@ -8195,13 +8195,13 @@ static bool ir_resolve_reduce_op(IrAnalyze *ira, IrInstGen *value, ReduceOp *out |
| 8195 | 8195 | return true; |
| 8196 | 8196 | } |
| 8197 | 8197 | |
| 8198 | static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstGen *value, AtomicOrder *out) { | |
| 8198 | static bool ir_resolve_atomic_order(IrAnalyze *ira, Stage1AirInst *value, AtomicOrder *out) { | |
| 8199 | 8199 | if (type_is_invalid(value->value->type)) |
| 8200 | 8200 | return false; |
| 8201 | 8201 | |
| 8202 | 8202 | ZigType *atomic_order_type = get_builtin_type(ira->codegen, "AtomicOrder"); |
| 8203 | 8203 | |
| 8204 | IrInstGen *casted_value = ir_implicit_cast(ira, value, atomic_order_type); | |
| 8204 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, atomic_order_type); | |
| 8205 | 8205 | if (type_is_invalid(casted_value->value->type)) |
| 8206 | 8206 | return false; |
| 8207 | 8207 | |
| ... | ... | @@ -8213,13 +8213,13 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstGen *value, AtomicOrde |
| 8213 | 8213 | return true; |
| 8214 | 8214 | } |
| 8215 | 8215 | |
| 8216 | static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstGen *value, AtomicRmwOp *out) { | |
| 8216 | static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, Stage1AirInst *value, AtomicRmwOp *out) { | |
| 8217 | 8217 | if (type_is_invalid(value->value->type)) |
| 8218 | 8218 | return false; |
| 8219 | 8219 | |
| 8220 | 8220 | ZigType *atomic_rmw_op_type = get_builtin_type(ira->codegen, "AtomicRmwOp"); |
| 8221 | 8221 | |
| 8222 | IrInstGen *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); | |
| 8222 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); | |
| 8223 | 8223 | if (type_is_invalid(casted_value->value->type)) |
| 8224 | 8224 | return false; |
| 8225 | 8225 | |
| ... | ... | @@ -8231,13 +8231,13 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstGen *value, AtomicRmw |
| 8231 | 8231 | return true; |
| 8232 | 8232 | } |
| 8233 | 8233 | |
| 8234 | static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstGen *value, GlobalLinkageId *out) { | |
| 8234 | static bool ir_resolve_global_linkage(IrAnalyze *ira, Stage1AirInst *value, GlobalLinkageId *out) { | |
| 8235 | 8235 | if (type_is_invalid(value->value->type)) |
| 8236 | 8236 | return false; |
| 8237 | 8237 | |
| 8238 | 8238 | ZigType *global_linkage_type = get_builtin_type(ira->codegen, "GlobalLinkage"); |
| 8239 | 8239 | |
| 8240 | IrInstGen *casted_value = ir_implicit_cast(ira, value, global_linkage_type); | |
| 8240 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, global_linkage_type); | |
| 8241 | 8241 | if (type_is_invalid(casted_value->value->type)) |
| 8242 | 8242 | return false; |
| 8243 | 8243 | |
| ... | ... | @@ -8249,13 +8249,13 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstGen *value, GlobalLi |
| 8249 | 8249 | return true; |
| 8250 | 8250 | } |
| 8251 | 8251 | |
| 8252 | static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstGen *value, FloatMode *out) { | |
| 8252 | static bool ir_resolve_float_mode(IrAnalyze *ira, Stage1AirInst *value, FloatMode *out) { | |
| 8253 | 8253 | if (type_is_invalid(value->value->type)) |
| 8254 | 8254 | return false; |
| 8255 | 8255 | |
| 8256 | 8256 | ZigType *float_mode_type = get_builtin_type(ira->codegen, "FloatMode"); |
| 8257 | 8257 | |
| 8258 | IrInstGen *casted_value = ir_implicit_cast(ira, value, float_mode_type); | |
| 8258 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, float_mode_type); | |
| 8259 | 8259 | if (type_is_invalid(casted_value->value->type)) |
| 8260 | 8260 | return false; |
| 8261 | 8261 | |
| ... | ... | @@ -8267,14 +8267,14 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstGen *value, FloatMode *o |
| 8267 | 8267 | return true; |
| 8268 | 8268 | } |
| 8269 | 8269 | |
| 8270 | static Buf *ir_resolve_str(IrAnalyze *ira, IrInstGen *value) { | |
| 8270 | static Buf *ir_resolve_str(IrAnalyze *ira, Stage1AirInst *value) { | |
| 8271 | 8271 | if (type_is_invalid(value->value->type)) |
| 8272 | 8272 | return nullptr; |
| 8273 | 8273 | |
| 8274 | 8274 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 8275 | 8275 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 8276 | 8276 | ZigType *str_type = get_slice_type(ira->codegen, ptr_type); |
| 8277 | IrInstGen *casted_value = ir_implicit_cast(ira, value, str_type); | |
| 8277 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, str_type); | |
| 8278 | 8278 | if (type_is_invalid(casted_value->value->type)) |
| 8279 | 8279 | return nullptr; |
| 8280 | 8280 | |
| ... | ... | @@ -8309,10 +8309,10 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstGen *value) { |
| 8309 | 8309 | return result; |
| 8310 | 8310 | } |
| 8311 | 8311 | |
| 8312 | static IrInstGen *ir_analyze_instruction_add_implicit_return_type(IrAnalyze *ira, | |
| 8313 | IrInstSrcAddImplicitReturnType *instruction) | |
| 8312 | static Stage1AirInst *ir_analyze_instruction_add_implicit_return_type(IrAnalyze *ira, | |
| 8313 | Stage1ZirInstAddImplicitReturnType *instruction) | |
| 8314 | 8314 | { |
| 8315 | IrInstGen *value = instruction->value->child; | |
| 8315 | Stage1AirInst *value = instruction->value->child; | |
| 8316 | 8316 | if (type_is_invalid(value->value->type)) |
| 8317 | 8317 | return ir_unreach_error(ira); |
| 8318 | 8318 | |
| ... | ... | @@ -8323,18 +8323,18 @@ static IrInstGen *ir_analyze_instruction_add_implicit_return_type(IrAnalyze *ira |
| 8323 | 8323 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 8324 | 8324 | } |
| 8325 | 8325 | |
| 8326 | static IrInstGen *ir_analyze_instruction_return(IrAnalyze *ira, IrInstSrcReturn *instruction) { | |
| 8326 | static Stage1AirInst *ir_analyze_instruction_return(IrAnalyze *ira, Stage1ZirInstReturn *instruction) { | |
| 8327 | 8327 | if (instruction->operand == nullptr) { |
| 8328 | 8328 | // result location mechanism took care of it. |
| 8329 | IrInstGen *result = ir_build_return_gen(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 8329 | Stage1AirInst *result = ir_build_return_gen(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 8330 | 8330 | return ir_finish_anal(ira, result); |
| 8331 | 8331 | } |
| 8332 | 8332 | |
| 8333 | IrInstGen *operand = instruction->operand->child; | |
| 8333 | Stage1AirInst *operand = instruction->operand->child; | |
| 8334 | 8334 | if (type_is_invalid(operand->value->type)) |
| 8335 | 8335 | return ir_unreach_error(ira); |
| 8336 | 8336 | |
| 8337 | IrInstGen *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type); | |
| 8337 | Stage1AirInst *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type); | |
| 8338 | 8338 | if (type_is_invalid(casted_operand->value->type)) { |
| 8339 | 8339 | AstNode *source_node = ira->explicit_return_type_source_node; |
| 8340 | 8340 | if (source_node != nullptr) { |
| ... | ... | @@ -8349,7 +8349,7 @@ static IrInstGen *ir_analyze_instruction_return(IrAnalyze *ira, IrInstSrcReturn |
| 8349 | 8349 | handle_is_ptr(ira->codegen, ira->explicit_return_type)) |
| 8350 | 8350 | { |
| 8351 | 8351 | // result location mechanism took care of it. |
| 8352 | IrInstGen *result = ir_build_return_gen(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 8352 | Stage1AirInst *result = ir_build_return_gen(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 8353 | 8353 | return ir_finish_anal(ira, result); |
| 8354 | 8354 | } |
| 8355 | 8355 | |
| ... | ... | @@ -8362,30 +8362,30 @@ static IrInstGen *ir_analyze_instruction_return(IrAnalyze *ira, IrInstSrcReturn |
| 8362 | 8362 | return ir_unreach_error(ira); |
| 8363 | 8363 | } |
| 8364 | 8364 | |
| 8365 | IrInstGen *result = ir_build_return_gen(ira, instruction->base.scope, instruction->base.source_node, casted_operand); | |
| 8365 | Stage1AirInst *result = ir_build_return_gen(ira, instruction->base.scope, instruction->base.source_node, casted_operand); | |
| 8366 | 8366 | return ir_finish_anal(ira, result); |
| 8367 | 8367 | } |
| 8368 | 8368 | |
| 8369 | static IrInstGen *ir_analyze_instruction_const(IrAnalyze *ira, IrInstSrcConst *instruction) { | |
| 8369 | static Stage1AirInst *ir_analyze_instruction_const(IrAnalyze *ira, Stage1ZirInstConst *instruction) { | |
| 8370 | 8370 | return ir_const_move(ira, instruction->base.scope, instruction->base.source_node, instruction->value); |
| 8371 | 8371 | } |
| 8372 | 8372 | |
| 8373 | static IrInstGen *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { | |
| 8374 | IrInstGen *op1 = bin_op_instruction->op1->child; | |
| 8373 | static Stage1AirInst *ir_analyze_bin_op_bool(IrAnalyze *ira, Stage1ZirInstBinOp *bin_op_instruction) { | |
| 8374 | Stage1AirInst *op1 = bin_op_instruction->op1->child; | |
| 8375 | 8375 | if (type_is_invalid(op1->value->type)) |
| 8376 | 8376 | return ira->codegen->invalid_inst_gen; |
| 8377 | 8377 | |
| 8378 | IrInstGen *op2 = bin_op_instruction->op2->child; | |
| 8378 | Stage1AirInst *op2 = bin_op_instruction->op2->child; | |
| 8379 | 8379 | if (type_is_invalid(op2->value->type)) |
| 8380 | 8380 | return ira->codegen->invalid_inst_gen; |
| 8381 | 8381 | |
| 8382 | 8382 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 8383 | 8383 | |
| 8384 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, bool_type); | |
| 8384 | Stage1AirInst *casted_op1 = ir_implicit_cast(ira, op1, bool_type); | |
| 8385 | 8385 | if (type_is_invalid(casted_op1->value->type)) |
| 8386 | 8386 | return ira->codegen->invalid_inst_gen; |
| 8387 | 8387 | |
| 8388 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, bool_type); | |
| 8388 | Stage1AirInst *casted_op2 = ir_implicit_cast(ira, op2, bool_type); | |
| 8389 | 8389 | if (type_is_invalid(casted_op2->value->type)) |
| 8390 | 8390 | return ira->codegen->invalid_inst_gen; |
| 8391 | 8391 | |
| ... | ... | @@ -8465,7 +8465,7 @@ static void set_optional_payload(ZigValue *opt_val, ZigValue *payload) { |
| 8465 | 8465 | } |
| 8466 | 8466 | } |
| 8467 | 8467 | |
| 8468 | static IrInstGen *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_type, | |
| 8468 | static Stage1AirInst *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_type, | |
| 8469 | 8469 | ZigValue *op1_val, ZigValue *op2_val, Scope *scope, AstNode *source_node, IrBinOp op_id, |
| 8470 | 8470 | bool one_possible_value) |
| 8471 | 8471 | { |
| ... | ... | @@ -8508,7 +8508,7 @@ static IrInstGen *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_type, |
| 8508 | 8508 | zig_unreachable(); |
| 8509 | 8509 | } |
| 8510 | 8510 | |
| 8511 | static IrInstGen *ir_try_evaluate_bin_op_cmp_const(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *op1, IrInstGen *op2, | |
| 8511 | static Stage1AirInst *ir_try_evaluate_bin_op_cmp_const(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *op1, Stage1AirInst *op2, | |
| 8512 | 8512 | ZigType *resolved_type, IrBinOp op_id) |
| 8513 | 8513 | { |
| 8514 | 8514 | assert(op1->value->type == resolved_type && op2->value->type == resolved_type); |
| ... | ... | @@ -8533,14 +8533,14 @@ static IrInstGen *ir_try_evaluate_bin_op_cmp_const(IrAnalyze *ira, Scope *scope, |
| 8533 | 8533 | return ira->codegen->invalid_inst_gen; |
| 8534 | 8534 | if (resolved_type->id != ZigTypeIdVector) |
| 8535 | 8535 | return ir_evaluate_bin_op_cmp(ira, resolved_type, op1_val, op2_val, scope, source_node, op_id, one_possible_value); |
| 8536 | IrInstGen *result = ir_const(ira, scope, source_node, | |
| 8536 | Stage1AirInst *result = ir_const(ira, scope, source_node, | |
| 8537 | 8537 | get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool)); |
| 8538 | 8538 | result->value->data.x_array.data.s_none.elements = |
| 8539 | 8539 | ira->codegen->pass1_arena->allocate<ZigValue>(resolved_type->data.vector.len); |
| 8540 | 8540 | |
| 8541 | 8541 | expand_undef_array(ira->codegen, result->value); |
| 8542 | 8542 | for (size_t i = 0;i < resolved_type->data.vector.len;i++) { |
| 8543 | IrInstGen *cur_res = ir_evaluate_bin_op_cmp(ira, resolved_type->data.vector.elem_type, | |
| 8543 | Stage1AirInst *cur_res = ir_evaluate_bin_op_cmp(ira, resolved_type->data.vector.elem_type, | |
| 8544 | 8544 | &op1_val->data.x_array.data.s_none.elements[i], |
| 8545 | 8545 | &op2_val->data.x_array.data.s_none.elements[i], |
| 8546 | 8546 | scope, source_node, op_id, one_possible_value); |
| ... | ... | @@ -8708,14 +8708,14 @@ never_mind_just_calculate_it_normally: |
| 8708 | 8708 | return nullptr; |
| 8709 | 8709 | } |
| 8710 | 8710 | if (op1_val->type->id == ZigTypeIdComptimeFloat) { |
| 8711 | IrInstGen *tmp = ir_const_noval(ira, scope, source_node); | |
| 8711 | Stage1AirInst *tmp = ir_const_noval(ira, scope, source_node); | |
| 8712 | 8712 | tmp->value = op1_val; |
| 8713 | IrInstGen *casted = ir_implicit_cast(ira, tmp, op2_val->type); | |
| 8713 | Stage1AirInst *casted = ir_implicit_cast(ira, tmp, op2_val->type); | |
| 8714 | 8714 | op1_val = casted->value; |
| 8715 | 8715 | } else if (op2_val->type->id == ZigTypeIdComptimeFloat) { |
| 8716 | IrInstGen *tmp = ir_const_noval(ira, scope, source_node); | |
| 8716 | Stage1AirInst *tmp = ir_const_noval(ira, scope, source_node); | |
| 8717 | 8717 | tmp->value = op2_val; |
| 8718 | IrInstGen *casted = ir_implicit_cast(ira, tmp, op1_val->type); | |
| 8718 | Stage1AirInst *casted = ir_implicit_cast(ira, tmp, op1_val->type); | |
| 8719 | 8719 | op2_val = casted->value; |
| 8720 | 8720 | } |
| 8721 | 8721 | Cmp cmp_result = float_cmp(op1_val, op2_val); |
| ... | ... | @@ -8768,8 +8768,8 @@ never_mind_just_calculate_it_normally: |
| 8768 | 8768 | return nullptr; |
| 8769 | 8769 | } |
| 8770 | 8770 | |
| 8771 | static IrInstGen *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 8772 | IrInstGen *op1, IrInstGen *op2, IrBinOp op_id) | |
| 8771 | static Stage1AirInst *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 8772 | Stage1AirInst *op1, Stage1AirInst *op2, IrBinOp op_id) | |
| 8773 | 8773 | { |
| 8774 | 8774 | Error err; |
| 8775 | 8775 | |
| ... | ... | @@ -8833,7 +8833,7 @@ static IrInstGen *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, Scope *scope, As |
| 8833 | 8833 | if (((opv_op1 || instr_is_comptime(op1)) && (opv_op2 || instr_is_comptime(op2))) || |
| 8834 | 8834 | (have_op1_cmp_zero && have_op2_cmp_zero)) |
| 8835 | 8835 | { |
| 8836 | IrInstGen *result_instruction = ir_const(ira, scope, source_node, result_type); | |
| 8836 | Stage1AirInst *result_instruction = ir_const(ira, scope, source_node, result_type); | |
| 8837 | 8837 | ZigValue *out_val = result_instruction->value; |
| 8838 | 8838 | if (result_type->id == ZigTypeIdVector) { |
| 8839 | 8839 | size_t len = result_type->data.vector.len; |
| ... | ... | @@ -8954,8 +8954,8 @@ static IrInstGen *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, Scope *scope, As |
| 8954 | 8954 | } |
| 8955 | 8955 | ZigType *dest_type = (result_type->id == ZigTypeIdVector) ? |
| 8956 | 8956 | get_vector_type(ira->codegen, result_type->data.vector.len, dest_scalar_type) : dest_scalar_type; |
| 8957 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | |
| 8958 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, dest_type); | |
| 8957 | Stage1AirInst *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | |
| 8958 | Stage1AirInst *casted_op2 = ir_implicit_cast(ira, op2, dest_type); | |
| 8959 | 8959 | if (type_is_invalid(casted_op1->value->type) || type_is_invalid(casted_op2->value->type)) |
| 8960 | 8960 | return ira->codegen->invalid_inst_gen; |
| 8961 | 8961 | return ir_build_bin_op_gen(ira, scope, source_node, result_type, op_id, casted_op1, casted_op2, true); |
| ... | ... | @@ -9071,10 +9071,10 @@ static IrInstGen *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, Scope *scope, As |
| 9071 | 9071 | ZigType *dest_type = (result_type->id == ZigTypeIdVector) ? |
| 9072 | 9072 | get_vector_type(ira->codegen, result_type->data.vector.len, dest_scalar_type) : dest_scalar_type; |
| 9073 | 9073 | |
| 9074 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | |
| 9074 | Stage1AirInst *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | |
| 9075 | 9075 | if (type_is_invalid(casted_op1->value->type)) |
| 9076 | 9076 | return ira->codegen->invalid_inst_gen; |
| 9077 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, dest_type); | |
| 9077 | Stage1AirInst *casted_op2 = ir_implicit_cast(ira, op2, dest_type); | |
| 9078 | 9078 | if (type_is_invalid(casted_op2->value->type)) |
| 9079 | 9079 | return ira->codegen->invalid_inst_gen; |
| 9080 | 9080 | return ir_build_bin_op_gen(ira, scope, source_node, result_type, op_id, casted_op1, casted_op2, true); |
| ... | ... | @@ -9128,8 +9128,8 @@ static bool type_is_self_comparable(ZigType *ty, bool is_equality_cmp) { |
| 9128 | 9128 | zig_unreachable(); |
| 9129 | 9129 | } |
| 9130 | 9130 | |
| 9131 | static IrInstGen *ir_try_evaluate_cmp_optional_non_optional_const(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *child_type, | |
| 9132 | IrInstGen *optional, IrInstGen *non_optional, IrBinOp op_id) | |
| 9131 | static Stage1AirInst *ir_try_evaluate_cmp_optional_non_optional_const(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *child_type, | |
| 9132 | Stage1AirInst *optional, Stage1AirInst *non_optional, IrBinOp op_id) | |
| 9133 | 9133 | { |
| 9134 | 9134 | assert(optional->value->type->id == ZigTypeIdOptional); |
| 9135 | 9135 | assert(optional->value->type->data.maybe.child_type == non_optional->value->type); |
| ... | ... | @@ -9148,12 +9148,12 @@ static IrInstGen *ir_try_evaluate_cmp_optional_non_optional_const(IrAnalyze *ira |
| 9148 | 9148 | } |
| 9149 | 9149 | |
| 9150 | 9150 | if (!optional_value_is_null(optional_val)) { |
| 9151 | IrInstGen *optional_unwrapped = ir_analyze_optional_value_payload_value(ira, scope, source_node, optional, false); | |
| 9151 | Stage1AirInst *optional_unwrapped = ir_analyze_optional_value_payload_value(ira, scope, source_node, optional, false); | |
| 9152 | 9152 | if (type_is_invalid(optional_unwrapped->value->type)) { |
| 9153 | 9153 | return ira->codegen->invalid_inst_gen; |
| 9154 | 9154 | } |
| 9155 | 9155 | |
| 9156 | IrInstGen *ret = ir_try_evaluate_bin_op_cmp_const(ira, scope, source_node, optional_unwrapped, non_optional, child_type, op_id); | |
| 9156 | Stage1AirInst *ret = ir_try_evaluate_bin_op_cmp_const(ira, scope, source_node, optional_unwrapped, non_optional, child_type, op_id); | |
| 9157 | 9157 | assert(ret != nullptr); |
| 9158 | 9158 | return ret; |
| 9159 | 9159 | } |
| ... | ... | @@ -9163,8 +9163,8 @@ static IrInstGen *ir_try_evaluate_cmp_optional_non_optional_const(IrAnalyze *ira |
| 9163 | 9163 | } |
| 9164 | 9164 | } |
| 9165 | 9165 | |
| 9166 | static IrInstGen *ir_evaluate_cmp_optional_non_optional(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *child_type, | |
| 9167 | IrInstGen *optional, IrInstGen *non_optional, IrBinOp op_id) | |
| 9166 | static Stage1AirInst *ir_evaluate_cmp_optional_non_optional(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *child_type, | |
| 9167 | Stage1AirInst *optional, Stage1AirInst *non_optional, IrBinOp op_id) | |
| 9168 | 9168 | { |
| 9169 | 9169 | assert(optional->value->type->id == ZigTypeIdOptional); |
| 9170 | 9170 | assert(optional->value->type->data.maybe.child_type == non_optional->value->type); |
| ... | ... | @@ -9174,47 +9174,47 @@ static IrInstGen *ir_evaluate_cmp_optional_non_optional(IrAnalyze *ira, Scope *s |
| 9174 | 9174 | ZigType *result_type = ira->codegen->builtin_types.entry_bool; |
| 9175 | 9175 | ir_append_basic_block_gen(&ira->new_irb, ira->new_irb.current_basic_block); |
| 9176 | 9176 | |
| 9177 | IrBasicBlockGen *null_block = ir_create_basic_block_gen(ira, scope, "CmpOptionalNonOptionalOptionalNull"); | |
| 9178 | IrBasicBlockGen *non_null_block = ir_create_basic_block_gen(ira, scope, "CmpOptionalNonOptionalOptionalNotNull"); | |
| 9179 | IrBasicBlockGen *end_block = ir_create_basic_block_gen(ira, scope, "CmpOptionalNonOptionalEnd"); | |
| 9177 | Stage1AirBasicBlock *null_block = ir_create_basic_block_gen(ira, scope, "CmpOptionalNonOptionalOptionalNull"); | |
| 9178 | Stage1AirBasicBlock *non_null_block = ir_create_basic_block_gen(ira, scope, "CmpOptionalNonOptionalOptionalNotNull"); | |
| 9179 | Stage1AirBasicBlock *end_block = ir_create_basic_block_gen(ira, scope, "CmpOptionalNonOptionalEnd"); | |
| 9180 | 9180 | |
| 9181 | IrInstGen *is_non_null = ir_build_test_non_null_gen(ira, scope, source_node, optional); | |
| 9181 | Stage1AirInst *is_non_null = ir_build_test_non_null_gen(ira, scope, source_node, optional); | |
| 9182 | 9182 | ir_build_cond_br_gen(ira, scope, source_node, is_non_null, non_null_block, null_block); |
| 9183 | 9183 | |
| 9184 | 9184 | ir_set_cursor_at_end_and_append_block_gen(&ira->new_irb, non_null_block); |
| 9185 | IrInstGen *optional_unwrapped = ir_analyze_optional_value_payload_value(ira, scope, source_node, optional, false); | |
| 9185 | Stage1AirInst *optional_unwrapped = ir_analyze_optional_value_payload_value(ira, scope, source_node, optional, false); | |
| 9186 | 9186 | if (type_is_invalid(optional_unwrapped->value->type)) { |
| 9187 | 9187 | return ira->codegen->invalid_inst_gen; |
| 9188 | 9188 | } |
| 9189 | IrInstGen *non_null_cmp_result = ir_build_bin_op_gen(ira, scope, source_node, result_type, op_id, | |
| 9189 | Stage1AirInst *non_null_cmp_result = ir_build_bin_op_gen(ira, scope, source_node, result_type, op_id, | |
| 9190 | 9190 | optional_unwrapped, non_optional, false); // safety check unnecessary for comparison operators |
| 9191 | 9191 | ir_build_br_gen(ira, scope, source_node, end_block); |
| 9192 | 9192 | |
| 9193 | 9193 | |
| 9194 | 9194 | ir_set_cursor_at_end_and_append_block_gen(&ira->new_irb, null_block); |
| 9195 | IrInstGen *null_result = ir_const_bool(ira, scope, source_node, (op_id != IrBinOpCmpEq)); | |
| 9195 | Stage1AirInst *null_result = ir_const_bool(ira, scope, source_node, (op_id != IrBinOpCmpEq)); | |
| 9196 | 9196 | ir_build_br_gen(ira, scope, source_node, end_block); |
| 9197 | 9197 | |
| 9198 | 9198 | ir_set_cursor_at_end_gen(&ira->new_irb, end_block); |
| 9199 | 9199 | int incoming_count = 2; |
| 9200 | IrBasicBlockGen **incoming_blocks = heap::c_allocator.allocate_nonzero<IrBasicBlockGen *>(incoming_count); | |
| 9200 | Stage1AirBasicBlock **incoming_blocks = heap::c_allocator.allocate_nonzero<Stage1AirBasicBlock *>(incoming_count); | |
| 9201 | 9201 | incoming_blocks[0] = null_block; |
| 9202 | 9202 | incoming_blocks[1] = non_null_block; |
| 9203 | IrInstGen **incoming_values = heap::c_allocator.allocate_nonzero<IrInstGen *>(incoming_count); | |
| 9203 | Stage1AirInst **incoming_values = heap::c_allocator.allocate_nonzero<Stage1AirInst *>(incoming_count); | |
| 9204 | 9204 | incoming_values[0] = null_result; |
| 9205 | 9205 | incoming_values[1] = non_null_cmp_result; |
| 9206 | 9206 | |
| 9207 | 9207 | return ir_build_phi_gen(ira, scope, source_node, incoming_count, incoming_blocks, incoming_values, result_type); |
| 9208 | 9208 | } |
| 9209 | 9209 | |
| 9210 | static IrInstGen *ir_analyze_cmp_optional_non_optional(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 9211 | IrInstGen *op1, IrInstGen *op2, IrInstGen *optional, IrBinOp op_id) | |
| 9210 | static Stage1AirInst *ir_analyze_cmp_optional_non_optional(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 9211 | Stage1AirInst *op1, Stage1AirInst *op2, Stage1AirInst *optional, IrBinOp op_id) | |
| 9212 | 9212 | { |
| 9213 | 9213 | assert(op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq); |
| 9214 | 9214 | assert(optional->value->type->id == ZigTypeIdOptional); |
| 9215 | 9215 | assert(get_src_ptr_type(optional->value->type) == nullptr); |
| 9216 | 9216 | |
| 9217 | IrInstGen *non_optional; | |
| 9217 | Stage1AirInst *non_optional; | |
| 9218 | 9218 | if (op1 == optional) { |
| 9219 | 9219 | non_optional = op2; |
| 9220 | 9220 | } else if (op2 == optional) { |
| ... | ... | @@ -9253,7 +9253,7 @@ static IrInstGen *ir_analyze_cmp_optional_non_optional(IrAnalyze *ira, Scope *sc |
| 9253 | 9253 | return ira->codegen->invalid_inst_gen; |
| 9254 | 9254 | } |
| 9255 | 9255 | |
| 9256 | if (IrInstGen *const_result = ir_try_evaluate_cmp_optional_non_optional_const(ira, scope, source_node, child_type, | |
| 9256 | if (Stage1AirInst *const_result = ir_try_evaluate_cmp_optional_non_optional_const(ira, scope, source_node, child_type, | |
| 9257 | 9257 | optional, non_optional, op_id)) |
| 9258 | 9258 | { |
| 9259 | 9259 | return const_result; |
| ... | ... | @@ -9262,12 +9262,12 @@ static IrInstGen *ir_analyze_cmp_optional_non_optional(IrAnalyze *ira, Scope *sc |
| 9262 | 9262 | return ir_evaluate_cmp_optional_non_optional(ira, scope, source_node, child_type, optional, non_optional, op_id); |
| 9263 | 9263 | } |
| 9264 | 9264 | |
| 9265 | static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { | |
| 9266 | IrInstGen *op1 = bin_op_instruction->op1->child; | |
| 9265 | static Stage1AirInst *ir_analyze_bin_op_cmp(IrAnalyze *ira, Stage1ZirInstBinOp *bin_op_instruction) { | |
| 9266 | Stage1AirInst *op1 = bin_op_instruction->op1->child; | |
| 9267 | 9267 | if (type_is_invalid(op1->value->type)) |
| 9268 | 9268 | return ira->codegen->invalid_inst_gen; |
| 9269 | 9269 | |
| 9270 | IrInstGen *op2 = bin_op_instruction->op2->child; | |
| 9270 | Stage1AirInst *op2 = bin_op_instruction->op2->child; | |
| 9271 | 9271 | if (type_is_invalid(op2->value->type)) |
| 9272 | 9272 | return ira->codegen->invalid_inst_gen; |
| 9273 | 9273 | |
| ... | ... | @@ -9282,7 +9282,7 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i |
| 9282 | 9282 | ((op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdOptional) || |
| 9283 | 9283 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdOptional))) |
| 9284 | 9284 | { |
| 9285 | IrInstGen *maybe_op; | |
| 9285 | Stage1AirInst *maybe_op; | |
| 9286 | 9286 | if (op1->value->type->id == ZigTypeIdNull) { |
| 9287 | 9287 | maybe_op = op2; |
| 9288 | 9288 | } else if (op2->value->type->id == ZigTypeIdNull) { |
| ... | ... | @@ -9300,7 +9300,7 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i |
| 9300 | 9300 | bin_op_instruction->base.source_node, bool_result); |
| 9301 | 9301 | } |
| 9302 | 9302 | |
| 9303 | IrInstGen *is_non_null = ir_build_test_non_null_gen(ira, bin_op_instruction->base.scope, | |
| 9303 | Stage1AirInst *is_non_null = ir_build_test_non_null_gen(ira, bin_op_instruction->base.scope, | |
| 9304 | 9304 | bin_op_instruction->base.source_node, maybe_op); |
| 9305 | 9305 | |
| 9306 | 9306 | if (op_id == IrBinOpCmpEq) { |
| ... | ... | @@ -9315,7 +9315,7 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i |
| 9315 | 9315 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdPointer && |
| 9316 | 9316 | op1->value->type->data.pointer.ptr_len == PtrLenC))) |
| 9317 | 9317 | { |
| 9318 | IrInstGen *c_ptr_op; | |
| 9318 | Stage1AirInst *c_ptr_op; | |
| 9319 | 9319 | if (op1->value->type->id == ZigTypeIdNull) { |
| 9320 | 9320 | c_ptr_op = op2; |
| 9321 | 9321 | } else if (op2->value->type->id == ZigTypeIdNull) { |
| ... | ... | @@ -9335,7 +9335,7 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i |
| 9335 | 9335 | bool bool_result = (op_id == IrBinOpCmpEq) ? is_null : !is_null; |
| 9336 | 9336 | return ir_const_bool(ira, bin_op_instruction->base.scope, bin_op_instruction->base.source_node, bool_result); |
| 9337 | 9337 | } |
| 9338 | IrInstGen *is_non_null = ir_build_test_non_null_gen(ira, bin_op_instruction->base.scope, bin_op_instruction->base.source_node, c_ptr_op); | |
| 9338 | Stage1AirInst *is_non_null = ir_build_test_non_null_gen(ira, bin_op_instruction->base.scope, bin_op_instruction->base.source_node, c_ptr_op); | |
| 9339 | 9339 | |
| 9340 | 9340 | if (op_id == IrBinOpCmpEq) { |
| 9341 | 9341 | return ir_build_bool_not_gen(ira, bin_op_instruction->base.scope, bin_op_instruction->base.source_node, is_non_null); |
| ... | ... | @@ -9360,8 +9360,8 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i |
| 9360 | 9360 | (op2->value->type->id == ZigTypeIdEnumLiteral && op1->value->type->id == ZigTypeIdUnion))) |
| 9361 | 9361 | { |
| 9362 | 9362 | // Support equality comparison between a union's tag value and a enum literal |
| 9363 | IrInstGen *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2; | |
| 9364 | IrInstGen *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1; | |
| 9363 | Stage1AirInst *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2; | |
| 9364 | Stage1AirInst *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1; | |
| 9365 | 9365 | |
| 9366 | 9366 | if (!is_tagged_union(union_val->value->type)) { |
| 9367 | 9367 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| ... | ... | @@ -9375,11 +9375,11 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i |
| 9375 | 9375 | ZigType *tag_type = union_val->value->type->data.unionation.tag_type; |
| 9376 | 9376 | assert(tag_type != nullptr); |
| 9377 | 9377 | |
| 9378 | IrInstGen *casted_union = ir_implicit_cast(ira, union_val, tag_type); | |
| 9378 | Stage1AirInst *casted_union = ir_implicit_cast(ira, union_val, tag_type); | |
| 9379 | 9379 | if (type_is_invalid(casted_union->value->type)) |
| 9380 | 9380 | return ira->codegen->invalid_inst_gen; |
| 9381 | 9381 | |
| 9382 | IrInstGen *casted_val = ir_implicit_cast(ira, enum_val, tag_type); | |
| 9382 | Stage1AirInst *casted_val = ir_implicit_cast(ira, enum_val, tag_type); | |
| 9383 | 9383 | if (type_is_invalid(casted_val->value->type)) |
| 9384 | 9384 | return ira->codegen->invalid_inst_gen; |
| 9385 | 9385 | |
| ... | ... | @@ -9486,7 +9486,7 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i |
| 9486 | 9486 | return ir_analyze_bin_op_cmp_numeric(ira, bin_op_instruction->base.scope, bin_op_instruction->base.source_node, op1, op2, op_id); |
| 9487 | 9487 | } |
| 9488 | 9488 | |
| 9489 | IrInstGen *instructions[] = {op1, op2}; | |
| 9489 | Stage1AirInst *instructions[] = {op1, op2}; | |
| 9490 | 9490 | ZigType *resolved_type = ir_resolve_peer_types(ira, source_node, nullptr, instructions, 2); |
| 9491 | 9491 | if (type_is_invalid(resolved_type)) |
| 9492 | 9492 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -9499,15 +9499,15 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i |
| 9499 | 9499 | return ira->codegen->invalid_inst_gen; |
| 9500 | 9500 | } |
| 9501 | 9501 | |
| 9502 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); | |
| 9502 | Stage1AirInst *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); | |
| 9503 | 9503 | if (type_is_invalid(casted_op1->value->type)) |
| 9504 | 9504 | return ira->codegen->invalid_inst_gen; |
| 9505 | 9505 | |
| 9506 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); | |
| 9506 | Stage1AirInst *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); | |
| 9507 | 9507 | if (type_is_invalid(casted_op2->value->type)) |
| 9508 | 9508 | return ira->codegen->invalid_inst_gen; |
| 9509 | 9509 | |
| 9510 | IrInstGen *resolve_const_result = ir_try_evaluate_bin_op_cmp_const(ira, bin_op_instruction->base.scope, bin_op_instruction->base.source_node, casted_op1, | |
| 9510 | Stage1AirInst *resolve_const_result = ir_try_evaluate_bin_op_cmp_const(ira, bin_op_instruction->base.scope, bin_op_instruction->base.source_node, casted_op1, | |
| 9511 | 9511 | casted_op2, resolved_type, op_id); |
| 9512 | 9512 | if (resolve_const_result != nullptr) { |
| 9513 | 9513 | return resolve_const_result; |
| ... | ... | @@ -9700,10 +9700,10 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, Scope *scope, AstNode *s |
| 9700 | 9700 | } |
| 9701 | 9701 | |
| 9702 | 9702 | // This works on operands that have already been checked to be comptime known. |
| 9703 | static IrInstGen *ir_analyze_math_op(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 9703 | static Stage1AirInst *ir_analyze_math_op(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 9704 | 9704 | ZigType *type_entry, ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val) |
| 9705 | 9705 | { |
| 9706 | IrInstGen *result_instruction = ir_const(ira, scope, source_node, type_entry); | |
| 9706 | Stage1AirInst *result_instruction = ir_const(ira, scope, source_node, type_entry); | |
| 9707 | 9707 | ZigValue *out_val = result_instruction->value; |
| 9708 | 9708 | if (type_entry->id == ZigTypeIdVector) { |
| 9709 | 9709 | expand_undef_array(ira->codegen, op1_val); |
| ... | ... | @@ -9736,12 +9736,12 @@ static IrInstGen *ir_analyze_math_op(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 9736 | 9736 | return ir_implicit_cast(ira, result_instruction, type_entry); |
| 9737 | 9737 | } |
| 9738 | 9738 | |
| 9739 | static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { | |
| 9740 | IrInstGen *op1 = bin_op_instruction->op1->child; | |
| 9739 | static Stage1AirInst *ir_analyze_bit_shift(IrAnalyze *ira, Stage1ZirInstBinOp *bin_op_instruction) { | |
| 9740 | Stage1AirInst *op1 = bin_op_instruction->op1->child; | |
| 9741 | 9741 | if (type_is_invalid(op1->value->type)) |
| 9742 | 9742 | return ira->codegen->invalid_inst_gen; |
| 9743 | 9743 | |
| 9744 | IrInstGen *op2 = bin_op_instruction->op2->child; | |
| 9744 | Stage1AirInst *op2 = bin_op_instruction->op2->child; | |
| 9745 | 9745 | if (type_is_invalid(op2->value->type)) |
| 9746 | 9746 | return ira->codegen->invalid_inst_gen; |
| 9747 | 9747 | |
| ... | ... | @@ -9781,7 +9781,7 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in |
| 9781 | 9781 | return ira->codegen->invalid_inst_gen; |
| 9782 | 9782 | } |
| 9783 | 9783 | |
| 9784 | IrInstGen *casted_op2; | |
| 9784 | Stage1AirInst *casted_op2; | |
| 9785 | 9785 | IrBinOp op_id = bin_op_instruction->op_id; |
| 9786 | 9786 | if (op1_scalar_type->id == ZigTypeIdComptimeInt) { |
| 9787 | 9787 | // comptime_int has no finite bit width |
| ... | ... | @@ -10005,14 +10005,14 @@ static bool value_cmp_numeric_val_all(ZigValue *left, Cmp predicate, ZigValue *r |
| 10005 | 10005 | return value_cmp_numeric_val(left, predicate, right, false); |
| 10006 | 10006 | } |
| 10007 | 10007 | |
| 10008 | static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruction) { | |
| 10008 | static Stage1AirInst *ir_analyze_bin_op_math(IrAnalyze *ira, Stage1ZirInstBinOp *instruction) { | |
| 10009 | 10009 | Error err; |
| 10010 | 10010 | |
| 10011 | IrInstGen *op1 = instruction->op1->child; | |
| 10011 | Stage1AirInst *op1 = instruction->op1->child; | |
| 10012 | 10012 | if (type_is_invalid(op1->value->type)) |
| 10013 | 10013 | return ira->codegen->invalid_inst_gen; |
| 10014 | 10014 | |
| 10015 | IrInstGen *op2 = instruction->op2->child; | |
| 10015 | Stage1AirInst *op2 = instruction->op2->child; | |
| 10016 | 10016 | if (type_is_invalid(op2->value->type)) |
| 10017 | 10017 | return ira->codegen->invalid_inst_gen; |
| 10018 | 10018 | |
| ... | ... | @@ -10020,7 +10020,7 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc |
| 10020 | 10020 | |
| 10021 | 10021 | // look for pointer math |
| 10022 | 10022 | if (is_pointer_arithmetic_allowed(op1->value->type, op_id)) { |
| 10023 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); | |
| 10023 | Stage1AirInst *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); | |
| 10024 | 10024 | if (type_is_invalid(casted_op2->value->type)) |
| 10025 | 10025 | return ira->codegen->invalid_inst_gen; |
| 10026 | 10026 | |
| ... | ... | @@ -10095,7 +10095,7 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc |
| 10095 | 10095 | } else { |
| 10096 | 10096 | zig_unreachable(); |
| 10097 | 10097 | } |
| 10098 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, result_type); | |
| 10098 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, result_type); | |
| 10099 | 10099 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 10100 | 10100 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; |
| 10101 | 10101 | result->value->data.x_ptr.data.hard_coded_addr.addr = new_addr; |
| ... | ... | @@ -10105,7 +10105,7 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc |
| 10105 | 10105 | return ir_build_bin_op_gen(ira, instruction->base.scope, instruction->base.source_node, result_type, op_id, op1, casted_op2, true); |
| 10106 | 10106 | } |
| 10107 | 10107 | |
| 10108 | IrInstGen *instructions[] = {op1, op2}; | |
| 10108 | Stage1AirInst *instructions[] = {op1, op2}; | |
| 10109 | 10109 | ZigType *resolved_type = ir_resolve_peer_types(ira, instruction->base.source_node, nullptr, instructions, 2); |
| 10110 | 10110 | if (type_is_invalid(resolved_type)) |
| 10111 | 10111 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -10125,11 +10125,11 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc |
| 10125 | 10125 | return ira->codegen->invalid_inst_gen; |
| 10126 | 10126 | } |
| 10127 | 10127 | |
| 10128 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); | |
| 10128 | Stage1AirInst *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); | |
| 10129 | 10129 | if (type_is_invalid(casted_op1->value->type)) |
| 10130 | 10130 | return ira->codegen->invalid_inst_gen; |
| 10131 | 10131 | |
| 10132 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); | |
| 10132 | Stage1AirInst *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); | |
| 10133 | 10133 | if (type_is_invalid(casted_op2->value->type)) |
| 10134 | 10134 | return ira->codegen->invalid_inst_gen; |
| 10135 | 10135 | |
| ... | ... | @@ -10170,17 +10170,17 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc |
| 10170 | 10170 | // division function ambiguity problem. |
| 10171 | 10171 | ok = true; |
| 10172 | 10172 | } else { |
| 10173 | IrInstGen *trunc_val = ir_analyze_math_op(ira, instruction->base.scope, instruction->base.source_node, resolved_type, | |
| 10173 | Stage1AirInst *trunc_val = ir_analyze_math_op(ira, instruction->base.scope, instruction->base.source_node, resolved_type, | |
| 10174 | 10174 | op1_val, IrBinOpDivTrunc, op2_val); |
| 10175 | 10175 | if (type_is_invalid(trunc_val->value->type)) |
| 10176 | 10176 | return ira->codegen->invalid_inst_gen; |
| 10177 | 10177 | |
| 10178 | IrInstGen *floor_val = ir_analyze_math_op(ira, instruction->base.scope, instruction->base.source_node, resolved_type, | |
| 10178 | Stage1AirInst *floor_val = ir_analyze_math_op(ira, instruction->base.scope, instruction->base.source_node, resolved_type, | |
| 10179 | 10179 | op1_val, IrBinOpDivFloor, op2_val); |
| 10180 | 10180 | if (type_is_invalid(floor_val->value->type)) |
| 10181 | 10181 | return ira->codegen->invalid_inst_gen; |
| 10182 | 10182 | |
| 10183 | IrInstGen *cmp_val = ir_analyze_bin_op_cmp_numeric(ira, instruction->base.scope, instruction->base.source_node, | |
| 10183 | Stage1AirInst *cmp_val = ir_analyze_bin_op_cmp_numeric(ira, instruction->base.scope, instruction->base.source_node, | |
| 10184 | 10184 | trunc_val, floor_val, IrBinOpCmpEq); |
| 10185 | 10185 | if (type_is_invalid(cmp_val->value->type)) |
| 10186 | 10186 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -10209,17 +10209,17 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc |
| 10209 | 10209 | // division function ambiguity problem. |
| 10210 | 10210 | ok = true; |
| 10211 | 10211 | } else { |
| 10212 | IrInstGen *rem_val = ir_analyze_math_op(ira, instruction->base.scope, instruction->base.source_node, resolved_type, | |
| 10212 | Stage1AirInst *rem_val = ir_analyze_math_op(ira, instruction->base.scope, instruction->base.source_node, resolved_type, | |
| 10213 | 10213 | op1_val, IrBinOpRemRem, op2_val); |
| 10214 | 10214 | if (type_is_invalid(rem_val->value->type)) |
| 10215 | 10215 | return ira->codegen->invalid_inst_gen; |
| 10216 | 10216 | |
| 10217 | IrInstGen *mod_val = ir_analyze_math_op(ira, instruction->base.scope, instruction->base.source_node, resolved_type, | |
| 10217 | Stage1AirInst *mod_val = ir_analyze_math_op(ira, instruction->base.scope, instruction->base.source_node, resolved_type, | |
| 10218 | 10218 | op1_val, IrBinOpRemMod, op2_val); |
| 10219 | 10219 | if (type_is_invalid(mod_val->value->type)) |
| 10220 | 10220 | return ira->codegen->invalid_inst_gen; |
| 10221 | 10221 | |
| 10222 | IrInstGen *cmp_val = ir_analyze_bin_op_cmp_numeric(ira, instruction->base.scope, instruction->base.source_node, | |
| 10222 | Stage1AirInst *cmp_val = ir_analyze_bin_op_cmp_numeric(ira, instruction->base.scope, instruction->base.source_node, | |
| 10223 | 10223 | rem_val, mod_val, IrBinOpCmpEq); |
| 10224 | 10224 | if (type_is_invalid(cmp_val->value->type)) |
| 10225 | 10225 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -10273,8 +10273,8 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc |
| 10273 | 10273 | op_id, casted_op1, casted_op2, instruction->safety_check_on); |
| 10274 | 10274 | } |
| 10275 | 10275 | |
| 10276 | static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 10277 | IrInstGen *op1, IrInstGen *op2) | |
| 10276 | static Stage1AirInst *ir_analyze_tuple_cat(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 10277 | Stage1AirInst *op1, Stage1AirInst *op2) | |
| 10278 | 10278 | { |
| 10279 | 10279 | Error err; |
| 10280 | 10280 | ZigType *op1_type = op1->value->type; |
| ... | ... | @@ -10296,7 +10296,7 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, Scope *scope, AstNode *so |
| 10296 | 10296 | new_type->data.structure.fields = realloc_type_struct_fields(new_type->data.structure.fields, |
| 10297 | 10297 | 0, new_field_count); |
| 10298 | 10298 | |
| 10299 | IrInstGen *new_struct_ptr = ir_resolve_result(ira, ira->suspend_source_instr, no_result_loc(), | |
| 10299 | Stage1AirInst *new_struct_ptr = ir_resolve_result(ira, ira->suspend_source_instr, no_result_loc(), | |
| 10300 | 10300 | new_type, nullptr, false, true); |
| 10301 | 10301 | |
| 10302 | 10302 | for (uint32_t i = 0; i < new_field_count; i += 1) { |
| ... | ... | @@ -10318,10 +10318,10 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, Scope *scope, AstNode *so |
| 10318 | 10318 | if ((err = type_resolve(ira->codegen, new_type, ResolveStatusZeroBitsKnown))) |
| 10319 | 10319 | return ira->codegen->invalid_inst_gen; |
| 10320 | 10320 | |
| 10321 | ZigList<IrInstGen *> const_ptrs = {}; | |
| 10321 | ZigList<Stage1AirInst *> const_ptrs = {}; | |
| 10322 | 10322 | for (uint32_t i = 0; i < new_field_count; i += 1) { |
| 10323 | 10323 | TypeStructField *dst_field = new_type->data.structure.fields[i]; |
| 10324 | IrInstGen *src_struct_op; | |
| 10324 | Stage1AirInst *src_struct_op; | |
| 10325 | 10325 | TypeStructField *src_field; |
| 10326 | 10326 | if (i < op1_field_count) { |
| 10327 | 10327 | src_field = op1_type->data.structure.fields[i]; |
| ... | ... | @@ -10330,18 +10330,18 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, Scope *scope, AstNode *so |
| 10330 | 10330 | src_field = op2_type->data.structure.fields[i - op1_field_count]; |
| 10331 | 10331 | src_struct_op = op2; |
| 10332 | 10332 | } |
| 10333 | IrInstGen *field_value = ir_analyze_struct_value_field_value(ira, scope, source_node, | |
| 10333 | Stage1AirInst *field_value = ir_analyze_struct_value_field_value(ira, scope, source_node, | |
| 10334 | 10334 | src_struct_op, src_field); |
| 10335 | 10335 | if (type_is_invalid(field_value->value->type)) |
| 10336 | 10336 | return ira->codegen->invalid_inst_gen; |
| 10337 | IrInstGen *dest_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, dst_field, | |
| 10337 | Stage1AirInst *dest_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, dst_field, | |
| 10338 | 10338 | new_struct_ptr, new_type, true); |
| 10339 | 10339 | if (type_is_invalid(dest_ptr->value->type)) |
| 10340 | 10340 | return ira->codegen->invalid_inst_gen; |
| 10341 | 10341 | if (instr_is_comptime(field_value)) { |
| 10342 | 10342 | const_ptrs.append(dest_ptr); |
| 10343 | 10343 | } |
| 10344 | IrInstGen *store_ptr_inst = ir_analyze_store_ptr(ira, scope, source_node, dest_ptr, field_value, | |
| 10344 | Stage1AirInst *store_ptr_inst = ir_analyze_store_ptr(ira, scope, source_node, dest_ptr, field_value, | |
| 10345 | 10345 | true); |
| 10346 | 10346 | if (type_is_invalid(store_ptr_inst->value->type)) |
| 10347 | 10347 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -10349,13 +10349,13 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, Scope *scope, AstNode *so |
| 10349 | 10349 | if (const_ptrs.length != new_field_count) { |
| 10350 | 10350 | new_struct_ptr->value->special = ConstValSpecialRuntime; |
| 10351 | 10351 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 10352 | IrInstGen *elem_result_loc = const_ptrs.at(i); | |
| 10352 | Stage1AirInst *elem_result_loc = const_ptrs.at(i); | |
| 10353 | 10353 | assert(elem_result_loc->value->special == ConstValSpecialStatic); |
| 10354 | 10354 | if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { |
| 10355 | 10355 | // This field will be generated comptime; no need to do this. |
| 10356 | 10356 | continue; |
| 10357 | 10357 | } |
| 10358 | IrInstGen *deref = ir_get_deref(ira, elem_result_loc->scope, | |
| 10358 | Stage1AirInst *deref = ir_get_deref(ira, elem_result_loc->scope, | |
| 10359 | 10359 | elem_result_loc->source_node, elem_result_loc, nullptr); |
| 10360 | 10360 | if (!type_requires_comptime(ira->codegen, elem_result_loc->value->type->data.pointer.child_type)) { |
| 10361 | 10361 | elem_result_loc->value->special = ConstValSpecialRuntime; |
| ... | ... | @@ -10369,13 +10369,13 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, Scope *scope, AstNode *so |
| 10369 | 10369 | return ir_get_deref(ira, scope, source_node, new_struct_ptr, nullptr); |
| 10370 | 10370 | } |
| 10371 | 10371 | |
| 10372 | static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instruction) { | |
| 10373 | IrInstGen *op1 = instruction->op1->child; | |
| 10372 | static Stage1AirInst *ir_analyze_array_cat(IrAnalyze *ira, Stage1ZirInstBinOp *instruction) { | |
| 10373 | Stage1AirInst *op1 = instruction->op1->child; | |
| 10374 | 10374 | ZigType *op1_type = op1->value->type; |
| 10375 | 10375 | if (type_is_invalid(op1_type)) |
| 10376 | 10376 | return ira->codegen->invalid_inst_gen; |
| 10377 | 10377 | |
| 10378 | IrInstGen *op2 = instruction->op2->child; | |
| 10378 | Stage1AirInst *op2 = instruction->op2->child; | |
| 10379 | 10379 | ZigType *op2_type = op2->value->type; |
| 10380 | 10380 | if (type_is_invalid(op2_type)) |
| 10381 | 10381 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -10510,7 +10510,7 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi |
| 10510 | 10510 | } |
| 10511 | 10511 | |
| 10512 | 10512 | // The type of result is populated in the following if blocks |
| 10513 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 10513 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 10514 | 10514 | ZigValue *out_val = result->value; |
| 10515 | 10515 | |
| 10516 | 10516 | ZigValue *out_array_val; |
| ... | ... | @@ -10598,8 +10598,8 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi |
| 10598 | 10598 | return result; |
| 10599 | 10599 | } |
| 10600 | 10600 | |
| 10601 | static IrInstGen *ir_analyze_tuple_mult(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 10602 | IrInstGen *op1, IrInstGen *op2) | |
| 10601 | static Stage1AirInst *ir_analyze_tuple_mult(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 10602 | Stage1AirInst *op1, Stage1AirInst *op2) | |
| 10603 | 10603 | { |
| 10604 | 10604 | Error err; |
| 10605 | 10605 | ZigType *op1_type = op1->value->type; |
| ... | ... | @@ -10626,7 +10626,7 @@ static IrInstGen *ir_analyze_tuple_mult(IrAnalyze *ira, Scope *scope, AstNode *s |
| 10626 | 10626 | new_type->data.structure.fields = realloc_type_struct_fields( |
| 10627 | 10627 | new_type->data.structure.fields, 0, new_field_count); |
| 10628 | 10628 | |
| 10629 | IrInstGen *new_struct_ptr = ir_resolve_result(ira, ira->suspend_source_instr, no_result_loc(), | |
| 10629 | Stage1AirInst *new_struct_ptr = ir_resolve_result(ira, ira->suspend_source_instr, no_result_loc(), | |
| 10630 | 10630 | new_type, nullptr, false, true); |
| 10631 | 10631 | |
| 10632 | 10632 | for (uint64_t i = 0; i < new_field_count; i += 1) { |
| ... | ... | @@ -10645,17 +10645,17 @@ static IrInstGen *ir_analyze_tuple_mult(IrAnalyze *ira, Scope *scope, AstNode *s |
| 10645 | 10645 | if ((err = type_resolve(ira->codegen, new_type, ResolveStatusZeroBitsKnown))) |
| 10646 | 10646 | return ira->codegen->invalid_inst_gen; |
| 10647 | 10647 | |
| 10648 | ZigList<IrInstGen *> const_ptrs = {}; | |
| 10648 | ZigList<Stage1AirInst *> const_ptrs = {}; | |
| 10649 | 10649 | for (uint64_t i = 0; i < new_field_count; i += 1) { |
| 10650 | 10650 | TypeStructField *src_field = op1_type->data.structure.fields[i % op1_field_count]; |
| 10651 | 10651 | TypeStructField *dst_field = new_type->data.structure.fields[i]; |
| 10652 | 10652 | |
| 10653 | IrInstGen *field_value = ir_analyze_struct_value_field_value( | |
| 10653 | Stage1AirInst *field_value = ir_analyze_struct_value_field_value( | |
| 10654 | 10654 | ira, scope, source_node, op1, src_field); |
| 10655 | 10655 | if (type_is_invalid(field_value->value->type)) |
| 10656 | 10656 | return ira->codegen->invalid_inst_gen; |
| 10657 | 10657 | |
| 10658 | IrInstGen *dest_ptr = ir_analyze_struct_field_ptr( | |
| 10658 | Stage1AirInst *dest_ptr = ir_analyze_struct_field_ptr( | |
| 10659 | 10659 | ira, scope, source_node, dst_field, new_struct_ptr, new_type, true); |
| 10660 | 10660 | if (type_is_invalid(dest_ptr->value->type)) |
| 10661 | 10661 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -10664,7 +10664,7 @@ static IrInstGen *ir_analyze_tuple_mult(IrAnalyze *ira, Scope *scope, AstNode *s |
| 10664 | 10664 | const_ptrs.append(dest_ptr); |
| 10665 | 10665 | } |
| 10666 | 10666 | |
| 10667 | IrInstGen *store_ptr_inst = ir_analyze_store_ptr( | |
| 10667 | Stage1AirInst *store_ptr_inst = ir_analyze_store_ptr( | |
| 10668 | 10668 | ira, scope, source_node, dest_ptr, field_value, true); |
| 10669 | 10669 | if (type_is_invalid(store_ptr_inst->value->type)) |
| 10670 | 10670 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -10673,18 +10673,18 @@ static IrInstGen *ir_analyze_tuple_mult(IrAnalyze *ira, Scope *scope, AstNode *s |
| 10673 | 10673 | if (const_ptrs.length != new_field_count) { |
| 10674 | 10674 | new_struct_ptr->value->special = ConstValSpecialRuntime; |
| 10675 | 10675 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 10676 | IrInstGen *elem_result_loc = const_ptrs.at(i); | |
| 10676 | Stage1AirInst *elem_result_loc = const_ptrs.at(i); | |
| 10677 | 10677 | assert(elem_result_loc->value->special == ConstValSpecialStatic); |
| 10678 | 10678 | if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { |
| 10679 | 10679 | // This field will be generated comptime; no need to do this. |
| 10680 | 10680 | continue; |
| 10681 | 10681 | } |
| 10682 | IrInstGen *deref = ir_get_deref(ira, elem_result_loc->scope, | |
| 10682 | Stage1AirInst *deref = ir_get_deref(ira, elem_result_loc->scope, | |
| 10683 | 10683 | elem_result_loc->source_node, elem_result_loc, nullptr); |
| 10684 | 10684 | if (!type_requires_comptime(ira->codegen, elem_result_loc->value->type->data.pointer.child_type)) { |
| 10685 | 10685 | elem_result_loc->value->special = ConstValSpecialRuntime; |
| 10686 | 10686 | } |
| 10687 | IrInstGen *store_ptr_inst = ir_analyze_store_ptr(ira, elem_result_loc->scope, | |
| 10687 | Stage1AirInst *store_ptr_inst = ir_analyze_store_ptr(ira, elem_result_loc->scope, | |
| 10688 | 10688 | elem_result_loc->source_node, elem_result_loc, deref, true); |
| 10689 | 10689 | if (type_is_invalid(store_ptr_inst->value->type)) |
| 10690 | 10690 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -10696,12 +10696,12 @@ static IrInstGen *ir_analyze_tuple_mult(IrAnalyze *ira, Scope *scope, AstNode *s |
| 10696 | 10696 | return ir_get_deref(ira, scope, source_node, new_struct_ptr, nullptr); |
| 10697 | 10697 | } |
| 10698 | 10698 | |
| 10699 | static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruction) { | |
| 10700 | IrInstGen *op1 = instruction->op1->child; | |
| 10699 | static Stage1AirInst *ir_analyze_array_mult(IrAnalyze *ira, Stage1ZirInstBinOp *instruction) { | |
| 10700 | Stage1AirInst *op1 = instruction->op1->child; | |
| 10701 | 10701 | if (type_is_invalid(op1->value->type)) |
| 10702 | 10702 | return ira->codegen->invalid_inst_gen; |
| 10703 | 10703 | |
| 10704 | IrInstGen *op2 = instruction->op2->child; | |
| 10704 | Stage1AirInst *op2 = instruction->op2->child; | |
| 10705 | 10705 | if (type_is_invalid(op2->value->type)) |
| 10706 | 10706 | return ira->codegen->invalid_inst_gen; |
| 10707 | 10707 | |
| ... | ... | @@ -10718,7 +10718,7 @@ static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruct |
| 10718 | 10718 | op1->value->type->data.pointer.child_type->id == ZigTypeIdArray) |
| 10719 | 10719 | { |
| 10720 | 10720 | array_type = op1->value->type->data.pointer.child_type; |
| 10721 | IrInstGen *array_inst = ir_get_deref(ira, op1->scope, op1->source_node, op1, nullptr); | |
| 10721 | Stage1AirInst *array_inst = ir_get_deref(ira, op1->scope, op1->source_node, op1, nullptr); | |
| 10722 | 10722 | if (type_is_invalid(array_inst->value->type)) |
| 10723 | 10723 | return ira->codegen->invalid_inst_gen; |
| 10724 | 10724 | array_val = ir_resolve_const(ira, array_inst, UndefOk); |
| ... | ... | @@ -10748,7 +10748,7 @@ static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruct |
| 10748 | 10748 | ZigType *result_array_type = get_array_type(ira->codegen, child_type, new_array_len, |
| 10749 | 10749 | array_type->data.array.sentinel); |
| 10750 | 10750 | |
| 10751 | IrInstGen *array_result; | |
| 10751 | Stage1AirInst *array_result; | |
| 10752 | 10752 | if (array_val->special == ConstValSpecialUndef || array_val->data.x_array.special == ConstArraySpecialUndef) { |
| 10753 | 10753 | array_result = ir_const_undef(ira, instruction->base.scope, instruction->base.source_node, result_array_type); |
| 10754 | 10754 | } else { |
| ... | ... | @@ -10799,8 +10799,8 @@ skip_computation: |
| 10799 | 10799 | } |
| 10800 | 10800 | } |
| 10801 | 10801 | |
| 10802 | static IrInstGen *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, | |
| 10803 | IrInstSrcMergeErrSets *instruction) | |
| 10802 | static Stage1AirInst *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, | |
| 10803 | Stage1ZirInstMergeErrSets *instruction) | |
| 10804 | 10804 | { |
| 10805 | 10805 | ZigType *op1_type = ir_resolve_error_set_type(ira, instruction->base.source_node, instruction->op1->child); |
| 10806 | 10806 | if (type_is_invalid(op1_type)) |
| ... | ... | @@ -10838,7 +10838,7 @@ static IrInstGen *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, |
| 10838 | 10838 | } |
| 10839 | 10839 | |
| 10840 | 10840 | |
| 10841 | static IrInstGen *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { | |
| 10841 | static Stage1AirInst *ir_analyze_instruction_bin_op(IrAnalyze *ira, Stage1ZirInstBinOp *bin_op_instruction) { | |
| 10842 | 10842 | IrBinOp op_id = bin_op_instruction->op_id; |
| 10843 | 10843 | switch (op_id) { |
| 10844 | 10844 | case IrBinOpInvalid: |
| ... | ... | @@ -10883,12 +10883,12 @@ static IrInstGen *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstSrcBinOp * |
| 10883 | 10883 | zig_unreachable(); |
| 10884 | 10884 | } |
| 10885 | 10885 | |
| 10886 | static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclVar *decl_var_instruction) { | |
| 10886 | static Stage1AirInst *ir_analyze_instruction_decl_var(IrAnalyze *ira, Stage1ZirInstDeclVar *decl_var_instruction) { | |
| 10887 | 10887 | Error err; |
| 10888 | 10888 | ZigVar *var = decl_var_instruction->var; |
| 10889 | 10889 | |
| 10890 | 10890 | ZigType *explicit_type = nullptr; |
| 10891 | IrInstGen *var_type = nullptr; | |
| 10891 | Stage1AirInst *var_type = nullptr; | |
| 10892 | 10892 | if (decl_var_instruction->var_type != nullptr) { |
| 10893 | 10893 | var_type = decl_var_instruction->var_type->child; |
| 10894 | 10894 | ZigType *proposed_type = ir_resolve_type(ira, var_type); |
| ... | ... | @@ -10905,7 +10905,7 @@ static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclV |
| 10905 | 10905 | |
| 10906 | 10906 | bool var_class_requires_const = false; |
| 10907 | 10907 | |
| 10908 | IrInstGen *var_ptr = decl_var_instruction->ptr->child; | |
| 10908 | Stage1AirInst *var_ptr = decl_var_instruction->ptr->child; | |
| 10909 | 10909 | // if this is null, a compiler error happened and did not initialize the variable. |
| 10910 | 10910 | // if there are no compile errors there may be a missing ir_expr_wrap in pass1 IR generation. |
| 10911 | 10911 | if (var_ptr == nullptr || type_is_invalid(var_ptr->value->type)) { |
| ... | ... | @@ -11022,7 +11022,7 @@ static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclV |
| 11022 | 11022 | // we need a runtime ptr but we have a comptime val. |
| 11023 | 11023 | // since it's a comptime val there are no instructions for it. |
| 11024 | 11024 | // we memcpy the init value here |
| 11025 | IrInstGen *deref = ir_get_deref(ira, var_ptr->scope, var_ptr->source_node, var_ptr, nullptr); | |
| 11025 | Stage1AirInst *deref = ir_get_deref(ira, var_ptr->scope, var_ptr->source_node, var_ptr, nullptr); | |
| 11026 | 11026 | if (type_is_invalid(deref->value->type)) { |
| 11027 | 11027 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 11028 | 11028 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -11051,12 +11051,12 @@ static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclV |
| 11051 | 11051 | return ir_build_var_decl_gen(ira, decl_var_instruction->base.scope, decl_var_instruction->base.source_node, var, var_ptr); |
| 11052 | 11052 | } |
| 11053 | 11053 | |
| 11054 | static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport *instruction) { | |
| 11055 | IrInstGen *target = instruction->target->child; | |
| 11054 | static Stage1AirInst *ir_analyze_instruction_export(IrAnalyze *ira, Stage1ZirInstExport *instruction) { | |
| 11055 | Stage1AirInst *target = instruction->target->child; | |
| 11056 | 11056 | if (type_is_invalid(target->value->type)) |
| 11057 | 11057 | return ira->codegen->invalid_inst_gen; |
| 11058 | 11058 | |
| 11059 | IrInstGen *options = instruction->options->child; | |
| 11059 | Stage1AirInst *options = instruction->options->child; | |
| 11060 | 11060 | if (type_is_invalid(options->value->type)) |
| 11061 | 11061 | return ira->codegen->invalid_inst_gen; |
| 11062 | 11062 | |
| ... | ... | @@ -11065,29 +11065,29 @@ static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport |
| 11065 | 11065 | |
| 11066 | 11066 | TypeStructField *name_field = find_struct_type_field(options_type, buf_create_from_str("name")); |
| 11067 | 11067 | src_assert(name_field != nullptr, instruction->base.source_node); |
| 11068 | IrInstGen *name_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, name_field); | |
| 11068 | Stage1AirInst *name_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, name_field); | |
| 11069 | 11069 | if (type_is_invalid(name_inst->value->type)) |
| 11070 | 11070 | return ira->codegen->invalid_inst_gen; |
| 11071 | 11071 | |
| 11072 | 11072 | TypeStructField *linkage_field = find_struct_type_field(options_type, buf_create_from_str("linkage")); |
| 11073 | 11073 | src_assert(linkage_field != nullptr, instruction->base.source_node); |
| 11074 | IrInstGen *linkage_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, linkage_field); | |
| 11074 | Stage1AirInst *linkage_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, linkage_field); | |
| 11075 | 11075 | if (type_is_invalid(linkage_inst->value->type)) |
| 11076 | 11076 | return ira->codegen->invalid_inst_gen; |
| 11077 | 11077 | |
| 11078 | 11078 | TypeStructField *section_field = find_struct_type_field(options_type, buf_create_from_str("section")); |
| 11079 | 11079 | src_assert(section_field != nullptr, instruction->base.source_node); |
| 11080 | IrInstGen *section_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, section_field); | |
| 11080 | Stage1AirInst *section_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, section_field); | |
| 11081 | 11081 | if (type_is_invalid(section_inst->value->type)) |
| 11082 | 11082 | return ira->codegen->invalid_inst_gen; |
| 11083 | 11083 | |
| 11084 | 11084 | // The `section` field is optional, we have to unwrap it first |
| 11085 | IrInstGen *non_null_check = ir_analyze_test_non_null(ira, instruction->base.scope, instruction->base.source_node, section_inst); | |
| 11085 | Stage1AirInst *non_null_check = ir_analyze_test_non_null(ira, instruction->base.scope, instruction->base.source_node, section_inst); | |
| 11086 | 11086 | bool is_non_null; |
| 11087 | 11087 | if (!ir_resolve_bool(ira, non_null_check, &is_non_null)) |
| 11088 | 11088 | return ira->codegen->invalid_inst_gen; |
| 11089 | 11089 | |
| 11090 | IrInstGen *section_str_inst = nullptr; | |
| 11090 | Stage1AirInst *section_str_inst = nullptr; | |
| 11091 | 11091 | if (is_non_null) { |
| 11092 | 11092 | section_str_inst = ir_analyze_optional_value_payload_value(ira, instruction->base.scope, instruction->base.source_node, section_inst, false); |
| 11093 | 11093 | if (type_is_invalid(section_str_inst->value->type)) |
| ... | ... | @@ -11307,10 +11307,10 @@ static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport |
| 11307 | 11307 | } |
| 11308 | 11308 | |
| 11309 | 11309 | // TODO audit the various ways to use @export |
| 11310 | if (want_var_export && target->id == IrInstGenIdLoadPtr) { | |
| 11311 | IrInstGenLoadPtr *load_ptr = reinterpret_cast<IrInstGenLoadPtr *>(target); | |
| 11312 | if (load_ptr->ptr->id == IrInstGenIdVarPtr) { | |
| 11313 | IrInstGenVarPtr *var_ptr = reinterpret_cast<IrInstGenVarPtr *>(load_ptr->ptr); | |
| 11310 | if (want_var_export && target->id == Stage1AirInstIdLoadPtr) { | |
| 11311 | Stage1AirInstLoadPtr *load_ptr = reinterpret_cast<Stage1AirInstLoadPtr *>(target); | |
| 11312 | if (load_ptr->ptr->id == Stage1AirInstIdVarPtr) { | |
| 11313 | Stage1AirInstVarPtr *var_ptr = reinterpret_cast<Stage1AirInstVarPtr *>(load_ptr->ptr); | |
| 11314 | 11314 | ZigVar *var = var_ptr->var; |
| 11315 | 11315 | add_var_export(ira->codegen, var, buf_ptr(symbol_name), global_linkage_id); |
| 11316 | 11316 | var->section_name = section_name; |
| ... | ... | @@ -11322,12 +11322,12 @@ static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport |
| 11322 | 11322 | |
| 11323 | 11323 | static void add_link_lib_symbol(IrAnalyze *ira, Buf *lib_name, Buf *symbol_name, AstNode *source_node); |
| 11324 | 11324 | |
| 11325 | static IrInstGen *ir_analyze_instruction_extern(IrAnalyze *ira, IrInstSrcExtern *instruction) { | |
| 11326 | IrInstGen *type_inst = instruction->type->child; | |
| 11325 | static Stage1AirInst *ir_analyze_instruction_extern(IrAnalyze *ira, Stage1ZirInstExtern *instruction) { | |
| 11326 | Stage1AirInst *type_inst = instruction->type->child; | |
| 11327 | 11327 | if (type_is_invalid(type_inst->value->type)) |
| 11328 | 11328 | return ira->codegen->invalid_inst_gen; |
| 11329 | 11329 | |
| 11330 | IrInstGen *options = instruction->options->child; | |
| 11330 | Stage1AirInst *options = instruction->options->child; | |
| 11331 | 11331 | if (type_is_invalid(options->value->type)) |
| 11332 | 11332 | return ira->codegen->invalid_inst_gen; |
| 11333 | 11333 | |
| ... | ... | @@ -11336,35 +11336,35 @@ static IrInstGen *ir_analyze_instruction_extern(IrAnalyze *ira, IrInstSrcExtern |
| 11336 | 11336 | |
| 11337 | 11337 | TypeStructField *name_field = find_struct_type_field(options_type, buf_create_from_str("name")); |
| 11338 | 11338 | src_assert(name_field != nullptr, instruction->base.source_node); |
| 11339 | IrInstGen *name_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, name_field); | |
| 11339 | Stage1AirInst *name_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, name_field); | |
| 11340 | 11340 | if (type_is_invalid(name_inst->value->type)) |
| 11341 | 11341 | return ira->codegen->invalid_inst_gen; |
| 11342 | 11342 | |
| 11343 | 11343 | TypeStructField *linkage_field = find_struct_type_field(options_type, buf_create_from_str("linkage")); |
| 11344 | 11344 | src_assert(linkage_field != nullptr, instruction->base.source_node); |
| 11345 | IrInstGen *linkage_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, linkage_field); | |
| 11345 | Stage1AirInst *linkage_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, linkage_field); | |
| 11346 | 11346 | if (type_is_invalid(linkage_inst->value->type)) |
| 11347 | 11347 | return ira->codegen->invalid_inst_gen; |
| 11348 | 11348 | |
| 11349 | 11349 | TypeStructField *is_thread_local_field = find_struct_type_field(options_type, buf_create_from_str("is_thread_local")); |
| 11350 | 11350 | src_assert(is_thread_local_field != nullptr, instruction->base.source_node); |
| 11351 | IrInstGen *is_thread_local_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, is_thread_local_field); | |
| 11351 | Stage1AirInst *is_thread_local_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, is_thread_local_field); | |
| 11352 | 11352 | if (type_is_invalid(is_thread_local_inst->value->type)) |
| 11353 | 11353 | return ira->codegen->invalid_inst_gen; |
| 11354 | 11354 | |
| 11355 | 11355 | TypeStructField *library_name_field = find_struct_type_field(options_type, buf_create_from_str("library_name")); |
| 11356 | 11356 | src_assert(library_name_field != nullptr, instruction->base.source_node); |
| 11357 | IrInstGen *library_name_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, library_name_field); | |
| 11357 | Stage1AirInst *library_name_inst = ir_analyze_struct_value_field_value(ira, instruction->base.scope, instruction->base.source_node, options, library_name_field); | |
| 11358 | 11358 | if (type_is_invalid(library_name_inst->value->type)) |
| 11359 | 11359 | return ira->codegen->invalid_inst_gen; |
| 11360 | 11360 | |
| 11361 | 11361 | // The `library_name` field is optional, we have to unwrap it first |
| 11362 | IrInstGen *non_null_check = ir_analyze_test_non_null(ira, instruction->base.scope, instruction->base.source_node, library_name_inst); | |
| 11362 | Stage1AirInst *non_null_check = ir_analyze_test_non_null(ira, instruction->base.scope, instruction->base.source_node, library_name_inst); | |
| 11363 | 11363 | bool is_non_null; |
| 11364 | 11364 | if (!ir_resolve_bool(ira, non_null_check, &is_non_null)) |
| 11365 | 11365 | return ira->codegen->invalid_inst_gen; |
| 11366 | 11366 | |
| 11367 | IrInstGen *library_name_val_inst = nullptr; | |
| 11367 | Stage1AirInst *library_name_val_inst = nullptr; | |
| 11368 | 11368 | if (is_non_null) { |
| 11369 | 11369 | library_name_val_inst = ir_analyze_optional_value_payload_value(ira, instruction->base.scope, instruction->base.source_node, library_name_inst, false); |
| 11370 | 11370 | if (type_is_invalid(library_name_val_inst->value->type)) |
| ... | ... | @@ -11445,14 +11445,14 @@ static bool ira_has_err_ret_trace(IrAnalyze *ira) { |
| 11445 | 11445 | return fn != nullptr && fn->calls_or_awaits_errorable_fn && ira->codegen->have_err_ret_tracing; |
| 11446 | 11446 | } |
| 11447 | 11447 | |
| 11448 | static IrInstGen *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, | |
| 11449 | IrInstSrcErrorReturnTrace *instruction) | |
| 11448 | static Stage1AirInst *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, | |
| 11449 | Stage1ZirInstErrorReturnTrace *instruction) | |
| 11450 | 11450 | { |
| 11451 | 11451 | ZigType *ptr_to_stack_trace_type = get_pointer_to_type(ira->codegen, get_stack_trace_type(ira->codegen), false); |
| 11452 | 11452 | if (instruction->optional == IrInstErrorReturnTraceNull) { |
| 11453 | 11453 | ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type); |
| 11454 | 11454 | if (!ira_has_err_ret_trace(ira)) { |
| 11455 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, optional_type); | |
| 11455 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, optional_type); | |
| 11456 | 11456 | ZigValue *out_val = result->value; |
| 11457 | 11457 | assert(get_src_ptr_type(optional_type) != nullptr); |
| 11458 | 11458 | out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| ... | ... | @@ -11468,8 +11468,8 @@ static IrInstGen *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, |
| 11468 | 11468 | } |
| 11469 | 11469 | } |
| 11470 | 11470 | |
| 11471 | static IrInstGen *ir_analyze_instruction_error_union(IrAnalyze *ira, IrInstSrcErrorUnion *instruction) { | |
| 11472 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_type); | |
| 11471 | static Stage1AirInst *ir_analyze_instruction_error_union(IrAnalyze *ira, Stage1ZirInstErrorUnion *instruction) { | |
| 11472 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_type); | |
| 11473 | 11473 | result->value->special = ConstValSpecialLazy; |
| 11474 | 11474 | |
| 11475 | 11475 | LazyValueErrUnionType *lazy_err_union_type = heap::c_allocator.create<LazyValueErrUnionType>(); |
| ... | ... | @@ -11488,7 +11488,7 @@ static IrInstGen *ir_analyze_instruction_error_union(IrAnalyze *ira, IrInstSrcEr |
| 11488 | 11488 | return result; |
| 11489 | 11489 | } |
| 11490 | 11490 | |
| 11491 | static IrInstGen *ir_analyze_alloca(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *var_type, | |
| 11491 | static Stage1AirInst *ir_analyze_alloca(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *var_type, | |
| 11492 | 11492 | uint32_t align, const char *name_hint, bool force_comptime) |
| 11493 | 11493 | { |
| 11494 | 11494 | Error err; |
| ... | ... | @@ -11497,7 +11497,7 @@ static IrInstGen *ir_analyze_alloca(IrAnalyze *ira, Scope *scope, AstNode *sourc |
| 11497 | 11497 | pointee->special = ConstValSpecialUndef; |
| 11498 | 11498 | pointee->llvm_align = align; |
| 11499 | 11499 | |
| 11500 | IrInstGenAlloca *result = ir_build_alloca_gen(ira, scope, source_node, align, name_hint); | |
| 11500 | Stage1AirInstAlloca *result = ir_build_alloca_gen(ira, scope, source_node, align, name_hint); | |
| 11501 | 11501 | result->base.value->special = ConstValSpecialStatic; |
| 11502 | 11502 | result->base.value->data.x_ptr.special = ConstPtrSpecialRef; |
| 11503 | 11503 | result->base.value->data.x_ptr.mut = force_comptime ? ConstPtrMutComptimeVar : ConstPtrMutInfer; |
| ... | ... | @@ -11572,7 +11572,7 @@ static bool type_can_bit_cast(ZigType *t) { |
| 11572 | 11572 | } |
| 11573 | 11573 | } |
| 11574 | 11574 | |
| 11575 | static void set_up_result_loc_for_inferred_comptime(IrAnalyze *ira, IrInstGen *ptr) { | |
| 11575 | static void set_up_result_loc_for_inferred_comptime(IrAnalyze *ira, Stage1AirInst *ptr) { | |
| 11576 | 11576 | ZigValue *undef_child = ira->codegen->pass1_arena->create<ZigValue>(); |
| 11577 | 11577 | undef_child->type = ptr->value->type->data.pointer.child_type; |
| 11578 | 11578 | undef_child->special = ConstValSpecialUndef; |
| ... | ... | @@ -11611,12 +11611,12 @@ static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out |
| 11611 | 11611 | zig_unreachable(); |
| 11612 | 11612 | } |
| 11613 | 11613 | |
| 11614 | static IrInstGen *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstSrc *suspend_source_instr, | |
| 11614 | static Stage1AirInst *ir_resolve_no_result_loc(IrAnalyze *ira, Stage1ZirInst *suspend_source_instr, | |
| 11615 | 11615 | ResultLoc *result_loc, ZigType *value_type) |
| 11616 | 11616 | { |
| 11617 | 11617 | if (type_is_invalid(value_type)) |
| 11618 | 11618 | return ira->codegen->invalid_inst_gen; |
| 11619 | IrInstGenAlloca *alloca_gen = ir_build_alloca_gen(ira, suspend_source_instr->scope, | |
| 11619 | Stage1AirInstAlloca *alloca_gen = ir_build_alloca_gen(ira, suspend_source_instr->scope, | |
| 11620 | 11620 | suspend_source_instr->source_node, 0, ""); |
| 11621 | 11621 | alloca_gen->base.value->type = get_pointer_to_type_extra(ira->codegen, value_type, false, false, |
| 11622 | 11622 | PtrLenSingle, 0, 0, 0, false); |
| ... | ... | @@ -11632,9 +11632,9 @@ static IrInstGen *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstSrc *suspend_so |
| 11632 | 11632 | |
| 11633 | 11633 | static bool result_loc_is_discard(ResultLoc *result_loc_pass1) { |
| 11634 | 11634 | if (result_loc_pass1->id == ResultLocIdInstruction && |
| 11635 | result_loc_pass1->source_instruction->id == IrInstSrcIdConst) | |
| 11635 | result_loc_pass1->source_instruction->id == Stage1ZirInstIdConst) | |
| 11636 | 11636 | { |
| 11637 | IrInstSrcConst *const_inst = reinterpret_cast<IrInstSrcConst *>(result_loc_pass1->source_instruction); | |
| 11637 | Stage1ZirInstConst *const_inst = reinterpret_cast<Stage1ZirInstConst *>(result_loc_pass1->source_instruction); | |
| 11638 | 11638 | if (value_is_comptime(const_inst->value) && |
| 11639 | 11639 | const_inst->value->type->id == ZigTypeIdPointer && |
| 11640 | 11640 | const_inst->value->data.x_ptr.special == ConstPtrSpecialDiscard) |
| ... | ... | @@ -11646,8 +11646,8 @@ static bool result_loc_is_discard(ResultLoc *result_loc_pass1) { |
| 11646 | 11646 | } |
| 11647 | 11647 | |
| 11648 | 11648 | // when calling this function, at the callsite must check for result type noreturn and propagate it up |
| 11649 | static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_source_instr, | |
| 11650 | ResultLoc *result_loc, ZigType *value_type, IrInstGen *value, bool force_runtime, | |
| 11649 | static Stage1AirInst *ir_resolve_result_raw(IrAnalyze *ira, Stage1ZirInst *suspend_source_instr, | |
| 11650 | ResultLoc *result_loc, ZigType *value_type, Stage1AirInst *value, bool force_runtime, | |
| 11651 | 11651 | bool allow_discard) |
| 11652 | 11652 | { |
| 11653 | 11653 | Error err; |
| ... | ... | @@ -11672,8 +11672,8 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_sourc |
| 11672 | 11672 | } |
| 11673 | 11673 | case ResultLocIdVar: { |
| 11674 | 11674 | ResultLocVar *result_loc_var = reinterpret_cast<ResultLocVar *>(result_loc); |
| 11675 | assert(result_loc->source_instruction->id == IrInstSrcIdAlloca); | |
| 11676 | IrInstSrcAlloca *alloca_src = reinterpret_cast<IrInstSrcAlloca *>(result_loc->source_instruction); | |
| 11675 | assert(result_loc->source_instruction->id == Stage1ZirInstIdAlloca); | |
| 11676 | Stage1ZirInstAlloca *alloca_src = reinterpret_cast<Stage1ZirInstAlloca *>(result_loc->source_instruction); | |
| 11677 | 11677 | |
| 11678 | 11678 | ZigVar *var = result_loc_var->var; |
| 11679 | 11679 | if (var->var_type != nullptr && !ir_get_var_is_comptime(var)) { |
| ... | ... | @@ -11702,7 +11702,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_sourc |
| 11702 | 11702 | if (alloca_src->align != nullptr && !ir_resolve_align(ira, alloca_src->align->child, nullptr, &align)) { |
| 11703 | 11703 | return ira->codegen->invalid_inst_gen; |
| 11704 | 11704 | } |
| 11705 | IrInstGen *alloca_gen = ir_analyze_alloca(ira, | |
| 11705 | Stage1AirInst *alloca_gen = ir_analyze_alloca(ira, | |
| 11706 | 11706 | result_loc->source_instruction->scope, |
| 11707 | 11707 | result_loc->source_instruction->source_node, value_type, |
| 11708 | 11708 | align, alloca_src->name_hint, force_comptime); |
| ... | ... | @@ -11739,7 +11739,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_sourc |
| 11739 | 11739 | ResultLocPeerParent *peer_parent = result_peer->parent; |
| 11740 | 11740 | |
| 11741 | 11741 | if (peer_parent->peers.length == 1) { |
| 11742 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | |
| 11742 | Stage1AirInst *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | |
| 11743 | 11743 | value_type, value, force_runtime, true); |
| 11744 | 11744 | result_peer->suspend_pos.basic_block_index = SIZE_MAX; |
| 11745 | 11745 | result_peer->suspend_pos.instruction_index = SIZE_MAX; |
| ... | ... | @@ -11766,7 +11766,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_sourc |
| 11766 | 11766 | return ira->codegen->invalid_inst_gen; |
| 11767 | 11767 | if (peer_parent_has_type) { |
| 11768 | 11768 | peer_parent->skipped = true; |
| 11769 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | |
| 11769 | Stage1AirInst *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | |
| 11770 | 11770 | value_type, value, force_runtime || !is_condition_comptime, true); |
| 11771 | 11771 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 11772 | 11772 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | ... | @@ -11783,7 +11783,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_sourc |
| 11783 | 11783 | if (peer_parent->end_bb->suspend_instruction_ref == nullptr) { |
| 11784 | 11784 | peer_parent->end_bb->suspend_instruction_ref = suspend_source_instr; |
| 11785 | 11785 | } |
| 11786 | IrInstGen *unreach_inst = ira_suspend(ira, suspend_source_instr, result_peer->next_bb, | |
| 11786 | Stage1AirInst *unreach_inst = ira_suspend(ira, suspend_source_instr, result_peer->next_bb, | |
| 11787 | 11787 | &result_peer->suspend_pos); |
| 11788 | 11788 | if (result_peer->next_bb == nullptr) { |
| 11789 | 11789 | ir_start_next_bb(ira); |
| ... | ... | @@ -11791,7 +11791,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_sourc |
| 11791 | 11791 | return unreach_inst; |
| 11792 | 11792 | } |
| 11793 | 11793 | |
| 11794 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | |
| 11794 | Stage1AirInst *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | |
| 11795 | 11795 | peer_parent->resolved_type, nullptr, force_runtime, true); |
| 11796 | 11796 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 11797 | 11797 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | ... | @@ -11814,7 +11814,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_sourc |
| 11814 | 11814 | return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type); |
| 11815 | 11815 | } |
| 11816 | 11816 | |
| 11817 | IrInstGen *casted_value; | |
| 11817 | Stage1AirInst *casted_value; | |
| 11818 | 11818 | if (value != nullptr) { |
| 11819 | 11819 | casted_value = ir_implicit_cast2(ira, suspend_source_instr->scope, |
| 11820 | 11820 | suspend_source_instr->source_node, value, dest_type); |
| ... | ... | @@ -11825,7 +11825,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_sourc |
| 11825 | 11825 | casted_value = nullptr; |
| 11826 | 11826 | } |
| 11827 | 11827 | |
| 11828 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent, | |
| 11828 | Stage1AirInst *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent, | |
| 11829 | 11829 | dest_type, casted_value, force_runtime, true); |
| 11830 | 11830 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 11831 | 11831 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | ... | @@ -11922,7 +11922,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_sourc |
| 11922 | 11922 | return ira->codegen->invalid_inst_gen; |
| 11923 | 11923 | } |
| 11924 | 11924 | |
| 11925 | IrInstGen *bitcasted_value; | |
| 11925 | Stage1AirInst *bitcasted_value; | |
| 11926 | 11926 | if (value != nullptr) { |
| 11927 | 11927 | bitcasted_value = ir_analyze_bit_cast(ira, result_loc->source_instruction->scope, |
| 11928 | 11928 | result_loc->source_instruction->source_node, value, dest_type); |
| ... | ... | @@ -11936,7 +11936,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_sourc |
| 11936 | 11936 | } |
| 11937 | 11937 | |
| 11938 | 11938 | bool parent_was_written = result_bit_cast->parent->written; |
| 11939 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent, | |
| 11939 | Stage1AirInst *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent, | |
| 11940 | 11940 | dest_type, bitcasted_value, force_runtime, true); |
| 11941 | 11941 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 11942 | 11942 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | ... | @@ -11987,15 +11987,15 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInstSrc *suspend_sourc |
| 11987 | 11987 | zig_unreachable(); |
| 11988 | 11988 | } |
| 11989 | 11989 | |
| 11990 | static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInstSrc *suspend_source_instr, | |
| 11991 | ResultLoc *result_loc_pass1, ZigType *value_type, IrInstGen *value, bool force_runtime, | |
| 11990 | static Stage1AirInst *ir_resolve_result(IrAnalyze *ira, Stage1ZirInst *suspend_source_instr, | |
| 11991 | ResultLoc *result_loc_pass1, ZigType *value_type, Stage1AirInst *value, bool force_runtime, | |
| 11992 | 11992 | bool allow_discard) |
| 11993 | 11993 | { |
| 11994 | 11994 | if (!allow_discard && result_loc_is_discard(result_loc_pass1)) { |
| 11995 | 11995 | result_loc_pass1 = no_result_loc(); |
| 11996 | 11996 | } |
| 11997 | 11997 | bool was_written = result_loc_pass1->written; |
| 11998 | IrInstGen *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, | |
| 11998 | Stage1AirInst *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, | |
| 11999 | 11999 | value, force_runtime, allow_discard); |
| 12000 | 12000 | if (result_loc == nullptr || result_loc->value->type->id == ZigTypeIdUnreachable || |
| 12001 | 12001 | type_is_invalid(result_loc->value->type)) |
| ... | ... | @@ -12012,7 +12012,7 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInstSrc *suspend_source_in |
| 12012 | 12012 | InferredStructField *isf = result_loc->value->type->data.pointer.inferred_struct_field; |
| 12013 | 12013 | if (isf != nullptr) { |
| 12014 | 12014 | TypeStructField *field; |
| 12015 | IrInstGen *casted_ptr; | |
| 12015 | Stage1AirInst *casted_ptr; | |
| 12016 | 12016 | if (isf->already_resolved) { |
| 12017 | 12017 | field = find_struct_type_field(isf->inferred_struct_type, isf->field_name); |
| 12018 | 12018 | casted_ptr = result_loc; |
| ... | ... | @@ -12102,7 +12102,7 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInstSrc *suspend_source_in |
| 12102 | 12102 | return ir_analyze_unwrap_err_code(ira, suspend_source_instr->scope, |
| 12103 | 12103 | suspend_source_instr->source_node, result_loc, true); |
| 12104 | 12104 | } else { |
| 12105 | IrInstGen *unwrapped_err_ptr = ir_analyze_unwrap_error_payload(ira, | |
| 12105 | Stage1AirInst *unwrapped_err_ptr = ir_analyze_unwrap_error_payload(ira, | |
| 12106 | 12106 | suspend_source_instr->scope, suspend_source_instr->source_node, |
| 12107 | 12107 | result_loc, false, true); |
| 12108 | 12108 | ZigType *actual_payload_type = actual_elem_type->data.error_union.payload_type; |
| ... | ... | @@ -12119,7 +12119,7 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInstSrc *suspend_source_in |
| 12119 | 12119 | return result_loc; |
| 12120 | 12120 | } |
| 12121 | 12121 | |
| 12122 | static IrInstGen *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstSrcResolveResult *instruction) { | |
| 12122 | static Stage1AirInst *ir_analyze_instruction_resolve_result(IrAnalyze *ira, Stage1ZirInstResolveResult *instruction) { | |
| 12123 | 12123 | ZigType *implicit_elem_type; |
| 12124 | 12124 | if (instruction->ty == nullptr) { |
| 12125 | 12125 | if (instruction->result_loc->id == ResultLocIdCast) { |
| ... | ... | @@ -12158,7 +12158,7 @@ static IrInstGen *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstSr |
| 12158 | 12158 | if (type_is_invalid(implicit_elem_type)) |
| 12159 | 12159 | return ira->codegen->invalid_inst_gen; |
| 12160 | 12160 | } |
| 12161 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | |
| 12161 | Stage1AirInst *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | |
| 12162 | 12162 | implicit_elem_type, nullptr, false, true); |
| 12163 | 12163 | if (result_loc != nullptr) |
| 12164 | 12164 | return result_loc; |
| ... | ... | @@ -12178,9 +12178,9 @@ static IrInstGen *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstSr |
| 12178 | 12178 | return result_loc; |
| 12179 | 12179 | } |
| 12180 | 12180 | |
| 12181 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, implicit_elem_type); | |
| 12181 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, implicit_elem_type); | |
| 12182 | 12182 | result->value->special = ConstValSpecialUndef; |
| 12183 | IrInstGen *ptr = ir_get_ref(ira, instruction->base.scope, instruction->base.source_node, result, false, false); | |
| 12183 | Stage1AirInst *ptr = ir_get_ref(ira, instruction->base.scope, instruction->base.source_node, result, false, false); | |
| 12184 | 12184 | ptr->value->data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 12185 | 12185 | return ptr; |
| 12186 | 12186 | } |
| ... | ... | @@ -12204,7 +12204,7 @@ static void ir_reset_result(ResultLoc *result_loc) { |
| 12204 | 12204 | break; |
| 12205 | 12205 | } |
| 12206 | 12206 | case ResultLocIdVar: { |
| 12207 | IrInstSrcAlloca *alloca_src = reinterpret_cast<IrInstSrcAlloca *>(result_loc->source_instruction); | |
| 12207 | Stage1ZirInstAlloca *alloca_src = reinterpret_cast<Stage1ZirInstAlloca *>(result_loc->source_instruction); | |
| 12208 | 12208 | alloca_src->base.child = nullptr; |
| 12209 | 12209 | break; |
| 12210 | 12210 | } |
| ... | ... | @@ -12220,14 +12220,14 @@ static void ir_reset_result(ResultLoc *result_loc) { |
| 12220 | 12220 | } |
| 12221 | 12221 | } |
| 12222 | 12222 | |
| 12223 | static IrInstGen *ir_analyze_instruction_reset_result(IrAnalyze *ira, IrInstSrcResetResult *instruction) { | |
| 12223 | static Stage1AirInst *ir_analyze_instruction_reset_result(IrAnalyze *ira, Stage1ZirInstResetResult *instruction) { | |
| 12224 | 12224 | ir_reset_result(instruction->result_loc); |
| 12225 | 12225 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 12226 | 12226 | } |
| 12227 | 12227 | |
| 12228 | static IrInstGen *get_async_call_result_loc(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 12229 | ZigType *fn_ret_type, bool is_async_call_builtin, IrInstGen **args_ptr, size_t args_len, | |
| 12230 | IrInstGen *ret_ptr_uncasted) | |
| 12228 | static Stage1AirInst *get_async_call_result_loc(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 12229 | ZigType *fn_ret_type, bool is_async_call_builtin, Stage1AirInst **args_ptr, size_t args_len, | |
| 12230 | Stage1AirInst *ret_ptr_uncasted) | |
| 12231 | 12231 | { |
| 12232 | 12232 | src_assert(is_async_call_builtin, source_node); |
| 12233 | 12233 | if (type_is_invalid(ret_ptr_uncasted->value->type)) |
| ... | ... | @@ -12239,9 +12239,9 @@ static IrInstGen *get_async_call_result_loc(IrAnalyze *ira, Scope *scope, AstNod |
| 12239 | 12239 | return ir_implicit_cast(ira, ret_ptr_uncasted, get_pointer_to_type(ira->codegen, fn_ret_type, false)); |
| 12240 | 12240 | } |
| 12241 | 12241 | |
| 12242 | static IrInstGen *ir_analyze_async_call(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigFn *fn_entry, | |
| 12243 | ZigType *fn_type, IrInstGen *fn_ref, IrInstGen **casted_args, size_t arg_count, | |
| 12244 | IrInstGen *casted_new_stack, bool is_async_call_builtin, IrInstGen *ret_ptr_uncasted, | |
| 12242 | static Stage1AirInst *ir_analyze_async_call(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigFn *fn_entry, | |
| 12243 | ZigType *fn_type, Stage1AirInst *fn_ref, Stage1AirInst **casted_args, size_t arg_count, | |
| 12244 | Stage1AirInst *casted_new_stack, bool is_async_call_builtin, Stage1AirInst *ret_ptr_uncasted, | |
| 12245 | 12245 | ResultLoc *call_result_loc) |
| 12246 | 12246 | { |
| 12247 | 12247 | if (fn_entry == nullptr) { |
| ... | ... | @@ -12257,20 +12257,20 @@ static IrInstGen *ir_analyze_async_call(IrAnalyze *ira, Scope *scope, AstNode *s |
| 12257 | 12257 | } |
| 12258 | 12258 | if (casted_new_stack != nullptr) { |
| 12259 | 12259 | ZigType *fn_ret_type = fn_type->data.fn.fn_type_id.return_type; |
| 12260 | IrInstGen *ret_ptr = get_async_call_result_loc(ira, scope, source_node, fn_ret_type, is_async_call_builtin, | |
| 12260 | Stage1AirInst *ret_ptr = get_async_call_result_loc(ira, scope, source_node, fn_ret_type, is_async_call_builtin, | |
| 12261 | 12261 | casted_args, arg_count, ret_ptr_uncasted); |
| 12262 | 12262 | if (ret_ptr != nullptr && type_is_invalid(ret_ptr->value->type)) |
| 12263 | 12263 | return ira->codegen->invalid_inst_gen; |
| 12264 | 12264 | |
| 12265 | 12265 | ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type); |
| 12266 | 12266 | |
| 12267 | IrInstGenCall *call_gen = ir_build_call_gen(ira, scope, source_node, fn_entry, fn_ref, | |
| 12267 | Stage1AirInstCall *call_gen = ir_build_call_gen(ira, scope, source_node, fn_entry, fn_ref, | |
| 12268 | 12268 | arg_count, casted_args, CallModifierAsync, casted_new_stack, |
| 12269 | 12269 | is_async_call_builtin, ret_ptr, anyframe_type); |
| 12270 | 12270 | return &call_gen->base; |
| 12271 | 12271 | } else { |
| 12272 | 12272 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry); |
| 12273 | IrInstGen *result_loc = ir_resolve_result(ira, ira->suspend_source_instr, call_result_loc, | |
| 12273 | Stage1AirInst *result_loc = ir_resolve_result(ira, ira->suspend_source_instr, call_result_loc, | |
| 12274 | 12274 | frame_type, nullptr, true, false); |
| 12275 | 12275 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 12276 | 12276 | return result_loc; |
| ... | ... | @@ -12285,12 +12285,12 @@ static IrInstGen *ir_analyze_async_call(IrAnalyze *ira, Scope *scope, AstNode *s |
| 12285 | 12285 | } |
| 12286 | 12286 | } |
| 12287 | 12287 | static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node, |
| 12288 | IrInstGen *arg, Scope **exec_scope, size_t *next_proto_i) | |
| 12288 | Stage1AirInst *arg, Scope **exec_scope, size_t *next_proto_i) | |
| 12289 | 12289 | { |
| 12290 | 12290 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); |
| 12291 | 12291 | assert(param_decl_node->type == NodeTypeParamDecl); |
| 12292 | 12292 | |
| 12293 | IrInstGen *casted_arg; | |
| 12293 | Stage1AirInst *casted_arg; | |
| 12294 | 12294 | if (param_decl_node->data.param_decl.anytype_token == 0) { |
| 12295 | 12295 | AstNode *param_type_node = param_decl_node->data.param_decl.type; |
| 12296 | 12296 | ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node); |
| ... | ... | @@ -12318,15 +12318,15 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 12318 | 12318 | } |
| 12319 | 12319 | |
| 12320 | 12320 | static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_node, |
| 12321 | IrInstGen *arg, AstNode *arg_src, Scope **child_scope, size_t *next_proto_i, | |
| 12322 | GenericFnTypeId *generic_id, FnTypeId *fn_type_id, IrInstGen **casted_args, | |
| 12321 | Stage1AirInst *arg, AstNode *arg_src, Scope **child_scope, size_t *next_proto_i, | |
| 12322 | GenericFnTypeId *generic_id, FnTypeId *fn_type_id, Stage1AirInst **casted_args, | |
| 12323 | 12323 | ZigFn *impl_fn) |
| 12324 | 12324 | { |
| 12325 | 12325 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); |
| 12326 | 12326 | assert(param_decl_node->type == NodeTypeParamDecl); |
| 12327 | 12327 | bool is_var_args = param_decl_node->data.param_decl.is_var_args; |
| 12328 | 12328 | bool arg_part_of_generic_id = false; |
| 12329 | IrInstGen *casted_arg; | |
| 12329 | Stage1AirInst *casted_arg; | |
| 12330 | 12330 | |
| 12331 | 12331 | ZigType *param_info_type = nullptr; |
| 12332 | 12332 | if (is_var_args) { |
| ... | ... | @@ -12414,7 +12414,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 12414 | 12414 | return true; |
| 12415 | 12415 | } |
| 12416 | 12416 | |
| 12417 | static IrInstGen *ir_get_var_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigVar *var) { | |
| 12417 | static Stage1AirInst *ir_get_var_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigVar *var) { | |
| 12418 | 12418 | while (var->next_var != nullptr) { |
| 12419 | 12419 | var = var->next_var; |
| 12420 | 12420 | } |
| ... | ... | @@ -12433,7 +12433,7 @@ static IrInstGen *ir_get_var_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_n |
| 12433 | 12433 | bool comptime_var_mem = ir_get_var_is_comptime(var); |
| 12434 | 12434 | bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern; |
| 12435 | 12435 | |
| 12436 | IrInstGen *result = ir_build_var_ptr_gen(ira, scope, source_node, var); | |
| 12436 | Stage1AirInst *result = ir_build_var_ptr_gen(ira, scope, source_node, var); | |
| 12437 | 12437 | result->value->type = var_ptr_type; |
| 12438 | 12438 | |
| 12439 | 12439 | if (!linkage_makes_it_runtime && !var->is_thread_local && value_is_comptime(var->const_value)) { |
| ... | ... | @@ -12482,8 +12482,8 @@ static void mark_comptime_value_escape(IrAnalyze *ira, Scope *scope, AstNode *so |
| 12482 | 12482 | } |
| 12483 | 12483 | } |
| 12484 | 12484 | |
| 12485 | static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 12486 | IrInstGen *ptr, IrInstGen *uncasted_value, bool allow_write_through_const) | |
| 12485 | static Stage1AirInst *ir_analyze_store_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 12486 | Stage1AirInst *ptr, Stage1AirInst *uncasted_value, bool allow_write_through_const) | |
| 12487 | 12487 | { |
| 12488 | 12488 | assert(ptr->value->type->id == ZigTypeIdPointer); |
| 12489 | 12489 | |
| ... | ... | @@ -12503,7 +12503,7 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, Scope *scope, AstNode *so |
| 12503 | 12503 | } |
| 12504 | 12504 | |
| 12505 | 12505 | ZigType *child_type = ptr->value->type->data.pointer.child_type; |
| 12506 | IrInstGen *value = ir_implicit_cast(ira, uncasted_value, child_type); | |
| 12506 | Stage1AirInst *value = ir_implicit_cast(ira, uncasted_value, child_type); | |
| 12507 | 12507 | if (type_is_invalid(value->value->type)) |
| 12508 | 12508 | return ira->codegen->invalid_inst_gen; |
| 12509 | 12509 | |
| ... | ... | @@ -12583,14 +12583,14 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, Scope *scope, AstNode *so |
| 12583 | 12583 | } |
| 12584 | 12584 | |
| 12585 | 12585 | // If this is a store to a pointer with a runtime-known vector index, |
| 12586 | // we have to figure out the IrInstGen which represents the index and | |
| 12587 | // emit a IrInstGenVectorStoreElem, or emit a compile error | |
| 12586 | // we have to figure out the Stage1AirInst which represents the index and | |
| 12587 | // emit a Stage1AirInstVectorStoreElem, or emit a compile error | |
| 12588 | 12588 | // explaining why it is impossible for this store to work. Which is that |
| 12589 | 12589 | // the pointer address is of the vector; without the element index being known |
| 12590 | 12590 | // we cannot properly perform the insertion. |
| 12591 | 12591 | if (ptr->value->type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { |
| 12592 | if (ptr->id == IrInstGenIdElemPtr) { | |
| 12593 | IrInstGenElemPtr *elem_ptr = (IrInstGenElemPtr *)ptr; | |
| 12592 | if (ptr->id == Stage1AirInstIdElemPtr) { | |
| 12593 | Stage1AirInstElemPtr *elem_ptr = (Stage1AirInstElemPtr *)ptr; | |
| 12594 | 12594 | return ir_build_vector_store_elem(ira, scope, source_node, elem_ptr->array_ptr, |
| 12595 | 12595 | elem_ptr->elem_index, value); |
| 12596 | 12596 | } |
| ... | ... | @@ -12603,8 +12603,8 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, Scope *scope, AstNode *so |
| 12603 | 12603 | return ir_build_store_ptr_gen(ira, scope, source_node, ptr, value); |
| 12604 | 12604 | } |
| 12605 | 12605 | |
| 12606 | static IrInstGen *analyze_casted_new_stack(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 12607 | IrInstGen *new_stack, AstNode *new_stack_src, bool is_async_call_builtin, ZigFn *fn_entry) | |
| 12606 | static Stage1AirInst *analyze_casted_new_stack(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 12607 | Stage1AirInst *new_stack, AstNode *new_stack_src, bool is_async_call_builtin, ZigFn *fn_entry) | |
| 12608 | 12608 | { |
| 12609 | 12609 | if (new_stack == nullptr) |
| 12610 | 12610 | return nullptr; |
| ... | ... | @@ -12637,11 +12637,11 @@ static IrInstGen *analyze_casted_new_stack(IrAnalyze *ira, Scope *scope, AstNode |
| 12637 | 12637 | } |
| 12638 | 12638 | } |
| 12639 | 12639 | |
| 12640 | static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 12641 | ZigFn *fn_entry, ZigType *fn_type, IrInstGen *fn_ref, | |
| 12642 | IrInstGen *first_arg_ptr, AstNode *first_arg_ptr_src, CallModifier modifier, | |
| 12643 | IrInstGen *new_stack, AstNode *new_stack_src, bool is_async_call_builtin, | |
| 12644 | IrInstGen **args_ptr, size_t args_len, IrInstGen *ret_ptr, ResultLoc *call_result_loc) | |
| 12640 | static Stage1AirInst *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 12641 | ZigFn *fn_entry, ZigType *fn_type, Stage1AirInst *fn_ref, | |
| 12642 | Stage1AirInst *first_arg_ptr, AstNode *first_arg_ptr_src, CallModifier modifier, | |
| 12643 | Stage1AirInst *new_stack, AstNode *new_stack_src, bool is_async_call_builtin, | |
| 12644 | Stage1AirInst **args_ptr, size_t args_len, Stage1AirInst *ret_ptr, ResultLoc *call_result_loc) | |
| 12645 | 12645 | { |
| 12646 | 12646 | Error err; |
| 12647 | 12647 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; |
| ... | ... | @@ -12729,7 +12729,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 12729 | 12729 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; |
| 12730 | 12730 | } |
| 12731 | 12731 | |
| 12732 | IrInstGen *first_arg; | |
| 12732 | Stage1AirInst *first_arg; | |
| 12733 | 12733 | if (!first_arg_known_bare) { |
| 12734 | 12734 | first_arg = first_arg_ptr; |
| 12735 | 12735 | } else { |
| ... | ... | @@ -12743,7 +12743,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 12743 | 12743 | } |
| 12744 | 12744 | |
| 12745 | 12745 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { |
| 12746 | IrInstGen *old_arg = args_ptr[call_i]; | |
| 12746 | Stage1AirInst *old_arg = args_ptr[call_i]; | |
| 12747 | 12747 | |
| 12748 | 12748 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) |
| 12749 | 12749 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -12841,7 +12841,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 12841 | 12841 | } |
| 12842 | 12842 | } |
| 12843 | 12843 | |
| 12844 | IrInstGen *new_instruction = ir_const_move(ira, scope, source_node, result); | |
| 12844 | Stage1AirInst *new_instruction = ir_const_move(ira, scope, source_node, result); | |
| 12845 | 12845 | return ir_finish_anal(ira, new_instruction); |
| 12846 | 12846 | } |
| 12847 | 12847 | |
| ... | ... | @@ -12854,7 +12854,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 12854 | 12854 | |
| 12855 | 12855 | size_t new_fn_arg_count = first_arg_1_or_0 + args_len; |
| 12856 | 12856 | |
| 12857 | IrInstGen **casted_args = heap::c_allocator.allocate<IrInstGen *>(new_fn_arg_count); | |
| 12857 | Stage1AirInst **casted_args = heap::c_allocator.allocate<Stage1AirInst *>(new_fn_arg_count); | |
| 12858 | 12858 | |
| 12859 | 12859 | // Fork a scope of the function with known values for the parameters. |
| 12860 | 12860 | Scope *parent_scope = fn_entry->fndef_scope->base.parent; |
| ... | ... | @@ -12887,7 +12887,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 12887 | 12887 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; |
| 12888 | 12888 | } |
| 12889 | 12889 | |
| 12890 | IrInstGen *first_arg; | |
| 12890 | Stage1AirInst *first_arg; | |
| 12891 | 12891 | if (!first_arg_known_bare) { |
| 12892 | 12892 | first_arg = first_arg_ptr; |
| 12893 | 12893 | } else { |
| ... | ... | @@ -12907,7 +12907,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 12907 | 12907 | ZigFn *parent_fn_entry = ira->fn; |
| 12908 | 12908 | assert(parent_fn_entry); |
| 12909 | 12909 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { |
| 12910 | IrInstGen *arg = args_ptr[call_i]; | |
| 12910 | Stage1AirInst *arg = args_ptr[call_i]; | |
| 12911 | 12911 | |
| 12912 | 12912 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); |
| 12913 | 12913 | assert(param_decl_node->type == NodeTypeParamDecl); |
| ... | ... | @@ -12932,7 +12932,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 12932 | 12932 | { |
| 12933 | 12933 | return ira->codegen->invalid_inst_gen; |
| 12934 | 12934 | } |
| 12935 | IrInstGenConst *const_instruction = ir_create_inst_noval<IrInstGenConst>(&ira->new_irb, | |
| 12935 | Stage1AirInstConst *const_instruction = ir_create_inst_noval<Stage1AirInstConst>(&ira->new_irb, | |
| 12936 | 12936 | impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr); |
| 12937 | 12937 | const_instruction->base.value = align_result; |
| 12938 | 12938 | |
| ... | ... | @@ -13015,20 +13015,20 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13015 | 13015 | parent_fn_entry->calls_or_awaits_errorable_fn = true; |
| 13016 | 13016 | } |
| 13017 | 13017 | |
| 13018 | IrInstGen *casted_new_stack = analyze_casted_new_stack(ira, scope, source_node, new_stack, | |
| 13018 | Stage1AirInst *casted_new_stack = analyze_casted_new_stack(ira, scope, source_node, new_stack, | |
| 13019 | 13019 | new_stack_src, is_async_call_builtin, impl_fn); |
| 13020 | 13020 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) |
| 13021 | 13021 | return ira->codegen->invalid_inst_gen; |
| 13022 | 13022 | |
| 13023 | 13023 | size_t impl_param_count = impl_fn_type_id->param_count; |
| 13024 | 13024 | if (modifier == CallModifierAsync) { |
| 13025 | IrInstGen *result = ir_analyze_async_call(ira, scope, source_node, impl_fn, impl_fn->type_entry, | |
| 13025 | Stage1AirInst *result = ir_analyze_async_call(ira, scope, source_node, impl_fn, impl_fn->type_entry, | |
| 13026 | 13026 | nullptr, casted_args, impl_param_count, casted_new_stack, is_async_call_builtin, ret_ptr, |
| 13027 | 13027 | call_result_loc); |
| 13028 | 13028 | return ir_finish_anal(ira, result); |
| 13029 | 13029 | } |
| 13030 | 13030 | |
| 13031 | IrInstGen *result_loc; | |
| 13031 | Stage1AirInst *result_loc; | |
| 13032 | 13032 | if (handle_is_ptr(ira->codegen, impl_fn_type_id->return_type)) { |
| 13033 | 13033 | result_loc = ir_resolve_result(ira, ira->suspend_source_instr, call_result_loc, |
| 13034 | 13034 | impl_fn_type_id->return_type, nullptr, true, false); |
| ... | ... | @@ -13041,9 +13041,9 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13041 | 13041 | return ira->codegen->invalid_inst_gen; |
| 13042 | 13042 | } |
| 13043 | 13043 | |
| 13044 | IrInstGen *dummy_value = ir_const(ira, scope, source_node, impl_fn_type_id->return_type); | |
| 13044 | Stage1AirInst *dummy_value = ir_const(ira, scope, source_node, impl_fn_type_id->return_type); | |
| 13045 | 13045 | dummy_value->value->special = ConstValSpecialRuntime; |
| 13046 | IrInstGen *dummy_result = ir_implicit_cast2(ira, scope, source_node, | |
| 13046 | Stage1AirInst *dummy_result = ir_implicit_cast2(ira, scope, source_node, | |
| 13047 | 13047 | dummy_value, result_loc->value->type->data.pointer.child_type); |
| 13048 | 13048 | if (type_is_invalid(dummy_result->value->type)) |
| 13049 | 13049 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -13073,7 +13073,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13073 | 13073 | parent_fn_entry->inferred_async_fn = impl_fn; |
| 13074 | 13074 | } |
| 13075 | 13075 | |
| 13076 | IrInstGenCall *new_call_instruction = ir_build_call_gen(ira, scope, source_node, | |
| 13076 | Stage1AirInstCall *new_call_instruction = ir_build_call_gen(ira, scope, source_node, | |
| 13077 | 13077 | impl_fn, nullptr, impl_param_count, casted_args, modifier, casted_new_stack, |
| 13078 | 13078 | is_async_call_builtin, result_loc, impl_fn_type_id->return_type); |
| 13079 | 13079 | |
| ... | ... | @@ -13092,7 +13092,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13092 | 13092 | } |
| 13093 | 13093 | |
| 13094 | 13094 | |
| 13095 | IrInstGen **casted_args = heap::c_allocator.allocate<IrInstGen *>(call_param_count); | |
| 13095 | Stage1AirInst **casted_args = heap::c_allocator.allocate<Stage1AirInst *>(call_param_count); | |
| 13096 | 13096 | size_t next_arg_index = 0; |
| 13097 | 13097 | if (first_arg_ptr) { |
| 13098 | 13098 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); |
| ... | ... | @@ -13101,7 +13101,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13101 | 13101 | if (type_is_invalid(param_type)) |
| 13102 | 13102 | return ira->codegen->invalid_inst_gen; |
| 13103 | 13103 | |
| 13104 | IrInstGen *first_arg; | |
| 13104 | Stage1AirInst *first_arg; | |
| 13105 | 13105 | if (param_type->id == ZigTypeIdPointer) { |
| 13106 | 13106 | first_arg = first_arg_ptr; |
| 13107 | 13107 | } else { |
| ... | ... | @@ -13111,7 +13111,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13111 | 13111 | return ira->codegen->invalid_inst_gen; |
| 13112 | 13112 | } |
| 13113 | 13113 | |
| 13114 | IrInstGen *casted_arg = ir_implicit_cast2(ira, first_arg->scope, first_arg_ptr_src, first_arg, param_type); | |
| 13114 | Stage1AirInst *casted_arg = ir_implicit_cast2(ira, first_arg->scope, first_arg_ptr_src, first_arg, param_type); | |
| 13115 | 13115 | if (type_is_invalid(casted_arg->value->type)) |
| 13116 | 13116 | return ira->codegen->invalid_inst_gen; |
| 13117 | 13117 | |
| ... | ... | @@ -13119,11 +13119,11 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13119 | 13119 | next_arg_index += 1; |
| 13120 | 13120 | } |
| 13121 | 13121 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { |
| 13122 | IrInstGen *old_arg = args_ptr[call_i]; | |
| 13122 | Stage1AirInst *old_arg = args_ptr[call_i]; | |
| 13123 | 13123 | if (type_is_invalid(old_arg->value->type)) |
| 13124 | 13124 | return ira->codegen->invalid_inst_gen; |
| 13125 | 13125 | |
| 13126 | IrInstGen *casted_arg; | |
| 13126 | Stage1AirInst *casted_arg; | |
| 13127 | 13127 | if (next_arg_index < src_param_count) { |
| 13128 | 13128 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; |
| 13129 | 13129 | if (type_is_invalid(param_type)) |
| ... | ... | @@ -13151,13 +13151,13 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13151 | 13151 | return ira->codegen->invalid_inst_gen; |
| 13152 | 13152 | } |
| 13153 | 13153 | |
| 13154 | IrInstGen *casted_new_stack = analyze_casted_new_stack(ira, scope, source_node, new_stack, new_stack_src, | |
| 13154 | Stage1AirInst *casted_new_stack = analyze_casted_new_stack(ira, scope, source_node, new_stack, new_stack_src, | |
| 13155 | 13155 | is_async_call_builtin, fn_entry); |
| 13156 | 13156 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) |
| 13157 | 13157 | return ira->codegen->invalid_inst_gen; |
| 13158 | 13158 | |
| 13159 | 13159 | if (modifier == CallModifierAsync) { |
| 13160 | IrInstGen *result = ir_analyze_async_call(ira, scope, source_node, fn_entry, fn_type, fn_ref, | |
| 13160 | Stage1AirInst *result = ir_analyze_async_call(ira, scope, source_node, fn_entry, fn_type, fn_ref, | |
| 13161 | 13161 | casted_args, call_param_count, casted_new_stack, is_async_call_builtin, ret_ptr, call_result_loc); |
| 13162 | 13162 | return ir_finish_anal(ira, result); |
| 13163 | 13163 | } |
| ... | ... | @@ -13170,7 +13170,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13170 | 13170 | parent_fn_entry->inferred_async_fn = fn_entry; |
| 13171 | 13171 | } |
| 13172 | 13172 | |
| 13173 | IrInstGen *result_loc; | |
| 13173 | Stage1AirInst *result_loc; | |
| 13174 | 13174 | if (handle_is_ptr(ira->codegen, return_type)) { |
| 13175 | 13175 | result_loc = ir_resolve_result(ira, ira->suspend_source_instr, call_result_loc, |
| 13176 | 13176 | return_type, nullptr, true, false); |
| ... | ... | @@ -13185,9 +13185,9 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13185 | 13185 | |
| 13186 | 13186 | ZigType *expected_return_type = result_loc->value->type->data.pointer.child_type; |
| 13187 | 13187 | |
| 13188 | IrInstGen *dummy_value = ir_const(ira, scope, source_node, return_type); | |
| 13188 | Stage1AirInst *dummy_value = ir_const(ira, scope, source_node, return_type); | |
| 13189 | 13189 | dummy_value->value->special = ConstValSpecialRuntime; |
| 13190 | IrInstGen *dummy_result = ir_implicit_cast2(ira, scope, source_node, | |
| 13190 | Stage1AirInst *dummy_result = ir_implicit_cast2(ira, scope, source_node, | |
| 13191 | 13191 | dummy_value, expected_return_type); |
| 13192 | 13192 | if (type_is_invalid(dummy_result->value->type)) { |
| 13193 | 13193 | if ((return_type->id == ZigTypeIdErrorUnion || return_type->id == ZigTypeIdErrorSet) && |
| ... | ... | @@ -13220,7 +13220,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13220 | 13220 | result_loc = nullptr; |
| 13221 | 13221 | } |
| 13222 | 13222 | |
| 13223 | IrInstGenCall *new_call_instruction = ir_build_call_gen(ira, scope, source_node, fn_entry, fn_ref, | |
| 13223 | Stage1AirInstCall *new_call_instruction = ir_build_call_gen(ira, scope, source_node, fn_entry, fn_ref, | |
| 13224 | 13224 | call_param_count, casted_args, modifier, casted_new_stack, |
| 13225 | 13225 | is_async_call_builtin, result_loc, return_type); |
| 13226 | 13226 | if (get_scope_typeof(scope) == nullptr) { |
| ... | ... | @@ -13229,11 +13229,11 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 13229 | 13229 | return ir_finish_anal(ira, &new_call_instruction->base); |
| 13230 | 13230 | } |
| 13231 | 13231 | |
| 13232 | static IrInstGen *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstSrcCall *call_instruction, | |
| 13233 | ZigFn *fn_entry, ZigType *fn_type, IrInstGen *fn_ref, | |
| 13234 | IrInstGen *first_arg_ptr, AstNode *first_arg_ptr_src, CallModifier modifier) | |
| 13232 | static Stage1AirInst *ir_analyze_fn_call_src(IrAnalyze *ira, Stage1ZirInstCall *call_instruction, | |
| 13233 | ZigFn *fn_entry, ZigType *fn_type, Stage1AirInst *fn_ref, | |
| 13234 | Stage1AirInst *first_arg_ptr, AstNode *first_arg_ptr_src, CallModifier modifier) | |
| 13235 | 13235 | { |
| 13236 | IrInstGen *new_stack = nullptr; | |
| 13236 | Stage1AirInst *new_stack = nullptr; | |
| 13237 | 13237 | AstNode *new_stack_src = nullptr; |
| 13238 | 13238 | if (call_instruction->new_stack) { |
| 13239 | 13239 | new_stack = call_instruction->new_stack->child; |
| ... | ... | @@ -13241,19 +13241,19 @@ static IrInstGen *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstSrcCall *call_ins |
| 13241 | 13241 | return ira->codegen->invalid_inst_gen; |
| 13242 | 13242 | new_stack_src = call_instruction->new_stack->source_node; |
| 13243 | 13243 | } |
| 13244 | IrInstGen **args_ptr = heap::c_allocator.allocate<IrInstGen *>(call_instruction->arg_count); | |
| 13244 | Stage1AirInst **args_ptr = heap::c_allocator.allocate<Stage1AirInst *>(call_instruction->arg_count); | |
| 13245 | 13245 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { |
| 13246 | 13246 | args_ptr[i] = call_instruction->args[i]->child; |
| 13247 | 13247 | if (type_is_invalid(args_ptr[i]->value->type)) |
| 13248 | 13248 | return ira->codegen->invalid_inst_gen; |
| 13249 | 13249 | } |
| 13250 | IrInstGen *ret_ptr = nullptr; | |
| 13250 | Stage1AirInst *ret_ptr = nullptr; | |
| 13251 | 13251 | if (call_instruction->ret_ptr != nullptr) { |
| 13252 | 13252 | ret_ptr = call_instruction->ret_ptr->child; |
| 13253 | 13253 | if (type_is_invalid(ret_ptr->value->type)) |
| 13254 | 13254 | return ira->codegen->invalid_inst_gen; |
| 13255 | 13255 | } |
| 13256 | IrInstGen *result = ir_analyze_fn_call(ira, call_instruction->base.scope, | |
| 13256 | Stage1AirInst *result = ir_analyze_fn_call(ira, call_instruction->base.scope, | |
| 13257 | 13257 | call_instruction->base.source_node, fn_entry, fn_type, fn_ref, |
| 13258 | 13258 | first_arg_ptr, first_arg_ptr_src, modifier, new_stack, new_stack_src, |
| 13259 | 13259 | call_instruction->is_async_call_builtin, args_ptr, call_instruction->arg_count, ret_ptr, |
| ... | ... | @@ -13262,21 +13262,21 @@ static IrInstGen *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstSrcCall *call_ins |
| 13262 | 13262 | return result; |
| 13263 | 13263 | } |
| 13264 | 13264 | |
| 13265 | static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 13266 | IrInstSrc *pass1_options, IrInstSrc *pass1_fn_ref, IrInstGen **args_ptr, size_t args_len, | |
| 13265 | static Stage1AirInst *ir_analyze_call_extra(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 13266 | Stage1ZirInst *pass1_options, Stage1ZirInst *pass1_fn_ref, Stage1AirInst **args_ptr, size_t args_len, | |
| 13267 | 13267 | ResultLoc *result_loc) |
| 13268 | 13268 | { |
| 13269 | IrInstGen *options = pass1_options->child; | |
| 13269 | Stage1AirInst *options = pass1_options->child; | |
| 13270 | 13270 | if (type_is_invalid(options->value->type)) |
| 13271 | 13271 | return ira->codegen->invalid_inst_gen; |
| 13272 | 13272 | |
| 13273 | IrInstGen *fn_ref = pass1_fn_ref->child; | |
| 13273 | Stage1AirInst *fn_ref = pass1_fn_ref->child; | |
| 13274 | 13274 | if (type_is_invalid(fn_ref->value->type)) |
| 13275 | 13275 | return ira->codegen->invalid_inst_gen; |
| 13276 | 13276 | |
| 13277 | 13277 | TypeStructField *modifier_field = find_struct_type_field(options->value->type, buf_create_from_str("modifier")); |
| 13278 | 13278 | src_assert(modifier_field != nullptr, source_node); |
| 13279 | IrInstGen *modifier_inst = ir_analyze_struct_value_field_value(ira, scope, source_node, options, modifier_field); | |
| 13279 | Stage1AirInst *modifier_inst = ir_analyze_struct_value_field_value(ira, scope, source_node, options, modifier_field); | |
| 13280 | 13280 | ZigValue *modifier_val = ir_resolve_const(ira, modifier_inst, UndefBad); |
| 13281 | 13281 | if (modifier_val == nullptr) |
| 13282 | 13282 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -13307,7 +13307,7 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, Scope *scope, AstNode *s |
| 13307 | 13307 | } |
| 13308 | 13308 | } |
| 13309 | 13309 | |
| 13310 | IrInstGen *first_arg_ptr = nullptr; | |
| 13310 | Stage1AirInst *first_arg_ptr = nullptr; | |
| 13311 | 13311 | AstNode *first_arg_ptr_src = nullptr; |
| 13312 | 13312 | ZigFn *fn = nullptr; |
| 13313 | 13313 | if (instr_is_comptime(fn_ref)) { |
| ... | ... | @@ -13342,16 +13342,16 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, Scope *scope, AstNode *s |
| 13342 | 13342 | |
| 13343 | 13343 | TypeStructField *stack_field = find_struct_type_field(options->value->type, buf_create_from_str("stack")); |
| 13344 | 13344 | src_assert(stack_field != nullptr, source_node); |
| 13345 | IrInstGen *opt_stack = ir_analyze_struct_value_field_value(ira, scope, source_node, options, stack_field); | |
| 13345 | Stage1AirInst *opt_stack = ir_analyze_struct_value_field_value(ira, scope, source_node, options, stack_field); | |
| 13346 | 13346 | if (type_is_invalid(opt_stack->value->type)) |
| 13347 | 13347 | return ira->codegen->invalid_inst_gen; |
| 13348 | 13348 | |
| 13349 | IrInstGen *stack_is_non_null_inst = ir_analyze_test_non_null(ira, scope, source_node, opt_stack); | |
| 13349 | Stage1AirInst *stack_is_non_null_inst = ir_analyze_test_non_null(ira, scope, source_node, opt_stack); | |
| 13350 | 13350 | bool stack_is_non_null; |
| 13351 | 13351 | if (!ir_resolve_bool(ira, stack_is_non_null_inst, &stack_is_non_null)) |
| 13352 | 13352 | return ira->codegen->invalid_inst_gen; |
| 13353 | 13353 | |
| 13354 | IrInstGen *stack = nullptr; | |
| 13354 | Stage1AirInst *stack = nullptr; | |
| 13355 | 13355 | AstNode *stack_src = nullptr; |
| 13356 | 13356 | if (stack_is_non_null) { |
| 13357 | 13357 | stack = ir_analyze_optional_value_payload_value(ira, scope, source_node, opt_stack, false); |
| ... | ... | @@ -13364,10 +13364,10 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, Scope *scope, AstNode *s |
| 13364 | 13364 | modifier, stack, stack_src, false, args_ptr, args_len, nullptr, result_loc); |
| 13365 | 13365 | } |
| 13366 | 13366 | |
| 13367 | static IrInstGen *ir_analyze_async_call_extra(IrAnalyze *ira, Scope *scope, AstNode *source_node, CallModifier modifier, | |
| 13368 | IrInstSrc *pass1_fn_ref, IrInstSrc *ret_ptr, IrInstSrc *new_stack, IrInstGen **args_ptr, size_t args_len, ResultLoc *result_loc) | |
| 13367 | static Stage1AirInst *ir_analyze_async_call_extra(IrAnalyze *ira, Scope *scope, AstNode *source_node, CallModifier modifier, | |
| 13368 | Stage1ZirInst *pass1_fn_ref, Stage1ZirInst *ret_ptr, Stage1ZirInst *new_stack, Stage1AirInst **args_ptr, size_t args_len, ResultLoc *result_loc) | |
| 13369 | 13369 | { |
| 13370 | IrInstGen *fn_ref = pass1_fn_ref->child; | |
| 13370 | Stage1AirInst *fn_ref = pass1_fn_ref->child; | |
| 13371 | 13371 | if (type_is_invalid(fn_ref->value->type)) |
| 13372 | 13372 | return ira->codegen->invalid_inst_gen; |
| 13373 | 13373 | |
| ... | ... | @@ -13376,7 +13376,7 @@ static IrInstGen *ir_analyze_async_call_extra(IrAnalyze *ira, Scope *scope, AstN |
| 13376 | 13376 | return ira->codegen->invalid_inst_gen; |
| 13377 | 13377 | } |
| 13378 | 13378 | |
| 13379 | IrInstGen *first_arg_ptr = nullptr; | |
| 13379 | Stage1AirInst *first_arg_ptr = nullptr; | |
| 13380 | 13380 | AstNode *first_arg_ptr_src = nullptr; |
| 13381 | 13381 | ZigFn *fn = nullptr; |
| 13382 | 13382 | if (instr_is_comptime(fn_ref)) { |
| ... | ... | @@ -13392,7 +13392,7 @@ static IrInstGen *ir_analyze_async_call_extra(IrAnalyze *ira, Scope *scope, AstN |
| 13392 | 13392 | } |
| 13393 | 13393 | } |
| 13394 | 13394 | |
| 13395 | IrInstGen *ret_ptr_uncasted = nullptr; | |
| 13395 | Stage1AirInst *ret_ptr_uncasted = nullptr; | |
| 13396 | 13396 | if (ret_ptr != nullptr) { |
| 13397 | 13397 | ret_ptr_uncasted = ret_ptr->child; |
| 13398 | 13398 | if (type_is_invalid(ret_ptr_uncasted->value->type)) |
| ... | ... | @@ -13400,7 +13400,7 @@ static IrInstGen *ir_analyze_async_call_extra(IrAnalyze *ira, Scope *scope, AstN |
| 13400 | 13400 | } |
| 13401 | 13401 | |
| 13402 | 13402 | ZigType *fn_type = (fn != nullptr) ? fn->type_entry : fn_ref->value->type; |
| 13403 | IrInstGen *casted_new_stack = analyze_casted_new_stack(ira, scope, source_node, | |
| 13403 | Stage1AirInst *casted_new_stack = analyze_casted_new_stack(ira, scope, source_node, | |
| 13404 | 13404 | new_stack->child, new_stack->source_node, true, fn); |
| 13405 | 13405 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) |
| 13406 | 13406 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -13410,7 +13410,7 @@ static IrInstGen *ir_analyze_async_call_extra(IrAnalyze *ira, Scope *scope, AstN |
| 13410 | 13410 | args_len, ret_ptr_uncasted, result_loc); |
| 13411 | 13411 | } |
| 13412 | 13412 | |
| 13413 | static bool ir_extract_tuple_call_args(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *args, IrInstGen ***args_ptr, size_t *args_len) { | |
| 13413 | static bool ir_extract_tuple_call_args(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *args, Stage1AirInst ***args_ptr, size_t *args_len) { | |
| 13414 | 13414 | ZigType *args_type = args->value->type; |
| 13415 | 13415 | if (type_is_invalid(args_type)) |
| 13416 | 13416 | return false; |
| ... | ... | @@ -13423,7 +13423,7 @@ static bool ir_extract_tuple_call_args(IrAnalyze *ira, Scope *scope, AstNode *so |
| 13423 | 13423 | |
| 13424 | 13424 | if (is_tuple(args_type)) { |
| 13425 | 13425 | *args_len = args_type->data.structure.src_field_count; |
| 13426 | *args_ptr = heap::c_allocator.allocate<IrInstGen *>(*args_len); | |
| 13426 | *args_ptr = heap::c_allocator.allocate<Stage1AirInst *>(*args_len); | |
| 13427 | 13427 | for (size_t i = 0; i < *args_len; i += 1) { |
| 13428 | 13428 | TypeStructField *arg_field = args_type->data.structure.fields[i]; |
| 13429 | 13429 | (*args_ptr)[i] = ir_analyze_struct_value_field_value(ira, scope, source_node, args, arg_field); |
| ... | ... | @@ -13437,50 +13437,50 @@ static bool ir_extract_tuple_call_args(IrAnalyze *ira, Scope *scope, AstNode *so |
| 13437 | 13437 | return true; |
| 13438 | 13438 | } |
| 13439 | 13439 | |
| 13440 | static IrInstGen *ir_analyze_instruction_call_extra(IrAnalyze *ira, IrInstSrcCallExtra *instruction) { | |
| 13441 | IrInstGen *args = instruction->args->child; | |
| 13442 | IrInstGen **args_ptr = nullptr; | |
| 13440 | static Stage1AirInst *ir_analyze_instruction_call_extra(IrAnalyze *ira, Stage1ZirInstCallExtra *instruction) { | |
| 13441 | Stage1AirInst *args = instruction->args->child; | |
| 13442 | Stage1AirInst **args_ptr = nullptr; | |
| 13443 | 13443 | size_t args_len = 0; |
| 13444 | 13444 | if (!ir_extract_tuple_call_args(ira, instruction->base.scope, instruction->base.source_node, args, &args_ptr, &args_len)) { |
| 13445 | 13445 | return ira->codegen->invalid_inst_gen; |
| 13446 | 13446 | } |
| 13447 | 13447 | |
| 13448 | IrInstGen *result = ir_analyze_call_extra(ira, instruction->base.scope, instruction->base.source_node, instruction->options, | |
| 13448 | Stage1AirInst *result = ir_analyze_call_extra(ira, instruction->base.scope, instruction->base.source_node, instruction->options, | |
| 13449 | 13449 | instruction->fn_ref, args_ptr, args_len, instruction->result_loc); |
| 13450 | 13450 | heap::c_allocator.deallocate(args_ptr, args_len); |
| 13451 | 13451 | return result; |
| 13452 | 13452 | } |
| 13453 | 13453 | |
| 13454 | static IrInstGen *ir_analyze_instruction_async_call_extra(IrAnalyze *ira, IrInstSrcAsyncCallExtra *instruction) { | |
| 13455 | IrInstGen *args = instruction->args->child; | |
| 13456 | IrInstGen **args_ptr = nullptr; | |
| 13454 | static Stage1AirInst *ir_analyze_instruction_async_call_extra(IrAnalyze *ira, Stage1ZirInstAsyncCallExtra *instruction) { | |
| 13455 | Stage1AirInst *args = instruction->args->child; | |
| 13456 | Stage1AirInst **args_ptr = nullptr; | |
| 13457 | 13457 | size_t args_len = 0; |
| 13458 | 13458 | if (!ir_extract_tuple_call_args(ira, instruction->base.scope, instruction->base.source_node, args, &args_ptr, &args_len)) { |
| 13459 | 13459 | return ira->codegen->invalid_inst_gen; |
| 13460 | 13460 | } |
| 13461 | 13461 | |
| 13462 | IrInstGen *result = ir_analyze_async_call_extra(ira, instruction->base.scope, instruction->base.source_node, instruction->modifier, | |
| 13462 | Stage1AirInst *result = ir_analyze_async_call_extra(ira, instruction->base.scope, instruction->base.source_node, instruction->modifier, | |
| 13463 | 13463 | instruction->fn_ref, instruction->ret_ptr, instruction->new_stack, args_ptr, args_len, instruction->result_loc); |
| 13464 | 13464 | heap::c_allocator.deallocate(args_ptr, args_len); |
| 13465 | 13465 | return result; |
| 13466 | 13466 | } |
| 13467 | 13467 | |
| 13468 | static IrInstGen *ir_analyze_instruction_call_args(IrAnalyze *ira, IrInstSrcCallArgs *instruction) { | |
| 13469 | IrInstGen **args_ptr = heap::c_allocator.allocate<IrInstGen *>(instruction->args_len); | |
| 13468 | static Stage1AirInst *ir_analyze_instruction_call_args(IrAnalyze *ira, Stage1ZirInstCallArgs *instruction) { | |
| 13469 | Stage1AirInst **args_ptr = heap::c_allocator.allocate<Stage1AirInst *>(instruction->args_len); | |
| 13470 | 13470 | for (size_t i = 0; i < instruction->args_len; i += 1) { |
| 13471 | 13471 | args_ptr[i] = instruction->args_ptr[i]->child; |
| 13472 | 13472 | if (type_is_invalid(args_ptr[i]->value->type)) |
| 13473 | 13473 | return ira->codegen->invalid_inst_gen; |
| 13474 | 13474 | } |
| 13475 | 13475 | |
| 13476 | IrInstGen *result = ir_analyze_call_extra(ira, instruction->base.scope, instruction->base.source_node, instruction->options, | |
| 13476 | Stage1AirInst *result = ir_analyze_call_extra(ira, instruction->base.scope, instruction->base.source_node, instruction->options, | |
| 13477 | 13477 | instruction->fn_ref, args_ptr, instruction->args_len, instruction->result_loc); |
| 13478 | 13478 | heap::c_allocator.deallocate(args_ptr, instruction->args_len); |
| 13479 | 13479 | return result; |
| 13480 | 13480 | } |
| 13481 | 13481 | |
| 13482 | static IrInstGen *ir_analyze_instruction_call(IrAnalyze *ira, IrInstSrcCall *call_instruction) { | |
| 13483 | IrInstGen *fn_ref = call_instruction->fn_ref->child; | |
| 13482 | static Stage1AirInst *ir_analyze_instruction_call(IrAnalyze *ira, Stage1ZirInstCall *call_instruction) { | |
| 13483 | Stage1AirInst *fn_ref = call_instruction->fn_ref->child; | |
| 13484 | 13484 | if (type_is_invalid(fn_ref->value->type)) |
| 13485 | 13485 | return ira->codegen->invalid_inst_gen; |
| 13486 | 13486 | |
| ... | ... | @@ -13507,7 +13507,7 @@ static IrInstGen *ir_analyze_instruction_call(IrAnalyze *ira, IrInstSrcCall *cal |
| 13507 | 13507 | } else if (fn_ref->value->type->id == ZigTypeIdBoundFn) { |
| 13508 | 13508 | assert(fn_ref->value->special == ConstValSpecialStatic); |
| 13509 | 13509 | ZigFn *fn_table_entry = fn_ref->value->data.x_bound_fn.fn; |
| 13510 | IrInstGen *first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; | |
| 13510 | Stage1AirInst *first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; | |
| 13511 | 13511 | AstNode *first_arg_ptr_src = fn_ref->value->data.x_bound_fn.first_arg_src; |
| 13512 | 13512 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; |
| 13513 | 13513 | return ir_analyze_fn_call_src(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, |
| ... | ... | @@ -13641,8 +13641,8 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 13641 | 13641 | zig_unreachable(); |
| 13642 | 13642 | } |
| 13643 | 13643 | |
| 13644 | static IrInstGen *ir_analyze_optional_type(IrAnalyze *ira, IrInstSrcUnOp *instruction) { | |
| 13645 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_type); | |
| 13644 | static Stage1AirInst *ir_analyze_optional_type(IrAnalyze *ira, Stage1ZirInstUnOp *instruction) { | |
| 13645 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_type); | |
| 13646 | 13646 | result->value->special = ConstValSpecialLazy; |
| 13647 | 13647 | |
| 13648 | 13648 | LazyValueOptType *lazy_opt_type = heap::c_allocator.create<LazyValueOptType>(); |
| ... | ... | @@ -13692,8 +13692,8 @@ static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, Scope *scope, AstNode * |
| 13692 | 13692 | return nullptr; |
| 13693 | 13693 | } |
| 13694 | 13694 | |
| 13695 | static IrInstGen *ir_analyze_negation(IrAnalyze *ira, IrInstSrcUnOp *instruction) { | |
| 13696 | IrInstGen *value = instruction->value->child; | |
| 13695 | static Stage1AirInst *ir_analyze_negation(IrAnalyze *ira, Stage1ZirInstUnOp *instruction) { | |
| 13696 | Stage1AirInst *value = instruction->value->child; | |
| 13697 | 13697 | ZigType *expr_type = value->value->type; |
| 13698 | 13698 | if (type_is_invalid(expr_type)) |
| 13699 | 13699 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -13723,7 +13723,7 @@ static IrInstGen *ir_analyze_negation(IrAnalyze *ira, IrInstSrcUnOp *instruction |
| 13723 | 13723 | if (!operand_val) |
| 13724 | 13724 | return ira->codegen->invalid_inst_gen; |
| 13725 | 13725 | |
| 13726 | IrInstGen *result_instruction = ir_const(ira, instruction->base.scope, instruction->base.source_node, expr_type); | |
| 13726 | Stage1AirInst *result_instruction = ir_const(ira, instruction->base.scope, instruction->base.source_node, expr_type); | |
| 13727 | 13727 | ZigValue *out_val = result_instruction->value; |
| 13728 | 13728 | if (expr_type->id == ZigTypeIdVector) { |
| 13729 | 13729 | expand_undef_array(ira->codegen, operand_val); |
| ... | ... | @@ -13758,8 +13758,8 @@ static IrInstGen *ir_analyze_negation(IrAnalyze *ira, IrInstSrcUnOp *instruction |
| 13758 | 13758 | return ir_build_negation(ira, instruction->base.scope, instruction->base.source_node, value, expr_type, is_wrap_op); |
| 13759 | 13759 | } |
| 13760 | 13760 | |
| 13761 | static IrInstGen *ir_analyze_bin_not(IrAnalyze *ira, IrInstSrcUnOp *instruction) { | |
| 13762 | IrInstGen *value = instruction->value->child; | |
| 13761 | static Stage1AirInst *ir_analyze_bin_not(IrAnalyze *ira, Stage1ZirInstUnOp *instruction) { | |
| 13762 | Stage1AirInst *value = instruction->value->child; | |
| 13763 | 13763 | ZigType *expr_type = value->value->type; |
| 13764 | 13764 | if (type_is_invalid(expr_type)) |
| 13765 | 13765 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -13778,7 +13778,7 @@ static IrInstGen *ir_analyze_bin_not(IrAnalyze *ira, IrInstSrcUnOp *instruction) |
| 13778 | 13778 | if (expr_val == nullptr) |
| 13779 | 13779 | return ira->codegen->invalid_inst_gen; |
| 13780 | 13780 | |
| 13781 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, expr_type); | |
| 13781 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, expr_type); | |
| 13782 | 13782 | |
| 13783 | 13783 | if (expr_type->id == ZigTypeIdVector) { |
| 13784 | 13784 | expand_undef_array(ira->codegen, expr_val); |
| ... | ... | @@ -13805,7 +13805,7 @@ static IrInstGen *ir_analyze_bin_not(IrAnalyze *ira, IrInstSrcUnOp *instruction) |
| 13805 | 13805 | return ir_build_binary_not(ira, instruction->base.scope, instruction->base.source_node, value, expr_type); |
| 13806 | 13806 | } |
| 13807 | 13807 | |
| 13808 | static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *instruction) { | |
| 13808 | static Stage1AirInst *ir_analyze_instruction_un_op(IrAnalyze *ira, Stage1ZirInstUnOp *instruction) { | |
| 13809 | 13809 | IrUnOp op_id = instruction->op_id; |
| 13810 | 13810 | switch (op_id) { |
| 13811 | 13811 | case IrUnOpInvalid: |
| ... | ... | @@ -13816,7 +13816,7 @@ static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *in |
| 13816 | 13816 | case IrUnOpNegationWrap: |
| 13817 | 13817 | return ir_analyze_negation(ira, instruction); |
| 13818 | 13818 | case IrUnOpDereference: { |
| 13819 | IrInstGen *ptr = instruction->value->child; | |
| 13819 | Stage1AirInst *ptr = instruction->value->child; | |
| 13820 | 13820 | if (type_is_invalid(ptr->value->type)) |
| 13821 | 13821 | return ira->codegen->invalid_inst_gen; |
| 13822 | 13822 | ZigType *ptr_type = ptr->value->type; |
| ... | ... | @@ -13827,7 +13827,7 @@ static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *in |
| 13827 | 13827 | return ira->codegen->invalid_inst_gen; |
| 13828 | 13828 | } |
| 13829 | 13829 | |
| 13830 | IrInstGen *result = ir_get_deref(ira, instruction->base.scope, | |
| 13830 | Stage1AirInst *result = ir_get_deref(ira, instruction->base.scope, | |
| 13831 | 13831 | instruction->base.source_node, ptr, instruction->result_loc); |
| 13832 | 13832 | if (type_is_invalid(result->value->type)) |
| 13833 | 13833 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -13860,7 +13860,7 @@ static void ir_push_resume_block(IrAnalyze *ira, Stage1ZirBasicBlock *old_bb) { |
| 13860 | 13860 | } |
| 13861 | 13861 | } |
| 13862 | 13862 | |
| 13863 | static IrInstGen *ir_analyze_instruction_br(IrAnalyze *ira, IrInstSrcBr *br_instruction) { | |
| 13863 | static Stage1AirInst *ir_analyze_instruction_br(IrAnalyze *ira, Stage1ZirInstBr *br_instruction) { | |
| 13864 | 13864 | Stage1ZirBasicBlock *old_dest_block = br_instruction->dest_block; |
| 13865 | 13865 | |
| 13866 | 13866 | bool is_comptime; |
| ... | ... | @@ -13870,18 +13870,18 @@ static IrInstGen *ir_analyze_instruction_br(IrAnalyze *ira, IrInstSrcBr *br_inst |
| 13870 | 13870 | if (is_comptime || (old_dest_block->ref_count == 1 && old_dest_block->suspend_instruction_ref == nullptr)) |
| 13871 | 13871 | return ir_inline_bb(ira, br_instruction->base.source_node, old_dest_block); |
| 13872 | 13872 | |
| 13873 | IrBasicBlockGen *new_bb = ir_get_new_bb_runtime(ira, old_dest_block, &br_instruction->base); | |
| 13873 | Stage1AirBasicBlock *new_bb = ir_get_new_bb_runtime(ira, old_dest_block, &br_instruction->base); | |
| 13874 | 13874 | if (new_bb == nullptr) |
| 13875 | 13875 | return ir_unreach_error(ira); |
| 13876 | 13876 | |
| 13877 | 13877 | ir_push_resume_block(ira, old_dest_block); |
| 13878 | 13878 | |
| 13879 | IrInstGen *result = ir_build_br_gen(ira, br_instruction->base.scope, br_instruction->base.source_node, new_bb); | |
| 13879 | Stage1AirInst *result = ir_build_br_gen(ira, br_instruction->base.scope, br_instruction->base.source_node, new_bb); | |
| 13880 | 13880 | return ir_finish_anal(ira, result); |
| 13881 | 13881 | } |
| 13882 | 13882 | |
| 13883 | static IrInstGen *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstSrcCondBr *cond_br_instruction) { | |
| 13884 | IrInstGen *condition = cond_br_instruction->condition->child; | |
| 13883 | static Stage1AirInst *ir_analyze_instruction_cond_br(IrAnalyze *ira, Stage1ZirInstCondBr *cond_br_instruction) { | |
| 13884 | Stage1AirInst *condition = cond_br_instruction->condition->child; | |
| 13885 | 13885 | if (type_is_invalid(condition->value->type)) |
| 13886 | 13886 | return ir_unreach_error(ira); |
| 13887 | 13887 | |
| ... | ... | @@ -13890,7 +13890,7 @@ static IrInstGen *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstSrcCondBr |
| 13890 | 13890 | return ir_unreach_error(ira); |
| 13891 | 13891 | |
| 13892 | 13892 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 13893 | IrInstGen *casted_condition = ir_implicit_cast(ira, condition, bool_type); | |
| 13893 | Stage1AirInst *casted_condition = ir_implicit_cast(ira, condition, bool_type); | |
| 13894 | 13894 | if (type_is_invalid(casted_condition->value->type)) |
| 13895 | 13895 | return ir_unreach_error(ira); |
| 13896 | 13896 | |
| ... | ... | @@ -13905,37 +13905,37 @@ static IrInstGen *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstSrcCondBr |
| 13905 | 13905 | if (is_comptime || (old_dest_block->ref_count == 1 && old_dest_block->suspend_instruction_ref == nullptr)) |
| 13906 | 13906 | return ir_inline_bb(ira, cond_br_instruction->base.source_node, old_dest_block); |
| 13907 | 13907 | |
| 13908 | IrBasicBlockGen *new_dest_block = ir_get_new_bb_runtime(ira, old_dest_block, &cond_br_instruction->base); | |
| 13908 | Stage1AirBasicBlock *new_dest_block = ir_get_new_bb_runtime(ira, old_dest_block, &cond_br_instruction->base); | |
| 13909 | 13909 | if (new_dest_block == nullptr) |
| 13910 | 13910 | return ir_unreach_error(ira); |
| 13911 | 13911 | |
| 13912 | 13912 | ir_push_resume_block(ira, old_dest_block); |
| 13913 | 13913 | |
| 13914 | IrInstGen *result = ir_build_br_gen(ira, cond_br_instruction->base.scope, | |
| 13914 | Stage1AirInst *result = ir_build_br_gen(ira, cond_br_instruction->base.scope, | |
| 13915 | 13915 | cond_br_instruction->base.source_node, new_dest_block); |
| 13916 | 13916 | return ir_finish_anal(ira, result); |
| 13917 | 13917 | } |
| 13918 | 13918 | |
| 13919 | 13919 | assert(cond_br_instruction->then_block != cond_br_instruction->else_block); |
| 13920 | IrBasicBlockGen *new_then_block = ir_get_new_bb_runtime(ira, cond_br_instruction->then_block, &cond_br_instruction->base); | |
| 13920 | Stage1AirBasicBlock *new_then_block = ir_get_new_bb_runtime(ira, cond_br_instruction->then_block, &cond_br_instruction->base); | |
| 13921 | 13921 | if (new_then_block == nullptr) |
| 13922 | 13922 | return ir_unreach_error(ira); |
| 13923 | 13923 | |
| 13924 | IrBasicBlockGen *new_else_block = ir_get_new_bb_runtime(ira, cond_br_instruction->else_block, &cond_br_instruction->base); | |
| 13924 | Stage1AirBasicBlock *new_else_block = ir_get_new_bb_runtime(ira, cond_br_instruction->else_block, &cond_br_instruction->base); | |
| 13925 | 13925 | if (new_else_block == nullptr) |
| 13926 | 13926 | return ir_unreach_error(ira); |
| 13927 | 13927 | |
| 13928 | 13928 | ir_push_resume_block(ira, cond_br_instruction->else_block); |
| 13929 | 13929 | ir_push_resume_block(ira, cond_br_instruction->then_block); |
| 13930 | 13930 | |
| 13931 | IrInstGen *result = ir_build_cond_br_gen(ira, cond_br_instruction->base.scope, | |
| 13931 | Stage1AirInst *result = ir_build_cond_br_gen(ira, cond_br_instruction->base.scope, | |
| 13932 | 13932 | cond_br_instruction->base.source_node, casted_condition, new_then_block, |
| 13933 | 13933 | new_else_block); |
| 13934 | 13934 | return ir_finish_anal(ira, result); |
| 13935 | 13935 | } |
| 13936 | 13936 | |
| 13937 | static IrInstGen *ir_analyze_instruction_unreachable(IrAnalyze *ira, | |
| 13938 | IrInstSrcUnreachable *unreachable_instruction) | |
| 13937 | static Stage1AirInst *ir_analyze_instruction_unreachable(IrAnalyze *ira, | |
| 13938 | Stage1ZirInstUnreachable *unreachable_instruction) | |
| 13939 | 13939 | { |
| 13940 | 13940 | if (ir_should_inline(ira->zir, unreachable_instruction->base.scope)) { |
| 13941 | 13941 | ir_add_error_node(ira, unreachable_instruction->base.source_node, |
| ... | ... | @@ -13943,12 +13943,12 @@ static IrInstGen *ir_analyze_instruction_unreachable(IrAnalyze *ira, |
| 13943 | 13943 | return ir_unreach_error(ira); |
| 13944 | 13944 | } |
| 13945 | 13945 | |
| 13946 | IrInstGen *result = ir_build_unreachable_gen(ira, unreachable_instruction->base.scope, | |
| 13946 | Stage1AirInst *result = ir_build_unreachable_gen(ira, unreachable_instruction->base.scope, | |
| 13947 | 13947 | unreachable_instruction->base.source_node); |
| 13948 | 13948 | return ir_finish_anal(ira, result); |
| 13949 | 13949 | } |
| 13950 | 13950 | |
| 13951 | static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_instruction) { | |
| 13951 | static Stage1AirInst *ir_analyze_instruction_phi(IrAnalyze *ira, Stage1ZirInstPhi *phi_instruction) { | |
| 13952 | 13952 | Error err; |
| 13953 | 13953 | |
| 13954 | 13954 | if (ira->const_predecessor_bb) { |
| ... | ... | @@ -13956,13 +13956,13 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 13956 | 13956 | Stage1ZirBasicBlock *predecessor = phi_instruction->incoming_blocks[i]; |
| 13957 | 13957 | if (predecessor != ira->const_predecessor_bb) |
| 13958 | 13958 | continue; |
| 13959 | IrInstGen *value = phi_instruction->incoming_values[i]->child; | |
| 13959 | Stage1AirInst *value = phi_instruction->incoming_values[i]->child; | |
| 13960 | 13960 | assert(value->value->type); |
| 13961 | 13961 | if (type_is_invalid(value->value->type)) |
| 13962 | 13962 | return ira->codegen->invalid_inst_gen; |
| 13963 | 13963 | |
| 13964 | 13964 | if (value->value->special != ConstValSpecialRuntime) { |
| 13965 | IrInstGen *result = ir_const(ira, phi_instruction->base.scope, | |
| 13965 | Stage1AirInst *result = ir_const(ira, phi_instruction->base.scope, | |
| 13966 | 13966 | phi_instruction->base.source_node, nullptr); |
| 13967 | 13967 | copy_const_val(ira->codegen, result->value, value->value); |
| 13968 | 13968 | return result; |
| ... | ... | @@ -13978,11 +13978,11 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 13978 | 13978 | peer_parent->peers.length >= 2) |
| 13979 | 13979 | { |
| 13980 | 13980 | if (peer_parent->resolved_type == nullptr) { |
| 13981 | IrInstGen **instructions = heap::c_allocator.allocate<IrInstGen *>(peer_parent->peers.length); | |
| 13981 | Stage1AirInst **instructions = heap::c_allocator.allocate<Stage1AirInst *>(peer_parent->peers.length); | |
| 13982 | 13982 | for (size_t i = 0; i < peer_parent->peers.length; i += 1) { |
| 13983 | 13983 | ResultLocPeer *this_peer = peer_parent->peers.at(i); |
| 13984 | 13984 | |
| 13985 | IrInstGen *gen_instruction = this_peer->base.gen_instruction; | |
| 13985 | Stage1AirInst *gen_instruction = this_peer->base.gen_instruction; | |
| 13986 | 13986 | if (gen_instruction == nullptr) { |
| 13987 | 13987 | // unreachable instructions will cause implicit_elem_type to be null |
| 13988 | 13988 | if (this_peer->base.implicit_elem_type == nullptr) { |
| ... | ... | @@ -14010,7 +14010,7 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 14010 | 14010 | phi_instruction->base.source_node); |
| 14011 | 14011 | |
| 14012 | 14012 | // In case resolving the parent activates a suspend, do it now |
| 14013 | IrInstGen *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base, peer_parent->parent, | |
| 14013 | Stage1AirInst *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base, peer_parent->parent, | |
| 14014 | 14014 | peer_parent->resolved_type, nullptr, false, true); |
| 14015 | 14015 | if (parent_result_loc != nullptr && |
| 14016 | 14016 | (type_is_invalid(parent_result_loc->value->type) || parent_result_loc->value->type->id == ZigTypeIdUnreachable)) |
| ... | ... | @@ -14019,13 +14019,13 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 14019 | 14019 | } |
| 14020 | 14020 | // If the above code generated any instructions in the current basic block, we need |
| 14021 | 14021 | // to move them to the peer parent predecessor. |
| 14022 | ZigList<IrInstGen *> instrs_to_move = {}; | |
| 14022 | ZigList<Stage1AirInst *> instrs_to_move = {}; | |
| 14023 | 14023 | while (ira->new_irb.current_basic_block->instruction_list.length != 0) { |
| 14024 | 14024 | instrs_to_move.append(ira->new_irb.current_basic_block->instruction_list.pop()); |
| 14025 | 14025 | } |
| 14026 | 14026 | if (instrs_to_move.length != 0) { |
| 14027 | IrBasicBlockGen *predecessor = peer_parent->base.source_instruction->child->owner_bb; | |
| 14028 | IrInstGen *branch_instruction = predecessor->instruction_list.pop(); | |
| 14027 | Stage1AirBasicBlock *predecessor = peer_parent->base.source_instruction->child->owner_bb; | |
| 14028 | Stage1AirInst *branch_instruction = predecessor->instruction_list.pop(); | |
| 14029 | 14029 | src_assert(branch_instruction->value->type->id == ZigTypeIdUnreachable, |
| 14030 | 14030 | phi_instruction->base.source_node); |
| 14031 | 14031 | while (instrs_to_move.length != 0) { |
| ... | ... | @@ -14053,8 +14053,8 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 14053 | 14053 | return ira_resume(ira); |
| 14054 | 14054 | } |
| 14055 | 14055 | |
| 14056 | ZigList<IrBasicBlockGen*> new_incoming_blocks = {0}; | |
| 14057 | ZigList<IrInstGen*> new_incoming_values = {0}; | |
| 14056 | ZigList<Stage1AirBasicBlock*> new_incoming_blocks = {0}; | |
| 14057 | ZigList<Stage1AirInst*> new_incoming_values = {0}; | |
| 14058 | 14058 | |
| 14059 | 14059 | for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) { |
| 14060 | 14060 | Stage1ZirBasicBlock *predecessor = phi_instruction->incoming_blocks[i]; |
| ... | ... | @@ -14062,9 +14062,9 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 14062 | 14062 | continue; |
| 14063 | 14063 | |
| 14064 | 14064 | |
| 14065 | IrInstSrc *old_value = phi_instruction->incoming_values[i]; | |
| 14065 | Stage1ZirInst *old_value = phi_instruction->incoming_values[i]; | |
| 14066 | 14066 | assert(old_value); |
| 14067 | IrInstGen *new_value = old_value->child; | |
| 14067 | Stage1AirInst *new_value = old_value->child; | |
| 14068 | 14068 | if (!new_value || new_value->value->type->id == ZigTypeIdUnreachable || predecessor->child == nullptr) |
| 14069 | 14069 | continue; |
| 14070 | 14070 | |
| ... | ... | @@ -14078,13 +14078,13 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 14078 | 14078 | } |
| 14079 | 14079 | |
| 14080 | 14080 | if (new_incoming_blocks.length == 0) { |
| 14081 | IrInstGen *result = ir_build_unreachable_gen(ira, phi_instruction->base.scope, | |
| 14081 | Stage1AirInst *result = ir_build_unreachable_gen(ira, phi_instruction->base.scope, | |
| 14082 | 14082 | phi_instruction->base.source_node); |
| 14083 | 14083 | return ir_finish_anal(ira, result); |
| 14084 | 14084 | } |
| 14085 | 14085 | |
| 14086 | 14086 | if (new_incoming_blocks.length == 1) { |
| 14087 | IrInstGen *incoming_value = new_incoming_values.at(0); | |
| 14087 | Stage1AirInst *incoming_value = new_incoming_values.at(0); | |
| 14088 | 14088 | new_incoming_blocks.deinit(); |
| 14089 | 14089 | new_incoming_values.deinit(); |
| 14090 | 14090 | return incoming_value; |
| ... | ... | @@ -14145,14 +14145,14 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 14145 | 14145 | // cast all values to the resolved type. however we can't put cast instructions in front of the phi instruction. |
| 14146 | 14146 | // so we go back and insert the casts as the last instruction in the corresponding predecessor blocks, and |
| 14147 | 14147 | // then make sure the branch instruction is preserved. |
| 14148 | IrBasicBlockGen *cur_bb = ira->new_irb.current_basic_block; | |
| 14148 | Stage1AirBasicBlock *cur_bb = ira->new_irb.current_basic_block; | |
| 14149 | 14149 | for (size_t i = 0; i < new_incoming_values.length; i += 1) { |
| 14150 | IrInstGen *new_value = new_incoming_values.at(i); | |
| 14151 | IrBasicBlockGen *predecessor = new_incoming_blocks.at(i); | |
| 14150 | Stage1AirInst *new_value = new_incoming_values.at(i); | |
| 14151 | Stage1AirBasicBlock *predecessor = new_incoming_blocks.at(i); | |
| 14152 | 14152 | src_assert(predecessor->instruction_list.length != 0, phi_instruction->base.source_node); |
| 14153 | IrInstGen *branch_instruction = predecessor->instruction_list.pop(); | |
| 14153 | Stage1AirInst *branch_instruction = predecessor->instruction_list.pop(); | |
| 14154 | 14154 | ir_set_cursor_at_end_gen(&ira->new_irb, predecessor); |
| 14155 | IrInstGen *casted_value = ir_implicit_cast(ira, new_value, resolved_type); | |
| 14155 | Stage1AirInst *casted_value = ir_implicit_cast(ira, new_value, resolved_type); | |
| 14156 | 14156 | if (type_is_invalid(casted_value->value->type)) { |
| 14157 | 14157 | return ira->codegen->invalid_inst_gen; |
| 14158 | 14158 | } |
| ... | ... | @@ -14167,7 +14167,7 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 14167 | 14167 | } |
| 14168 | 14168 | ir_set_cursor_at_end_gen(&ira->new_irb, cur_bb); |
| 14169 | 14169 | |
| 14170 | IrInstGen *result = ir_build_phi_gen(ira, phi_instruction->base.scope, | |
| 14170 | Stage1AirInst *result = ir_build_phi_gen(ira, phi_instruction->base.scope, | |
| 14171 | 14171 | phi_instruction->base.source_node, new_incoming_blocks.length, |
| 14172 | 14172 | new_incoming_blocks.items, new_incoming_values.items, resolved_type); |
| 14173 | 14173 | |
| ... | ... | @@ -14179,9 +14179,9 @@ static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_i |
| 14179 | 14179 | return result; |
| 14180 | 14180 | } |
| 14181 | 14181 | |
| 14182 | static IrInstGen *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstSrcVarPtr *instruction) { | |
| 14182 | static Stage1AirInst *ir_analyze_instruction_var_ptr(IrAnalyze *ira, Stage1ZirInstVarPtr *instruction) { | |
| 14183 | 14183 | ZigVar *var = instruction->var; |
| 14184 | IrInstGen *result = ir_get_var_ptr(ira, instruction->base.scope, instruction->base.source_node, var); | |
| 14184 | Stage1AirInst *result = ir_get_var_ptr(ira, instruction->base.scope, instruction->base.source_node, var); | |
| 14185 | 14185 | if (instruction->crossed_fndef_scope != nullptr && !instr_is_comptime(result)) { |
| 14186 | 14186 | ErrorMsg *msg = ir_add_error_node(ira, instruction->base.source_node, |
| 14187 | 14187 | buf_sprintf("'%s' not accessible from inner function", var->name)); |
| ... | ... | @@ -14309,13 +14309,13 @@ static Error compute_elem_align(IrAnalyze *ira, ZigType *elem_type, uint32_t bas |
| 14309 | 14309 | return ErrorNone; |
| 14310 | 14310 | } |
| 14311 | 14311 | |
| 14312 | static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemPtr *elem_ptr_instruction) { | |
| 14312 | static Stage1AirInst *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, Stage1ZirInstElemPtr *elem_ptr_instruction) { | |
| 14313 | 14313 | Error err; |
| 14314 | IrInstGen *array_ptr = elem_ptr_instruction->array_ptr->child; | |
| 14314 | Stage1AirInst *array_ptr = elem_ptr_instruction->array_ptr->child; | |
| 14315 | 14315 | if (type_is_invalid(array_ptr->value->type)) |
| 14316 | 14316 | return ira->codegen->invalid_inst_gen; |
| 14317 | 14317 | |
| 14318 | IrInstGen *elem_index = elem_ptr_instruction->elem_index->child; | |
| 14318 | Stage1AirInst *elem_index = elem_ptr_instruction->elem_index->child; | |
| 14319 | 14319 | if (type_is_invalid(elem_index->value->type)) |
| 14320 | 14320 | return ira->codegen->invalid_inst_gen; |
| 14321 | 14321 | |
| ... | ... | @@ -14337,7 +14337,7 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 14337 | 14337 | array_type->data.pointer.ptr_len == PtrLenSingle && |
| 14338 | 14338 | array_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 14339 | 14339 | { |
| 14340 | IrInstGen *ptr_value = ir_get_deref(ira, elem_ptr_instruction->base.scope, | |
| 14340 | Stage1AirInst *ptr_value = ir_get_deref(ira, elem_ptr_instruction->base.scope, | |
| 14341 | 14341 | elem_ptr_instruction->base.source_node, array_ptr, nullptr); |
| 14342 | 14342 | if (type_is_invalid(ptr_value->value->type)) |
| 14343 | 14343 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -14392,7 +14392,7 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 14392 | 14392 | array_type->data.structure.resolve_status == ResolveStatusBeingInferred) |
| 14393 | 14393 | { |
| 14394 | 14394 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 14395 | IrInstGen *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); | |
| 14395 | Stage1AirInst *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); | |
| 14396 | 14396 | if (type_is_invalid(casted_elem_index->value->type)) |
| 14397 | 14397 | return ira->codegen->invalid_inst_gen; |
| 14398 | 14398 | src_assert(instr_is_comptime(casted_elem_index), elem_ptr_instruction->base.source_node); |
| ... | ... | @@ -14421,7 +14421,7 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 14421 | 14421 | } |
| 14422 | 14422 | |
| 14423 | 14423 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 14424 | IrInstGen *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); | |
| 14424 | Stage1AirInst *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); | |
| 14425 | 14425 | if (type_is_invalid(casted_elem_index->value->type)) |
| 14426 | 14426 | return ira->codegen->invalid_inst_gen; |
| 14427 | 14427 | |
| ... | ... | @@ -14553,7 +14553,7 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 14553 | 14553 | return ira->codegen->invalid_inst_gen; |
| 14554 | 14554 | } |
| 14555 | 14555 | if (array_type->id == ZigTypeIdPointer) { |
| 14556 | IrInstGen *result = ir_const(ira, elem_ptr_instruction->base.scope, elem_ptr_instruction->base.source_node, return_type); | |
| 14556 | Stage1AirInst *result = ir_const(ira, elem_ptr_instruction->base.scope, elem_ptr_instruction->base.source_node, return_type); | |
| 14557 | 14557 | ZigValue *out_val = result->value; |
| 14558 | 14558 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; |
| 14559 | 14559 | size_t new_index; |
| ... | ... | @@ -14639,7 +14639,7 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 14639 | 14639 | return_type); |
| 14640 | 14640 | } |
| 14641 | 14641 | ZigValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index]; |
| 14642 | IrInstGen *result = ir_const(ira, elem_ptr_instruction->base.scope, | |
| 14642 | Stage1AirInst *result = ir_const(ira, elem_ptr_instruction->base.scope, | |
| 14643 | 14643 | elem_ptr_instruction->base.source_node, return_type); |
| 14644 | 14644 | ZigValue *out_val = result->value; |
| 14645 | 14645 | ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; |
| ... | ... | @@ -14699,7 +14699,7 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 14699 | 14699 | } else if (array_type->id == ZigTypeIdArray || array_type->id == ZigTypeIdVector) { |
| 14700 | 14700 | expand_undef_array(ira->codegen, array_ptr_val); |
| 14701 | 14701 | |
| 14702 | IrInstGen *result; | |
| 14702 | Stage1AirInst *result; | |
| 14703 | 14703 | if (orig_array_ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 14704 | 14704 | result = ir_build_elem_ptr_gen(ira, elem_ptr_instruction->base.scope, |
| 14705 | 14705 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, |
| ... | ... | @@ -14766,9 +14766,9 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 14766 | 14766 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, safety_check_on, return_type); |
| 14767 | 14767 | } |
| 14768 | 14768 | |
| 14769 | static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira, | |
| 14769 | static Stage1AirInst *ir_analyze_container_member_access_inner(IrAnalyze *ira, | |
| 14770 | 14770 | ZigType *bare_struct_type, Buf *field_name, Scope *scope, AstNode *source_node, |
| 14771 | IrInstGen *container_ptr, AstNode *container_ptr_src, ZigType *container_type) | |
| 14771 | Stage1AirInst *container_ptr, AstNode *container_ptr_src, ZigType *container_type) | |
| 14772 | 14772 | { |
| 14773 | 14773 | if (!is_slice(bare_struct_type)) { |
| 14774 | 14774 | ScopeDecls *container_scope = get_container_scope(bare_struct_type); |
| ... | ... | @@ -14798,7 +14798,7 @@ static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 14798 | 14798 | if (type_is_invalid(fn_entry->type_entry)) |
| 14799 | 14799 | return ira->codegen->invalid_inst_gen; |
| 14800 | 14800 | |
| 14801 | IrInstGen *bound_fn_value = ir_const_bound_fn(ira, scope, source_node, fn_entry, container_ptr, | |
| 14801 | Stage1AirInst *bound_fn_value = ir_const_bound_fn(ira, scope, source_node, fn_entry, container_ptr, | |
| 14802 | 14802 | container_ptr_src); |
| 14803 | 14803 | return ir_get_ref(ira, scope, source_node, bound_fn_value, true, false); |
| 14804 | 14804 | } else if (tld->id == TldIdVar) { |
| ... | ... | @@ -14818,7 +14818,7 @@ static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 14818 | 14818 | if (var->const_value->type->id == ZigTypeIdFn) { |
| 14819 | 14819 | src_assert(var->const_value->data.x_ptr.special == ConstPtrSpecialFunction, source_node); |
| 14820 | 14820 | ZigFn *fn = var->const_value->data.x_ptr.data.fn.fn_entry; |
| 14821 | IrInstGen *bound_fn_value = ir_const_bound_fn(ira, scope, source_node, fn, container_ptr, | |
| 14821 | Stage1AirInst *bound_fn_value = ir_const_bound_fn(ira, scope, source_node, fn, container_ptr, | |
| 14822 | 14822 | container_ptr_src); |
| 14823 | 14823 | return ir_get_ref(ira, scope, source_node, bound_fn_value, true, false); |
| 14824 | 14824 | } |
| ... | ... | @@ -14857,15 +14857,15 @@ static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, Ty |
| 14857 | 14857 | field->type_entry, nullptr, UndefOk); |
| 14858 | 14858 | } |
| 14859 | 14859 | |
| 14860 | static IrInstGen *ir_analyze_struct_field_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 14861 | TypeStructField *field, IrInstGen *struct_ptr, ZigType *struct_type, bool initializing) | |
| 14860 | static Stage1AirInst *ir_analyze_struct_field_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 14861 | TypeStructField *field, Stage1AirInst *struct_ptr, ZigType *struct_type, bool initializing) | |
| 14862 | 14862 | { |
| 14863 | 14863 | Error err; |
| 14864 | 14864 | ZigType *field_type = resolve_struct_field_type(ira->codegen, field); |
| 14865 | 14865 | if (field_type == nullptr) |
| 14866 | 14866 | return ira->codegen->invalid_inst_gen; |
| 14867 | 14867 | if (field->is_comptime) { |
| 14868 | IrInstGen *elem = ir_const(ira, scope, source_node, field_type); | |
| 14868 | Stage1AirInst *elem = ir_const(ira, scope, source_node, field_type); | |
| 14869 | 14869 | memoize_field_init_val(ira->codegen, struct_type, field); |
| 14870 | 14870 | if(field->init_val != nullptr && type_is_invalid(field->init_val->type)){ |
| 14871 | 14871 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -14877,7 +14877,7 @@ static IrInstGen *ir_analyze_struct_field_ptr(IrAnalyze *ira, Scope *scope, AstN |
| 14877 | 14877 | case OnePossibleValueInvalid: |
| 14878 | 14878 | return ira->codegen->invalid_inst_gen; |
| 14879 | 14879 | case OnePossibleValueYes: { |
| 14880 | IrInstGen *elem = ir_const_move(ira, scope, source_node, | |
| 14880 | Stage1AirInst *elem = ir_const_move(ira, scope, source_node, | |
| 14881 | 14881 | get_the_one_possible_value(ira->codegen, field_type)); |
| 14882 | 14882 | return ir_get_ref(ira, scope, source_node, elem, |
| 14883 | 14883 | struct_ptr->value->type->data.pointer.is_const, |
| ... | ... | @@ -14941,7 +14941,7 @@ static IrInstGen *ir_analyze_struct_field_ptr(IrAnalyze *ira, Scope *scope, AstN |
| 14941 | 14941 | field_val->parent.data.p_struct.field_index = i; |
| 14942 | 14942 | } |
| 14943 | 14943 | } |
| 14944 | IrInstGen *result; | |
| 14944 | Stage1AirInst *result; | |
| 14945 | 14945 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 14946 | 14946 | result = ir_build_struct_field_ptr(ira, scope, source_node, struct_ptr, field, ptr_type); |
| 14947 | 14947 | result->value->special = ConstValSpecialStatic; |
| ... | ... | @@ -14959,8 +14959,8 @@ static IrInstGen *ir_analyze_struct_field_ptr(IrAnalyze *ira, Scope *scope, AstN |
| 14959 | 14959 | return ir_build_struct_field_ptr(ira, scope, source_node, struct_ptr, field, ptr_type); |
| 14960 | 14960 | } |
| 14961 | 14961 | |
| 14962 | static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, | |
| 14963 | Scope *scope, AstNode *source_node, IrInstGen *container_ptr, ZigType *container_type) | |
| 14962 | static Stage1AirInst *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, | |
| 14963 | Scope *scope, AstNode *source_node, Stage1AirInst *container_ptr, ZigType *container_type) | |
| 14964 | 14964 | { |
| 14965 | 14965 | // The type of the field is not available until a store using this pointer happens. |
| 14966 | 14966 | // So, here we create a special pointer type which has the inferred struct type and |
| ... | ... | @@ -14985,7 +14985,7 @@ static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 14985 | 14985 | if (ptr_val == nullptr) |
| 14986 | 14986 | return ira->codegen->invalid_inst_gen; |
| 14987 | 14987 | |
| 14988 | IrInstGen *result; | |
| 14988 | Stage1AirInst *result; | |
| 14989 | 14989 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 14990 | 14990 | result = ir_build_cast(ira, scope, source_node, container_ptr_type, container_ptr, CastOpNoop); |
| 14991 | 14991 | } else { |
| ... | ... | @@ -14999,8 +14999,8 @@ static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 14999 | 14999 | return ir_build_cast(ira, scope, source_node, field_ptr_type, container_ptr, CastOpNoop); |
| 15000 | 15000 | } |
| 15001 | 15001 | |
| 15002 | static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, | |
| 15003 | Scope *scope, AstNode *source_node, IrInstGen *container_ptr, AstNode *container_ptr_src, | |
| 15002 | static Stage1AirInst *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, | |
| 15003 | Scope *scope, AstNode *source_node, Stage1AirInst *container_ptr, AstNode *container_ptr_src, | |
| 15004 | 15004 | ZigType *container_type, bool initializing) |
| 15005 | 15005 | { |
| 15006 | 15006 | Error err; |
| ... | ... | @@ -15108,7 +15108,7 @@ static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name |
| 15108 | 15108 | ZigValue *payload_val = union_val->data.x_union.payload; |
| 15109 | 15109 | assert(payload_val); |
| 15110 | 15110 | |
| 15111 | IrInstGen *result; | |
| 15111 | Stage1AirInst *result; | |
| 15112 | 15112 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 15113 | 15113 | result = ir_build_union_field_ptr(ira, scope, source_node, container_ptr, field, true, |
| 15114 | 15114 | initializing, ptr_type); |
| ... | ... | @@ -15139,12 +15139,12 @@ static void add_link_lib_symbol(IrAnalyze *ira, Buf *lib_name, Buf *symbol_name, |
| 15139 | 15139 | } |
| 15140 | 15140 | } |
| 15141 | 15141 | |
| 15142 | static IrInstGen *ir_error_dependency_loop(IrAnalyze *ira, AstNode* source_node) { | |
| 15142 | static Stage1AirInst *ir_error_dependency_loop(IrAnalyze *ira, AstNode* source_node) { | |
| 15143 | 15143 | ir_add_error_node(ira, source_node, buf_sprintf("dependency loop detected")); |
| 15144 | 15144 | return ira->codegen->invalid_inst_gen; |
| 15145 | 15145 | } |
| 15146 | 15146 | |
| 15147 | static IrInstGen *ir_analyze_decl_ref(IrAnalyze *ira, Scope *scope, AstNode *source_node, Tld *tld) { | |
| 15147 | static Stage1AirInst *ir_analyze_decl_ref(IrAnalyze *ira, Scope *scope, AstNode *source_node, Tld *tld) { | |
| 15148 | 15148 | resolve_top_level_decl(ira->codegen, tld, source_node, true); |
| 15149 | 15149 | if (tld->resolution == TldResolutionInvalid) { |
| 15150 | 15150 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -15181,7 +15181,7 @@ static IrInstGen *ir_analyze_decl_ref(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 15181 | 15181 | add_link_lib_symbol(ira, tld_fn->extern_lib_name, &fn_entry->symbol_name, source_node); |
| 15182 | 15182 | } |
| 15183 | 15183 | |
| 15184 | IrInstGen *fn_inst = ir_const_fn(ira, scope, source_node, fn_entry); | |
| 15184 | Stage1AirInst *fn_inst = ir_const_fn(ira, scope, source_node, fn_entry); | |
| 15185 | 15185 | return ir_get_ref(ira, scope, source_node, fn_inst, true, false); |
| 15186 | 15186 | } |
| 15187 | 15187 | } |
| ... | ... | @@ -15199,9 +15199,9 @@ static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_n |
| 15199 | 15199 | return nullptr; |
| 15200 | 15200 | } |
| 15201 | 15201 | |
| 15202 | static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFieldPtr *field_ptr_instruction) { | |
| 15202 | static Stage1AirInst *ir_analyze_instruction_field_ptr(IrAnalyze *ira, Stage1ZirInstFieldPtr *field_ptr_instruction) { | |
| 15203 | 15203 | Error err; |
| 15204 | IrInstGen *container_ptr = field_ptr_instruction->container_ptr->child; | |
| 15204 | Stage1AirInst *container_ptr = field_ptr_instruction->container_ptr->child; | |
| 15205 | 15205 | if (type_is_invalid(container_ptr->value->type)) |
| 15206 | 15206 | return ira->codegen->invalid_inst_gen; |
| 15207 | 15207 | |
| ... | ... | @@ -15209,7 +15209,7 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 15209 | 15209 | |
| 15210 | 15210 | Buf *field_name = field_ptr_instruction->field_name_buffer; |
| 15211 | 15211 | if (!field_name) { |
| 15212 | IrInstGen *field_name_expr = field_ptr_instruction->field_name_expr->child; | |
| 15212 | Stage1AirInst *field_name_expr = field_ptr_instruction->field_name_expr->child; | |
| 15213 | 15213 | field_name = ir_resolve_str(ira, field_name_expr); |
| 15214 | 15214 | if (!field_name) |
| 15215 | 15215 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -15221,22 +15221,22 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 15221 | 15221 | if (type_is_invalid(container_type)) { |
| 15222 | 15222 | return ira->codegen->invalid_inst_gen; |
| 15223 | 15223 | } else if (is_tuple(container_type) && !field_ptr_instruction->initializing && buf_eql_str(field_name, "len")) { |
| 15224 | IrInstGen *len_inst = ir_const_unsigned(ira, field_ptr_instruction->base.scope, field_ptr_instruction->base.source_node, | |
| 15224 | Stage1AirInst *len_inst = ir_const_unsigned(ira, field_ptr_instruction->base.scope, field_ptr_instruction->base.source_node, | |
| 15225 | 15225 | container_type->data.structure.src_field_count); |
| 15226 | 15226 | return ir_get_ref(ira, field_ptr_instruction->base.scope, field_ptr_instruction->base.source_node, len_inst, true, false); |
| 15227 | 15227 | } else if (is_slice(container_type) || is_container_ref(container_type)) { |
| 15228 | 15228 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 15229 | 15229 | if (container_type->id == ZigTypeIdPointer) { |
| 15230 | 15230 | ZigType *bare_type = container_ref_type(container_type); |
| 15231 | IrInstGen *container_child = ir_get_deref(ira, field_ptr_instruction->base.scope, | |
| 15231 | Stage1AirInst *container_child = ir_get_deref(ira, field_ptr_instruction->base.scope, | |
| 15232 | 15232 | field_ptr_instruction->base.source_node, container_ptr, nullptr); |
| 15233 | IrInstGen *result = ir_analyze_container_field_ptr(ira, field_name, | |
| 15233 | Stage1AirInst *result = ir_analyze_container_field_ptr(ira, field_name, | |
| 15234 | 15234 | field_ptr_instruction->base.scope, field_ptr_instruction->base.source_node, |
| 15235 | 15235 | container_child, field_ptr_instruction->container_ptr->source_node, bare_type, |
| 15236 | 15236 | field_ptr_instruction->initializing); |
| 15237 | 15237 | return result; |
| 15238 | 15238 | } else { |
| 15239 | IrInstGen *result = ir_analyze_container_field_ptr(ira, field_name, | |
| 15239 | Stage1AirInst *result = ir_analyze_container_field_ptr(ira, field_name, | |
| 15240 | 15240 | field_ptr_instruction->base.scope, field_ptr_instruction->base.source_node, |
| 15241 | 15241 | container_ptr, field_ptr_instruction->container_ptr->source_node, |
| 15242 | 15242 | container_type, field_ptr_instruction->initializing); |
| ... | ... | @@ -15390,26 +15390,26 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 15390 | 15390 | } |
| 15391 | 15391 | } |
| 15392 | 15392 | |
| 15393 | static IrInstGen *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstSrcStorePtr *instruction) { | |
| 15394 | IrInstGen *ptr = instruction->ptr->child; | |
| 15393 | static Stage1AirInst *ir_analyze_instruction_store_ptr(IrAnalyze *ira, Stage1ZirInstStorePtr *instruction) { | |
| 15394 | Stage1AirInst *ptr = instruction->ptr->child; | |
| 15395 | 15395 | if (type_is_invalid(ptr->value->type)) |
| 15396 | 15396 | return ira->codegen->invalid_inst_gen; |
| 15397 | 15397 | |
| 15398 | IrInstGen *value = instruction->value->child; | |
| 15398 | Stage1AirInst *value = instruction->value->child; | |
| 15399 | 15399 | if (type_is_invalid(value->value->type)) |
| 15400 | 15400 | return ira->codegen->invalid_inst_gen; |
| 15401 | 15401 | |
| 15402 | 15402 | return ir_analyze_store_ptr(ira, instruction->base.scope, instruction->base.source_node, ptr, value, instruction->allow_write_through_const); |
| 15403 | 15403 | } |
| 15404 | 15404 | |
| 15405 | static IrInstGen *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstSrcLoadPtr *instruction) { | |
| 15406 | IrInstGen *ptr = instruction->ptr->child; | |
| 15405 | static Stage1AirInst *ir_analyze_instruction_load_ptr(IrAnalyze *ira, Stage1ZirInstLoadPtr *instruction) { | |
| 15406 | Stage1AirInst *ptr = instruction->ptr->child; | |
| 15407 | 15407 | if (type_is_invalid(ptr->value->type)) |
| 15408 | 15408 | return ira->codegen->invalid_inst_gen; |
| 15409 | 15409 | return ir_get_deref(ira, instruction->base.scope, instruction->base.source_node, ptr, nullptr); |
| 15410 | 15410 | } |
| 15411 | 15411 | |
| 15412 | static IrInstGen *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstSrcTypeOf *typeof_instruction) { | |
| 15412 | static Stage1AirInst *ir_analyze_instruction_typeof(IrAnalyze *ira, Stage1ZirInstTypeOf *typeof_instruction) { | |
| 15413 | 15413 | ZigType *type_entry; |
| 15414 | 15414 | |
| 15415 | 15415 | const size_t value_count = typeof_instruction->value_count; |
| ... | ... | @@ -15418,9 +15418,9 @@ static IrInstGen *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstSrcTypeOf |
| 15418 | 15418 | if (value_count < 2) { |
| 15419 | 15419 | type_entry = typeof_instruction->value.scalar->child->value->type; |
| 15420 | 15420 | } else { |
| 15421 | IrInstGen **args = heap::c_allocator.allocate<IrInstGen*>(value_count); | |
| 15421 | Stage1AirInst **args = heap::c_allocator.allocate<Stage1AirInst*>(value_count); | |
| 15422 | 15422 | for (size_t i = 0; i < value_count; i += 1) { |
| 15423 | IrInstGen *value = typeof_instruction->value.list[i]->child; | |
| 15423 | Stage1AirInst *value = typeof_instruction->value.list[i]->child; | |
| 15424 | 15424 | if (type_is_invalid(value->value->type)) |
| 15425 | 15425 | return ira->codegen->invalid_inst_gen; |
| 15426 | 15426 | args[i] = value; |
| ... | ... | @@ -15438,13 +15438,13 @@ static IrInstGen *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstSrcTypeOf |
| 15438 | 15438 | return ir_const_type(ira, typeof_instruction->base.scope, typeof_instruction->base.source_node, type_entry); |
| 15439 | 15439 | } |
| 15440 | 15440 | |
| 15441 | static IrInstGen *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstSrcSetCold *instruction) { | |
| 15441 | static Stage1AirInst *ir_analyze_instruction_set_cold(IrAnalyze *ira, Stage1ZirInstSetCold *instruction) { | |
| 15442 | 15442 | if (ira->new_irb.exec->is_inline) { |
| 15443 | 15443 | // ignore setCold when running functions at compile time |
| 15444 | 15444 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 15445 | 15445 | } |
| 15446 | 15446 | |
| 15447 | IrInstGen *is_cold_value = instruction->is_cold->child; | |
| 15447 | Stage1AirInst *is_cold_value = instruction->is_cold->child; | |
| 15448 | 15448 | bool want_cold; |
| 15449 | 15449 | if (!ir_resolve_bool(ira, is_cold_value, &want_cold)) |
| 15450 | 15450 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -15467,8 +15467,8 @@ static IrInstGen *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstSrcSetCo |
| 15467 | 15467 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 15468 | 15468 | } |
| 15469 | 15469 | |
| 15470 | static IrInstGen *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, | |
| 15471 | IrInstSrcSetRuntimeSafety *set_runtime_safety_instruction) | |
| 15470 | static Stage1AirInst *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, | |
| 15471 | Stage1ZirInstSetRuntimeSafety *set_runtime_safety_instruction) | |
| 15472 | 15472 | { |
| 15473 | 15473 | if (ira->new_irb.exec->is_inline) { |
| 15474 | 15474 | // ignore setRuntimeSafety when running functions at compile time |
| ... | ... | @@ -15505,7 +15505,7 @@ static IrInstGen *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, |
| 15505 | 15505 | } |
| 15506 | 15506 | assert(scope != nullptr); |
| 15507 | 15507 | |
| 15508 | IrInstGen *safety_on_value = set_runtime_safety_instruction->safety_on->child; | |
| 15508 | Stage1AirInst *safety_on_value = set_runtime_safety_instruction->safety_on->child; | |
| 15509 | 15509 | bool want_runtime_safety; |
| 15510 | 15510 | if (!ir_resolve_bool(ira, safety_on_value, &want_runtime_safety)) |
| 15511 | 15511 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -15524,8 +15524,8 @@ static IrInstGen *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, |
| 15524 | 15524 | set_runtime_safety_instruction->base.source_node); |
| 15525 | 15525 | } |
| 15526 | 15526 | |
| 15527 | static IrInstGen *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, | |
| 15528 | IrInstSrcSetFloatMode *instruction) | |
| 15527 | static Stage1AirInst *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, | |
| 15528 | Stage1ZirInstSetFloatMode *instruction) | |
| 15529 | 15529 | { |
| 15530 | 15530 | if (ira->new_irb.exec->is_inline) { |
| 15531 | 15531 | // ignore setFloatMode when running functions at compile time |
| ... | ... | @@ -15561,7 +15561,7 @@ static IrInstGen *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, |
| 15561 | 15561 | } |
| 15562 | 15562 | assert(scope != nullptr); |
| 15563 | 15563 | |
| 15564 | IrInstGen *float_mode_value = instruction->mode_value->child; | |
| 15564 | Stage1AirInst *float_mode_value = instruction->mode_value->child; | |
| 15565 | 15565 | FloatMode float_mode_scalar; |
| 15566 | 15566 | if (!ir_resolve_float_mode(ira, float_mode_value, &float_mode_scalar)) |
| 15567 | 15567 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -15579,7 +15579,7 @@ static IrInstGen *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, |
| 15579 | 15579 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 15580 | 15580 | } |
| 15581 | 15581 | |
| 15582 | static IrInstGen *ir_analyze_instruction_any_frame_type(IrAnalyze *ira, IrInstSrcAnyFrameType *instruction) { | |
| 15582 | static Stage1AirInst *ir_analyze_instruction_any_frame_type(IrAnalyze *ira, Stage1ZirInstAnyFrameType *instruction) { | |
| 15583 | 15583 | ZigType *payload_type = nullptr; |
| 15584 | 15584 | if (instruction->payload_type != nullptr) { |
| 15585 | 15585 | payload_type = ir_resolve_type(ira, instruction->payload_type->child); |
| ... | ... | @@ -15591,8 +15591,8 @@ static IrInstGen *ir_analyze_instruction_any_frame_type(IrAnalyze *ira, IrInstSr |
| 15591 | 15591 | return ir_const_type(ira, instruction->base.scope, instruction->base.source_node, any_frame_type); |
| 15592 | 15592 | } |
| 15593 | 15593 | |
| 15594 | static IrInstGen *ir_analyze_instruction_slice_type(IrAnalyze *ira, IrInstSrcSliceType *slice_type_instruction) { | |
| 15595 | IrInstGen *result = ir_const(ira, slice_type_instruction->base.scope, | |
| 15594 | static Stage1AirInst *ir_analyze_instruction_slice_type(IrAnalyze *ira, Stage1ZirInstSliceType *slice_type_instruction) { | |
| 15595 | Stage1AirInst *result = ir_const(ira, slice_type_instruction->base.scope, | |
| 15596 | 15596 | slice_type_instruction->base.source_node, ira->codegen->builtin_types.entry_type); |
| 15597 | 15597 | result->value->special = ConstValSpecialLazy; |
| 15598 | 15598 | |
| ... | ... | @@ -15643,7 +15643,7 @@ static size_t find_asm_index(CodeGen *g, AstNode *node, AsmToken *tok, Buf *src_ |
| 15643 | 15643 | return SIZE_MAX; |
| 15644 | 15644 | } |
| 15645 | 15645 | |
| 15646 | static IrInstGen *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstSrcAsm *asm_instruction) { | |
| 15646 | static Stage1AirInst *ir_analyze_instruction_asm(IrAnalyze *ira, Stage1ZirInstAsm *asm_instruction) { | |
| 15647 | 15647 | Error err; |
| 15648 | 15648 | |
| 15649 | 15649 | assert(asm_instruction->base.source_node->type == NodeTypeAsmExpr); |
| ... | ... | @@ -15688,8 +15688,8 @@ static IrInstGen *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstSrcAsm *asm_i |
| 15688 | 15688 | |
| 15689 | 15689 | // TODO validate the output types and variable types |
| 15690 | 15690 | |
| 15691 | IrInstGen **input_list = heap::c_allocator.allocate<IrInstGen *>(asm_expr->input_list.length); | |
| 15692 | IrInstGen **output_types = heap::c_allocator.allocate<IrInstGen *>(asm_expr->output_list.length); | |
| 15691 | Stage1AirInst **input_list = heap::c_allocator.allocate<Stage1AirInst *>(asm_expr->input_list.length); | |
| 15692 | Stage1AirInst **output_types = heap::c_allocator.allocate<Stage1AirInst *>(asm_expr->output_list.length); | |
| 15693 | 15693 | |
| 15694 | 15694 | ZigType *return_type = ira->codegen->builtin_types.entry_void; |
| 15695 | 15695 | for (size_t i = 0; i < asm_expr->output_list.length; i += 1) { |
| ... | ... | @@ -15703,7 +15703,7 @@ static IrInstGen *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstSrcAsm *asm_i |
| 15703 | 15703 | } |
| 15704 | 15704 | |
| 15705 | 15705 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { |
| 15706 | IrInstGen *const input_value = asm_instruction->input_list[i]->child; | |
| 15706 | Stage1AirInst *const input_value = asm_instruction->input_list[i]->child; | |
| 15707 | 15707 | if (type_is_invalid(input_value->value->type)) |
| 15708 | 15708 | return ira->codegen->invalid_inst_gen; |
| 15709 | 15709 | |
| ... | ... | @@ -15724,8 +15724,8 @@ static IrInstGen *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstSrcAsm *asm_i |
| 15724 | 15724 | asm_instruction->has_side_effects, return_type); |
| 15725 | 15725 | } |
| 15726 | 15726 | |
| 15727 | static IrInstGen *ir_analyze_instruction_array_type(IrAnalyze *ira, IrInstSrcArrayType *array_type_instruction) { | |
| 15728 | IrInstGen *result = ir_const(ira, array_type_instruction->base.scope, | |
| 15727 | static Stage1AirInst *ir_analyze_instruction_array_type(IrAnalyze *ira, Stage1ZirInstArrayType *array_type_instruction) { | |
| 15728 | Stage1AirInst *result = ir_const(ira, array_type_instruction->base.scope, | |
| 15729 | 15729 | array_type_instruction->base.source_node, ira->codegen->builtin_types.entry_type); |
| 15730 | 15730 | result->value->special = ConstValSpecialLazy; |
| 15731 | 15731 | |
| ... | ... | @@ -15750,8 +15750,8 @@ static IrInstGen *ir_analyze_instruction_array_type(IrAnalyze *ira, IrInstSrcArr |
| 15750 | 15750 | return result; |
| 15751 | 15751 | } |
| 15752 | 15752 | |
| 15753 | static IrInstGen *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstSrcSizeOf *instruction) { | |
| 15754 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_num_lit_int); | |
| 15753 | static Stage1AirInst *ir_analyze_instruction_size_of(IrAnalyze *ira, Stage1ZirInstSizeOf *instruction) { | |
| 15754 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_num_lit_int); | |
| 15755 | 15755 | result->value->special = ConstValSpecialLazy; |
| 15756 | 15756 | |
| 15757 | 15757 | LazyValueSizeOf *lazy_size_of = heap::c_allocator.create<LazyValueSizeOf>(); |
| ... | ... | @@ -15767,7 +15767,7 @@ static IrInstGen *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstSrcSizeOf |
| 15767 | 15767 | return result; |
| 15768 | 15768 | } |
| 15769 | 15769 | |
| 15770 | static IrInstGen *ir_analyze_test_non_null(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value) { | |
| 15770 | static Stage1AirInst *ir_analyze_test_non_null(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value) { | |
| 15771 | 15771 | ZigType *type_entry = value->value->type; |
| 15772 | 15772 | |
| 15773 | 15773 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) { |
| ... | ... | @@ -15803,16 +15803,16 @@ static IrInstGen *ir_analyze_test_non_null(IrAnalyze *ira, Scope *scope, AstNode |
| 15803 | 15803 | } |
| 15804 | 15804 | } |
| 15805 | 15805 | |
| 15806 | static IrInstGen *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstSrcTestNonNull *instruction) { | |
| 15807 | IrInstGen *value = instruction->value->child; | |
| 15806 | static Stage1AirInst *ir_analyze_instruction_test_non_null(IrAnalyze *ira, Stage1ZirInstTestNonNull *instruction) { | |
| 15807 | Stage1AirInst *value = instruction->value->child; | |
| 15808 | 15808 | if (type_is_invalid(value->value->type)) |
| 15809 | 15809 | return ira->codegen->invalid_inst_gen; |
| 15810 | 15810 | |
| 15811 | 15811 | return ir_analyze_test_non_null(ira, instruction->base.scope, instruction->base.source_node, value); |
| 15812 | 15812 | } |
| 15813 | 15813 | |
| 15814 | static IrInstGen *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 15815 | IrInstGen *base_ptr, bool safety_check_on, bool initializing) | |
| 15814 | static Stage1AirInst *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 15815 | Stage1AirInst *base_ptr, bool safety_check_on, bool initializing) | |
| 15816 | 15816 | { |
| 15817 | 15817 | Error err; |
| 15818 | 15818 | |
| ... | ... | @@ -15841,7 +15841,7 @@ static IrInstGen *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, Scope *scop |
| 15841 | 15841 | } |
| 15842 | 15842 | if (!safety_check_on) |
| 15843 | 15843 | return base_ptr; |
| 15844 | IrInstGen *c_ptr_val = ir_get_deref(ira, scope, source_node, base_ptr, nullptr); | |
| 15844 | Stage1AirInst *c_ptr_val = ir_get_deref(ira, scope, source_node, base_ptr, nullptr); | |
| 15845 | 15845 | ir_build_assert_non_null(ira, scope, source_node, c_ptr_val); |
| 15846 | 15846 | return base_ptr; |
| 15847 | 15847 | } |
| ... | ... | @@ -15900,7 +15900,7 @@ static IrInstGen *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, Scope *scop |
| 15900 | 15900 | } |
| 15901 | 15901 | } |
| 15902 | 15902 | |
| 15903 | IrInstGen *result; | |
| 15903 | Stage1AirInst *result; | |
| 15904 | 15904 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 15905 | 15905 | result = ir_build_optional_unwrap_ptr_gen(ira, scope, source_node, base_ptr, false, |
| 15906 | 15906 | initializing, result_type); |
| ... | ... | @@ -15935,10 +15935,10 @@ static IrInstGen *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, Scope *scop |
| 15935 | 15935 | initializing, result_type); |
| 15936 | 15936 | } |
| 15937 | 15937 | |
| 15938 | static IrInstGen *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira, | |
| 15939 | IrInstSrcOptionalUnwrapPtr *instruction) | |
| 15938 | static Stage1AirInst *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira, | |
| 15939 | Stage1ZirInstOptionalUnwrapPtr *instruction) | |
| 15940 | 15940 | { |
| 15941 | IrInstGen *base_ptr = instruction->base_ptr->child; | |
| 15941 | Stage1AirInst *base_ptr = instruction->base_ptr->child; | |
| 15942 | 15942 | if (type_is_invalid(base_ptr->value->type)) |
| 15943 | 15943 | return ira->codegen->invalid_inst_gen; |
| 15944 | 15944 | |
| ... | ... | @@ -15946,12 +15946,12 @@ static IrInstGen *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira, |
| 15946 | 15946 | instruction->safety_check_on, false); |
| 15947 | 15947 | } |
| 15948 | 15948 | |
| 15949 | static IrInstGen *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstSrcCtz *instruction) { | |
| 15949 | static Stage1AirInst *ir_analyze_instruction_ctz(IrAnalyze *ira, Stage1ZirInstCtz *instruction) { | |
| 15950 | 15950 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 15951 | 15951 | if (type_is_invalid(int_type)) |
| 15952 | 15952 | return ira->codegen->invalid_inst_gen; |
| 15953 | 15953 | |
| 15954 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); | |
| 15954 | Stage1AirInst *op = ir_implicit_cast(ira, instruction->op->child, int_type); | |
| 15955 | 15955 | if (type_is_invalid(op->value->type)) |
| 15956 | 15956 | return ira->codegen->invalid_inst_gen; |
| 15957 | 15957 | |
| ... | ... | @@ -15972,12 +15972,12 @@ static IrInstGen *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstSrcCtz *instr |
| 15972 | 15972 | return ir_build_ctz_gen(ira, instruction->base.scope, instruction->base.source_node, return_type, op); |
| 15973 | 15973 | } |
| 15974 | 15974 | |
| 15975 | static IrInstGen *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstSrcClz *instruction) { | |
| 15975 | static Stage1AirInst *ir_analyze_instruction_clz(IrAnalyze *ira, Stage1ZirInstClz *instruction) { | |
| 15976 | 15976 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 15977 | 15977 | if (type_is_invalid(int_type)) |
| 15978 | 15978 | return ira->codegen->invalid_inst_gen; |
| 15979 | 15979 | |
| 15980 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); | |
| 15980 | Stage1AirInst *op = ir_implicit_cast(ira, instruction->op->child, int_type); | |
| 15981 | 15981 | if (type_is_invalid(op->value->type)) |
| 15982 | 15982 | return ira->codegen->invalid_inst_gen; |
| 15983 | 15983 | |
| ... | ... | @@ -15998,12 +15998,12 @@ static IrInstGen *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstSrcClz *instr |
| 15998 | 15998 | return ir_build_clz_gen(ira, instruction->base.scope, instruction->base.source_node, return_type, op); |
| 15999 | 15999 | } |
| 16000 | 16000 | |
| 16001 | static IrInstGen *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstSrcPopCount *instruction) { | |
| 16001 | static Stage1AirInst *ir_analyze_instruction_pop_count(IrAnalyze *ira, Stage1ZirInstPopCount *instruction) { | |
| 16002 | 16002 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 16003 | 16003 | if (type_is_invalid(int_type)) |
| 16004 | 16004 | return ira->codegen->invalid_inst_gen; |
| 16005 | 16005 | |
| 16006 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); | |
| 16006 | Stage1AirInst *op = ir_implicit_cast(ira, instruction->op->child, int_type); | |
| 16007 | 16007 | if (type_is_invalid(op->value->type)) |
| 16008 | 16008 | return ira->codegen->invalid_inst_gen; |
| 16009 | 16009 | |
| ... | ... | @@ -16029,7 +16029,7 @@ static IrInstGen *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstSrcPopC |
| 16029 | 16029 | return ir_build_pop_count_gen(ira, instruction->base.scope, instruction->base.source_node, return_type, op); |
| 16030 | 16030 | } |
| 16031 | 16031 | |
| 16032 | static IrInstGen *ir_analyze_union_tag(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value) { | |
| 16032 | static Stage1AirInst *ir_analyze_union_tag(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value) { | |
| 16033 | 16033 | if (type_is_invalid(value->value->type)) |
| 16034 | 16034 | return ira->codegen->invalid_inst_gen; |
| 16035 | 16035 | |
| ... | ... | @@ -16055,7 +16055,7 @@ static IrInstGen *ir_analyze_union_tag(IrAnalyze *ira, Scope *scope, AstNode *so |
| 16055 | 16055 | if (!val) |
| 16056 | 16056 | return ira->codegen->invalid_inst_gen; |
| 16057 | 16057 | |
| 16058 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, | |
| 16058 | Stage1AirInstConst *const_instruction = ir_create_inst_gen<Stage1AirInstConst>(&ira->new_irb, | |
| 16059 | 16059 | scope, source_node); |
| 16060 | 16060 | const_instruction->base.value->type = tag_type; |
| 16061 | 16061 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | ... | @@ -16066,10 +16066,10 @@ static IrInstGen *ir_analyze_union_tag(IrAnalyze *ira, Scope *scope, AstNode *so |
| 16066 | 16066 | return ir_build_union_tag(ira, scope, source_node, value, tag_type); |
| 16067 | 16067 | } |
| 16068 | 16068 | |
| 16069 | static IrInstGen *ir_analyze_instruction_switch_br(IrAnalyze *ira, | |
| 16070 | IrInstSrcSwitchBr *switch_br_instruction) | |
| 16069 | static Stage1AirInst *ir_analyze_instruction_switch_br(IrAnalyze *ira, | |
| 16070 | Stage1ZirInstSwitchBr *switch_br_instruction) | |
| 16071 | 16071 | { |
| 16072 | IrInstGen *target_value = switch_br_instruction->target_value->child; | |
| 16072 | Stage1AirInst *target_value = switch_br_instruction->target_value->child; | |
| 16073 | 16073 | if (type_is_invalid(target_value->value->type)) |
| 16074 | 16074 | return ir_unreach_error(ira); |
| 16075 | 16075 | |
| ... | ... | @@ -16093,12 +16093,12 @@ static IrInstGen *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 16093 | 16093 | |
| 16094 | 16094 | Stage1ZirBasicBlock *old_dest_block = switch_br_instruction->else_block; |
| 16095 | 16095 | for (size_t i = 0; i < case_count; i += 1) { |
| 16096 | IrInstSrcSwitchBrCase *old_case = &switch_br_instruction->cases[i]; | |
| 16097 | IrInstGen *case_value = old_case->value->child; | |
| 16096 | Stage1ZirInstSwitchBrCase *old_case = &switch_br_instruction->cases[i]; | |
| 16097 | Stage1AirInst *case_value = old_case->value->child; | |
| 16098 | 16098 | if (type_is_invalid(case_value->value->type)) |
| 16099 | 16099 | return ir_unreach_error(ira); |
| 16100 | 16100 | |
| 16101 | IrInstGen *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value->type); | |
| 16101 | Stage1AirInst *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value->type); | |
| 16102 | 16102 | if (type_is_invalid(casted_case_value->value->type)) |
| 16103 | 16103 | return ir_unreach_error(ira); |
| 16104 | 16104 | |
| ... | ... | @@ -16115,17 +16115,17 @@ static IrInstGen *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 16115 | 16115 | if (is_comptime || old_dest_block->ref_count == 1) { |
| 16116 | 16116 | return ir_inline_bb(ira, switch_br_instruction->base.source_node, old_dest_block); |
| 16117 | 16117 | } else { |
| 16118 | IrBasicBlockGen *new_dest_block = ir_get_new_bb(ira, old_dest_block, &switch_br_instruction->base); | |
| 16119 | IrInstGen *result = ir_build_br_gen(ira, switch_br_instruction->base.scope, | |
| 16118 | Stage1AirBasicBlock *new_dest_block = ir_get_new_bb(ira, old_dest_block, &switch_br_instruction->base); | |
| 16119 | Stage1AirInst *result = ir_build_br_gen(ira, switch_br_instruction->base.scope, | |
| 16120 | 16120 | switch_br_instruction->base.source_node, new_dest_block); |
| 16121 | 16121 | return ir_finish_anal(ira, result); |
| 16122 | 16122 | } |
| 16123 | 16123 | } |
| 16124 | 16124 | |
| 16125 | IrInstGenSwitchBrCase *cases = heap::c_allocator.allocate<IrInstGenSwitchBrCase>(case_count); | |
| 16125 | Stage1AirInstSwitchBrCase *cases = heap::c_allocator.allocate<Stage1AirInstSwitchBrCase>(case_count); | |
| 16126 | 16126 | for (size_t i = 0; i < case_count; i += 1) { |
| 16127 | IrInstSrcSwitchBrCase *old_case = &switch_br_instruction->cases[i]; | |
| 16128 | IrInstGenSwitchBrCase *new_case = &cases[i]; | |
| 16127 | Stage1ZirInstSwitchBrCase *old_case = &switch_br_instruction->cases[i]; | |
| 16128 | Stage1AirInstSwitchBrCase *new_case = &cases[i]; | |
| 16129 | 16129 | new_case->block = ir_get_new_bb(ira, old_case->block, &switch_br_instruction->base); |
| 16130 | 16130 | new_case->value = ira->codegen->invalid_inst_gen; |
| 16131 | 16131 | |
| ... | ... | @@ -16135,12 +16135,12 @@ static IrInstGen *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 16135 | 16135 | // it back after the loop. |
| 16136 | 16136 | new_case->block->ref_instruction = nullptr; |
| 16137 | 16137 | |
| 16138 | IrInstSrc *old_value = old_case->value; | |
| 16139 | IrInstGen *new_value = old_value->child; | |
| 16138 | Stage1ZirInst *old_value = old_case->value; | |
| 16139 | Stage1AirInst *new_value = old_value->child; | |
| 16140 | 16140 | if (type_is_invalid(new_value->value->type)) |
| 16141 | 16141 | continue; |
| 16142 | 16142 | |
| 16143 | IrInstGen *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value->type); | |
| 16143 | Stage1AirInst *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value->type); | |
| 16144 | 16144 | if (type_is_invalid(casted_new_value->value->type)) |
| 16145 | 16145 | continue; |
| 16146 | 16146 | |
| ... | ... | @@ -16151,23 +16151,23 @@ static IrInstGen *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 16151 | 16151 | } |
| 16152 | 16152 | |
| 16153 | 16153 | for (size_t i = 0; i < case_count; i += 1) { |
| 16154 | IrInstGenSwitchBrCase *new_case = &cases[i]; | |
| 16154 | Stage1AirInstSwitchBrCase *new_case = &cases[i]; | |
| 16155 | 16155 | if (type_is_invalid(new_case->value->value->type)) |
| 16156 | 16156 | return ir_unreach_error(ira); |
| 16157 | 16157 | new_case->block->ref_instruction = &switch_br_instruction->base; |
| 16158 | 16158 | } |
| 16159 | 16159 | |
| 16160 | IrBasicBlockGen *new_else_block = ir_get_new_bb(ira, switch_br_instruction->else_block, &switch_br_instruction->base); | |
| 16161 | IrInstGenSwitchBr *switch_br = ir_build_switch_br_gen(ira, switch_br_instruction->base.scope, | |
| 16160 | Stage1AirBasicBlock *new_else_block = ir_get_new_bb(ira, switch_br_instruction->else_block, &switch_br_instruction->base); | |
| 16161 | Stage1AirInstSwitchBr *switch_br = ir_build_switch_br_gen(ira, switch_br_instruction->base.scope, | |
| 16162 | 16162 | switch_br_instruction->base.source_node, target_value, new_else_block, case_count, cases); |
| 16163 | 16163 | return ir_finish_anal(ira, &switch_br->base); |
| 16164 | 16164 | } |
| 16165 | 16165 | |
| 16166 | static IrInstGen *ir_analyze_instruction_switch_target(IrAnalyze *ira, | |
| 16167 | IrInstSrcSwitchTarget *switch_target_instruction) | |
| 16166 | static Stage1AirInst *ir_analyze_instruction_switch_target(IrAnalyze *ira, | |
| 16167 | Stage1ZirInstSwitchTarget *switch_target_instruction) | |
| 16168 | 16168 | { |
| 16169 | 16169 | Error err; |
| 16170 | IrInstGen *target_value_ptr = switch_target_instruction->target_value_ptr->child; | |
| 16170 | Stage1AirInst *target_value_ptr = switch_target_instruction->target_value_ptr->child; | |
| 16171 | 16171 | if (type_is_invalid(target_value_ptr->value->type)) |
| 16172 | 16172 | return ira->codegen->invalid_inst_gen; |
| 16173 | 16173 | |
| ... | ... | @@ -16207,14 +16207,14 @@ static IrInstGen *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 16207 | 16207 | case ZigTypeIdFn: |
| 16208 | 16208 | case ZigTypeIdErrorSet: { |
| 16209 | 16209 | if (pointee_val) { |
| 16210 | IrInstGen *result = ir_const(ira, switch_target_instruction->base.scope, | |
| 16210 | Stage1AirInst *result = ir_const(ira, switch_target_instruction->base.scope, | |
| 16211 | 16211 | switch_target_instruction->base.source_node, nullptr); |
| 16212 | 16212 | copy_const_val(ira->codegen, result->value, pointee_val); |
| 16213 | 16213 | result->value->type = target_type; |
| 16214 | 16214 | return result; |
| 16215 | 16215 | } |
| 16216 | 16216 | |
| 16217 | IrInstGen *result = ir_get_deref(ira, switch_target_instruction->base.scope, | |
| 16217 | Stage1AirInst *result = ir_get_deref(ira, switch_target_instruction->base.scope, | |
| 16218 | 16218 | switch_target_instruction->base.source_node, target_value_ptr, nullptr); |
| 16219 | 16219 | result->value->type = target_type; |
| 16220 | 16220 | return result; |
| ... | ... | @@ -16234,19 +16234,19 @@ static IrInstGen *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 16234 | 16234 | assert(tag_type != nullptr); |
| 16235 | 16235 | assert(tag_type->id == ZigTypeIdEnum); |
| 16236 | 16236 | if (pointee_val) { |
| 16237 | IrInstGen *result = ir_const(ira, switch_target_instruction->base.scope, switch_target_instruction->base.source_node, tag_type); | |
| 16237 | Stage1AirInst *result = ir_const(ira, switch_target_instruction->base.scope, switch_target_instruction->base.source_node, tag_type); | |
| 16238 | 16238 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_union.tag); |
| 16239 | 16239 | return result; |
| 16240 | 16240 | } |
| 16241 | 16241 | |
| 16242 | 16242 | if (can_fold_enum_type(tag_type)) { |
| 16243 | IrInstGen *result = ir_const(ira, switch_target_instruction->base.scope, switch_target_instruction->base.source_node, tag_type); | |
| 16243 | Stage1AirInst *result = ir_const(ira, switch_target_instruction->base.scope, switch_target_instruction->base.source_node, tag_type); | |
| 16244 | 16244 | TypeEnumField *only_field = &tag_type->data.enumeration.fields[0]; |
| 16245 | 16245 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); |
| 16246 | 16246 | return result; |
| 16247 | 16247 | } |
| 16248 | 16248 | |
| 16249 | IrInstGen *union_value = ir_get_deref(ira, switch_target_instruction->base.scope, | |
| 16249 | Stage1AirInst *union_value = ir_get_deref(ira, switch_target_instruction->base.scope, | |
| 16250 | 16250 | switch_target_instruction->base.source_node, target_value_ptr, nullptr); |
| 16251 | 16251 | union_value->value->type = target_type; |
| 16252 | 16252 | |
| ... | ... | @@ -16258,18 +16258,18 @@ static IrInstGen *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 16258 | 16258 | |
| 16259 | 16259 | if (can_fold_enum_type(target_type)) { |
| 16260 | 16260 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; |
| 16261 | IrInstGen *result = ir_const(ira, switch_target_instruction->base.scope, switch_target_instruction->base.source_node, target_type); | |
| 16261 | Stage1AirInst *result = ir_const(ira, switch_target_instruction->base.scope, switch_target_instruction->base.source_node, target_type); | |
| 16262 | 16262 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); |
| 16263 | 16263 | return result; |
| 16264 | 16264 | } |
| 16265 | 16265 | |
| 16266 | 16266 | if (pointee_val) { |
| 16267 | IrInstGen *result = ir_const(ira, switch_target_instruction->base.scope, switch_target_instruction->base.source_node, target_type); | |
| 16267 | Stage1AirInst *result = ir_const(ira, switch_target_instruction->base.scope, switch_target_instruction->base.source_node, target_type); | |
| 16268 | 16268 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_enum_tag); |
| 16269 | 16269 | return result; |
| 16270 | 16270 | } |
| 16271 | 16271 | |
| 16272 | IrInstGen *enum_value = ir_get_deref(ira, switch_target_instruction->base.scope, | |
| 16272 | Stage1AirInst *enum_value = ir_get_deref(ira, switch_target_instruction->base.scope, | |
| 16273 | 16273 | switch_target_instruction->base.source_node, target_value_ptr, nullptr); |
| 16274 | 16274 | enum_value->value->type = target_type; |
| 16275 | 16275 | return enum_value; |
| ... | ... | @@ -16293,8 +16293,8 @@ static IrInstGen *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 16293 | 16293 | zig_unreachable(); |
| 16294 | 16294 | } |
| 16295 | 16295 | |
| 16296 | static IrInstGen *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstSrcSwitchVar *instruction) { | |
| 16297 | IrInstGen *target_value_ptr = instruction->target_value_ptr->child; | |
| 16296 | static Stage1AirInst *ir_analyze_instruction_switch_var(IrAnalyze *ira, Stage1ZirInstSwitchVar *instruction) { | |
| 16297 | Stage1AirInst *target_value_ptr = instruction->target_value_ptr->child; | |
| 16298 | 16298 | if (type_is_invalid(target_value_ptr->value->type)) |
| 16299 | 16299 | return ira->codegen->invalid_inst_gen; |
| 16300 | 16300 | |
| ... | ... | @@ -16307,11 +16307,11 @@ static IrInstGen *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstSrcSwi |
| 16307 | 16307 | assert(enum_type->id == ZigTypeIdEnum); |
| 16308 | 16308 | assert(instruction->prongs_len > 0); |
| 16309 | 16309 | |
| 16310 | IrInstGen *first_prong_value = instruction->prongs_ptr[0]->child; | |
| 16310 | Stage1AirInst *first_prong_value = instruction->prongs_ptr[0]->child; | |
| 16311 | 16311 | if (type_is_invalid(first_prong_value->value->type)) |
| 16312 | 16312 | return ira->codegen->invalid_inst_gen; |
| 16313 | 16313 | |
| 16314 | IrInstGen *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type); | |
| 16314 | Stage1AirInst *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type); | |
| 16315 | 16315 | if (type_is_invalid(first_casted_prong_value->value->type)) |
| 16316 | 16316 | return ira->codegen->invalid_inst_gen; |
| 16317 | 16317 | |
| ... | ... | @@ -16323,11 +16323,11 @@ static IrInstGen *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstSrcSwi |
| 16323 | 16323 | |
| 16324 | 16324 | ErrorMsg *invalid_payload_msg = nullptr; |
| 16325 | 16325 | for (size_t prong_i = 1; prong_i < instruction->prongs_len; prong_i += 1) { |
| 16326 | IrInstGen *this_prong_inst = instruction->prongs_ptr[prong_i]->child; | |
| 16326 | Stage1AirInst *this_prong_inst = instruction->prongs_ptr[prong_i]->child; | |
| 16327 | 16327 | if (type_is_invalid(this_prong_inst->value->type)) |
| 16328 | 16328 | return ira->codegen->invalid_inst_gen; |
| 16329 | 16329 | |
| 16330 | IrInstGen *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type); | |
| 16330 | Stage1AirInst *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type); | |
| 16331 | 16331 | if (type_is_invalid(this_casted_prong_value->value->type)) |
| 16332 | 16332 | return ira->codegen->invalid_inst_gen; |
| 16333 | 16333 | |
| ... | ... | @@ -16362,7 +16362,7 @@ static IrInstGen *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstSrcSwi |
| 16362 | 16362 | if (pointee_val == nullptr) |
| 16363 | 16363 | return ira->codegen->invalid_inst_gen; |
| 16364 | 16364 | |
| 16365 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, | |
| 16365 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, | |
| 16366 | 16366 | get_pointer_to_type(ira->codegen, first_field->type_entry, |
| 16367 | 16367 | target_val_ptr->type->data.pointer.is_const)); |
| 16368 | 16368 | ZigValue *out_val = result->value; |
| ... | ... | @@ -16416,10 +16416,10 @@ static IrInstGen *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstSrcSwi |
| 16416 | 16416 | } |
| 16417 | 16417 | } |
| 16418 | 16418 | |
| 16419 | static IrInstGen *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | |
| 16420 | IrInstSrcSwitchElseVar *instruction) | |
| 16419 | static Stage1AirInst *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | |
| 16420 | Stage1ZirInstSwitchElseVar *instruction) | |
| 16421 | 16421 | { |
| 16422 | IrInstGen *target_value_ptr = instruction->target_value_ptr->child; | |
| 16422 | Stage1AirInst *target_value_ptr = instruction->target_value_ptr->child; | |
| 16423 | 16423 | if (type_is_invalid(target_value_ptr->value->type)) |
| 16424 | 16424 | return ira->codegen->invalid_inst_gen; |
| 16425 | 16425 | |
| ... | ... | @@ -16441,8 +16441,8 @@ static IrInstGen *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 16441 | 16441 | // We may not have any case in the switch if this is a lone else |
| 16442 | 16442 | const size_t switch_cases = instruction->switch_br ? instruction->switch_br->case_count : 0; |
| 16443 | 16443 | for (size_t case_i = 0; case_i < switch_cases; case_i += 1) { |
| 16444 | IrInstSrcSwitchBrCase *br_case = &instruction->switch_br->cases[case_i]; | |
| 16445 | IrInstGen *case_expr = br_case->value->child; | |
| 16444 | Stage1ZirInstSwitchBrCase *br_case = &instruction->switch_br->cases[case_i]; | |
| 16445 | Stage1AirInst *case_expr = br_case->value->child; | |
| 16446 | 16446 | if (case_expr->value->type->id == ZigTypeIdErrorSet) { |
| 16447 | 16447 | ErrorTableEntry *err = ir_resolve_error(ira, case_expr); |
| 16448 | 16448 | if (err == nullptr) |
| ... | ... | @@ -16498,10 +16498,10 @@ static IrInstGen *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 16498 | 16498 | return target_value_ptr; |
| 16499 | 16499 | } |
| 16500 | 16500 | |
| 16501 | static IrInstGen *ir_analyze_instruction_import(IrAnalyze *ira, IrInstSrcImport *import_instruction) { | |
| 16501 | static Stage1AirInst *ir_analyze_instruction_import(IrAnalyze *ira, Stage1ZirInstImport *import_instruction) { | |
| 16502 | 16502 | Error err; |
| 16503 | 16503 | |
| 16504 | IrInstGen *name_value = import_instruction->name->child; | |
| 16504 | Stage1AirInst *name_value = import_instruction->name->child; | |
| 16505 | 16505 | Buf *import_target_str = ir_resolve_str(ira, name_value); |
| 16506 | 16506 | if (!import_target_str) |
| 16507 | 16507 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -16534,8 +16534,8 @@ static IrInstGen *ir_analyze_instruction_import(IrAnalyze *ira, IrInstSrcImport |
| 16534 | 16534 | return ir_const_type(ira, import_instruction->base.scope, import_instruction->base.source_node, target_import); |
| 16535 | 16535 | } |
| 16536 | 16536 | |
| 16537 | static IrInstGen *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstSrcRef *ref_instruction) { | |
| 16538 | IrInstGen *value = ref_instruction->value->child; | |
| 16537 | static Stage1AirInst *ir_analyze_instruction_ref(IrAnalyze *ira, Stage1ZirInstRef *ref_instruction) { | |
| 16538 | Stage1AirInst *value = ref_instruction->value->child; | |
| 16539 | 16539 | if (type_is_invalid(value->value->type)) |
| 16540 | 16540 | return ira->codegen->invalid_inst_gen; |
| 16541 | 16541 | |
| ... | ... | @@ -16550,9 +16550,9 @@ static IrInstGen *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstSrcRef *ref_i |
| 16550 | 16550 | return ir_get_ref(ira, ref_instruction->base.scope, ref_instruction->base.source_node, value, is_const, is_volatile); |
| 16551 | 16551 | } |
| 16552 | 16552 | |
| 16553 | static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 16554 | AstNode *field_source_node, ZigType *union_type, Buf *field_name, IrInstGen *field_result_loc, | |
| 16555 | IrInstGen *result_loc) | |
| 16553 | static Stage1AirInst *ir_analyze_union_init(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 16554 | AstNode *field_source_node, ZigType *union_type, Buf *field_name, Stage1AirInst *field_result_loc, | |
| 16555 | Stage1AirInst *result_loc) | |
| 16556 | 16556 | { |
| 16557 | 16557 | Error err; |
| 16558 | 16558 | assert(union_type->id == ZigTypeIdUnion); |
| ... | ... | @@ -16584,7 +16584,7 @@ static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, Scope *scope, AstNode *s |
| 16584 | 16584 | bool is_comptime = ir_should_inline(ira->zir, scope) |
| 16585 | 16585 | || type_requires_comptime(ira->codegen, union_type) == ReqCompTimeYes; |
| 16586 | 16586 | |
| 16587 | IrInstGen *result = ir_get_deref(ira, scope, source_node, result_loc, nullptr); | |
| 16587 | Stage1AirInst *result = ir_get_deref(ira, scope, source_node, result_loc, nullptr); | |
| 16588 | 16588 | if (is_comptime && !instr_is_comptime(result)) { |
| 16589 | 16589 | ir_add_error(ira, field_result_loc, |
| 16590 | 16590 | buf_sprintf("unable to evaluate constant expression")); |
| ... | ... | @@ -16593,9 +16593,9 @@ static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, Scope *scope, AstNode *s |
| 16593 | 16593 | return result; |
| 16594 | 16594 | } |
| 16595 | 16595 | |
| 16596 | static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 16597 | ZigType *container_type, size_t instr_field_count, IrInstSrcContainerInitFieldsField *fields, | |
| 16598 | IrInstGen *result_loc) | |
| 16596 | static Stage1AirInst *ir_analyze_container_init_fields(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 16597 | ZigType *container_type, size_t instr_field_count, Stage1ZirInstContainerInitFieldsField *fields, | |
| 16598 | Stage1AirInst *result_loc) | |
| 16599 | 16599 | { |
| 16600 | 16600 | Error err; |
| 16601 | 16601 | if (container_type->id == ZigTypeIdUnion) { |
| ... | ... | @@ -16604,8 +16604,8 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, Scope *scope, |
| 16604 | 16604 | buf_sprintf("union initialization expects exactly one field")); |
| 16605 | 16605 | return ira->codegen->invalid_inst_gen; |
| 16606 | 16606 | } |
| 16607 | IrInstSrcContainerInitFieldsField *field = &fields[0]; | |
| 16608 | IrInstGen *field_result_loc = field->result_loc->child; | |
| 16607 | Stage1ZirInstContainerInitFieldsField *field = &fields[0]; | |
| 16608 | Stage1AirInst *field_result_loc = field->result_loc->child; | |
| 16609 | 16609 | if (type_is_invalid(field_result_loc->value->type)) |
| 16610 | 16610 | return ira->codegen->invalid_inst_gen; |
| 16611 | 16611 | |
| ... | ... | @@ -16629,10 +16629,10 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, Scope *scope, |
| 16629 | 16629 | |
| 16630 | 16630 | size_t actual_field_count = container_type->data.structure.src_field_count; |
| 16631 | 16631 | |
| 16632 | IrInstGen *first_non_const_instruction = nullptr; | |
| 16632 | Stage1AirInst *first_non_const_instruction = nullptr; | |
| 16633 | 16633 | |
| 16634 | 16634 | AstNode **field_assign_nodes = heap::c_allocator.allocate<AstNode *>(actual_field_count); |
| 16635 | ZigList<IrInstGen *> const_ptrs = {}; | |
| 16635 | ZigList<Stage1AirInst *> const_ptrs = {}; | |
| 16636 | 16636 | |
| 16637 | 16637 | bool is_comptime = ir_should_inline(ira->zir, scope) |
| 16638 | 16638 | || type_requires_comptime(ira->codegen, container_type) == ReqCompTimeYes; |
| ... | ... | @@ -16650,9 +16650,9 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, Scope *scope, |
| 16650 | 16650 | // comptime-known values. |
| 16651 | 16651 | |
| 16652 | 16652 | for (size_t i = 0; i < instr_field_count; i += 1) { |
| 16653 | IrInstSrcContainerInitFieldsField *field = &fields[i]; | |
| 16653 | Stage1ZirInstContainerInitFieldsField *field = &fields[i]; | |
| 16654 | 16654 | |
| 16655 | IrInstGen *field_result_loc = field->result_loc->child; | |
| 16655 | Stage1AirInst *field_result_loc = field->result_loc->child; | |
| 16656 | 16656 | if (type_is_invalid(field_result_loc->value->type)) |
| 16657 | 16657 | return ira->codegen->invalid_inst_gen; |
| 16658 | 16658 | |
| ... | ... | @@ -16701,10 +16701,10 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, Scope *scope, |
| 16701 | 16701 | if (type_is_invalid(field->init_val->type)) |
| 16702 | 16702 | return ira->codegen->invalid_inst_gen; |
| 16703 | 16703 | |
| 16704 | IrInstGen *runtime_inst = ir_const(ira, scope, source_node, field->init_val->type); | |
| 16704 | Stage1AirInst *runtime_inst = ir_const(ira, scope, source_node, field->init_val->type); | |
| 16705 | 16705 | copy_const_val(ira->codegen, runtime_inst->value, field->init_val); |
| 16706 | 16706 | |
| 16707 | IrInstGen *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, field, result_loc, | |
| 16707 | Stage1AirInst *field_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, field, result_loc, | |
| 16708 | 16708 | container_type, true); |
| 16709 | 16709 | ir_analyze_store_ptr(ira, scope, source_node, field_ptr, runtime_inst, false); |
| 16710 | 16710 | if (instr_is_comptime(field_ptr) && field_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| ... | ... | @@ -16721,8 +16721,8 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, Scope *scope, |
| 16721 | 16721 | if (const_ptrs.length != actual_field_count) { |
| 16722 | 16722 | result_loc->value->special = ConstValSpecialRuntime; |
| 16723 | 16723 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 16724 | IrInstGen *field_result_loc = const_ptrs.at(i); | |
| 16725 | IrInstGen *deref = ir_get_deref(ira, field_result_loc->scope, | |
| 16724 | Stage1AirInst *field_result_loc = const_ptrs.at(i); | |
| 16725 | Stage1AirInst *deref = ir_get_deref(ira, field_result_loc->scope, | |
| 16726 | 16726 | field_result_loc->source_node, field_result_loc, nullptr); |
| 16727 | 16727 | field_result_loc->value->special = ConstValSpecialRuntime; |
| 16728 | 16728 | ir_analyze_store_ptr(ira, field_result_loc->scope, field_result_loc->source_node, |
| ... | ... | @@ -16732,7 +16732,7 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, Scope *scope, |
| 16732 | 16732 | } |
| 16733 | 16733 | |
| 16734 | 16734 | const_ptrs.deinit(); |
| 16735 | IrInstGen *result = ir_get_deref(ira, scope, source_node, result_loc, nullptr); | |
| 16735 | Stage1AirInst *result = ir_get_deref(ira, scope, source_node, result_loc, nullptr); | |
| 16736 | 16736 | |
| 16737 | 16737 | if (is_comptime && !instr_is_comptime(result)) { |
| 16738 | 16738 | ir_add_error_node(ira, first_non_const_instruction->source_node, |
| ... | ... | @@ -16743,11 +16743,11 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, Scope *scope, |
| 16743 | 16743 | return result; |
| 16744 | 16744 | } |
| 16745 | 16745 | |
| 16746 | static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | |
| 16747 | IrInstSrcContainerInitList *instruction) | |
| 16746 | static Stage1AirInst *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | |
| 16747 | Stage1ZirInstContainerInitList *instruction) | |
| 16748 | 16748 | { |
| 16749 | 16749 | src_assert(instruction->result_loc != nullptr, instruction->base.source_node); |
| 16750 | IrInstGen *result_loc = instruction->result_loc->child; | |
| 16750 | Stage1AirInst *result_loc = instruction->result_loc->child; | |
| 16751 | 16751 | if (type_is_invalid(result_loc->value->type)) |
| 16752 | 16752 | return result_loc; |
| 16753 | 16753 | |
| ... | ... | @@ -16778,7 +16778,7 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16778 | 16778 | |
| 16779 | 16779 | if (container_type->id == ZigTypeIdStruct && elem_count == 0) { |
| 16780 | 16780 | src_assert(instruction->result_loc != nullptr, instruction->base.source_node); |
| 16781 | IrInstGen *result_loc = instruction->result_loc->child; | |
| 16781 | Stage1AirInst *result_loc = instruction->result_loc->child; | |
| 16782 | 16782 | if (type_is_invalid(result_loc->value->type)) |
| 16783 | 16783 | return result_loc; |
| 16784 | 16784 | return ir_analyze_container_init_fields(ira, instruction->base.scope, instruction->base.source_node, container_type, 0, nullptr, result_loc); |
| ... | ... | @@ -16830,7 +16830,7 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16830 | 16830 | break; |
| 16831 | 16831 | } |
| 16832 | 16832 | |
| 16833 | IrInstGen *first_non_const_instruction = nullptr; | |
| 16833 | Stage1AirInst *first_non_const_instruction = nullptr; | |
| 16834 | 16834 | |
| 16835 | 16835 | // The Result Location Mechanism has already emitted runtime instructions to |
| 16836 | 16836 | // initialize runtime elements and has omitted instructions for the comptime |
| ... | ... | @@ -16839,10 +16839,10 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16839 | 16839 | // array initialization can be a comptime value, overwrite ConstPtrMutInfer with |
| 16840 | 16840 | // ConstPtrMutComptimeConst. Otherwise, emit instructions to runtime-initialize the |
| 16841 | 16841 | // elements that have comptime-known values. |
| 16842 | ZigList<IrInstGen *> const_ptrs = {}; | |
| 16842 | ZigList<Stage1AirInst *> const_ptrs = {}; | |
| 16843 | 16843 | |
| 16844 | 16844 | for (size_t i = 0; i < elem_count; i += 1) { |
| 16845 | IrInstGen *elem_result_loc = instruction->elem_result_loc_list[i]->child; | |
| 16845 | Stage1AirInst *elem_result_loc = instruction->elem_result_loc_list[i]->child; | |
| 16846 | 16846 | if (type_is_invalid(elem_result_loc->value->type)) |
| 16847 | 16847 | return ira->codegen->invalid_inst_gen; |
| 16848 | 16848 | |
| ... | ... | @@ -16861,13 +16861,13 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16861 | 16861 | if (const_ptrs.length != elem_count) { |
| 16862 | 16862 | result_loc->value->special = ConstValSpecialRuntime; |
| 16863 | 16863 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 16864 | IrInstGen *elem_result_loc = const_ptrs.at(i); | |
| 16864 | Stage1AirInst *elem_result_loc = const_ptrs.at(i); | |
| 16865 | 16865 | assert(elem_result_loc->value->special == ConstValSpecialStatic); |
| 16866 | 16866 | if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { |
| 16867 | 16867 | // This field will be generated comptime; no need to do this. |
| 16868 | 16868 | continue; |
| 16869 | 16869 | } |
| 16870 | IrInstGen *deref = ir_get_deref(ira, elem_result_loc->scope, | |
| 16870 | Stage1AirInst *deref = ir_get_deref(ira, elem_result_loc->scope, | |
| 16871 | 16871 | elem_result_loc->source_node, elem_result_loc, nullptr); |
| 16872 | 16872 | elem_result_loc->value->special = ConstValSpecialRuntime; |
| 16873 | 16873 | ir_analyze_store_ptr(ira, elem_result_loc->scope, elem_result_loc->source_node, |
| ... | ... | @@ -16878,7 +16878,7 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16878 | 16878 | |
| 16879 | 16879 | const_ptrs.deinit(); |
| 16880 | 16880 | |
| 16881 | IrInstGen *result = ir_get_deref(ira, instruction->base.scope, instruction->base.source_node, | |
| 16881 | Stage1AirInst *result = ir_get_deref(ira, instruction->base.scope, instruction->base.source_node, | |
| 16882 | 16882 | result_loc, nullptr); |
| 16883 | 16883 | // If the result is a tuple, we are allowed to return a struct that uses ConstValSpecialRuntime fields at comptime. |
| 16884 | 16884 | if (instr_is_comptime(result) || is_tuple(container_type)) |
| ... | ... | @@ -16902,11 +16902,11 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16902 | 16902 | return result; |
| 16903 | 16903 | } |
| 16904 | 16904 | |
| 16905 | static IrInstGen *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, | |
| 16906 | IrInstSrcContainerInitFields *instruction) | |
| 16905 | static Stage1AirInst *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, | |
| 16906 | Stage1ZirInstContainerInitFields *instruction) | |
| 16907 | 16907 | { |
| 16908 | 16908 | src_assert(instruction->result_loc != nullptr, instruction->base.source_node); |
| 16909 | IrInstGen *result_loc = instruction->result_loc->child; | |
| 16909 | Stage1AirInst *result_loc = instruction->result_loc->child; | |
| 16910 | 16910 | if (type_is_invalid(result_loc->value->type)) |
| 16911 | 16911 | return result_loc; |
| 16912 | 16912 | |
| ... | ... | @@ -16922,8 +16922,8 @@ static IrInstGen *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, |
| 16922 | 16922 | instruction->field_count, instruction->fields, result_loc); |
| 16923 | 16923 | } |
| 16924 | 16924 | |
| 16925 | static IrInstGen *ir_analyze_instruction_compile_err(IrAnalyze *ira, IrInstSrcCompileErr *instruction) { | |
| 16926 | IrInstGen *msg_value = instruction->msg->child; | |
| 16925 | static Stage1AirInst *ir_analyze_instruction_compile_err(IrAnalyze *ira, Stage1ZirInstCompileErr *instruction) { | |
| 16926 | Stage1AirInst *msg_value = instruction->msg->child; | |
| 16927 | 16927 | Buf *msg_buf = ir_resolve_str(ira, msg_value); |
| 16928 | 16928 | if (!msg_buf) |
| 16929 | 16929 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -16933,11 +16933,11 @@ static IrInstGen *ir_analyze_instruction_compile_err(IrAnalyze *ira, IrInstSrcCo |
| 16933 | 16933 | return ira->codegen->invalid_inst_gen; |
| 16934 | 16934 | } |
| 16935 | 16935 | |
| 16936 | static IrInstGen *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstSrcCompileLog *instruction) { | |
| 16936 | static Stage1AirInst *ir_analyze_instruction_compile_log(IrAnalyze *ira, Stage1ZirInstCompileLog *instruction) { | |
| 16937 | 16937 | Buf buf = BUF_INIT; |
| 16938 | 16938 | fprintf(stderr, "| "); |
| 16939 | 16939 | for (size_t i = 0; i < instruction->msg_count; i += 1) { |
| 16940 | IrInstGen *msg = instruction->msg_list[i]->child; | |
| 16940 | Stage1AirInst *msg = instruction->msg_list[i]->child; | |
| 16941 | 16941 | if (type_is_invalid(msg->value->type)) |
| 16942 | 16942 | return ira->codegen->invalid_inst_gen; |
| 16943 | 16943 | buf_resize(&buf, 0); |
| ... | ... | @@ -16963,12 +16963,12 @@ static IrInstGen *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstSrcCo |
| 16963 | 16963 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 16964 | 16964 | } |
| 16965 | 16965 | |
| 16966 | static IrInstGen *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstSrcErrName *instruction) { | |
| 16967 | IrInstGen *value = instruction->value->child; | |
| 16966 | static Stage1AirInst *ir_analyze_instruction_err_name(IrAnalyze *ira, Stage1ZirInstErrName *instruction) { | |
| 16967 | Stage1AirInst *value = instruction->value->child; | |
| 16968 | 16968 | if (type_is_invalid(value->value->type)) |
| 16969 | 16969 | return ira->codegen->invalid_inst_gen; |
| 16970 | 16970 | |
| 16971 | IrInstGen *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set); | |
| 16971 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set); | |
| 16972 | 16972 | if (type_is_invalid(casted_value->value->type)) |
| 16973 | 16973 | return ira->codegen->invalid_inst_gen; |
| 16974 | 16974 | |
| ... | ... | @@ -16982,7 +16982,7 @@ static IrInstGen *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstSrcErrNa |
| 16982 | 16982 | ira->codegen, &err->name, |
| 16983 | 16983 | ira->codegen->intern.for_zero_byte()); |
| 16984 | 16984 | } |
| 16985 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 16985 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 16986 | 16986 | result->value = err->cached_error_name_val; |
| 16987 | 16987 | return result; |
| 16988 | 16988 | } |
| ... | ... | @@ -16996,16 +16996,16 @@ static IrInstGen *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstSrcErrNa |
| 16996 | 16996 | return ir_build_err_name_gen(ira, instruction->base.scope, instruction->base.source_node, value, str_type); |
| 16997 | 16997 | } |
| 16998 | 16998 | |
| 16999 | static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrcTagName *instruction) { | |
| 16999 | static Stage1AirInst *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, Stage1ZirInstTagName *instruction) { | |
| 17000 | 17000 | Error err; |
| 17001 | IrInstGen *target = instruction->target->child; | |
| 17001 | Stage1AirInst *target = instruction->target->child; | |
| 17002 | 17002 | if (type_is_invalid(target->value->type)) |
| 17003 | 17003 | return ira->codegen->invalid_inst_gen; |
| 17004 | 17004 | |
| 17005 | 17005 | ZigType *target_type = target->value->type; |
| 17006 | 17006 | |
| 17007 | 17007 | if (target_type->id == ZigTypeIdEnumLiteral) { |
| 17008 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 17008 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 17009 | 17009 | Buf *field_name = target->value->data.x_enum_literal; |
| 17010 | 17010 | result->value = create_sentineled_str_lit( |
| 17011 | 17011 | ira->codegen, field_name, |
| ... | ... | @@ -17028,7 +17028,7 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc |
| 17028 | 17028 | |
| 17029 | 17029 | if (can_fold_enum_type(target_type)) { |
| 17030 | 17030 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; |
| 17031 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 17031 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 17032 | 17032 | result->value = create_sentineled_str_lit( |
| 17033 | 17033 | ira->codegen, only_field->name, |
| 17034 | 17034 | ira->codegen->intern.for_zero_byte()); |
| ... | ... | @@ -17047,7 +17047,7 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc |
| 17047 | 17047 | buf_sprintf("no tag by value %s", buf_ptr(int_buf))); |
| 17048 | 17048 | return ira->codegen->invalid_inst_gen; |
| 17049 | 17049 | } |
| 17050 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 17050 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 17051 | 17051 | result->value = create_sentineled_str_lit( |
| 17052 | 17052 | ira->codegen, field->name, |
| 17053 | 17053 | ira->codegen->intern.for_zero_byte()); |
| ... | ... | @@ -17062,21 +17062,21 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc |
| 17062 | 17062 | return ir_build_tag_name_gen(ira, instruction->base.scope, instruction->base.source_node, target, result_type); |
| 17063 | 17063 | } |
| 17064 | 17064 | |
| 17065 | static IrInstGen *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | |
| 17066 | IrInstSrcFieldParentPtr *instruction) | |
| 17065 | static Stage1AirInst *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | |
| 17066 | Stage1ZirInstFieldParentPtr *instruction) | |
| 17067 | 17067 | { |
| 17068 | 17068 | Error err; |
| 17069 | IrInstGen *type_value = instruction->type_value->child; | |
| 17069 | Stage1AirInst *type_value = instruction->type_value->child; | |
| 17070 | 17070 | ZigType *container_type = ir_resolve_type(ira, type_value); |
| 17071 | 17071 | if (type_is_invalid(container_type)) |
| 17072 | 17072 | return ira->codegen->invalid_inst_gen; |
| 17073 | 17073 | |
| 17074 | IrInstGen *field_name_value = instruction->field_name->child; | |
| 17074 | Stage1AirInst *field_name_value = instruction->field_name->child; | |
| 17075 | 17075 | Buf *field_name = ir_resolve_str(ira, field_name_value); |
| 17076 | 17076 | if (!field_name) |
| 17077 | 17077 | return ira->codegen->invalid_inst_gen; |
| 17078 | 17078 | |
| 17079 | IrInstGen *field_ptr = instruction->field_ptr->child; | |
| 17079 | Stage1AirInst *field_ptr = instruction->field_ptr->child; | |
| 17080 | 17080 | if (type_is_invalid(field_ptr->value->type)) |
| 17081 | 17081 | return ira->codegen->invalid_inst_gen; |
| 17082 | 17082 | |
| ... | ... | @@ -17112,7 +17112,7 @@ static IrInstGen *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 17112 | 17112 | field_ptr->value->type->data.pointer.is_volatile, |
| 17113 | 17113 | PtrLenSingle, |
| 17114 | 17114 | field_ptr_align, 0, 0, false); |
| 17115 | IrInstGen *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type); | |
| 17115 | Stage1AirInst *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type); | |
| 17116 | 17116 | if (type_is_invalid(casted_field_ptr->value->type)) |
| 17117 | 17117 | return ira->codegen->invalid_inst_gen; |
| 17118 | 17118 | |
| ... | ... | @@ -17141,7 +17141,7 @@ static IrInstGen *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 17141 | 17141 | return ira->codegen->invalid_inst_gen; |
| 17142 | 17142 | } |
| 17143 | 17143 | |
| 17144 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, result_type); | |
| 17144 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, result_type); | |
| 17145 | 17145 | ZigValue *out_val = result->value; |
| 17146 | 17146 | out_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 17147 | 17147 | out_val->data.x_ptr.data.ref.pointee = field_ptr_val->data.x_ptr.data.base_struct.struct_val; |
| ... | ... | @@ -17153,8 +17153,8 @@ static IrInstGen *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 17153 | 17153 | } |
| 17154 | 17154 | |
| 17155 | 17155 | static TypeStructField *validate_host_int_byte_offset(IrAnalyze *ira, |
| 17156 | IrInstGen *type_value, | |
| 17157 | IrInstGen *field_name_value, | |
| 17156 | Stage1AirInst *type_value, | |
| 17157 | Stage1AirInst *field_name_value, | |
| 17158 | 17158 | size_t *byte_offset) |
| 17159 | 17159 | { |
| 17160 | 17160 | ZigType *container_type = ir_resolve_type(ira, type_value); |
| ... | ... | @@ -17194,12 +17194,12 @@ static TypeStructField *validate_host_int_byte_offset(IrAnalyze *ira, |
| 17194 | 17194 | return field; |
| 17195 | 17195 | } |
| 17196 | 17196 | |
| 17197 | static IrInstGen *ir_analyze_instruction_offset_of(IrAnalyze *ira, IrInstSrcOffsetOf *instruction) { | |
| 17198 | IrInstGen *type_value = instruction->type_value->child; | |
| 17197 | static Stage1AirInst *ir_analyze_instruction_offset_of(IrAnalyze *ira, Stage1ZirInstOffsetOf *instruction) { | |
| 17198 | Stage1AirInst *type_value = instruction->type_value->child; | |
| 17199 | 17199 | if (type_is_invalid(type_value->value->type)) |
| 17200 | 17200 | return ira->codegen->invalid_inst_gen; |
| 17201 | 17201 | |
| 17202 | IrInstGen *field_name_value = instruction->field_name->child; | |
| 17202 | Stage1AirInst *field_name_value = instruction->field_name->child; | |
| 17203 | 17203 | size_t host_int_byte_offset = 0; |
| 17204 | 17204 | TypeStructField *field = nullptr; |
| 17205 | 17205 | if (!(field = validate_host_int_byte_offset(ira, type_value, field_name_value, &host_int_byte_offset))) |
| ... | ... | @@ -17209,11 +17209,11 @@ static IrInstGen *ir_analyze_instruction_offset_of(IrAnalyze *ira, IrInstSrcOffs |
| 17209 | 17209 | return ir_const_unsigned(ira, instruction->base.scope, instruction->base.source_node, byte_offset); |
| 17210 | 17210 | } |
| 17211 | 17211 | |
| 17212 | static IrInstGen *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira, IrInstSrcBitOffsetOf *instruction) { | |
| 17213 | IrInstGen *type_value = instruction->type_value->child; | |
| 17212 | static Stage1AirInst *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira, Stage1ZirInstBitOffsetOf *instruction) { | |
| 17213 | Stage1AirInst *type_value = instruction->type_value->child; | |
| 17214 | 17214 | if (type_is_invalid(type_value->value->type)) |
| 17215 | 17215 | return ira->codegen->invalid_inst_gen; |
| 17216 | IrInstGen *field_name_value = instruction->field_name->child; | |
| 17216 | Stage1AirInst *field_name_value = instruction->field_name->child; | |
| 17217 | 17217 | size_t host_int_byte_offset = 0; |
| 17218 | 17218 | TypeStructField *field = nullptr; |
| 17219 | 17219 | if (!(field = validate_host_int_byte_offset(ira, type_value, field_name_value, &host_int_byte_offset))) |
| ... | ... | @@ -18275,9 +18275,9 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 18275 | 18275 | return ErrorNone; |
| 18276 | 18276 | } |
| 18277 | 18277 | |
| 18278 | static IrInstGen *ir_analyze_instruction_type_info(IrAnalyze *ira, IrInstSrcTypeInfo *instruction) { | |
| 18278 | static Stage1AirInst *ir_analyze_instruction_type_info(IrAnalyze *ira, Stage1ZirInstTypeInfo *instruction) { | |
| 18279 | 18279 | Error err; |
| 18280 | IrInstGen *type_value = instruction->type_value->child; | |
| 18280 | Stage1AirInst *type_value = instruction->type_value->child; | |
| 18281 | 18281 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 18282 | 18282 | if (type_is_invalid(type_entry)) |
| 18283 | 18283 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -18288,7 +18288,7 @@ static IrInstGen *ir_analyze_instruction_type_info(IrAnalyze *ira, IrInstSrcType |
| 18288 | 18288 | if ((err = ir_make_type_info_value(ira, instruction->base.scope, instruction->base.source_node, type_entry, &payload))) |
| 18289 | 18289 | return ira->codegen->invalid_inst_gen; |
| 18290 | 18290 | |
| 18291 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, result_type); | |
| 18291 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, result_type); | |
| 18292 | 18292 | ZigValue *out_val = result->value; |
| 18293 | 18293 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry)); |
| 18294 | 18294 | out_val->data.x_union.payload = payload; |
| ... | ... | @@ -18321,8 +18321,8 @@ static Error get_const_field_sentinel(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 18321 | 18321 | if (field_val == nullptr) |
| 18322 | 18322 | return ErrorSemanticAnalyzeFail; |
| 18323 | 18323 | |
| 18324 | IrInstGen *field_inst = ir_const_move(ira, scope, source_node, field_val); | |
| 18325 | IrInstGen *casted_field_inst = ir_implicit_cast(ira, field_inst, | |
| 18324 | Stage1AirInst *field_inst = ir_const_move(ira, scope, source_node, field_val); | |
| 18325 | Stage1AirInst *casted_field_inst = ir_implicit_cast(ira, field_inst, | |
| 18326 | 18326 | get_optional_type(ira->codegen, elem_type)); |
| 18327 | 18327 | if (type_is_invalid(casted_field_inst->value->type)) |
| 18328 | 18328 | return ErrorSemanticAnalyzeFail; |
| ... | ... | @@ -19065,12 +19065,12 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 19065 | 19065 | zig_unreachable(); |
| 19066 | 19066 | } |
| 19067 | 19067 | |
| 19068 | static IrInstGen *ir_analyze_instruction_type(IrAnalyze *ira, IrInstSrcType *instruction) { | |
| 19069 | IrInstGen *uncasted_type_info = instruction->type_info->child; | |
| 19068 | static Stage1AirInst *ir_analyze_instruction_type(IrAnalyze *ira, Stage1ZirInstType *instruction) { | |
| 19069 | Stage1AirInst *uncasted_type_info = instruction->type_info->child; | |
| 19070 | 19070 | if (type_is_invalid(uncasted_type_info->value->type)) |
| 19071 | 19071 | return ira->codegen->invalid_inst_gen; |
| 19072 | 19072 | |
| 19073 | IrInstGen *type_info = ir_implicit_cast(ira, uncasted_type_info, ir_type_info_get_type(ira, nullptr, nullptr)); | |
| 19073 | Stage1AirInst *type_info = ir_implicit_cast(ira, uncasted_type_info, ir_type_info_get_type(ira, nullptr, nullptr)); | |
| 19074 | 19074 | if (type_is_invalid(type_info->value->type)) |
| 19075 | 19075 | return ira->codegen->invalid_inst_gen; |
| 19076 | 19076 | |
| ... | ... | @@ -19085,8 +19085,8 @@ static IrInstGen *ir_analyze_instruction_type(IrAnalyze *ira, IrInstSrcType *ins |
| 19085 | 19085 | return ir_const_type(ira, instruction->base.scope, instruction->base.source_node, type); |
| 19086 | 19086 | } |
| 19087 | 19087 | |
| 19088 | static IrInstGen *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira, | |
| 19089 | IrInstSrcSetEvalBranchQuota *instruction) | |
| 19088 | static Stage1AirInst *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira, | |
| 19089 | Stage1ZirInstSetEvalBranchQuota *instruction) | |
| 19090 | 19090 | { |
| 19091 | 19091 | uint64_t new_quota; |
| 19092 | 19092 | if (!ir_resolve_unsigned(ira, instruction->new_quota->child, ira->codegen->builtin_types.entry_u32, &new_quota)) |
| ... | ... | @@ -19099,8 +19099,8 @@ static IrInstGen *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira, |
| 19099 | 19099 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 19100 | 19100 | } |
| 19101 | 19101 | |
| 19102 | static IrInstGen *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstSrcTypeName *instruction) { | |
| 19103 | IrInstGen *type_value = instruction->type_value->child; | |
| 19102 | static Stage1AirInst *ir_analyze_instruction_type_name(IrAnalyze *ira, Stage1ZirInstTypeName *instruction) { | |
| 19103 | Stage1AirInst *type_value = instruction->type_value->child; | |
| 19104 | 19104 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 19105 | 19105 | if (type_is_invalid(type_entry)) |
| 19106 | 19106 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -19108,12 +19108,12 @@ static IrInstGen *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstSrcType |
| 19108 | 19108 | if (!type_entry->cached_const_name_val) { |
| 19109 | 19109 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, type_bare_name(type_entry)); |
| 19110 | 19110 | } |
| 19111 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 19111 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 19112 | 19112 | copy_const_val(ira->codegen, result->value, type_entry->cached_const_name_val); |
| 19113 | 19113 | return result; |
| 19114 | 19114 | } |
| 19115 | 19115 | |
| 19116 | static IrInstGen *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstSrcCImport *instruction) { | |
| 19116 | static Stage1AirInst *ir_analyze_instruction_c_import(IrAnalyze *ira, Stage1ZirInstCImport *instruction) { | |
| 19117 | 19117 | Error err; |
| 19118 | 19118 | AstNode *node = instruction->base.source_node; |
| 19119 | 19119 | assert(node->type == NodeTypeFnCallExpr); |
| ... | ... | @@ -19195,8 +19195,8 @@ static IrInstGen *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstSrcCImpo |
| 19195 | 19195 | return ir_const_type(ira, instruction->base.scope, instruction->base.source_node, child_import); |
| 19196 | 19196 | } |
| 19197 | 19197 | |
| 19198 | static IrInstGen *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstSrcCInclude *instruction) { | |
| 19199 | IrInstGen *name_value = instruction->name->child; | |
| 19198 | static Stage1AirInst *ir_analyze_instruction_c_include(IrAnalyze *ira, Stage1ZirInstCInclude *instruction) { | |
| 19199 | Stage1AirInst *name_value = instruction->name->child; | |
| 19200 | 19200 | if (type_is_invalid(name_value->value->type)) |
| 19201 | 19201 | return ira->codegen->invalid_inst_gen; |
| 19202 | 19202 | |
| ... | ... | @@ -19213,8 +19213,8 @@ static IrInstGen *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstSrcCInc |
| 19213 | 19213 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 19214 | 19214 | } |
| 19215 | 19215 | |
| 19216 | static IrInstGen *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstSrcCDefine *instruction) { | |
| 19217 | IrInstGen *name = instruction->name->child; | |
| 19216 | static Stage1AirInst *ir_analyze_instruction_c_define(IrAnalyze *ira, Stage1ZirInstCDefine *instruction) { | |
| 19217 | Stage1AirInst *name = instruction->name->child; | |
| 19218 | 19218 | if (type_is_invalid(name->value->type)) |
| 19219 | 19219 | return ira->codegen->invalid_inst_gen; |
| 19220 | 19220 | |
| ... | ... | @@ -19222,7 +19222,7 @@ static IrInstGen *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstSrcCDefi |
| 19222 | 19222 | if (!define_name) |
| 19223 | 19223 | return ira->codegen->invalid_inst_gen; |
| 19224 | 19224 | |
| 19225 | IrInstGen *value = instruction->value->child; | |
| 19225 | Stage1AirInst *value = instruction->value->child; | |
| 19226 | 19226 | if (type_is_invalid(value->value->type)) |
| 19227 | 19227 | return ira->codegen->invalid_inst_gen; |
| 19228 | 19228 | |
| ... | ... | @@ -19244,8 +19244,8 @@ static IrInstGen *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstSrcCDefi |
| 19244 | 19244 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 19245 | 19245 | } |
| 19246 | 19246 | |
| 19247 | static IrInstGen *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstSrcCUndef *instruction) { | |
| 19248 | IrInstGen *name = instruction->name->child; | |
| 19247 | static Stage1AirInst *ir_analyze_instruction_c_undef(IrAnalyze *ira, Stage1ZirInstCUndef *instruction) { | |
| 19248 | Stage1AirInst *name = instruction->name->child; | |
| 19249 | 19249 | if (type_is_invalid(name->value->type)) |
| 19250 | 19250 | return ira->codegen->invalid_inst_gen; |
| 19251 | 19251 | |
| ... | ... | @@ -19262,8 +19262,8 @@ static IrInstGen *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstSrcCUndef |
| 19262 | 19262 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 19263 | 19263 | } |
| 19264 | 19264 | |
| 19265 | static IrInstGen *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstSrcEmbedFile *instruction) { | |
| 19266 | IrInstGen *name = instruction->name->child; | |
| 19265 | static Stage1AirInst *ir_analyze_instruction_embed_file(IrAnalyze *ira, Stage1ZirInstEmbedFile *instruction) { | |
| 19266 | Stage1AirInst *name = instruction->name->child; | |
| 19267 | 19267 | if (type_is_invalid(name->value->type)) |
| 19268 | 19268 | return ira->codegen->invalid_inst_gen; |
| 19269 | 19269 | |
| ... | ... | @@ -19298,12 +19298,12 @@ static IrInstGen *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstSrcEmb |
| 19298 | 19298 | } |
| 19299 | 19299 | } |
| 19300 | 19300 | |
| 19301 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 19301 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, nullptr); | |
| 19302 | 19302 | init_const_str_lit(ira->codegen, result->value, file_contents, true); |
| 19303 | 19303 | return result; |
| 19304 | 19304 | } |
| 19305 | 19305 | |
| 19306 | static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxchg *instruction) { | |
| 19306 | static Stage1AirInst *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, Stage1ZirInstCmpxchg *instruction) { | |
| 19307 | 19307 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->type_value->child); |
| 19308 | 19308 | if (type_is_invalid(operand_type)) |
| 19309 | 19309 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -19314,26 +19314,26 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch |
| 19314 | 19314 | return ira->codegen->invalid_inst_gen; |
| 19315 | 19315 | } |
| 19316 | 19316 | |
| 19317 | IrInstGen *ptr = instruction->ptr->child; | |
| 19317 | Stage1AirInst *ptr = instruction->ptr->child; | |
| 19318 | 19318 | if (type_is_invalid(ptr->value->type)) |
| 19319 | 19319 | return ira->codegen->invalid_inst_gen; |
| 19320 | 19320 | |
| 19321 | 19321 | // TODO let this be volatile |
| 19322 | 19322 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 19323 | IrInstGen *casted_ptr = ir_implicit_cast2(ira, instruction->ptr->scope, | |
| 19323 | Stage1AirInst *casted_ptr = ir_implicit_cast2(ira, instruction->ptr->scope, | |
| 19324 | 19324 | instruction->ptr->source_node, ptr, ptr_type); |
| 19325 | 19325 | if (type_is_invalid(casted_ptr->value->type)) |
| 19326 | 19326 | return ira->codegen->invalid_inst_gen; |
| 19327 | 19327 | |
| 19328 | IrInstGen *cmp_value = instruction->cmp_value->child; | |
| 19328 | Stage1AirInst *cmp_value = instruction->cmp_value->child; | |
| 19329 | 19329 | if (type_is_invalid(cmp_value->value->type)) |
| 19330 | 19330 | return ira->codegen->invalid_inst_gen; |
| 19331 | 19331 | |
| 19332 | IrInstGen *new_value = instruction->new_value->child; | |
| 19332 | Stage1AirInst *new_value = instruction->new_value->child; | |
| 19333 | 19333 | if (type_is_invalid(new_value->value->type)) |
| 19334 | 19334 | return ira->codegen->invalid_inst_gen; |
| 19335 | 19335 | |
| 19336 | IrInstGen *success_order_value = instruction->success_order_value->child; | |
| 19336 | Stage1AirInst *success_order_value = instruction->success_order_value->child; | |
| 19337 | 19337 | if (type_is_invalid(success_order_value->value->type)) |
| 19338 | 19338 | return ira->codegen->invalid_inst_gen; |
| 19339 | 19339 | |
| ... | ... | @@ -19341,7 +19341,7 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch |
| 19341 | 19341 | if (!ir_resolve_atomic_order(ira, success_order_value, &success_order)) |
| 19342 | 19342 | return ira->codegen->invalid_inst_gen; |
| 19343 | 19343 | |
| 19344 | IrInstGen *failure_order_value = instruction->failure_order_value->child; | |
| 19344 | Stage1AirInst *failure_order_value = instruction->failure_order_value->child; | |
| 19345 | 19345 | if (type_is_invalid(failure_order_value->value->type)) |
| 19346 | 19346 | return ira->codegen->invalid_inst_gen; |
| 19347 | 19347 | |
| ... | ... | @@ -19349,12 +19349,12 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch |
| 19349 | 19349 | if (!ir_resolve_atomic_order(ira, failure_order_value, &failure_order)) |
| 19350 | 19350 | return ira->codegen->invalid_inst_gen; |
| 19351 | 19351 | |
| 19352 | IrInstGen *casted_cmp_value = ir_implicit_cast2(ira, instruction->cmp_value->scope, | |
| 19352 | Stage1AirInst *casted_cmp_value = ir_implicit_cast2(ira, instruction->cmp_value->scope, | |
| 19353 | 19353 | instruction->cmp_value->source_node, cmp_value, operand_type); |
| 19354 | 19354 | if (type_is_invalid(casted_cmp_value->value->type)) |
| 19355 | 19355 | return ira->codegen->invalid_inst_gen; |
| 19356 | 19356 | |
| 19357 | IrInstGen *casted_new_value = ir_implicit_cast2(ira, instruction->new_value->scope, | |
| 19357 | Stage1AirInst *casted_new_value = ir_implicit_cast2(ira, instruction->new_value->scope, | |
| 19358 | 19358 | instruction->new_value->source_node, new_value, operand_type); |
| 19359 | 19359 | if (type_is_invalid(casted_new_value->value->type)) |
| 19360 | 19360 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -19387,7 +19387,7 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch |
| 19387 | 19387 | case OnePossibleValueInvalid: |
| 19388 | 19388 | return ira->codegen->invalid_inst_gen; |
| 19389 | 19389 | case OnePossibleValueYes: { |
| 19390 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, result_type); | |
| 19390 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, result_type); | |
| 19391 | 19391 | set_optional_value_to_null(result->value); |
| 19392 | 19392 | return result; |
| 19393 | 19393 | } |
| ... | ... | @@ -19414,7 +19414,7 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch |
| 19414 | 19414 | return ira->codegen->invalid_inst_gen; |
| 19415 | 19415 | |
| 19416 | 19416 | bool eql = const_values_equal(ira->codegen, stored_val, expected_val); |
| 19417 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, result_type); | |
| 19417 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, result_type); | |
| 19418 | 19418 | if (eql) { |
| 19419 | 19419 | copy_const_val(ira->codegen, stored_val, new_val); |
| 19420 | 19420 | set_optional_value_to_null(result->value); |
| ... | ... | @@ -19424,7 +19424,7 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch |
| 19424 | 19424 | return result; |
| 19425 | 19425 | } |
| 19426 | 19426 | |
| 19427 | IrInstGen *result_loc; | |
| 19427 | Stage1AirInst *result_loc; | |
| 19428 | 19428 | if (handle_is_ptr(ira->codegen, result_type)) { |
| 19429 | 19429 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 19430 | 19430 | result_type, nullptr, true, true); |
| ... | ... | @@ -19568,12 +19568,12 @@ static ErrorMsg *ir_eval_reduce(IrAnalyze *ira, Scope *scope, AstNode *source_no |
| 19568 | 19568 | return nullptr; |
| 19569 | 19569 | } |
| 19570 | 19570 | |
| 19571 | static IrInstGen *ir_analyze_instruction_reduce(IrAnalyze *ira, IrInstSrcReduce *instruction) { | |
| 19572 | IrInstGen *op_inst = instruction->op->child; | |
| 19571 | static Stage1AirInst *ir_analyze_instruction_reduce(IrAnalyze *ira, Stage1ZirInstReduce *instruction) { | |
| 19572 | Stage1AirInst *op_inst = instruction->op->child; | |
| 19573 | 19573 | if (type_is_invalid(op_inst->value->type)) |
| 19574 | 19574 | return ira->codegen->invalid_inst_gen; |
| 19575 | 19575 | |
| 19576 | IrInstGen *value_inst = instruction->value->child; | |
| 19576 | Stage1AirInst *value_inst = instruction->value->child; | |
| 19577 | 19577 | if (type_is_invalid(value_inst->value->type)) |
| 19578 | 19578 | return ira->codegen->invalid_inst_gen; |
| 19579 | 19579 | |
| ... | ... | @@ -19624,7 +19624,7 @@ static IrInstGen *ir_analyze_instruction_reduce(IrAnalyze *ira, IrInstSrcReduce |
| 19624 | 19624 | } |
| 19625 | 19625 | |
| 19626 | 19626 | if (instr_is_comptime(value_inst)) { |
| 19627 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, elem_type); | |
| 19627 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, elem_type); | |
| 19628 | 19628 | if (ir_eval_reduce(ira, instruction->base.scope, instruction->base.source_node, op, value_inst->value, result->value)) |
| 19629 | 19629 | return ira->codegen->invalid_inst_gen; |
| 19630 | 19630 | return result; |
| ... | ... | @@ -19633,8 +19633,8 @@ static IrInstGen *ir_analyze_instruction_reduce(IrAnalyze *ira, IrInstSrcReduce |
| 19633 | 19633 | return ir_build_reduce_gen(ira, instruction->base.scope, instruction->base.source_node, op, value_inst, elem_type); |
| 19634 | 19634 | } |
| 19635 | 19635 | |
| 19636 | static IrInstGen *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstSrcFence *instruction) { | |
| 19637 | IrInstGen *order_inst = instruction->order->child; | |
| 19636 | static Stage1AirInst *ir_analyze_instruction_fence(IrAnalyze *ira, Stage1ZirInstFence *instruction) { | |
| 19637 | Stage1AirInst *order_inst = instruction->order->child; | |
| 19638 | 19638 | if (type_is_invalid(order_inst->value->type)) |
| 19639 | 19639 | return ira->codegen->invalid_inst_gen; |
| 19640 | 19640 | |
| ... | ... | @@ -19651,8 +19651,8 @@ static IrInstGen *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstSrcFence *i |
| 19651 | 19651 | return ir_build_fence_gen(ira, instruction->base.scope, instruction->base.source_node, order); |
| 19652 | 19652 | } |
| 19653 | 19653 | |
| 19654 | static IrInstGen *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstSrcTruncate *instruction) { | |
| 19655 | IrInstGen *dest_type_value = instruction->dest_type->child; | |
| 19654 | static Stage1AirInst *ir_analyze_instruction_truncate(IrAnalyze *ira, Stage1ZirInstTruncate *instruction) { | |
| 19655 | Stage1AirInst *dest_type_value = instruction->dest_type->child; | |
| 19656 | 19656 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 19657 | 19657 | if (type_is_invalid(dest_type)) |
| 19658 | 19658 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -19664,7 +19664,7 @@ static IrInstGen *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstSrcTrunc |
| 19664 | 19664 | return ira->codegen->invalid_inst_gen; |
| 19665 | 19665 | } |
| 19666 | 19666 | |
| 19667 | IrInstGen *target = instruction->target->child; | |
| 19667 | Stage1AirInst *target = instruction->target->child; | |
| 19668 | 19668 | ZigType *src_type = target->value->type; |
| 19669 | 19669 | if (type_is_invalid(src_type)) |
| 19670 | 19670 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -19697,14 +19697,14 @@ static IrInstGen *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstSrcTrunc |
| 19697 | 19697 | if (val == nullptr) |
| 19698 | 19698 | return ira->codegen->invalid_inst_gen; |
| 19699 | 19699 | |
| 19700 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, dest_type); | |
| 19700 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, dest_type); | |
| 19701 | 19701 | bigint_truncate(&result->value->data.x_bigint, &val->data.x_bigint, |
| 19702 | 19702 | dest_type->data.integral.bit_count, dest_type->data.integral.is_signed); |
| 19703 | 19703 | return result; |
| 19704 | 19704 | } |
| 19705 | 19705 | |
| 19706 | 19706 | if (src_type->data.integral.bit_count == 0 || dest_type->data.integral.bit_count == 0) { |
| 19707 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, dest_type); | |
| 19707 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, dest_type); | |
| 19708 | 19708 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 19709 | 19709 | return result; |
| 19710 | 19710 | } |
| ... | ... | @@ -19712,7 +19712,7 @@ static IrInstGen *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstSrcTrunc |
| 19712 | 19712 | return ir_build_truncate_gen(ira, instruction->base.scope, instruction->base.source_node, dest_type, target); |
| 19713 | 19713 | } |
| 19714 | 19714 | |
| 19715 | static IrInstGen *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstSrcIntCast *instruction) { | |
| 19715 | static Stage1AirInst *ir_analyze_instruction_int_cast(IrAnalyze *ira, Stage1ZirInstIntCast *instruction) { | |
| 19716 | 19716 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 19717 | 19717 | if (type_is_invalid(dest_type)) |
| 19718 | 19718 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -19726,7 +19726,7 @@ static IrInstGen *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstSrcIntCa |
| 19726 | 19726 | return ira->codegen->invalid_inst_gen; |
| 19727 | 19727 | } |
| 19728 | 19728 | |
| 19729 | IrInstGen *target = instruction->target->child; | |
| 19729 | Stage1AirInst *target = instruction->target->child; | |
| 19730 | 19730 | if (type_is_invalid(target->value->type)) |
| 19731 | 19731 | return ira->codegen->invalid_inst_gen; |
| 19732 | 19732 | |
| ... | ... | @@ -19750,7 +19750,7 @@ static IrInstGen *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstSrcIntCa |
| 19750 | 19750 | return ir_analyze_widen_or_shorten(ira, instruction->base.scope, instruction->base.source_node, target, dest_type); |
| 19751 | 19751 | } |
| 19752 | 19752 | |
| 19753 | static IrInstGen *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstSrcFloatCast *instruction) { | |
| 19753 | static Stage1AirInst *ir_analyze_instruction_float_cast(IrAnalyze *ira, Stage1ZirInstFloatCast *instruction) { | |
| 19754 | 19754 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 19755 | 19755 | if (type_is_invalid(dest_type)) |
| 19756 | 19756 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -19761,7 +19761,7 @@ static IrInstGen *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstSrcFlo |
| 19761 | 19761 | return ira->codegen->invalid_inst_gen; |
| 19762 | 19762 | } |
| 19763 | 19763 | |
| 19764 | IrInstGen *target = instruction->target->child; | |
| 19764 | Stage1AirInst *target = instruction->target->child; | |
| 19765 | 19765 | if (type_is_invalid(target->value->type)) |
| 19766 | 19766 | return ira->codegen->invalid_inst_gen; |
| 19767 | 19767 | |
| ... | ... | @@ -19800,7 +19800,7 @@ static IrInstGen *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstSrcFlo |
| 19800 | 19800 | return ir_analyze_widen_or_shorten(ira, instruction->base.scope, instruction->base.source_node, target, dest_type); |
| 19801 | 19801 | } |
| 19802 | 19802 | |
| 19803 | static IrInstGen *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstSrcErrSetCast *instruction) { | |
| 19803 | static Stage1AirInst *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, Stage1ZirInstErrSetCast *instruction) { | |
| 19804 | 19804 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 19805 | 19805 | if (type_is_invalid(dest_type)) |
| 19806 | 19806 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -19811,7 +19811,7 @@ static IrInstGen *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstSrcE |
| 19811 | 19811 | return ira->codegen->invalid_inst_gen; |
| 19812 | 19812 | } |
| 19813 | 19813 | |
| 19814 | IrInstGen *target = instruction->target->child; | |
| 19814 | Stage1AirInst *target = instruction->target->child; | |
| 19815 | 19815 | if (type_is_invalid(target->value->type)) |
| 19816 | 19816 | return ira->codegen->invalid_inst_gen; |
| 19817 | 19817 | |
| ... | ... | @@ -19849,7 +19849,7 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali |
| 19849 | 19849 | return ErrorNone; |
| 19850 | 19850 | } |
| 19851 | 19851 | |
| 19852 | static IrInstGen *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstSrcIntToFloat *instruction) { | |
| 19852 | static Stage1AirInst *ir_analyze_instruction_int_to_float(IrAnalyze *ira, Stage1ZirInstIntToFloat *instruction) { | |
| 19853 | 19853 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 19854 | 19854 | if (type_is_invalid(dest_type)) |
| 19855 | 19855 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -19860,7 +19860,7 @@ static IrInstGen *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstSrcI |
| 19860 | 19860 | return ira->codegen->invalid_inst_gen; |
| 19861 | 19861 | } |
| 19862 | 19862 | |
| 19863 | IrInstGen *target = instruction->target->child; | |
| 19863 | Stage1AirInst *target = instruction->target->child; | |
| 19864 | 19864 | if (type_is_invalid(target->value->type)) |
| 19865 | 19865 | return ira->codegen->invalid_inst_gen; |
| 19866 | 19866 | |
| ... | ... | @@ -19873,7 +19873,7 @@ static IrInstGen *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstSrcI |
| 19873 | 19873 | return ir_resolve_cast(ira, instruction->base.scope, instruction->base.source_node, target, dest_type, CastOpIntToFloat); |
| 19874 | 19874 | } |
| 19875 | 19875 | |
| 19876 | static IrInstGen *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstSrcFloatToInt *instruction) { | |
| 19876 | static Stage1AirInst *ir_analyze_instruction_float_to_int(IrAnalyze *ira, Stage1ZirInstFloatToInt *instruction) { | |
| 19877 | 19877 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 19878 | 19878 | if (type_is_invalid(dest_type)) |
| 19879 | 19879 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -19884,7 +19884,7 @@ static IrInstGen *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstSrcF |
| 19884 | 19884 | return ira->codegen->invalid_inst_gen; |
| 19885 | 19885 | } |
| 19886 | 19886 | |
| 19887 | IrInstGen *target = instruction->target->child; | |
| 19887 | Stage1AirInst *target = instruction->target->child; | |
| 19888 | 19888 | if (type_is_invalid(target->value->type)) |
| 19889 | 19889 | return ira->codegen->invalid_inst_gen; |
| 19890 | 19890 | |
| ... | ... | @@ -19901,12 +19901,12 @@ static IrInstGen *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstSrcF |
| 19901 | 19901 | return ir_resolve_cast(ira, instruction->base.scope, instruction->base.source_node, target, dest_type, CastOpFloatToInt); |
| 19902 | 19902 | } |
| 19903 | 19903 | |
| 19904 | static IrInstGen *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstSrcErrToInt *instruction) { | |
| 19905 | IrInstGen *target = instruction->target->child; | |
| 19904 | static Stage1AirInst *ir_analyze_instruction_err_to_int(IrAnalyze *ira, Stage1ZirInstErrToInt *instruction) { | |
| 19905 | Stage1AirInst *target = instruction->target->child; | |
| 19906 | 19906 | if (type_is_invalid(target->value->type)) |
| 19907 | 19907 | return ira->codegen->invalid_inst_gen; |
| 19908 | 19908 | |
| 19909 | IrInstGen *casted_target; | |
| 19909 | Stage1AirInst *casted_target; | |
| 19910 | 19910 | if (target->value->type->id == ZigTypeIdErrorSet) { |
| 19911 | 19911 | casted_target = target; |
| 19912 | 19912 | } else { |
| ... | ... | @@ -19918,20 +19918,20 @@ static IrInstGen *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstSrcErr |
| 19918 | 19918 | return ir_analyze_err_to_int(ira, instruction->base.scope, instruction->base.source_node, casted_target, ira->codegen->err_tag_type); |
| 19919 | 19919 | } |
| 19920 | 19920 | |
| 19921 | static IrInstGen *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstSrcIntToErr *instruction) { | |
| 19922 | IrInstGen *target = instruction->target->child; | |
| 19921 | static Stage1AirInst *ir_analyze_instruction_int_to_err(IrAnalyze *ira, Stage1ZirInstIntToErr *instruction) { | |
| 19922 | Stage1AirInst *target = instruction->target->child; | |
| 19923 | 19923 | if (type_is_invalid(target->value->type)) |
| 19924 | 19924 | return ira->codegen->invalid_inst_gen; |
| 19925 | 19925 | |
| 19926 | IrInstGen *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type); | |
| 19926 | Stage1AirInst *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type); | |
| 19927 | 19927 | if (type_is_invalid(casted_target->value->type)) |
| 19928 | 19928 | return ira->codegen->invalid_inst_gen; |
| 19929 | 19929 | |
| 19930 | 19930 | return ir_analyze_int_to_err(ira, instruction->base.scope, instruction->base.source_node, casted_target, ira->codegen->builtin_types.entry_global_error_set); |
| 19931 | 19931 | } |
| 19932 | 19932 | |
| 19933 | static IrInstGen *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstSrcBoolToInt *instruction) { | |
| 19934 | IrInstGen *target = instruction->target->child; | |
| 19933 | static Stage1AirInst *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, Stage1ZirInstBoolToInt *instruction) { | |
| 19934 | Stage1AirInst *target = instruction->target->child; | |
| 19935 | 19935 | if (type_is_invalid(target->value->type)) |
| 19936 | 19936 | return ira->codegen->invalid_inst_gen; |
| 19937 | 19937 | |
| ... | ... | @@ -19953,7 +19953,7 @@ static IrInstGen *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstSrcBo |
| 19953 | 19953 | return ir_resolve_cast(ira, instruction->base.scope, instruction->base.source_node, target, u1_type, CastOpBoolToInt); |
| 19954 | 19954 | } |
| 19955 | 19955 | |
| 19956 | static IrInstGen *ir_analyze_instruction_vector_type(IrAnalyze *ira, IrInstSrcVectorType *instruction) { | |
| 19956 | static Stage1AirInst *ir_analyze_instruction_vector_type(IrAnalyze *ira, Stage1ZirInstVectorType *instruction) { | |
| 19957 | 19957 | uint64_t len; |
| 19958 | 19958 | if (!ir_resolve_unsigned(ira, instruction->len->child, ira->codegen->builtin_types.entry_u32, &len)) |
| 19959 | 19959 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -19967,8 +19967,8 @@ static IrInstGen *ir_analyze_instruction_vector_type(IrAnalyze *ira, IrInstSrcVe |
| 19967 | 19967 | return ir_const_type(ira, instruction->base.scope, instruction->base.source_node, vector_type); |
| 19968 | 19968 | } |
| 19969 | 19969 | |
| 19970 | static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 19971 | ZigType *scalar_type, IrInstGen *a, IrInstGen *b, IrInstGen *mask) | |
| 19970 | static Stage1AirInst *ir_analyze_shuffle_vector(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 19971 | ZigType *scalar_type, Stage1AirInst *a, Stage1AirInst *b, Stage1AirInst *mask) | |
| 19972 | 19972 | { |
| 19973 | 19973 | Error err; |
| 19974 | 19974 | src_assert(source_node && scalar_type && a && b && mask, source_node); |
| ... | ... | @@ -20056,7 +20056,7 @@ static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, Scope *scope, AstNod |
| 20056 | 20056 | continue; |
| 20057 | 20057 | int32_t v_i32 = bigint_as_signed(&mask_elem_val->data.x_bigint); |
| 20058 | 20058 | uint32_t v; |
| 20059 | IrInstGen *chosen_operand; | |
| 20059 | Stage1AirInst *chosen_operand; | |
| 20060 | 20060 | if (v_i32 >= 0) { |
| 20061 | 20061 | v = (uint32_t)v_i32; |
| 20062 | 20062 | chosen_operand = a; |
| ... | ... | @@ -20091,7 +20091,7 @@ static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, Scope *scope, AstNod |
| 20091 | 20091 | expand_undef_array(ira->codegen, a_val); |
| 20092 | 20092 | expand_undef_array(ira->codegen, b_val); |
| 20093 | 20093 | |
| 20094 | IrInstGen *result = ir_const(ira, scope, source_node, result_type); | |
| 20094 | Stage1AirInst *result = ir_const(ira, scope, source_node, result_type); | |
| 20095 | 20095 | result->value->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(len_mask); |
| 20096 | 20096 | for (uint32_t i = 0; i < mask_val->type->data.vector.len; i += 1) { |
| 20097 | 20097 | ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; |
| ... | ... | @@ -20123,7 +20123,7 @@ static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, Scope *scope, AstNod |
| 20123 | 20123 | uint32_t len_min = min(len_a, len_b); |
| 20124 | 20124 | uint32_t len_max = max(len_a, len_b); |
| 20125 | 20125 | |
| 20126 | IrInstGen *expand_mask = ir_const(ira, mask->scope, mask->source_node, | |
| 20126 | Stage1AirInst *expand_mask = ir_const(ira, mask->scope, mask->source_node, | |
| 20127 | 20127 | get_vector_type(ira->codegen, len_max, ira->codegen->builtin_types.entry_i32)); |
| 20128 | 20128 | expand_mask->value->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(len_max); |
| 20129 | 20129 | uint32_t i = 0; |
| ... | ... | @@ -20132,7 +20132,7 @@ static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, Scope *scope, AstNod |
| 20132 | 20132 | for (; i < len_max; i += 1) |
| 20133 | 20133 | bigint_init_signed(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, -1); |
| 20134 | 20134 | |
| 20135 | IrInstGen *undef = ir_const_undef(ira, scope, source_node, | |
| 20135 | Stage1AirInst *undef = ir_const_undef(ira, scope, source_node, | |
| 20136 | 20136 | get_vector_type(ira->codegen, len_min, scalar_type)); |
| 20137 | 20137 | |
| 20138 | 20138 | if (len_b < len_a) { |
| ... | ... | @@ -20146,34 +20146,34 @@ static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, Scope *scope, AstNod |
| 20146 | 20146 | result_type, a, b, mask); |
| 20147 | 20147 | } |
| 20148 | 20148 | |
| 20149 | static IrInstGen *ir_analyze_instruction_shuffle_vector(IrAnalyze *ira, IrInstSrcShuffleVector *instruction) { | |
| 20149 | static Stage1AirInst *ir_analyze_instruction_shuffle_vector(IrAnalyze *ira, Stage1ZirInstShuffleVector *instruction) { | |
| 20150 | 20150 | ZigType *scalar_type = ir_resolve_vector_elem_type(ira, instruction->scalar_type->child); |
| 20151 | 20151 | if (type_is_invalid(scalar_type)) |
| 20152 | 20152 | return ira->codegen->invalid_inst_gen; |
| 20153 | 20153 | |
| 20154 | IrInstGen *a = instruction->a->child; | |
| 20154 | Stage1AirInst *a = instruction->a->child; | |
| 20155 | 20155 | if (type_is_invalid(a->value->type)) |
| 20156 | 20156 | return ira->codegen->invalid_inst_gen; |
| 20157 | 20157 | |
| 20158 | IrInstGen *b = instruction->b->child; | |
| 20158 | Stage1AirInst *b = instruction->b->child; | |
| 20159 | 20159 | if (type_is_invalid(b->value->type)) |
| 20160 | 20160 | return ira->codegen->invalid_inst_gen; |
| 20161 | 20161 | |
| 20162 | IrInstGen *mask = instruction->mask->child; | |
| 20162 | Stage1AirInst *mask = instruction->mask->child; | |
| 20163 | 20163 | if (type_is_invalid(mask->value->type)) |
| 20164 | 20164 | return ira->codegen->invalid_inst_gen; |
| 20165 | 20165 | |
| 20166 | 20166 | return ir_analyze_shuffle_vector(ira, instruction->base.scope, instruction->base.source_node, scalar_type, a, b, mask); |
| 20167 | 20167 | } |
| 20168 | 20168 | |
| 20169 | static IrInstGen *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstSrcSplat *instruction) { | |
| 20169 | static Stage1AirInst *ir_analyze_instruction_splat(IrAnalyze *ira, Stage1ZirInstSplat *instruction) { | |
| 20170 | 20170 | Error err; |
| 20171 | 20171 | |
| 20172 | IrInstGen *len = instruction->len->child; | |
| 20172 | Stage1AirInst *len = instruction->len->child; | |
| 20173 | 20173 | if (type_is_invalid(len->value->type)) |
| 20174 | 20174 | return ira->codegen->invalid_inst_gen; |
| 20175 | 20175 | |
| 20176 | IrInstGen *scalar = instruction->scalar->child; | |
| 20176 | Stage1AirInst *scalar = instruction->scalar->child; | |
| 20177 | 20177 | if (type_is_invalid(scalar->value->type)) |
| 20178 | 20178 | return ira->codegen->invalid_inst_gen; |
| 20179 | 20179 | |
| ... | ... | @@ -20194,7 +20194,7 @@ static IrInstGen *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstSrcSplat *i |
| 20194 | 20194 | if (scalar_val->special == ConstValSpecialUndef) |
| 20195 | 20195 | return ir_const_undef(ira, instruction->base.scope, instruction->base.source_node, return_type); |
| 20196 | 20196 | |
| 20197 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, return_type); | |
| 20197 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, return_type); | |
| 20198 | 20198 | result->value->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(len_int); |
| 20199 | 20199 | for (uint32_t i = 0; i < len_int; i += 1) { |
| 20200 | 20200 | copy_const_val(ira->codegen, &result->value->data.x_array.data.s_none.elements[i], scalar_val); |
| ... | ... | @@ -20205,14 +20205,14 @@ static IrInstGen *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstSrcSplat *i |
| 20205 | 20205 | return ir_build_splat_gen(ira, instruction->base.scope, instruction->base.source_node, return_type, scalar); |
| 20206 | 20206 | } |
| 20207 | 20207 | |
| 20208 | static IrInstGen *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstSrcBoolNot *instruction) { | |
| 20209 | IrInstGen *value = instruction->value->child; | |
| 20208 | static Stage1AirInst *ir_analyze_instruction_bool_not(IrAnalyze *ira, Stage1ZirInstBoolNot *instruction) { | |
| 20209 | Stage1AirInst *value = instruction->value->child; | |
| 20210 | 20210 | if (type_is_invalid(value->value->type)) |
| 20211 | 20211 | return ira->codegen->invalid_inst_gen; |
| 20212 | 20212 | |
| 20213 | 20213 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 20214 | 20214 | |
| 20215 | IrInstGen *casted_value = ir_implicit_cast(ira, value, bool_type); | |
| 20215 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, bool_type); | |
| 20216 | 20216 | if (type_is_invalid(casted_value->value->type)) |
| 20217 | 20217 | return ira->codegen->invalid_inst_gen; |
| 20218 | 20218 | |
| ... | ... | @@ -20227,18 +20227,18 @@ static IrInstGen *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstSrcBoolN |
| 20227 | 20227 | return ir_build_bool_not_gen(ira, instruction->base.scope, instruction->base.source_node, casted_value); |
| 20228 | 20228 | } |
| 20229 | 20229 | |
| 20230 | static IrInstGen *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstSrcMemset *instruction) { | |
| 20230 | static Stage1AirInst *ir_analyze_instruction_memset(IrAnalyze *ira, Stage1ZirInstMemset *instruction) { | |
| 20231 | 20231 | Error err; |
| 20232 | 20232 | |
| 20233 | IrInstGen *dest_ptr = instruction->dest_ptr->child; | |
| 20233 | Stage1AirInst *dest_ptr = instruction->dest_ptr->child; | |
| 20234 | 20234 | if (type_is_invalid(dest_ptr->value->type)) |
| 20235 | 20235 | return ira->codegen->invalid_inst_gen; |
| 20236 | 20236 | |
| 20237 | IrInstGen *byte_value = instruction->byte->child; | |
| 20237 | Stage1AirInst *byte_value = instruction->byte->child; | |
| 20238 | 20238 | if (type_is_invalid(byte_value->value->type)) |
| 20239 | 20239 | return ira->codegen->invalid_inst_gen; |
| 20240 | 20240 | |
| 20241 | IrInstGen *count_value = instruction->count->child; | |
| 20241 | Stage1AirInst *count_value = instruction->count->child; | |
| 20242 | 20242 | if (type_is_invalid(count_value->value->type)) |
| 20243 | 20243 | return ira->codegen->invalid_inst_gen; |
| 20244 | 20244 | |
| ... | ... | @@ -20258,15 +20258,15 @@ static IrInstGen *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstSrcMemset |
| 20258 | 20258 | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile, |
| 20259 | 20259 | PtrLenUnknown, dest_align, 0, 0, false); |
| 20260 | 20260 | |
| 20261 | IrInstGen *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); | |
| 20261 | Stage1AirInst *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); | |
| 20262 | 20262 | if (type_is_invalid(casted_dest_ptr->value->type)) |
| 20263 | 20263 | return ira->codegen->invalid_inst_gen; |
| 20264 | 20264 | |
| 20265 | IrInstGen *casted_byte = ir_implicit_cast(ira, byte_value, u8); | |
| 20265 | Stage1AirInst *casted_byte = ir_implicit_cast(ira, byte_value, u8); | |
| 20266 | 20266 | if (type_is_invalid(casted_byte->value->type)) |
| 20267 | 20267 | return ira->codegen->invalid_inst_gen; |
| 20268 | 20268 | |
| 20269 | IrInstGen *casted_count = ir_implicit_cast(ira, count_value, usize); | |
| 20269 | Stage1AirInst *casted_count = ir_implicit_cast(ira, count_value, usize); | |
| 20270 | 20270 | if (type_is_invalid(casted_count->value->type)) |
| 20271 | 20271 | return ira->codegen->invalid_inst_gen; |
| 20272 | 20272 | |
| ... | ... | @@ -20346,18 +20346,18 @@ static IrInstGen *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstSrcMemset |
| 20346 | 20346 | return ir_build_memset_gen(ira, instruction->base.scope, instruction->base.source_node, casted_dest_ptr, casted_byte, casted_count); |
| 20347 | 20347 | } |
| 20348 | 20348 | |
| 20349 | static IrInstGen *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstSrcMemcpy *instruction) { | |
| 20349 | static Stage1AirInst *ir_analyze_instruction_memcpy(IrAnalyze *ira, Stage1ZirInstMemcpy *instruction) { | |
| 20350 | 20350 | Error err; |
| 20351 | 20351 | |
| 20352 | IrInstGen *dest_ptr = instruction->dest_ptr->child; | |
| 20352 | Stage1AirInst *dest_ptr = instruction->dest_ptr->child; | |
| 20353 | 20353 | if (type_is_invalid(dest_ptr->value->type)) |
| 20354 | 20354 | return ira->codegen->invalid_inst_gen; |
| 20355 | 20355 | |
| 20356 | IrInstGen *src_ptr = instruction->src_ptr->child; | |
| 20356 | Stage1AirInst *src_ptr = instruction->src_ptr->child; | |
| 20357 | 20357 | if (type_is_invalid(src_ptr->value->type)) |
| 20358 | 20358 | return ira->codegen->invalid_inst_gen; |
| 20359 | 20359 | |
| 20360 | IrInstGen *count_value = instruction->count->child; | |
| 20360 | Stage1AirInst *count_value = instruction->count->child; | |
| 20361 | 20361 | if (type_is_invalid(count_value->value->type)) |
| 20362 | 20362 | return ira->codegen->invalid_inst_gen; |
| 20363 | 20363 | |
| ... | ... | @@ -20391,15 +20391,15 @@ static IrInstGen *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstSrcMemcpy |
| 20391 | 20391 | ZigType *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile, |
| 20392 | 20392 | PtrLenUnknown, src_align, 0, 0, false); |
| 20393 | 20393 | |
| 20394 | IrInstGen *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); | |
| 20394 | Stage1AirInst *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); | |
| 20395 | 20395 | if (type_is_invalid(casted_dest_ptr->value->type)) |
| 20396 | 20396 | return ira->codegen->invalid_inst_gen; |
| 20397 | 20397 | |
| 20398 | IrInstGen *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); | |
| 20398 | Stage1AirInst *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); | |
| 20399 | 20399 | if (type_is_invalid(casted_src_ptr->value->type)) |
| 20400 | 20400 | return ira->codegen->invalid_inst_gen; |
| 20401 | 20401 | |
| 20402 | IrInstGen *casted_count = ir_implicit_cast(ira, count_value, usize); | |
| 20402 | Stage1AirInst *casted_count = ir_implicit_cast(ira, count_value, usize); | |
| 20403 | 20403 | if (type_is_invalid(casted_count->value->type)) |
| 20404 | 20404 | return ira->codegen->invalid_inst_gen; |
| 20405 | 20405 | |
| ... | ... | @@ -20534,10 +20534,10 @@ static ZigType *get_result_loc_type(IrAnalyze *ira, ResultLoc *result_loc) { |
| 20534 | 20534 | return nullptr; |
| 20535 | 20535 | } |
| 20536 | 20536 | |
| 20537 | static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *instruction) { | |
| 20537 | static Stage1AirInst *ir_analyze_instruction_slice(IrAnalyze *ira, Stage1ZirInstSlice *instruction) { | |
| 20538 | 20538 | Error err; |
| 20539 | 20539 | |
| 20540 | IrInstGen *ptr_ptr = instruction->ptr->child; | |
| 20540 | Stage1AirInst *ptr_ptr = instruction->ptr->child; | |
| 20541 | 20541 | if (type_is_invalid(ptr_ptr->value->type)) |
| 20542 | 20542 | return ira->codegen->invalid_inst_gen; |
| 20543 | 20543 | |
| ... | ... | @@ -20545,16 +20545,16 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i |
| 20545 | 20545 | assert(ptr_ptr_type->id == ZigTypeIdPointer); |
| 20546 | 20546 | ZigType *array_type = ptr_ptr_type->data.pointer.child_type; |
| 20547 | 20547 | |
| 20548 | IrInstGen *start = instruction->start->child; | |
| 20548 | Stage1AirInst *start = instruction->start->child; | |
| 20549 | 20549 | if (type_is_invalid(start->value->type)) |
| 20550 | 20550 | return ira->codegen->invalid_inst_gen; |
| 20551 | 20551 | |
| 20552 | 20552 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 20553 | IrInstGen *casted_start = ir_implicit_cast(ira, start, usize); | |
| 20553 | Stage1AirInst *casted_start = ir_implicit_cast(ira, start, usize); | |
| 20554 | 20554 | if (type_is_invalid(casted_start->value->type)) |
| 20555 | 20555 | return ira->codegen->invalid_inst_gen; |
| 20556 | 20556 | |
| 20557 | IrInstGen *end; | |
| 20557 | Stage1AirInst *end; | |
| 20558 | 20558 | if (instruction->end) { |
| 20559 | 20559 | end = instruction->end->child; |
| 20560 | 20560 | if (type_is_invalid(end->value->type)) |
| ... | ... | @@ -20626,10 +20626,10 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i |
| 20626 | 20626 | |
| 20627 | 20627 | ZigValue *sentinel_val = nullptr; |
| 20628 | 20628 | if (instruction->sentinel) { |
| 20629 | IrInstGen *uncasted_sentinel = instruction->sentinel->child; | |
| 20629 | Stage1AirInst *uncasted_sentinel = instruction->sentinel->child; | |
| 20630 | 20630 | if (type_is_invalid(uncasted_sentinel->value->type)) |
| 20631 | 20631 | return ira->codegen->invalid_inst_gen; |
| 20632 | IrInstGen *sentinel = ir_implicit_cast(ira, uncasted_sentinel, elem_type); | |
| 20632 | Stage1AirInst *sentinel = ir_implicit_cast(ira, uncasted_sentinel, elem_type); | |
| 20633 | 20633 | if (type_is_invalid(sentinel->value->type)) |
| 20634 | 20634 | return ira->codegen->invalid_inst_gen; |
| 20635 | 20635 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | ... | @@ -20990,7 +20990,7 @@ done_with_return_type: |
| 20990 | 20990 | } |
| 20991 | 20991 | exit_check_sentinel: |
| 20992 | 20992 | |
| 20993 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, return_type); | |
| 20993 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, return_type); | |
| 20994 | 20994 | |
| 20995 | 20995 | ZigValue *ptr_val; |
| 20996 | 20996 | if (return_type->id == ZigTypeIdPointer) { |
| ... | ... | @@ -21061,7 +21061,7 @@ done_with_return_type: |
| 21061 | 21061 | } |
| 21062 | 21062 | |
| 21063 | 21063 | if (generate_non_null_assert) { |
| 21064 | IrInstGen *ptr_val = ir_get_deref(ira, instruction->base.scope, | |
| 21064 | Stage1AirInst *ptr_val = ir_get_deref(ira, instruction->base.scope, | |
| 21065 | 21065 | instruction->base.source_node, ptr_ptr, nullptr); |
| 21066 | 21066 | |
| 21067 | 21067 | if (type_is_invalid(ptr_val->value->type)) |
| ... | ... | @@ -21070,7 +21070,7 @@ done_with_return_type: |
| 21070 | 21070 | ir_build_assert_non_null(ira, instruction->base.scope, instruction->base.source_node, ptr_val); |
| 21071 | 21071 | } |
| 21072 | 21072 | |
| 21073 | IrInstGen *result_loc = nullptr; | |
| 21073 | Stage1AirInst *result_loc = nullptr; | |
| 21074 | 21074 | |
| 21075 | 21075 | if (return_type->id != ZigTypeIdPointer) { |
| 21076 | 21076 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| ... | ... | @@ -21086,9 +21086,9 @@ done_with_return_type: |
| 21086 | 21086 | return ira->codegen->invalid_inst_gen; |
| 21087 | 21087 | } |
| 21088 | 21088 | |
| 21089 | IrInstGen *dummy_value = ir_const(ira, instruction->base.scope, instruction->base.source_node, return_type); | |
| 21089 | Stage1AirInst *dummy_value = ir_const(ira, instruction->base.scope, instruction->base.source_node, return_type); | |
| 21090 | 21090 | dummy_value->value->special = ConstValSpecialRuntime; |
| 21091 | IrInstGen *dummy_result = ir_implicit_cast2(ira, | |
| 21091 | Stage1AirInst *dummy_result = ir_implicit_cast2(ira, | |
| 21092 | 21092 | instruction->base.scope, instruction->base.source_node, |
| 21093 | 21093 | dummy_value, result_loc->value->type->data.pointer.child_type); |
| 21094 | 21094 | if (type_is_invalid(dummy_result->value->type)) |
| ... | ... | @@ -21100,7 +21100,7 @@ done_with_return_type: |
| 21100 | 21100 | casted_start, end, instruction->safety_check_on, result_loc, sentinel_val); |
| 21101 | 21101 | } |
| 21102 | 21102 | |
| 21103 | static IrInstGen *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstSrcHasField *instruction) { | |
| 21103 | static Stage1AirInst *ir_analyze_instruction_has_field(IrAnalyze *ira, Stage1ZirInstHasField *instruction) { | |
| 21104 | 21104 | Error err; |
| 21105 | 21105 | ZigType *container_type = ir_resolve_type(ira, instruction->container_type->child); |
| 21106 | 21106 | if (type_is_invalid(container_type)) |
| ... | ... | @@ -21128,7 +21128,7 @@ static IrInstGen *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstSrcHasF |
| 21128 | 21128 | return ir_const_bool(ira, instruction->base.scope, instruction->base.source_node, result); |
| 21129 | 21129 | } |
| 21130 | 21130 | |
| 21131 | static IrInstGen *ir_analyze_instruction_wasm_memory_size(IrAnalyze *ira, IrInstSrcWasmMemorySize *instruction) { | |
| 21131 | static Stage1AirInst *ir_analyze_instruction_wasm_memory_size(IrAnalyze *ira, Stage1ZirInstWasmMemorySize *instruction) { | |
| 21132 | 21132 | // TODO generate compile error for target_arch different than 32bit |
| 21133 | 21133 | if (!target_is_wasm(ira->codegen->zig_target)) { |
| 21134 | 21134 | ir_add_error_node(ira, instruction->base.source_node, |
| ... | ... | @@ -21136,20 +21136,20 @@ static IrInstGen *ir_analyze_instruction_wasm_memory_size(IrAnalyze *ira, IrInst |
| 21136 | 21136 | return ira->codegen->invalid_inst_gen; |
| 21137 | 21137 | } |
| 21138 | 21138 | |
| 21139 | IrInstGen *index = instruction->index->child; | |
| 21139 | Stage1AirInst *index = instruction->index->child; | |
| 21140 | 21140 | if (type_is_invalid(index->value->type)) |
| 21141 | 21141 | return ira->codegen->invalid_inst_gen; |
| 21142 | 21142 | |
| 21143 | 21143 | ZigType *u32 = ira->codegen->builtin_types.entry_u32; |
| 21144 | 21144 | |
| 21145 | IrInstGen *casted_index = ir_implicit_cast(ira, index, u32); | |
| 21145 | Stage1AirInst *casted_index = ir_implicit_cast(ira, index, u32); | |
| 21146 | 21146 | if (type_is_invalid(casted_index->value->type)) |
| 21147 | 21147 | return ira->codegen->invalid_inst_gen; |
| 21148 | 21148 | |
| 21149 | 21149 | return ir_build_wasm_memory_size_gen(ira, instruction->base.scope, instruction->base.source_node, casted_index); |
| 21150 | 21150 | } |
| 21151 | 21151 | |
| 21152 | static IrInstGen *ir_analyze_instruction_wasm_memory_grow(IrAnalyze *ira, IrInstSrcWasmMemoryGrow *instruction) { | |
| 21152 | static Stage1AirInst *ir_analyze_instruction_wasm_memory_grow(IrAnalyze *ira, Stage1ZirInstWasmMemoryGrow *instruction) { | |
| 21153 | 21153 | // TODO generate compile error for target_arch different than 32bit |
| 21154 | 21154 | if (!target_is_wasm(ira->codegen->zig_target)) { |
| 21155 | 21155 | ir_add_error_node(ira, instruction->base.source_node, |
| ... | ... | @@ -21157,40 +21157,40 @@ static IrInstGen *ir_analyze_instruction_wasm_memory_grow(IrAnalyze *ira, IrInst |
| 21157 | 21157 | return ira->codegen->invalid_inst_gen; |
| 21158 | 21158 | } |
| 21159 | 21159 | |
| 21160 | IrInstGen *index = instruction->index->child; | |
| 21160 | Stage1AirInst *index = instruction->index->child; | |
| 21161 | 21161 | if (type_is_invalid(index->value->type)) |
| 21162 | 21162 | return ira->codegen->invalid_inst_gen; |
| 21163 | 21163 | |
| 21164 | 21164 | ZigType *u32 = ira->codegen->builtin_types.entry_u32; |
| 21165 | 21165 | |
| 21166 | IrInstGen *casted_index = ir_implicit_cast(ira, index, u32); | |
| 21166 | Stage1AirInst *casted_index = ir_implicit_cast(ira, index, u32); | |
| 21167 | 21167 | if (type_is_invalid(casted_index->value->type)) |
| 21168 | 21168 | return ira->codegen->invalid_inst_gen; |
| 21169 | 21169 | |
| 21170 | IrInstGen *delta = instruction->delta->child; | |
| 21170 | Stage1AirInst *delta = instruction->delta->child; | |
| 21171 | 21171 | if (type_is_invalid(delta->value->type)) |
| 21172 | 21172 | return ira->codegen->invalid_inst_gen; |
| 21173 | 21173 | |
| 21174 | IrInstGen *casted_delta = ir_implicit_cast(ira, delta, u32); | |
| 21174 | Stage1AirInst *casted_delta = ir_implicit_cast(ira, delta, u32); | |
| 21175 | 21175 | if (type_is_invalid(casted_delta->value->type)) |
| 21176 | 21176 | return ira->codegen->invalid_inst_gen; |
| 21177 | 21177 | |
| 21178 | 21178 | return ir_build_wasm_memory_grow_gen(ira, instruction->base.scope, instruction->base.source_node, casted_index, casted_delta); |
| 21179 | 21179 | } |
| 21180 | 21180 | |
| 21181 | static IrInstGen *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstSrcBreakpoint *instruction) { | |
| 21181 | static Stage1AirInst *ir_analyze_instruction_breakpoint(IrAnalyze *ira, Stage1ZirInstBreakpoint *instruction) { | |
| 21182 | 21182 | return ir_build_breakpoint_gen(ira, instruction->base.scope, instruction->base.source_node); |
| 21183 | 21183 | } |
| 21184 | 21184 | |
| 21185 | static IrInstGen *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstSrcReturnAddress *instruction) { | |
| 21185 | static Stage1AirInst *ir_analyze_instruction_return_address(IrAnalyze *ira, Stage1ZirInstReturnAddress *instruction) { | |
| 21186 | 21186 | return ir_build_return_address_gen(ira, instruction->base.scope, instruction->base.source_node); |
| 21187 | 21187 | } |
| 21188 | 21188 | |
| 21189 | static IrInstGen *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstSrcFrameAddress *instruction) { | |
| 21189 | static Stage1AirInst *ir_analyze_instruction_frame_address(IrAnalyze *ira, Stage1ZirInstFrameAddress *instruction) { | |
| 21190 | 21190 | return ir_build_frame_address_gen(ira, instruction->base.scope, instruction->base.source_node); |
| 21191 | 21191 | } |
| 21192 | 21192 | |
| 21193 | static IrInstGen *ir_analyze_instruction_frame_handle(IrAnalyze *ira, IrInstSrcFrameHandle *instruction) { | |
| 21193 | static Stage1AirInst *ir_analyze_instruction_frame_handle(IrAnalyze *ira, Stage1ZirInstFrameHandle *instruction) { | |
| 21194 | 21194 | ZigFn *fn = ira->fn; |
| 21195 | 21195 | src_assert(fn != nullptr, instruction->base.source_node); |
| 21196 | 21196 | |
| ... | ... | @@ -21204,7 +21204,7 @@ static IrInstGen *ir_analyze_instruction_frame_handle(IrAnalyze *ira, IrInstSrcF |
| 21204 | 21204 | return ir_build_handle_gen(ira, instruction->base.scope, instruction->base.source_node, ptr_frame_type); |
| 21205 | 21205 | } |
| 21206 | 21206 | |
| 21207 | static IrInstGen *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstSrcFrameType *instruction) { | |
| 21207 | static Stage1AirInst *ir_analyze_instruction_frame_type(IrAnalyze *ira, Stage1ZirInstFrameType *instruction) { | |
| 21208 | 21208 | ZigFn *fn = ir_resolve_fn(ira, instruction->fn->child); |
| 21209 | 21209 | if (fn == nullptr) |
| 21210 | 21210 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -21219,8 +21219,8 @@ static IrInstGen *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstSrcFra |
| 21219 | 21219 | return ir_const_type(ira, instruction->base.scope, instruction->base.source_node, ty); |
| 21220 | 21220 | } |
| 21221 | 21221 | |
| 21222 | static IrInstGen *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstSrcFrameSize *instruction) { | |
| 21223 | IrInstGen *fn = instruction->fn->child; | |
| 21222 | static Stage1AirInst *ir_analyze_instruction_frame_size(IrAnalyze *ira, Stage1ZirInstFrameSize *instruction) { | |
| 21223 | Stage1AirInst *fn = instruction->fn->child; | |
| 21224 | 21224 | if (type_is_invalid(fn->value->type)) |
| 21225 | 21225 | return ira->codegen->invalid_inst_gen; |
| 21226 | 21226 | |
| ... | ... | @@ -21235,13 +21235,13 @@ static IrInstGen *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstSrcFra |
| 21235 | 21235 | return ir_build_frame_size_gen(ira, instruction->base.scope, instruction->base.source_node, fn); |
| 21236 | 21236 | } |
| 21237 | 21237 | |
| 21238 | static IrInstGen *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstSrcAlignOf *instruction) { | |
| 21238 | static Stage1AirInst *ir_analyze_instruction_align_of(IrAnalyze *ira, Stage1ZirInstAlignOf *instruction) { | |
| 21239 | 21239 | // Here we create a lazy value in order to avoid resolving the alignment of the type |
| 21240 | 21240 | // immediately. This avoids false positive dependency loops such as: |
| 21241 | 21241 | // const Node = struct { |
| 21242 | 21242 | // field: []align(@alignOf(Node)) Node, |
| 21243 | 21243 | // }; |
| 21244 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_num_lit_int); | |
| 21244 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_num_lit_int); | |
| 21245 | 21245 | result->value->special = ConstValSpecialLazy; |
| 21246 | 21246 | |
| 21247 | 21247 | LazyValueAlignOf *lazy_align_of = heap::c_allocator.create<LazyValueAlignOf>(); |
| ... | ... | @@ -21256,10 +21256,10 @@ static IrInstGen *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstSrcAlign |
| 21256 | 21256 | return result; |
| 21257 | 21257 | } |
| 21258 | 21258 | |
| 21259 | static IrInstGen *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstSrcOverflowOp *instruction) { | |
| 21259 | static Stage1AirInst *ir_analyze_instruction_overflow_op(IrAnalyze *ira, Stage1ZirInstOverflowOp *instruction) { | |
| 21260 | 21260 | Error err; |
| 21261 | 21261 | |
| 21262 | IrInstGen *type_value = instruction->type_value->child; | |
| 21262 | Stage1AirInst *type_value = instruction->type_value->child; | |
| 21263 | 21263 | if (type_is_invalid(type_value->value->type)) |
| 21264 | 21264 | return ira->codegen->invalid_inst_gen; |
| 21265 | 21265 | |
| ... | ... | @@ -21273,19 +21273,19 @@ static IrInstGen *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstSrcOv |
| 21273 | 21273 | return ira->codegen->invalid_inst_gen; |
| 21274 | 21274 | } |
| 21275 | 21275 | |
| 21276 | IrInstGen *op1 = instruction->op1->child; | |
| 21276 | Stage1AirInst *op1 = instruction->op1->child; | |
| 21277 | 21277 | if (type_is_invalid(op1->value->type)) |
| 21278 | 21278 | return ira->codegen->invalid_inst_gen; |
| 21279 | 21279 | |
| 21280 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | |
| 21280 | Stage1AirInst *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | |
| 21281 | 21281 | if (type_is_invalid(casted_op1->value->type)) |
| 21282 | 21282 | return ira->codegen->invalid_inst_gen; |
| 21283 | 21283 | |
| 21284 | IrInstGen *op2 = instruction->op2->child; | |
| 21284 | Stage1AirInst *op2 = instruction->op2->child; | |
| 21285 | 21285 | if (type_is_invalid(op2->value->type)) |
| 21286 | 21286 | return ira->codegen->invalid_inst_gen; |
| 21287 | 21287 | |
| 21288 | IrInstGen *casted_op2; | |
| 21288 | Stage1AirInst *casted_op2; | |
| 21289 | 21289 | if (instruction->op == IrOverflowOpShl) { |
| 21290 | 21290 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, |
| 21291 | 21291 | dest_type->data.integral.bit_count - 1); |
| ... | ... | @@ -21296,7 +21296,7 @@ static IrInstGen *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstSrcOv |
| 21296 | 21296 | if (type_is_invalid(casted_op2->value->type)) |
| 21297 | 21297 | return ira->codegen->invalid_inst_gen; |
| 21298 | 21298 | |
| 21299 | IrInstGen *result_ptr = instruction->result_ptr->child; | |
| 21299 | Stage1AirInst *result_ptr = instruction->result_ptr->child; | |
| 21300 | 21300 | if (type_is_invalid(result_ptr->value->type)) |
| 21301 | 21301 | return ira->codegen->invalid_inst_gen; |
| 21302 | 21302 | |
| ... | ... | @@ -21313,7 +21313,7 @@ static IrInstGen *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstSrcOv |
| 21313 | 21313 | expected_ptr_type = get_pointer_to_type(ira->codegen, dest_type, false); |
| 21314 | 21314 | } |
| 21315 | 21315 | |
| 21316 | IrInstGen *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); | |
| 21316 | Stage1AirInst *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); | |
| 21317 | 21317 | if (type_is_invalid(casted_result_ptr->value->type)) |
| 21318 | 21318 | return ira->codegen->invalid_inst_gen; |
| 21319 | 21319 | |
| ... | ... | @@ -21403,8 +21403,8 @@ static void ir_eval_mul_add(IrAnalyze *ira, ZigType *float_type, |
| 21403 | 21403 | } |
| 21404 | 21404 | } |
| 21405 | 21405 | |
| 21406 | static IrInstGen *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstSrcMulAdd *instruction) { | |
| 21407 | IrInstGen *type_value = instruction->type_value->child; | |
| 21406 | static Stage1AirInst *ir_analyze_instruction_mul_add(IrAnalyze *ira, Stage1ZirInstMulAdd *instruction) { | |
| 21407 | Stage1AirInst *type_value = instruction->type_value->child; | |
| 21408 | 21408 | if (type_is_invalid(type_value->value->type)) |
| 21409 | 21409 | return ira->codegen->invalid_inst_gen; |
| 21410 | 21410 | |
| ... | ... | @@ -21420,27 +21420,27 @@ static IrInstGen *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstSrcMulAdd |
| 21420 | 21420 | return ira->codegen->invalid_inst_gen; |
| 21421 | 21421 | } |
| 21422 | 21422 | |
| 21423 | IrInstGen *op1 = instruction->op1->child; | |
| 21423 | Stage1AirInst *op1 = instruction->op1->child; | |
| 21424 | 21424 | if (type_is_invalid(op1->value->type)) |
| 21425 | 21425 | return ira->codegen->invalid_inst_gen; |
| 21426 | 21426 | |
| 21427 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, expr_type); | |
| 21427 | Stage1AirInst *casted_op1 = ir_implicit_cast(ira, op1, expr_type); | |
| 21428 | 21428 | if (type_is_invalid(casted_op1->value->type)) |
| 21429 | 21429 | return ira->codegen->invalid_inst_gen; |
| 21430 | 21430 | |
| 21431 | IrInstGen *op2 = instruction->op2->child; | |
| 21431 | Stage1AirInst *op2 = instruction->op2->child; | |
| 21432 | 21432 | if (type_is_invalid(op2->value->type)) |
| 21433 | 21433 | return ira->codegen->invalid_inst_gen; |
| 21434 | 21434 | |
| 21435 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, expr_type); | |
| 21435 | Stage1AirInst *casted_op2 = ir_implicit_cast(ira, op2, expr_type); | |
| 21436 | 21436 | if (type_is_invalid(casted_op2->value->type)) |
| 21437 | 21437 | return ira->codegen->invalid_inst_gen; |
| 21438 | 21438 | |
| 21439 | IrInstGen *op3 = instruction->op3->child; | |
| 21439 | Stage1AirInst *op3 = instruction->op3->child; | |
| 21440 | 21440 | if (type_is_invalid(op3->value->type)) |
| 21441 | 21441 | return ira->codegen->invalid_inst_gen; |
| 21442 | 21442 | |
| 21443 | IrInstGen *casted_op3 = ir_implicit_cast(ira, op3, expr_type); | |
| 21443 | Stage1AirInst *casted_op3 = ir_implicit_cast(ira, op3, expr_type); | |
| 21444 | 21444 | if (type_is_invalid(casted_op3->value->type)) |
| 21445 | 21445 | return ira->codegen->invalid_inst_gen; |
| 21446 | 21446 | |
| ... | ... | @@ -21457,7 +21457,7 @@ static IrInstGen *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstSrcMulAdd |
| 21457 | 21457 | if (!op3_const) |
| 21458 | 21458 | return ira->codegen->invalid_inst_gen; |
| 21459 | 21459 | |
| 21460 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, expr_type); | |
| 21460 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, expr_type); | |
| 21461 | 21461 | ZigValue *out_val = result->value; |
| 21462 | 21462 | |
| 21463 | 21463 | if (expr_type->id == ZigTypeIdVector) { |
| ... | ... | @@ -21491,12 +21491,12 @@ static IrInstGen *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstSrcMulAdd |
| 21491 | 21491 | return ir_build_mul_add_gen(ira, instruction->base.scope, instruction->base.source_node, casted_op1, casted_op2, casted_op3, expr_type); |
| 21492 | 21492 | } |
| 21493 | 21493 | |
| 21494 | static IrInstGen *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstSrcTestErr *instruction) { | |
| 21495 | IrInstGen *base_ptr = instruction->base_ptr->child; | |
| 21494 | static Stage1AirInst *ir_analyze_instruction_test_err(IrAnalyze *ira, Stage1ZirInstTestErr *instruction) { | |
| 21495 | Stage1AirInst *base_ptr = instruction->base_ptr->child; | |
| 21496 | 21496 | if (type_is_invalid(base_ptr->value->type)) |
| 21497 | 21497 | return ira->codegen->invalid_inst_gen; |
| 21498 | 21498 | |
| 21499 | IrInstGen *value; | |
| 21499 | Stage1AirInst *value; | |
| 21500 | 21500 | if (instruction->base_ptr_is_payload) { |
| 21501 | 21501 | value = base_ptr; |
| 21502 | 21502 | } else { |
| ... | ... | @@ -21540,8 +21540,8 @@ static IrInstGen *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstSrcTestE |
| 21540 | 21540 | } |
| 21541 | 21541 | } |
| 21542 | 21542 | |
| 21543 | static IrInstGen *ir_analyze_unwrap_err_code(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 21544 | IrInstGen *base_ptr, bool initializing) | |
| 21543 | static Stage1AirInst *ir_analyze_unwrap_err_code(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 21544 | Stage1AirInst *base_ptr, bool initializing) | |
| 21545 | 21545 | { |
| 21546 | 21546 | ZigType *ptr_type = base_ptr->value->type; |
| 21547 | 21547 | |
| ... | ... | @@ -21595,7 +21595,7 @@ static IrInstGen *ir_analyze_unwrap_err_code(IrAnalyze *ira, Scope *scope, AstNo |
| 21595 | 21595 | } |
| 21596 | 21596 | src_assert(err_union_val->special != ConstValSpecialRuntime, source_node); |
| 21597 | 21597 | |
| 21598 | IrInstGen *result; | |
| 21598 | Stage1AirInst *result; | |
| 21599 | 21599 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 21600 | 21600 | result = ir_build_unwrap_err_code_gen(ira, scope, |
| 21601 | 21601 | source_node, base_ptr, result_type); |
| ... | ... | @@ -21614,15 +21614,15 @@ static IrInstGen *ir_analyze_unwrap_err_code(IrAnalyze *ira, Scope *scope, AstNo |
| 21614 | 21614 | return ir_build_unwrap_err_code_gen(ira, scope, source_node, base_ptr, result_type); |
| 21615 | 21615 | } |
| 21616 | 21616 | |
| 21617 | static IrInstGen *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, IrInstSrcUnwrapErrCode *instruction) { | |
| 21618 | IrInstGen *base_ptr = instruction->err_union_ptr->child; | |
| 21617 | static Stage1AirInst *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, Stage1ZirInstUnwrapErrCode *instruction) { | |
| 21618 | Stage1AirInst *base_ptr = instruction->err_union_ptr->child; | |
| 21619 | 21619 | if (type_is_invalid(base_ptr->value->type)) |
| 21620 | 21620 | return ira->codegen->invalid_inst_gen; |
| 21621 | 21621 | return ir_analyze_unwrap_err_code(ira, instruction->base.scope, instruction->base.source_node, base_ptr, false); |
| 21622 | 21622 | } |
| 21623 | 21623 | |
| 21624 | static IrInstGen *ir_analyze_unwrap_error_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 21625 | IrInstGen *base_ptr, bool safety_check_on, bool initializing) | |
| 21624 | static Stage1AirInst *ir_analyze_unwrap_error_payload(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 21625 | Stage1AirInst *base_ptr, bool safety_check_on, bool initializing) | |
| 21626 | 21626 | { |
| 21627 | 21627 | ZigType *ptr_type = base_ptr->value->type; |
| 21628 | 21628 | |
| ... | ... | @@ -21680,7 +21680,7 @@ static IrInstGen *ir_analyze_unwrap_error_payload(IrAnalyze *ira, Scope *scope, |
| 21680 | 21680 | return ira->codegen->invalid_inst_gen; |
| 21681 | 21681 | } |
| 21682 | 21682 | |
| 21683 | IrInstGen *result; | |
| 21683 | Stage1AirInst *result; | |
| 21684 | 21684 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 21685 | 21685 | result = ir_build_unwrap_err_payload_gen(ira, scope, |
| 21686 | 21686 | source_node, base_ptr, safety_check_on, initializing, result_type); |
| ... | ... | @@ -21700,22 +21700,22 @@ static IrInstGen *ir_analyze_unwrap_error_payload(IrAnalyze *ira, Scope *scope, |
| 21700 | 21700 | base_ptr, safety_check_on, initializing, result_type); |
| 21701 | 21701 | } |
| 21702 | 21702 | |
| 21703 | static IrInstGen *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, | |
| 21704 | IrInstSrcUnwrapErrPayload *instruction) | |
| 21703 | static Stage1AirInst *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, | |
| 21704 | Stage1ZirInstUnwrapErrPayload *instruction) | |
| 21705 | 21705 | { |
| 21706 | 21706 | assert(instruction->value->child); |
| 21707 | IrInstGen *value = instruction->value->child; | |
| 21707 | Stage1AirInst *value = instruction->value->child; | |
| 21708 | 21708 | if (type_is_invalid(value->value->type)) |
| 21709 | 21709 | return ira->codegen->invalid_inst_gen; |
| 21710 | 21710 | |
| 21711 | 21711 | return ir_analyze_unwrap_error_payload(ira, instruction->base.scope, instruction->base.source_node, value, instruction->safety_check_on, false); |
| 21712 | 21712 | } |
| 21713 | 21713 | |
| 21714 | static IrInstGen *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstSrcFnProto *instruction) { | |
| 21714 | static Stage1AirInst *ir_analyze_instruction_fn_proto(IrAnalyze *ira, Stage1ZirInstFnProto *instruction) { | |
| 21715 | 21715 | AstNode *proto_node = instruction->base.source_node; |
| 21716 | 21716 | assert(proto_node->type == NodeTypeFnProto); |
| 21717 | 21717 | |
| 21718 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_type); | |
| 21718 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_type); | |
| 21719 | 21719 | result->value->special = ConstValSpecialLazy; |
| 21720 | 21720 | |
| 21721 | 21721 | LazyValueFnType *lazy_fn_type = heap::c_allocator.create<LazyValueFnType>(); |
| ... | ... | @@ -21733,7 +21733,7 @@ static IrInstGen *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstSrcFnPro |
| 21733 | 21733 | if (instruction->callconv_value != nullptr) { |
| 21734 | 21734 | ZigType *cc_enum_type = get_builtin_type(ira->codegen, "CallingConvention"); |
| 21735 | 21735 | |
| 21736 | IrInstGen *casted_value = ir_implicit_cast(ira, instruction->callconv_value->child, cc_enum_type); | |
| 21736 | Stage1AirInst *casted_value = ir_implicit_cast(ira, instruction->callconv_value->child, cc_enum_type); | |
| 21737 | 21737 | if (type_is_invalid(casted_value->value->type)) |
| 21738 | 21738 | return ira->codegen->invalid_inst_gen; |
| 21739 | 21739 | |
| ... | ... | @@ -21746,7 +21746,7 @@ static IrInstGen *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstSrcFnPro |
| 21746 | 21746 | |
| 21747 | 21747 | size_t param_count = proto_node->data.fn_proto.params.length; |
| 21748 | 21748 | lazy_fn_type->proto_node = proto_node; |
| 21749 | lazy_fn_type->param_types = heap::c_allocator.allocate<IrInstGen *>(param_count); | |
| 21749 | lazy_fn_type->param_types = heap::c_allocator.allocate<Stage1AirInst *>(param_count); | |
| 21750 | 21750 | |
| 21751 | 21751 | for (size_t param_index = 0; param_index < param_count; param_index += 1) { |
| 21752 | 21752 | AstNode *param_node = proto_node->data.fn_proto.params.at(param_index); |
| ... | ... | @@ -21770,7 +21770,7 @@ static IrInstGen *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstSrcFnPro |
| 21770 | 21770 | return result; |
| 21771 | 21771 | } |
| 21772 | 21772 | |
| 21773 | IrInstGen *param_type_value = instruction->param_types[param_index]->child; | |
| 21773 | Stage1AirInst *param_type_value = instruction->param_types[param_index]->child; | |
| 21774 | 21774 | if (type_is_invalid(param_type_value->value->type)) |
| 21775 | 21775 | return ira->codegen->invalid_inst_gen; |
| 21776 | 21776 | if (ir_resolve_const(ira, param_type_value, LazyOk) == nullptr) |
| ... | ... | @@ -21791,23 +21791,23 @@ static IrInstGen *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstSrcFnPro |
| 21791 | 21791 | return result; |
| 21792 | 21792 | } |
| 21793 | 21793 | |
| 21794 | static IrInstGen *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstSrcTestComptime *instruction) { | |
| 21795 | IrInstGen *value = instruction->value->child; | |
| 21794 | static Stage1AirInst *ir_analyze_instruction_test_comptime(IrAnalyze *ira, Stage1ZirInstTestComptime *instruction) { | |
| 21795 | Stage1AirInst *value = instruction->value->child; | |
| 21796 | 21796 | if (type_is_invalid(value->value->type)) |
| 21797 | 21797 | return ira->codegen->invalid_inst_gen; |
| 21798 | 21798 | |
| 21799 | 21799 | return ir_const_bool(ira, instruction->base.scope, instruction->base.source_node, instr_is_comptime(value)); |
| 21800 | 21800 | } |
| 21801 | 21801 | |
| 21802 | static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | |
| 21803 | IrInstSrcCheckSwitchProngs *instruction, bool have_underscore_prong) | |
| 21802 | static Stage1AirInst *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | |
| 21803 | Stage1ZirInstCheckSwitchProngs *instruction, bool have_underscore_prong) | |
| 21804 | 21804 | { |
| 21805 | IrInstGen *target_value = instruction->target_value->child; | |
| 21805 | Stage1AirInst *target_value = instruction->target_value->child; | |
| 21806 | 21806 | ZigType *switch_type = target_value->value->type; |
| 21807 | 21807 | if (type_is_invalid(switch_type)) |
| 21808 | 21808 | return ira->codegen->invalid_inst_gen; |
| 21809 | 21809 | |
| 21810 | ZigValue *original_value = ((IrInstSrcSwitchTarget *)(instruction->target_value))->target_value_ptr->child->value; | |
| 21810 | ZigValue *original_value = ((Stage1ZirInstSwitchTarget *)(instruction->target_value))->target_value_ptr->child->value; | |
| 21811 | 21811 | bool target_is_originally_union = original_value->type->id == ZigTypeIdPointer && |
| 21812 | 21812 | original_value->type->data.pointer.child_type->id == ZigTypeIdUnion; |
| 21813 | 21813 | |
| ... | ... | @@ -21816,19 +21816,19 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 21816 | 21816 | field_prev_uses.init(switch_type->data.enumeration.src_field_count); |
| 21817 | 21817 | |
| 21818 | 21818 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 21819 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | |
| 21819 | Stage1ZirInstCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | |
| 21820 | 21820 | |
| 21821 | IrInstGen *start_value_uncasted = range->start->child; | |
| 21821 | Stage1AirInst *start_value_uncasted = range->start->child; | |
| 21822 | 21822 | if (type_is_invalid(start_value_uncasted->value->type)) |
| 21823 | 21823 | return ira->codegen->invalid_inst_gen; |
| 21824 | IrInstGen *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | |
| 21824 | Stage1AirInst *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | |
| 21825 | 21825 | if (type_is_invalid(start_value->value->type)) |
| 21826 | 21826 | return ira->codegen->invalid_inst_gen; |
| 21827 | 21827 | |
| 21828 | IrInstGen *end_value_uncasted = range->end->child; | |
| 21828 | Stage1AirInst *end_value_uncasted = range->end->child; | |
| 21829 | 21829 | if (type_is_invalid(end_value_uncasted->value->type)) |
| 21830 | 21830 | return ira->codegen->invalid_inst_gen; |
| 21831 | IrInstGen *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | |
| 21831 | Stage1AirInst *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | |
| 21832 | 21832 | if (type_is_invalid(end_value->value->type)) |
| 21833 | 21833 | return ira->codegen->invalid_inst_gen; |
| 21834 | 21834 | |
| ... | ... | @@ -21914,19 +21914,19 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 21914 | 21914 | AstNode **field_prev_uses = heap::c_allocator.allocate<AstNode *>(field_prev_uses_count); |
| 21915 | 21915 | |
| 21916 | 21916 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 21917 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | |
| 21917 | Stage1ZirInstCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | |
| 21918 | 21918 | |
| 21919 | IrInstGen *start_value_uncasted = range->start->child; | |
| 21919 | Stage1AirInst *start_value_uncasted = range->start->child; | |
| 21920 | 21920 | if (type_is_invalid(start_value_uncasted->value->type)) |
| 21921 | 21921 | return ira->codegen->invalid_inst_gen; |
| 21922 | IrInstGen *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | |
| 21922 | Stage1AirInst *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | |
| 21923 | 21923 | if (type_is_invalid(start_value->value->type)) |
| 21924 | 21924 | return ira->codegen->invalid_inst_gen; |
| 21925 | 21925 | |
| 21926 | IrInstGen *end_value_uncasted = range->end->child; | |
| 21926 | Stage1AirInst *end_value_uncasted = range->end->child; | |
| 21927 | 21927 | if (type_is_invalid(end_value_uncasted->value->type)) |
| 21928 | 21928 | return ira->codegen->invalid_inst_gen; |
| 21929 | IrInstGen *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | |
| 21929 | Stage1AirInst *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | |
| 21930 | 21930 | if (type_is_invalid(end_value->value->type)) |
| 21931 | 21931 | return ira->codegen->invalid_inst_gen; |
| 21932 | 21932 | |
| ... | ... | @@ -21972,19 +21972,19 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 21972 | 21972 | } else if (switch_type->id == ZigTypeIdInt) { |
| 21973 | 21973 | RangeSet rs = {0}; |
| 21974 | 21974 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 21975 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | |
| 21975 | Stage1ZirInstCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | |
| 21976 | 21976 | |
| 21977 | IrInstGen *start_value = range->start->child; | |
| 21977 | Stage1AirInst *start_value = range->start->child; | |
| 21978 | 21978 | if (type_is_invalid(start_value->value->type)) |
| 21979 | 21979 | return ira->codegen->invalid_inst_gen; |
| 21980 | IrInstGen *casted_start_value = ir_implicit_cast(ira, start_value, switch_type); | |
| 21980 | Stage1AirInst *casted_start_value = ir_implicit_cast(ira, start_value, switch_type); | |
| 21981 | 21981 | if (type_is_invalid(casted_start_value->value->type)) |
| 21982 | 21982 | return ira->codegen->invalid_inst_gen; |
| 21983 | 21983 | |
| 21984 | IrInstGen *end_value = range->end->child; | |
| 21984 | Stage1AirInst *end_value = range->end->child; | |
| 21985 | 21985 | if (type_is_invalid(end_value->value->type)) |
| 21986 | 21986 | return ira->codegen->invalid_inst_gen; |
| 21987 | IrInstGen *casted_end_value = ir_implicit_cast(ira, end_value, switch_type); | |
| 21987 | Stage1AirInst *casted_end_value = ir_implicit_cast(ira, end_value, switch_type); | |
| 21988 | 21988 | if (type_is_invalid(casted_end_value->value->type)) |
| 21989 | 21989 | return ira->codegen->invalid_inst_gen; |
| 21990 | 21990 | |
| ... | ... | @@ -22030,11 +22030,11 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 22030 | 22030 | int seenTrue = 0; |
| 22031 | 22031 | int seenFalse = 0; |
| 22032 | 22032 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 22033 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | |
| 22033 | Stage1ZirInstCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | |
| 22034 | 22034 | |
| 22035 | IrInstGen *value = range->start->child; | |
| 22035 | Stage1AirInst *value = range->start->child; | |
| 22036 | 22036 | |
| 22037 | IrInstGen *casted_value = ir_implicit_cast(ira, value, switch_type); | |
| 22037 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, switch_type); | |
| 22038 | 22038 | if (type_is_invalid(casted_value->value->type)) |
| 22039 | 22039 | return ira->codegen->invalid_inst_gen; |
| 22040 | 22040 | |
| ... | ... | @@ -22070,15 +22070,15 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 22070 | 22070 | buf_sprintf("else prong required when switching on type '%s'", buf_ptr(&switch_type->name))); |
| 22071 | 22071 | return ira->codegen->invalid_inst_gen; |
| 22072 | 22072 | } else if(switch_type->id == ZigTypeIdMetaType) { |
| 22073 | HashMap<const ZigType*, IrInstGen*, type_ptr_hash, type_ptr_eql> prevs; | |
| 22073 | HashMap<const ZigType*, Stage1AirInst*, type_ptr_hash, type_ptr_eql> prevs; | |
| 22074 | 22074 | // HashMap doubles capacity when reaching 60% capacity, |
| 22075 | 22075 | // because we know the size at init we can avoid reallocation by doubling it here |
| 22076 | 22076 | prevs.init(instruction->range_count * 2); |
| 22077 | 22077 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 22078 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | |
| 22078 | Stage1ZirInstCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | |
| 22079 | 22079 | |
| 22080 | IrInstGen *value = range->start->child; | |
| 22081 | IrInstGen *casted_value = ir_implicit_cast(ira, value, switch_type); | |
| 22080 | Stage1AirInst *value = range->start->child; | |
| 22081 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, switch_type); | |
| 22082 | 22082 | if (type_is_invalid(casted_value->value->type)) { |
| 22083 | 22083 | prevs.deinit(); |
| 22084 | 22084 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -22103,10 +22103,10 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 22103 | 22103 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 22104 | 22104 | } |
| 22105 | 22105 | |
| 22106 | static IrInstGen *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira, | |
| 22107 | IrInstSrcCheckStatementIsVoid *instruction) | |
| 22106 | static Stage1AirInst *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira, | |
| 22107 | Stage1ZirInstCheckStatementIsVoid *instruction) | |
| 22108 | 22108 | { |
| 22109 | IrInstGen *statement_value = instruction->statement_value->child; | |
| 22109 | Stage1AirInst *statement_value = instruction->statement_value->child; | |
| 22110 | 22110 | ZigType *statement_type = statement_value->value->type; |
| 22111 | 22111 | if (type_is_invalid(statement_type)) |
| 22112 | 22112 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -22122,8 +22122,8 @@ static IrInstGen *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira, |
| 22122 | 22122 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 22123 | 22123 | } |
| 22124 | 22124 | |
| 22125 | static IrInstGen *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstSrcPanic *instruction) { | |
| 22126 | IrInstGen *msg = instruction->msg->child; | |
| 22125 | static Stage1AirInst *ir_analyze_instruction_panic(IrAnalyze *ira, Stage1ZirInstPanic *instruction) { | |
| 22126 | Stage1AirInst *msg = instruction->msg->child; | |
| 22127 | 22127 | if (type_is_invalid(msg->value->type)) |
| 22128 | 22128 | return ir_unreach_error(ira); |
| 22129 | 22129 | |
| ... | ... | @@ -22135,15 +22135,15 @@ static IrInstGen *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstSrcPanic *i |
| 22135 | 22135 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 22136 | 22136 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 22137 | 22137 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 22138 | IrInstGen *casted_msg = ir_implicit_cast(ira, msg, str_type); | |
| 22138 | Stage1AirInst *casted_msg = ir_implicit_cast(ira, msg, str_type); | |
| 22139 | 22139 | if (type_is_invalid(casted_msg->value->type)) |
| 22140 | 22140 | return ir_unreach_error(ira); |
| 22141 | 22141 | |
| 22142 | IrInstGen *new_instruction = ir_build_panic_gen(ira, instruction->base.scope, instruction->base.source_node, casted_msg); | |
| 22142 | Stage1AirInst *new_instruction = ir_build_panic_gen(ira, instruction->base.scope, instruction->base.source_node, casted_msg); | |
| 22143 | 22143 | return ir_finish_anal(ira, new_instruction); |
| 22144 | 22144 | } |
| 22145 | 22145 | |
| 22146 | static IrInstGen *ir_align_cast(IrAnalyze *ira, IrInstGen *target, uint32_t align_bytes, bool safety_check_on) { | |
| 22146 | static Stage1AirInst *ir_align_cast(IrAnalyze *ira, Stage1AirInst *target, uint32_t align_bytes, bool safety_check_on) { | |
| 22147 | 22147 | Error err; |
| 22148 | 22148 | |
| 22149 | 22149 | ZigType *target_type = target->value->type; |
| ... | ... | @@ -22224,7 +22224,7 @@ static IrInstGen *ir_align_cast(IrAnalyze *ira, IrInstGen *target, uint32_t alig |
| 22224 | 22224 | return ira->codegen->invalid_inst_gen; |
| 22225 | 22225 | } |
| 22226 | 22226 | |
| 22227 | IrInstGen *result = ir_const(ira, target->scope, target->source_node, result_type); | |
| 22227 | Stage1AirInst *result = ir_const(ira, target->scope, target->source_node, result_type); | |
| 22228 | 22228 | copy_const_val(ira->codegen, result->value, val); |
| 22229 | 22229 | result->value->type = result_type; |
| 22230 | 22230 | return result; |
| ... | ... | @@ -22237,8 +22237,8 @@ static IrInstGen *ir_align_cast(IrAnalyze *ira, IrInstGen *target, uint32_t alig |
| 22237 | 22237 | } |
| 22238 | 22238 | } |
| 22239 | 22239 | |
| 22240 | static IrInstGen *ir_analyze_ptr_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 22241 | IrInstGen *ptr, AstNode *ptr_src, ZigType *dest_type, AstNode *dest_type_src, | |
| 22240 | static Stage1AirInst *ir_analyze_ptr_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 22241 | Stage1AirInst *ptr, AstNode *ptr_src, ZigType *dest_type, AstNode *dest_type_src, | |
| 22242 | 22242 | bool safety_check_on, bool keep_bigger_alignment) |
| 22243 | 22243 | { |
| 22244 | 22244 | Error err; |
| ... | ... | @@ -22312,8 +22312,8 @@ static IrInstGen *ir_analyze_ptr_cast(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 22312 | 22312 | // For slices, follow the `ptr` field. |
| 22313 | 22313 | if (is_slice(src_type)) { |
| 22314 | 22314 | TypeStructField *ptr_field = src_type->data.structure.fields[slice_ptr_index]; |
| 22315 | IrInstGen *ptr_ref = ir_get_ref(ira, scope, source_node, ptr, true, false); | |
| 22316 | IrInstGen *ptr_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, ptr_field, ptr_ref, src_type, false); | |
| 22315 | Stage1AirInst *ptr_ref = ir_get_ref(ira, scope, source_node, ptr, true, false); | |
| 22316 | Stage1AirInst *ptr_ptr = ir_analyze_struct_field_ptr(ira, scope, source_node, ptr_field, ptr_ref, src_type, false); | |
| 22317 | 22317 | ptr = ir_get_deref(ira, scope, source_node, ptr_ptr, nullptr); |
| 22318 | 22318 | } |
| 22319 | 22319 | |
| ... | ... | @@ -22335,7 +22335,7 @@ static IrInstGen *ir_analyze_ptr_cast(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 22335 | 22335 | } |
| 22336 | 22336 | } |
| 22337 | 22337 | |
| 22338 | IrInstGen *result; | |
| 22338 | Stage1AirInst *result; | |
| 22339 | 22339 | if (val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 22340 | 22340 | result = ir_build_ptr_cast_gen(ira, scope, source_node, dest_type, ptr, safety_check_on); |
| 22341 | 22341 | } else { |
| ... | ... | @@ -22380,10 +22380,10 @@ static IrInstGen *ir_analyze_ptr_cast(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 22380 | 22380 | return ira->codegen->invalid_inst_gen; |
| 22381 | 22381 | } |
| 22382 | 22382 | |
| 22383 | IrInstGen *casted_ptr = ir_build_ptr_cast_gen(ira, scope, source_node, dest_type, ptr, safety_check_on); | |
| 22383 | Stage1AirInst *casted_ptr = ir_build_ptr_cast_gen(ira, scope, source_node, dest_type, ptr, safety_check_on); | |
| 22384 | 22384 | |
| 22385 | 22385 | // Keep the bigger alignment, it can only help- unless the target is zero bits. |
| 22386 | IrInstGen *result; | |
| 22386 | Stage1AirInst *result; | |
| 22387 | 22387 | if (keep_bigger_alignment && src_align_bytes > dest_align_bytes && type_has_bits(ira->codegen, dest_type)) { |
| 22388 | 22388 | result = ir_align_cast(ira, casted_ptr, src_align_bytes, false); |
| 22389 | 22389 | if (type_is_invalid(result->value->type)) |
| ... | ... | @@ -22394,13 +22394,13 @@ static IrInstGen *ir_analyze_ptr_cast(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 22394 | 22394 | return result; |
| 22395 | 22395 | } |
| 22396 | 22396 | |
| 22397 | static IrInstGen *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstSrcPtrCast *instruction) { | |
| 22398 | IrInstGen *dest_type_value = instruction->dest_type->child; | |
| 22397 | static Stage1AirInst *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, Stage1ZirInstPtrCast *instruction) { | |
| 22398 | Stage1AirInst *dest_type_value = instruction->dest_type->child; | |
| 22399 | 22399 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 22400 | 22400 | if (type_is_invalid(dest_type)) |
| 22401 | 22401 | return ira->codegen->invalid_inst_gen; |
| 22402 | 22402 | |
| 22403 | IrInstGen *ptr = instruction->ptr->child; | |
| 22403 | Stage1AirInst *ptr = instruction->ptr->child; | |
| 22404 | 22404 | ZigType *src_type = ptr->value->type; |
| 22405 | 22405 | if (type_is_invalid(src_type)) |
| 22406 | 22406 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -22762,7 +22762,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 22762 | 22762 | zig_unreachable(); |
| 22763 | 22763 | } |
| 22764 | 22764 | |
| 22765 | static IrInstGen *ir_analyze_bit_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *value, | |
| 22765 | static Stage1AirInst *ir_analyze_bit_cast(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *value, | |
| 22766 | 22766 | ZigType *dest_type) |
| 22767 | 22767 | { |
| 22768 | 22768 | Error err; |
| ... | ... | @@ -22813,7 +22813,7 @@ static IrInstGen *ir_analyze_bit_cast(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 22813 | 22813 | if (!val) |
| 22814 | 22814 | return ira->codegen->invalid_inst_gen; |
| 22815 | 22815 | |
| 22816 | IrInstGen *result = ir_const(ira, scope, source_node, dest_type); | |
| 22816 | Stage1AirInst *result = ir_const(ira, scope, source_node, dest_type); | |
| 22817 | 22817 | uint8_t *buf = heap::c_allocator.allocate_nonzero<uint8_t>(src_size_bytes); |
| 22818 | 22818 | buf_write_value_bytes(ira->codegen, buf, val); |
| 22819 | 22819 | if ((err = buf_read_value_bytes(ira, ira->codegen, source_node, buf, result->value))) |
| ... | ... | @@ -22830,7 +22830,7 @@ static IrInstGen *ir_analyze_bit_cast(IrAnalyze *ira, Scope *scope, AstNode *sou |
| 22830 | 22830 | return ir_build_bit_cast_gen(ira, scope, source_node, value, dest_type); |
| 22831 | 22831 | } |
| 22832 | 22832 | |
| 22833 | static IrInstGen *ir_analyze_int_to_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, | |
| 22833 | static Stage1AirInst *ir_analyze_int_to_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, Stage1AirInst *target, | |
| 22834 | 22834 | ZigType *ptr_type) |
| 22835 | 22835 | { |
| 22836 | 22836 | Error err; |
| ... | ... | @@ -22838,7 +22838,7 @@ static IrInstGen *ir_analyze_int_to_ptr(IrAnalyze *ira, Scope *scope, AstNode *s |
| 22838 | 22838 | src_assert(get_src_ptr_type(ptr_type) != nullptr, source_node); |
| 22839 | 22839 | src_assert(type_has_bits(ira->codegen, ptr_type), source_node); |
| 22840 | 22840 | |
| 22841 | IrInstGen *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); | |
| 22841 | Stage1AirInst *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); | |
| 22842 | 22842 | if (type_is_invalid(casted_int->value->type)) |
| 22843 | 22843 | return ira->codegen->invalid_inst_gen; |
| 22844 | 22844 | |
| ... | ... | @@ -22865,7 +22865,7 @@ static IrInstGen *ir_analyze_int_to_ptr(IrAnalyze *ira, Scope *scope, AstNode *s |
| 22865 | 22865 | return ira->codegen->invalid_inst_gen; |
| 22866 | 22866 | } |
| 22867 | 22867 | |
| 22868 | IrInstGen *result = ir_const(ira, scope, source_node, ptr_type); | |
| 22868 | Stage1AirInst *result = ir_const(ira, scope, source_node, ptr_type); | |
| 22869 | 22869 | if (ptr_type->id == ZigTypeIdOptional && addr == 0) { |
| 22870 | 22870 | result->value->data.x_ptr.special = ConstPtrSpecialNull; |
| 22871 | 22871 | result->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| ... | ... | @@ -22881,9 +22881,9 @@ static IrInstGen *ir_analyze_int_to_ptr(IrAnalyze *ira, Scope *scope, AstNode *s |
| 22881 | 22881 | return ir_build_int_to_ptr_gen(ira, scope, source_node, casted_int, ptr_type); |
| 22882 | 22882 | } |
| 22883 | 22883 | |
| 22884 | static IrInstGen *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstSrcIntToPtr *instruction) { | |
| 22884 | static Stage1AirInst *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, Stage1ZirInstIntToPtr *instruction) { | |
| 22885 | 22885 | Error err; |
| 22886 | IrInstGen *dest_type_value = instruction->dest_type->child; | |
| 22886 | Stage1AirInst *dest_type_value = instruction->dest_type->child; | |
| 22887 | 22887 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 22888 | 22888 | if (type_is_invalid(dest_type)) |
| 22889 | 22889 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -22904,15 +22904,15 @@ static IrInstGen *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstSrcInt |
| 22904 | 22904 | return ira->codegen->invalid_inst_gen; |
| 22905 | 22905 | } |
| 22906 | 22906 | |
| 22907 | IrInstGen *target = instruction->target->child; | |
| 22907 | Stage1AirInst *target = instruction->target->child; | |
| 22908 | 22908 | if (type_is_invalid(target->value->type)) |
| 22909 | 22909 | return ira->codegen->invalid_inst_gen; |
| 22910 | 22910 | |
| 22911 | 22911 | return ir_analyze_int_to_ptr(ira, instruction->base.scope, instruction->base.source_node, target, dest_type); |
| 22912 | 22912 | } |
| 22913 | 22913 | |
| 22914 | static IrInstGen *ir_analyze_instruction_decl_ref(IrAnalyze *ira, IrInstSrcDeclRef *instruction) { | |
| 22915 | IrInstGen *ref_instruction = ir_analyze_decl_ref(ira, instruction->base.scope, instruction->base.source_node, instruction->tld); | |
| 22914 | static Stage1AirInst *ir_analyze_instruction_decl_ref(IrAnalyze *ira, Stage1ZirInstDeclRef *instruction) { | |
| 22915 | Stage1AirInst *ref_instruction = ir_analyze_decl_ref(ira, instruction->base.scope, instruction->base.source_node, instruction->tld); | |
| 22916 | 22916 | if (type_is_invalid(ref_instruction->value->type)) { |
| 22917 | 22917 | return ira->codegen->invalid_inst_gen; |
| 22918 | 22918 | } |
| ... | ... | @@ -22924,9 +22924,9 @@ static IrInstGen *ir_analyze_instruction_decl_ref(IrAnalyze *ira, IrInstSrcDeclR |
| 22924 | 22924 | } |
| 22925 | 22925 | } |
| 22926 | 22926 | |
| 22927 | static IrInstGen *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstSrcPtrToInt *instruction) { | |
| 22927 | static Stage1AirInst *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, Stage1ZirInstPtrToInt *instruction) { | |
| 22928 | 22928 | Error err; |
| 22929 | IrInstGen *target = instruction->target->child; | |
| 22929 | Stage1AirInst *target = instruction->target->child; | |
| 22930 | 22930 | if (type_is_invalid(target->value->type)) |
| 22931 | 22931 | return ira->codegen->invalid_inst_gen; |
| 22932 | 22932 | |
| ... | ... | @@ -22957,12 +22957,12 @@ static IrInstGen *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstSrcPtr |
| 22957 | 22957 | // Since we've already run this type trough get_src_ptr_type it is |
| 22958 | 22958 | // safe to access the x_ptr fields |
| 22959 | 22959 | if (val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 22960 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, usize); | |
| 22960 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, usize); | |
| 22961 | 22961 | bigint_init_unsigned(&result->value->data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr); |
| 22962 | 22962 | result->value->type = usize; |
| 22963 | 22963 | return result; |
| 22964 | 22964 | } else if (val->data.x_ptr.special == ConstPtrSpecialNull) { |
| 22965 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, usize); | |
| 22965 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, usize); | |
| 22966 | 22966 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 22967 | 22967 | result->value->type = usize; |
| 22968 | 22968 | return result; |
| ... | ... | @@ -22972,10 +22972,10 @@ static IrInstGen *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstSrcPtr |
| 22972 | 22972 | return ir_build_ptr_to_int_gen(ira, instruction->base.scope, instruction->base.source_node, target); |
| 22973 | 22973 | } |
| 22974 | 22974 | |
| 22975 | static IrInstGen *ir_analyze_instruction_ptr_type_simple(IrAnalyze *ira, | |
| 22976 | IrInstSrcPtrTypeSimple *instruction, bool is_const) | |
| 22975 | static Stage1AirInst *ir_analyze_instruction_ptr_type_simple(IrAnalyze *ira, | |
| 22976 | Stage1ZirInstPtrTypeSimple *instruction, bool is_const) | |
| 22977 | 22977 | { |
| 22978 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_type); | |
| 22978 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_type); | |
| 22979 | 22979 | result->value->special = ConstValSpecialLazy; |
| 22980 | 22980 | |
| 22981 | 22981 | LazyValuePtrTypeSimple *lazy_ptr_type = heap::c_allocator.create<LazyValuePtrTypeSimple>(); |
| ... | ... | @@ -22990,8 +22990,8 @@ static IrInstGen *ir_analyze_instruction_ptr_type_simple(IrAnalyze *ira, |
| 22990 | 22990 | return result; |
| 22991 | 22991 | } |
| 22992 | 22992 | |
| 22993 | static IrInstGen *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstSrcPtrType *instruction) { | |
| 22994 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_type); | |
| 22993 | static Stage1AirInst *ir_analyze_instruction_ptr_type(IrAnalyze *ira, Stage1ZirInstPtrType *instruction) { | |
| 22994 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_type); | |
| 22995 | 22995 | result->value->special = ConstValSpecialLazy; |
| 22996 | 22996 | |
| 22997 | 22997 | LazyValuePtrType *lazy_ptr_type = heap::c_allocator.create<LazyValuePtrType>(); |
| ... | ... | @@ -23031,8 +23031,8 @@ static IrInstGen *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstSrcPtrTy |
| 23031 | 23031 | return result; |
| 23032 | 23032 | } |
| 23033 | 23033 | |
| 23034 | static IrInstGen *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstSrcAlignCast *instruction) { | |
| 23035 | IrInstGen *target = instruction->target->child; | |
| 23034 | static Stage1AirInst *ir_analyze_instruction_align_cast(IrAnalyze *ira, Stage1ZirInstAlignCast *instruction) { | |
| 23035 | Stage1AirInst *target = instruction->target->child; | |
| 23036 | 23036 | if (type_is_invalid(target->value->type)) |
| 23037 | 23037 | return ira->codegen->invalid_inst_gen; |
| 23038 | 23038 | |
| ... | ... | @@ -23045,20 +23045,20 @@ static IrInstGen *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstSrcAli |
| 23045 | 23045 | } |
| 23046 | 23046 | |
| 23047 | 23047 | uint32_t align_bytes; |
| 23048 | IrInstGen *align_bytes_inst = instruction->align_bytes->child; | |
| 23048 | Stage1AirInst *align_bytes_inst = instruction->align_bytes->child; | |
| 23049 | 23049 | if (!ir_resolve_align(ira, align_bytes_inst, elem_type, &align_bytes)) |
| 23050 | 23050 | return ira->codegen->invalid_inst_gen; |
| 23051 | 23051 | |
| 23052 | IrInstGen *result = ir_align_cast(ira, target, align_bytes, true); | |
| 23052 | Stage1AirInst *result = ir_align_cast(ira, target, align_bytes, true); | |
| 23053 | 23053 | if (type_is_invalid(result->value->type)) |
| 23054 | 23054 | return ira->codegen->invalid_inst_gen; |
| 23055 | 23055 | |
| 23056 | 23056 | return result; |
| 23057 | 23057 | } |
| 23058 | 23058 | |
| 23059 | static IrInstGen *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstSrcSetAlignStack *instruction) { | |
| 23059 | static Stage1AirInst *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, Stage1ZirInstSetAlignStack *instruction) { | |
| 23060 | 23060 | uint32_t align_bytes; |
| 23061 | IrInstGen *align_bytes_inst = instruction->align_bytes->child; | |
| 23061 | Stage1AirInst *align_bytes_inst = instruction->align_bytes->child; | |
| 23062 | 23062 | if (!ir_resolve_align(ira, align_bytes_inst, nullptr, &align_bytes)) |
| 23063 | 23063 | return ira->codegen->invalid_inst_gen; |
| 23064 | 23064 | |
| ... | ... | @@ -23095,15 +23095,15 @@ static IrInstGen *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstS |
| 23095 | 23095 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 23096 | 23096 | } |
| 23097 | 23097 | |
| 23098 | static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgType *instruction, | |
| 23098 | static Stage1AirInst *ir_analyze_instruction_arg_type(IrAnalyze *ira, Stage1ZirInstArgType *instruction, | |
| 23099 | 23099 | bool allow_var) |
| 23100 | 23100 | { |
| 23101 | IrInstGen *fn_type_inst = instruction->fn_type->child; | |
| 23101 | Stage1AirInst *fn_type_inst = instruction->fn_type->child; | |
| 23102 | 23102 | ZigType *fn_type = ir_resolve_type(ira, fn_type_inst); |
| 23103 | 23103 | if (type_is_invalid(fn_type)) |
| 23104 | 23104 | return ira->codegen->invalid_inst_gen; |
| 23105 | 23105 | |
| 23106 | IrInstGen *arg_index_inst = instruction->arg_index->child; | |
| 23106 | Stage1AirInst *arg_index_inst = instruction->arg_index->child; | |
| 23107 | 23107 | uint64_t arg_index; |
| 23108 | 23108 | if (!ir_resolve_usize(ira, arg_index_inst, &arg_index)) |
| 23109 | 23109 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -23146,7 +23146,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy |
| 23146 | 23146 | return ir_const_type(ira, instruction->base.scope, instruction->base.source_node, result_type); |
| 23147 | 23147 | } |
| 23148 | 23148 | |
| 23149 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstGen *op) { | |
| 23149 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, Stage1AirInst *op) { | |
| 23150 | 23150 | ZigType *operand_type = ir_resolve_type(ira, op); |
| 23151 | 23151 | if (type_is_invalid(operand_type)) |
| 23152 | 23152 | return ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -23193,18 +23193,18 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstGen *op) { |
| 23193 | 23193 | return operand_type; |
| 23194 | 23194 | } |
| 23195 | 23195 | |
| 23196 | static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAtomicRmw *instruction) { | |
| 23196 | static Stage1AirInst *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, Stage1ZirInstAtomicRmw *instruction) { | |
| 23197 | 23197 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); |
| 23198 | 23198 | if (type_is_invalid(operand_type)) |
| 23199 | 23199 | return ira->codegen->invalid_inst_gen; |
| 23200 | 23200 | |
| 23201 | IrInstGen *ptr_inst = instruction->ptr->child; | |
| 23201 | Stage1AirInst *ptr_inst = instruction->ptr->child; | |
| 23202 | 23202 | if (type_is_invalid(ptr_inst->value->type)) |
| 23203 | 23203 | return ira->codegen->invalid_inst_gen; |
| 23204 | 23204 | |
| 23205 | 23205 | // TODO let this be volatile |
| 23206 | 23206 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 23207 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | |
| 23207 | Stage1AirInst *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | |
| 23208 | 23208 | if (type_is_invalid(casted_ptr->value->type)) |
| 23209 | 23209 | return ira->codegen->invalid_inst_gen; |
| 23210 | 23210 | |
| ... | ... | @@ -23227,11 +23227,11 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto |
| 23227 | 23227 | return ira->codegen->invalid_inst_gen; |
| 23228 | 23228 | } |
| 23229 | 23229 | |
| 23230 | IrInstGen *operand = instruction->operand->child; | |
| 23230 | Stage1AirInst *operand = instruction->operand->child; | |
| 23231 | 23231 | if (type_is_invalid(operand->value->type)) |
| 23232 | 23232 | return ira->codegen->invalid_inst_gen; |
| 23233 | 23233 | |
| 23234 | IrInstGen *casted_operand = ir_implicit_cast(ira, operand, operand_type); | |
| 23234 | Stage1AirInst *casted_operand = ir_implicit_cast(ira, operand, operand_type); | |
| 23235 | 23235 | if (type_is_invalid(casted_operand->value->type)) |
| 23236 | 23236 | return ira->codegen->invalid_inst_gen; |
| 23237 | 23237 | |
| ... | ... | @@ -23269,7 +23269,7 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto |
| 23269 | 23269 | if (op2_val == nullptr) |
| 23270 | 23270 | return ira->codegen->invalid_inst_gen; |
| 23271 | 23271 | |
| 23272 | IrInstGen *result = ir_const(ira, scope, source_node, operand_type); | |
| 23272 | Stage1AirInst *result = ir_const(ira, scope, source_node, operand_type); | |
| 23273 | 23273 | copy_const_val(ira->codegen, result->value, op1_val); |
| 23274 | 23274 | if (op == AtomicRmwOp_xchg) { |
| 23275 | 23275 | copy_const_val(ira->codegen, op1_val, op2_val); |
| ... | ... | @@ -23292,7 +23292,7 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto |
| 23292 | 23292 | // store op2 if op2 > op1 |
| 23293 | 23293 | bin_op = IrBinOpCmpLessThan; |
| 23294 | 23294 | |
| 23295 | IrInstGen *dummy_value = ir_const(ira, scope, source_node, operand_type); | |
| 23295 | Stage1AirInst *dummy_value = ir_const(ira, scope, source_node, operand_type); | |
| 23296 | 23296 | msg = ir_eval_bin_op_cmp_scalar(ira, scope, source_node, op1_val, bin_op, op2_val, dummy_value->value); |
| 23297 | 23297 | if (msg != nullptr) { |
| 23298 | 23298 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -23345,17 +23345,17 @@ static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAto |
| 23345 | 23345 | ordering, operand_type); |
| 23346 | 23346 | } |
| 23347 | 23347 | |
| 23348 | static IrInstGen *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstSrcAtomicLoad *instruction) { | |
| 23348 | static Stage1AirInst *ir_analyze_instruction_atomic_load(IrAnalyze *ira, Stage1ZirInstAtomicLoad *instruction) { | |
| 23349 | 23349 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); |
| 23350 | 23350 | if (type_is_invalid(operand_type)) |
| 23351 | 23351 | return ira->codegen->invalid_inst_gen; |
| 23352 | 23352 | |
| 23353 | IrInstGen *ptr_inst = instruction->ptr->child; | |
| 23353 | Stage1AirInst *ptr_inst = instruction->ptr->child; | |
| 23354 | 23354 | if (type_is_invalid(ptr_inst->value->type)) |
| 23355 | 23355 | return ira->codegen->invalid_inst_gen; |
| 23356 | 23356 | |
| 23357 | 23357 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true); |
| 23358 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | |
| 23358 | Stage1AirInst *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | |
| 23359 | 23359 | if (type_is_invalid(casted_ptr->value->type)) |
| 23360 | 23360 | return ira->codegen->invalid_inst_gen; |
| 23361 | 23361 | |
| ... | ... | @@ -23371,7 +23371,7 @@ static IrInstGen *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstSrcAt |
| 23371 | 23371 | } |
| 23372 | 23372 | |
| 23373 | 23373 | if (instr_is_comptime(casted_ptr)) { |
| 23374 | IrInstGen *result = ir_get_deref(ira, instruction->base.scope, | |
| 23374 | Stage1AirInst *result = ir_get_deref(ira, instruction->base.scope, | |
| 23375 | 23375 | instruction->base.source_node, casted_ptr, nullptr); |
| 23376 | 23376 | src_assert(result->value->type != nullptr, instruction->base.source_node); |
| 23377 | 23377 | return result; |
| ... | ... | @@ -23380,25 +23380,25 @@ static IrInstGen *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstSrcAt |
| 23380 | 23380 | return ir_build_atomic_load_gen(ira, instruction->base.scope, instruction->base.source_node, casted_ptr, ordering, operand_type); |
| 23381 | 23381 | } |
| 23382 | 23382 | |
| 23383 | static IrInstGen *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInstSrcAtomicStore *instruction) { | |
| 23383 | static Stage1AirInst *ir_analyze_instruction_atomic_store(IrAnalyze *ira, Stage1ZirInstAtomicStore *instruction) { | |
| 23384 | 23384 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); |
| 23385 | 23385 | if (type_is_invalid(operand_type)) |
| 23386 | 23386 | return ira->codegen->invalid_inst_gen; |
| 23387 | 23387 | |
| 23388 | IrInstGen *ptr_inst = instruction->ptr->child; | |
| 23388 | Stage1AirInst *ptr_inst = instruction->ptr->child; | |
| 23389 | 23389 | if (type_is_invalid(ptr_inst->value->type)) |
| 23390 | 23390 | return ira->codegen->invalid_inst_gen; |
| 23391 | 23391 | |
| 23392 | 23392 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 23393 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | |
| 23393 | Stage1AirInst *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | |
| 23394 | 23394 | if (type_is_invalid(casted_ptr->value->type)) |
| 23395 | 23395 | return ira->codegen->invalid_inst_gen; |
| 23396 | 23396 | |
| 23397 | IrInstGen *value = instruction->value->child; | |
| 23397 | Stage1AirInst *value = instruction->value->child; | |
| 23398 | 23398 | if (type_is_invalid(value->value->type)) |
| 23399 | 23399 | return ira->codegen->invalid_inst_gen; |
| 23400 | 23400 | |
| 23401 | IrInstGen *casted_value = ir_implicit_cast(ira, value, operand_type); | |
| 23401 | Stage1AirInst *casted_value = ir_implicit_cast(ira, value, operand_type); | |
| 23402 | 23402 | if (type_is_invalid(casted_value->value->type)) |
| 23403 | 23403 | return ira->codegen->invalid_inst_gen; |
| 23404 | 23404 | |
| ... | ... | @@ -23425,7 +23425,7 @@ static IrInstGen *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInstSrcA |
| 23425 | 23425 | } |
| 23426 | 23426 | |
| 23427 | 23427 | if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) { |
| 23428 | IrInstGen *result = ir_analyze_store_ptr(ira, instruction->base.scope, instruction->base.source_node, casted_ptr, value, false); | |
| 23428 | Stage1AirInst *result = ir_analyze_store_ptr(ira, instruction->base.scope, instruction->base.source_node, casted_ptr, value, false); | |
| 23429 | 23429 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 23430 | 23430 | return result; |
| 23431 | 23431 | } |
| ... | ... | @@ -23433,7 +23433,7 @@ static IrInstGen *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInstSrcA |
| 23433 | 23433 | return ir_build_atomic_store_gen(ira, instruction->base.scope, instruction->base.source_node, casted_ptr, casted_value, ordering); |
| 23434 | 23434 | } |
| 23435 | 23435 | |
| 23436 | static IrInstGen *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstSrcSaveErrRetAddr *instruction) { | |
| 23436 | static Stage1AirInst *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, Stage1ZirInstSaveErrRetAddr *instruction) { | |
| 23437 | 23437 | return ir_build_save_err_ret_addr_gen(ira, instruction->base.scope, instruction->base.source_node); |
| 23438 | 23438 | } |
| 23439 | 23439 | |
| ... | ... | @@ -23660,8 +23660,8 @@ static ErrorMsg *ir_eval_float_op(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 23660 | 23660 | return nullptr; |
| 23661 | 23661 | } |
| 23662 | 23662 | |
| 23663 | static IrInstGen *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstSrcFloatOp *instruction) { | |
| 23664 | IrInstGen *operand = instruction->operand->child; | |
| 23663 | static Stage1AirInst *ir_analyze_instruction_float_op(IrAnalyze *ira, Stage1ZirInstFloatOp *instruction) { | |
| 23664 | Stage1AirInst *operand = instruction->operand->child; | |
| 23665 | 23665 | ZigType *operand_type = operand->value->type; |
| 23666 | 23666 | if (type_is_invalid(operand_type)) |
| 23667 | 23667 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -23683,7 +23683,7 @@ static IrInstGen *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstSrcFloat |
| 23683 | 23683 | if (operand_val->special == ConstValSpecialUndef) |
| 23684 | 23684 | return ir_const_undef(ira, instruction->base.scope, instruction->base.source_node, operand_type); |
| 23685 | 23685 | |
| 23686 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, operand_type); | |
| 23686 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, operand_type); | |
| 23687 | 23687 | ZigValue *out_val = result->value; |
| 23688 | 23688 | |
| 23689 | 23689 | if (operand_type->id == ZigTypeIdVector) { |
| ... | ... | @@ -23722,14 +23722,14 @@ static IrInstGen *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstSrcFloat |
| 23722 | 23722 | return ir_build_float_op_gen(ira, instruction->base.scope, instruction->base.source_node, operand, instruction->fn_id, operand_type); |
| 23723 | 23723 | } |
| 23724 | 23724 | |
| 23725 | static IrInstGen *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstSrcBswap *instruction) { | |
| 23725 | static Stage1AirInst *ir_analyze_instruction_bswap(IrAnalyze *ira, Stage1ZirInstBswap *instruction) { | |
| 23726 | 23726 | Error err; |
| 23727 | 23727 | |
| 23728 | 23728 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 23729 | 23729 | if (type_is_invalid(int_type)) |
| 23730 | 23730 | return ira->codegen->invalid_inst_gen; |
| 23731 | 23731 | |
| 23732 | IrInstGen *uncasted_op = instruction->op->child; | |
| 23732 | Stage1AirInst *uncasted_op = instruction->op->child; | |
| 23733 | 23733 | if (type_is_invalid(uncasted_op->value->type)) |
| 23734 | 23734 | return ira->codegen->invalid_inst_gen; |
| 23735 | 23735 | |
| ... | ... | @@ -23751,7 +23751,7 @@ static IrInstGen *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstSrcBswap *i |
| 23751 | 23751 | bool is_vector = (vector_len != UINT32_MAX); |
| 23752 | 23752 | ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type; |
| 23753 | 23753 | |
| 23754 | IrInstGen *op = ir_implicit_cast(ira, uncasted_op, op_type); | |
| 23754 | Stage1AirInst *op = ir_implicit_cast(ira, uncasted_op, op_type); | |
| 23755 | 23755 | if (type_is_invalid(op->value->type)) |
| 23756 | 23756 | return ira->codegen->invalid_inst_gen; |
| 23757 | 23757 | |
| ... | ... | @@ -23772,7 +23772,7 @@ static IrInstGen *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstSrcBswap *i |
| 23772 | 23772 | if (val->special == ConstValSpecialUndef) |
| 23773 | 23773 | return ir_const_undef(ira, instruction->base.scope, instruction->base.source_node, op_type); |
| 23774 | 23774 | |
| 23775 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, op_type); | |
| 23775 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, op_type); | |
| 23776 | 23776 | const size_t buf_size = int_type->data.integral.bit_count / 8; |
| 23777 | 23777 | uint8_t *buf = heap::c_allocator.allocate_nonzero<uint8_t>(buf_size); |
| 23778 | 23778 | if (is_vector) { |
| ... | ... | @@ -23808,17 +23808,17 @@ static IrInstGen *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstSrcBswap *i |
| 23808 | 23808 | return ir_build_bswap_gen(ira, instruction->base.scope, instruction->base.source_node, op_type, op); |
| 23809 | 23809 | } |
| 23810 | 23810 | |
| 23811 | static IrInstGen *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstSrcBitReverse *instruction) { | |
| 23811 | static Stage1AirInst *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, Stage1ZirInstBitReverse *instruction) { | |
| 23812 | 23812 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 23813 | 23813 | if (type_is_invalid(int_type)) |
| 23814 | 23814 | return ira->codegen->invalid_inst_gen; |
| 23815 | 23815 | |
| 23816 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); | |
| 23816 | Stage1AirInst *op = ir_implicit_cast(ira, instruction->op->child, int_type); | |
| 23817 | 23817 | if (type_is_invalid(op->value->type)) |
| 23818 | 23818 | return ira->codegen->invalid_inst_gen; |
| 23819 | 23819 | |
| 23820 | 23820 | if (int_type->data.integral.bit_count == 0) { |
| 23821 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, int_type); | |
| 23821 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, int_type); | |
| 23822 | 23822 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 23823 | 23823 | return result; |
| 23824 | 23824 | } |
| ... | ... | @@ -23830,7 +23830,7 @@ static IrInstGen *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstSrcBi |
| 23830 | 23830 | if (val->special == ConstValSpecialUndef) |
| 23831 | 23831 | return ir_const_undef(ira, instruction->base.scope, instruction->base.source_node, int_type); |
| 23832 | 23832 | |
| 23833 | IrInstGen *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, int_type); | |
| 23833 | Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, int_type); | |
| 23834 | 23834 | size_t num_bits = int_type->data.integral.bit_count; |
| 23835 | 23835 | size_t buf_size = (num_bits + 7) / 8; |
| 23836 | 23836 | uint8_t *comptime_buf = heap::c_allocator.allocate_nonzero<uint8_t>(buf_size); |
| ... | ... | @@ -23863,17 +23863,17 @@ static IrInstGen *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstSrcBi |
| 23863 | 23863 | } |
| 23864 | 23864 | |
| 23865 | 23865 | |
| 23866 | static IrInstGen *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstSrcEnumToInt *instruction) { | |
| 23867 | IrInstGen *target = instruction->target->child; | |
| 23866 | static Stage1AirInst *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, Stage1ZirInstEnumToInt *instruction) { | |
| 23867 | Stage1AirInst *target = instruction->target->child; | |
| 23868 | 23868 | if (type_is_invalid(target->value->type)) |
| 23869 | 23869 | return ira->codegen->invalid_inst_gen; |
| 23870 | 23870 | |
| 23871 | 23871 | return ir_analyze_enum_to_int(ira, instruction->base.scope, instruction->base.source_node, target); |
| 23872 | 23872 | } |
| 23873 | 23873 | |
| 23874 | static IrInstGen *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstSrcIntToEnum *instruction) { | |
| 23874 | static Stage1AirInst *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, Stage1ZirInstIntToEnum *instruction) { | |
| 23875 | 23875 | Error err; |
| 23876 | IrInstGen *dest_type_value = instruction->dest_type->child; | |
| 23876 | Stage1AirInst *dest_type_value = instruction->dest_type->child; | |
| 23877 | 23877 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 23878 | 23878 | if (type_is_invalid(dest_type)) |
| 23879 | 23879 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -23889,24 +23889,24 @@ static IrInstGen *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstSrcIn |
| 23889 | 23889 | |
| 23890 | 23890 | ZigType *tag_type = dest_type->data.enumeration.tag_int_type; |
| 23891 | 23891 | |
| 23892 | IrInstGen *target = instruction->target->child; | |
| 23892 | Stage1AirInst *target = instruction->target->child; | |
| 23893 | 23893 | if (type_is_invalid(target->value->type)) |
| 23894 | 23894 | return ira->codegen->invalid_inst_gen; |
| 23895 | 23895 | |
| 23896 | IrInstGen *casted_target = ir_implicit_cast(ira, target, tag_type); | |
| 23896 | Stage1AirInst *casted_target = ir_implicit_cast(ira, target, tag_type); | |
| 23897 | 23897 | if (type_is_invalid(casted_target->value->type)) |
| 23898 | 23898 | return ira->codegen->invalid_inst_gen; |
| 23899 | 23899 | |
| 23900 | 23900 | return ir_analyze_int_to_enum(ira, instruction->base.scope, instruction->base.source_node, casted_target, dest_type); |
| 23901 | 23901 | } |
| 23902 | 23902 | |
| 23903 | static IrInstGen *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira, IrInstSrcCheckRuntimeScope *instruction) { | |
| 23904 | IrInstGen *block_comptime_inst = instruction->scope_is_comptime->child; | |
| 23903 | static Stage1AirInst *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira, Stage1ZirInstCheckRuntimeScope *instruction) { | |
| 23904 | Stage1AirInst *block_comptime_inst = instruction->scope_is_comptime->child; | |
| 23905 | 23905 | bool scope_is_comptime; |
| 23906 | 23906 | if (!ir_resolve_bool(ira, block_comptime_inst, &scope_is_comptime)) |
| 23907 | 23907 | return ira->codegen->invalid_inst_gen; |
| 23908 | 23908 | |
| 23909 | IrInstGen *is_comptime_inst = instruction->is_comptime->child; | |
| 23909 | Stage1AirInst *is_comptime_inst = instruction->is_comptime->child; | |
| 23910 | 23910 | bool is_comptime; |
| 23911 | 23911 | if (!ir_resolve_bool(ira, is_comptime_inst, &is_comptime)) |
| 23912 | 23912 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -23922,7 +23922,7 @@ static IrInstGen *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira, IrI |
| 23922 | 23922 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 23923 | 23923 | } |
| 23924 | 23924 | |
| 23925 | static IrInstGen *ir_analyze_instruction_has_decl(IrAnalyze *ira, IrInstSrcHasDecl *instruction) { | |
| 23925 | static Stage1AirInst *ir_analyze_instruction_has_decl(IrAnalyze *ira, Stage1ZirInstHasDecl *instruction) { | |
| 23926 | 23926 | ZigType *container_type = ir_resolve_type(ira, instruction->container->child); |
| 23927 | 23927 | if (type_is_invalid(container_type)) |
| 23928 | 23928 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -23965,7 +23965,7 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode |
| 23965 | 23965 | scope_decls->decl_table.put(var_name, &tld_var->base); |
| 23966 | 23966 | } |
| 23967 | 23967 | |
| 23968 | static IrInstGen *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, IrInstSrcUndeclaredIdent *instruction) { | |
| 23968 | static Stage1AirInst *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, Stage1ZirInstUndeclaredIdent *instruction) { | |
| 23969 | 23969 | // put a variable of same name with invalid type in global scope |
| 23970 | 23970 | // so that future references to this same name will find a variable with an invalid type |
| 23971 | 23971 | populate_invalid_variable_in_scope(ira->codegen, instruction->base.scope, |
| ... | ... | @@ -23975,13 +23975,13 @@ static IrInstGen *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, IrInst |
| 23975 | 23975 | return ira->codegen->invalid_inst_gen; |
| 23976 | 23976 | } |
| 23977 | 23977 | |
| 23978 | static IrInstGen *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstSrcEndExpr *instruction) { | |
| 23979 | IrInstGen *value = instruction->value->child; | |
| 23978 | static Stage1AirInst *ir_analyze_instruction_end_expr(IrAnalyze *ira, Stage1ZirInstEndExpr *instruction) { | |
| 23979 | Stage1AirInst *value = instruction->value->child; | |
| 23980 | 23980 | if (type_is_invalid(value->value->type)) |
| 23981 | 23981 | return ira->codegen->invalid_inst_gen; |
| 23982 | 23982 | |
| 23983 | 23983 | bool was_written = instruction->result_loc->written; |
| 23984 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | |
| 23984 | Stage1AirInst *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | |
| 23985 | 23985 | value->value->type, value, false, true); |
| 23986 | 23986 | if (result_loc != nullptr) { |
| 23987 | 23987 | if (type_is_invalid(result_loc->value->type)) |
| ... | ... | @@ -23990,7 +23990,7 @@ static IrInstGen *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstSrcEndEx |
| 23990 | 23990 | return result_loc; |
| 23991 | 23991 | |
| 23992 | 23992 | if (!was_written || instruction->result_loc->id == ResultLocIdPeer) { |
| 23993 | IrInstGen *store_ptr = ir_analyze_store_ptr(ira, instruction->base.scope, instruction->base.source_node, result_loc, value, | |
| 23993 | Stage1AirInst *store_ptr = ir_analyze_store_ptr(ira, instruction->base.scope, instruction->base.source_node, result_loc, value, | |
| 23994 | 23994 | instruction->result_loc->allow_write_through_const); |
| 23995 | 23995 | if (type_is_invalid(store_ptr->value->type)) { |
| 23996 | 23996 | if (instruction->result_loc->id == ResultLocIdReturn && |
| ... | ... | @@ -24018,8 +24018,8 @@ static IrInstGen *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstSrcEndEx |
| 24018 | 24018 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 24019 | 24019 | } |
| 24020 | 24020 | |
| 24021 | static IrInstGen *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrInstSrcImplicitCast *instruction) { | |
| 24022 | IrInstGen *operand = instruction->operand->child; | |
| 24021 | static Stage1AirInst *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, Stage1ZirInstImplicitCast *instruction) { | |
| 24022 | Stage1AirInst *operand = instruction->operand->child; | |
| 24023 | 24023 | if (type_is_invalid(operand->value->type)) |
| 24024 | 24024 | return operand; |
| 24025 | 24025 | |
| ... | ... | @@ -24030,12 +24030,12 @@ static IrInstGen *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrInstSrc |
| 24030 | 24030 | operand, dest_type); |
| 24031 | 24031 | } |
| 24032 | 24032 | |
| 24033 | static IrInstGen *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstSrcBitCast *instruction) { | |
| 24034 | IrInstGen *operand = instruction->operand->child; | |
| 24033 | static Stage1AirInst *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, Stage1ZirInstBitCast *instruction) { | |
| 24034 | Stage1AirInst *operand = instruction->operand->child; | |
| 24035 | 24035 | if (type_is_invalid(operand->value->type)) |
| 24036 | 24036 | return operand; |
| 24037 | 24037 | |
| 24038 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base, | |
| 24038 | Stage1AirInst *result_loc = ir_resolve_result(ira, &instruction->base, | |
| 24039 | 24039 | &instruction->result_loc_bit_cast->base, operand->value->type, operand, false, true); |
| 24040 | 24040 | if (result_loc != nullptr && |
| 24041 | 24041 | (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable)) |
| ... | ... | @@ -24050,8 +24050,8 @@ static IrInstGen *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstSrcB |
| 24050 | 24050 | return ir_analyze_bit_cast(ira, instruction->base.scope, instruction->base.source_node, operand, dest_type); |
| 24051 | 24051 | } |
| 24052 | 24052 | |
| 24053 | static IrInstGen *ir_analyze_instruction_union_init_named_field(IrAnalyze *ira, | |
| 24054 | IrInstSrcUnionInitNamedField *instruction) | |
| 24053 | static Stage1AirInst *ir_analyze_instruction_union_init_named_field(IrAnalyze *ira, | |
| 24054 | Stage1ZirInstUnionInitNamedField *instruction) | |
| 24055 | 24055 | { |
| 24056 | 24056 | ZigType *union_type = ir_resolve_type(ira, instruction->union_type->child); |
| 24057 | 24057 | if (type_is_invalid(union_type)) |
| ... | ... | @@ -24067,11 +24067,11 @@ static IrInstGen *ir_analyze_instruction_union_init_named_field(IrAnalyze *ira, |
| 24067 | 24067 | if (field_name == nullptr) |
| 24068 | 24068 | return ira->codegen->invalid_inst_gen; |
| 24069 | 24069 | |
| 24070 | IrInstGen *field_result_loc = instruction->field_result_loc->child; | |
| 24070 | Stage1AirInst *field_result_loc = instruction->field_result_loc->child; | |
| 24071 | 24071 | if (type_is_invalid(field_result_loc->value->type)) |
| 24072 | 24072 | return ira->codegen->invalid_inst_gen; |
| 24073 | 24073 | |
| 24074 | IrInstGen *result_loc = instruction->result_loc->child; | |
| 24074 | Stage1AirInst *result_loc = instruction->result_loc->child; | |
| 24075 | 24075 | if (type_is_invalid(result_loc->value->type)) |
| 24076 | 24076 | return ira->codegen->invalid_inst_gen; |
| 24077 | 24077 | |
| ... | ... | @@ -24079,16 +24079,16 @@ static IrInstGen *ir_analyze_instruction_union_init_named_field(IrAnalyze *ira, |
| 24079 | 24079 | union_type, field_name, field_result_loc, result_loc); |
| 24080 | 24080 | } |
| 24081 | 24081 | |
| 24082 | static IrInstGen *ir_analyze_instruction_suspend_begin(IrAnalyze *ira, IrInstSrcSuspendBegin *instruction) { | |
| 24082 | static Stage1AirInst *ir_analyze_instruction_suspend_begin(IrAnalyze *ira, Stage1ZirInstSuspendBegin *instruction) { | |
| 24083 | 24083 | return ir_build_suspend_begin_gen(ira, instruction->base.scope, instruction->base.source_node); |
| 24084 | 24084 | } |
| 24085 | 24085 | |
| 24086 | static IrInstGen *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, IrInstSrcSuspendFinish *instruction) { | |
| 24087 | IrInstGen *begin_base = instruction->begin->base.child; | |
| 24086 | static Stage1AirInst *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, Stage1ZirInstSuspendFinish *instruction) { | |
| 24087 | Stage1AirInst *begin_base = instruction->begin->base.child; | |
| 24088 | 24088 | if (type_is_invalid(begin_base->value->type)) |
| 24089 | 24089 | return ira->codegen->invalid_inst_gen; |
| 24090 | src_assert(begin_base->id == IrInstGenIdSuspendBegin, instruction->base.source_node); | |
| 24091 | IrInstGenSuspendBegin *begin = reinterpret_cast<IrInstGenSuspendBegin *>(begin_base); | |
| 24090 | src_assert(begin_base->id == Stage1AirInstIdSuspendBegin, instruction->base.source_node); | |
| 24091 | Stage1AirInstSuspendBegin *begin = reinterpret_cast<Stage1AirInstSuspendBegin *>(begin_base); | |
| 24092 | 24092 | |
| 24093 | 24093 | ZigFn *fn_entry = ira->fn; |
| 24094 | 24094 | src_assert(fn_entry != nullptr, instruction->base.source_node); |
| ... | ... | @@ -24100,8 +24100,8 @@ static IrInstGen *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, IrInstSr |
| 24100 | 24100 | return ir_build_suspend_finish_gen(ira, instruction->base.scope, instruction->base.source_node, begin); |
| 24101 | 24101 | } |
| 24102 | 24102 | |
| 24103 | static IrInstGen *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 24104 | IrInstGen *frame_ptr, ZigFn **target_fn) | |
| 24103 | static Stage1AirInst *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, Scope *scope, AstNode *source_node, | |
| 24104 | Stage1AirInst *frame_ptr, ZigFn **target_fn) | |
| 24105 | 24105 | { |
| 24106 | 24106 | if (type_is_invalid(frame_ptr->value->type)) |
| 24107 | 24107 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -24109,7 +24109,7 @@ static IrInstGen *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, Scope *scope, |
| 24109 | 24109 | *target_fn = nullptr; |
| 24110 | 24110 | |
| 24111 | 24111 | ZigType *result_type; |
| 24112 | IrInstGen *frame; | |
| 24112 | Stage1AirInst *frame; | |
| 24113 | 24113 | if (frame_ptr->value->type->id == ZigTypeIdPointer && |
| 24114 | 24114 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 24115 | 24115 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| ... | ... | @@ -24139,19 +24139,19 @@ static IrInstGen *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, Scope *scope, |
| 24139 | 24139 | } |
| 24140 | 24140 | |
| 24141 | 24141 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); |
| 24142 | IrInstGen *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); | |
| 24142 | Stage1AirInst *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); | |
| 24143 | 24143 | if (type_is_invalid(casted_frame->value->type)) |
| 24144 | 24144 | return ira->codegen->invalid_inst_gen; |
| 24145 | 24145 | |
| 24146 | 24146 | return casted_frame; |
| 24147 | 24147 | } |
| 24148 | 24148 | |
| 24149 | static IrInstGen *ir_analyze_instruction_await(IrAnalyze *ira, IrInstSrcAwait *instruction) { | |
| 24150 | IrInstGen *operand = instruction->frame->child; | |
| 24149 | static Stage1AirInst *ir_analyze_instruction_await(IrAnalyze *ira, Stage1ZirInstAwait *instruction) { | |
| 24150 | Stage1AirInst *operand = instruction->frame->child; | |
| 24151 | 24151 | if (type_is_invalid(operand->value->type)) |
| 24152 | 24152 | return ira->codegen->invalid_inst_gen; |
| 24153 | 24153 | ZigFn *target_fn; |
| 24154 | IrInstGen *frame = analyze_frame_ptr_to_anyframe_T(ira, instruction->base.scope, instruction->base.source_node, operand, &target_fn); | |
| 24154 | Stage1AirInst *frame = analyze_frame_ptr_to_anyframe_T(ira, instruction->base.scope, instruction->base.source_node, operand, &target_fn); | |
| 24155 | 24155 | if (type_is_invalid(frame->value->type)) |
| 24156 | 24156 | return ira->codegen->invalid_inst_gen; |
| 24157 | 24157 | |
| ... | ... | @@ -24171,7 +24171,7 @@ static IrInstGen *ir_analyze_instruction_await(IrAnalyze *ira, IrInstSrcAwait *i |
| 24171 | 24171 | fn_entry->calls_or_awaits_errorable_fn = true; |
| 24172 | 24172 | } |
| 24173 | 24173 | |
| 24174 | IrInstGen *result_loc; | |
| 24174 | Stage1AirInst *result_loc; | |
| 24175 | 24175 | if (type_has_bits(ira->codegen, result_type)) { |
| 24176 | 24176 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 24177 | 24177 | result_type, nullptr, true, true); |
| ... | ... | @@ -24184,19 +24184,19 @@ static IrInstGen *ir_analyze_instruction_await(IrAnalyze *ira, IrInstSrcAwait *i |
| 24184 | 24184 | result_loc = nullptr; |
| 24185 | 24185 | } |
| 24186 | 24186 | |
| 24187 | IrInstGenAwait *result = ir_build_await_gen(ira, instruction->base.scope, instruction->base.source_node, frame, result_type, result_loc, | |
| 24187 | Stage1AirInstAwait *result = ir_build_await_gen(ira, instruction->base.scope, instruction->base.source_node, frame, result_type, result_loc, | |
| 24188 | 24188 | instruction->is_nosuspend); |
| 24189 | 24189 | result->target_fn = target_fn; |
| 24190 | 24190 | fn_entry->await_list.append(result); |
| 24191 | 24191 | return ir_finish_anal(ira, &result->base); |
| 24192 | 24192 | } |
| 24193 | 24193 | |
| 24194 | static IrInstGen *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstSrcResume *instruction) { | |
| 24195 | IrInstGen *frame_ptr = instruction->frame->child; | |
| 24194 | static Stage1AirInst *ir_analyze_instruction_resume(IrAnalyze *ira, Stage1ZirInstResume *instruction) { | |
| 24195 | Stage1AirInst *frame_ptr = instruction->frame->child; | |
| 24196 | 24196 | if (type_is_invalid(frame_ptr->value->type)) |
| 24197 | 24197 | return ira->codegen->invalid_inst_gen; |
| 24198 | 24198 | |
| 24199 | IrInstGen *frame; | |
| 24199 | Stage1AirInst *frame; | |
| 24200 | 24200 | if (frame_ptr->value->type->id == ZigTypeIdPointer && |
| 24201 | 24201 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 24202 | 24202 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| ... | ... | @@ -24208,7 +24208,7 @@ static IrInstGen *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstSrcResume |
| 24208 | 24208 | } |
| 24209 | 24209 | |
| 24210 | 24210 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); |
| 24211 | IrInstGen *casted_frame = ir_implicit_cast2(ira, instruction->frame->scope, | |
| 24211 | Stage1AirInst *casted_frame = ir_implicit_cast2(ira, instruction->frame->scope, | |
| 24212 | 24212 | instruction->frame->source_node, frame, any_frame_type); |
| 24213 | 24213 | if (type_is_invalid(casted_frame->value->type)) |
| 24214 | 24214 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -24216,11 +24216,11 @@ static IrInstGen *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstSrcResume |
| 24216 | 24216 | return ir_build_resume_gen(ira, instruction->base.scope, instruction->base.source_node, casted_frame); |
| 24217 | 24217 | } |
| 24218 | 24218 | |
| 24219 | static IrInstGen *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstSrcSpillBegin *instruction) { | |
| 24219 | static Stage1AirInst *ir_analyze_instruction_spill_begin(IrAnalyze *ira, Stage1ZirInstSpillBegin *instruction) { | |
| 24220 | 24220 | if (ir_should_inline(ira->zir, instruction->base.scope)) |
| 24221 | 24221 | return ir_const_void(ira, instruction->base.scope, instruction->base.source_node); |
| 24222 | 24222 | |
| 24223 | IrInstGen *operand = instruction->operand->child; | |
| 24223 | Stage1AirInst *operand = instruction->operand->child; | |
| 24224 | 24224 | if (type_is_invalid(operand->value->type)) |
| 24225 | 24225 | return ira->codegen->invalid_inst_gen; |
| 24226 | 24226 | |
| ... | ... | @@ -24238,8 +24238,8 @@ static IrInstGen *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstSrcSp |
| 24238 | 24238 | return ir_build_spill_begin_gen(ira, instruction->base.scope, instruction->base.source_node, operand, instruction->spill_id); |
| 24239 | 24239 | } |
| 24240 | 24240 | |
| 24241 | static IrInstGen *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstSrcSpillEnd *instruction) { | |
| 24242 | IrInstGen *operand = instruction->begin->operand->child; | |
| 24241 | static Stage1AirInst *ir_analyze_instruction_spill_end(IrAnalyze *ira, Stage1ZirInstSpillEnd *instruction) { | |
| 24242 | Stage1AirInst *operand = instruction->begin->operand->child; | |
| 24243 | 24243 | if (type_is_invalid(operand->value->type)) |
| 24244 | 24244 | return ira->codegen->invalid_inst_gen; |
| 24245 | 24245 | |
| ... | ... | @@ -24250,13 +24250,13 @@ static IrInstGen *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstSrcSpil |
| 24250 | 24250 | return operand; |
| 24251 | 24251 | } |
| 24252 | 24252 | |
| 24253 | src_assert(instruction->begin->base.child->id == IrInstGenIdSpillBegin, instruction->base.source_node); | |
| 24254 | IrInstGenSpillBegin *begin = reinterpret_cast<IrInstGenSpillBegin *>(instruction->begin->base.child); | |
| 24253 | src_assert(instruction->begin->base.child->id == Stage1AirInstIdSpillBegin, instruction->base.source_node); | |
| 24254 | Stage1AirInstSpillBegin *begin = reinterpret_cast<Stage1AirInstSpillBegin *>(instruction->begin->base.child); | |
| 24255 | 24255 | |
| 24256 | 24256 | return ir_build_spill_end_gen(ira, instruction->base.scope, instruction->base.source_node, begin, operand->value->type); |
| 24257 | 24257 | } |
| 24258 | 24258 | |
| 24259 | static IrInstGen *ir_analyze_instruction_src(IrAnalyze *ira, IrInstSrcSrc *instruction) { | |
| 24259 | static Stage1AirInst *ir_analyze_instruction_src(IrAnalyze *ira, Stage1ZirInstSrc *instruction) { | |
| 24260 | 24260 | ZigFn *fn_entry = scope_fn_entry(instruction->base.scope); |
| 24261 | 24261 | if (fn_entry == nullptr) { |
| 24262 | 24262 | ir_add_error_node(ira, instruction->base.source_node, buf_sprintf("@src outside function")); |
| ... | ... | @@ -24318,289 +24318,289 @@ static IrInstGen *ir_analyze_instruction_src(IrAnalyze *ira, IrInstSrcSrc *instr |
| 24318 | 24318 | return ir_const_move(ira, instruction->base.scope, instruction->base.source_node, result); |
| 24319 | 24319 | } |
| 24320 | 24320 | |
| 24321 | static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruction) { | |
| 24321 | static Stage1AirInst *ir_analyze_instruction_base(IrAnalyze *ira, Stage1ZirInst *instruction) { | |
| 24322 | 24322 | switch (instruction->id) { |
| 24323 | case IrInstSrcIdInvalid: | |
| 24323 | case Stage1ZirInstIdInvalid: | |
| 24324 | 24324 | zig_unreachable(); |
| 24325 | 24325 | |
| 24326 | case IrInstSrcIdReturn: | |
| 24327 | return ir_analyze_instruction_return(ira, (IrInstSrcReturn *)instruction); | |
| 24328 | case IrInstSrcIdConst: | |
| 24329 | return ir_analyze_instruction_const(ira, (IrInstSrcConst *)instruction); | |
| 24330 | case IrInstSrcIdUnOp: | |
| 24331 | return ir_analyze_instruction_un_op(ira, (IrInstSrcUnOp *)instruction); | |
| 24332 | case IrInstSrcIdBinOp: | |
| 24333 | return ir_analyze_instruction_bin_op(ira, (IrInstSrcBinOp *)instruction); | |
| 24334 | case IrInstSrcIdMergeErrSets: | |
| 24335 | return ir_analyze_instruction_merge_err_sets(ira, (IrInstSrcMergeErrSets *)instruction); | |
| 24336 | case IrInstSrcIdDeclVar: | |
| 24337 | return ir_analyze_instruction_decl_var(ira, (IrInstSrcDeclVar *)instruction); | |
| 24338 | case IrInstSrcIdLoadPtr: | |
| 24339 | return ir_analyze_instruction_load_ptr(ira, (IrInstSrcLoadPtr *)instruction); | |
| 24340 | case IrInstSrcIdStorePtr: | |
| 24341 | return ir_analyze_instruction_store_ptr(ira, (IrInstSrcStorePtr *)instruction); | |
| 24342 | case IrInstSrcIdElemPtr: | |
| 24343 | return ir_analyze_instruction_elem_ptr(ira, (IrInstSrcElemPtr *)instruction); | |
| 24344 | case IrInstSrcIdVarPtr: | |
| 24345 | return ir_analyze_instruction_var_ptr(ira, (IrInstSrcVarPtr *)instruction); | |
| 24346 | case IrInstSrcIdFieldPtr: | |
| 24347 | return ir_analyze_instruction_field_ptr(ira, (IrInstSrcFieldPtr *)instruction); | |
| 24348 | case IrInstSrcIdCall: | |
| 24349 | return ir_analyze_instruction_call(ira, (IrInstSrcCall *)instruction); | |
| 24350 | case IrInstSrcIdCallArgs: | |
| 24351 | return ir_analyze_instruction_call_args(ira, (IrInstSrcCallArgs *)instruction); | |
| 24352 | case IrInstSrcIdCallExtra: | |
| 24353 | return ir_analyze_instruction_call_extra(ira, (IrInstSrcCallExtra *)instruction); | |
| 24354 | case IrInstSrcIdAsyncCallExtra: | |
| 24355 | return ir_analyze_instruction_async_call_extra(ira, (IrInstSrcAsyncCallExtra *)instruction); | |
| 24356 | case IrInstSrcIdBr: | |
| 24357 | return ir_analyze_instruction_br(ira, (IrInstSrcBr *)instruction); | |
| 24358 | case IrInstSrcIdCondBr: | |
| 24359 | return ir_analyze_instruction_cond_br(ira, (IrInstSrcCondBr *)instruction); | |
| 24360 | case IrInstSrcIdUnreachable: | |
| 24361 | return ir_analyze_instruction_unreachable(ira, (IrInstSrcUnreachable *)instruction); | |
| 24362 | case IrInstSrcIdPhi: | |
| 24363 | return ir_analyze_instruction_phi(ira, (IrInstSrcPhi *)instruction); | |
| 24364 | case IrInstSrcIdTypeOf: | |
| 24365 | return ir_analyze_instruction_typeof(ira, (IrInstSrcTypeOf *)instruction); | |
| 24366 | case IrInstSrcIdSetCold: | |
| 24367 | return ir_analyze_instruction_set_cold(ira, (IrInstSrcSetCold *)instruction); | |
| 24368 | case IrInstSrcIdSetRuntimeSafety: | |
| 24369 | return ir_analyze_instruction_set_runtime_safety(ira, (IrInstSrcSetRuntimeSafety *)instruction); | |
| 24370 | case IrInstSrcIdSetFloatMode: | |
| 24371 | return ir_analyze_instruction_set_float_mode(ira, (IrInstSrcSetFloatMode *)instruction); | |
| 24372 | case IrInstSrcIdAnyFrameType: | |
| 24373 | return ir_analyze_instruction_any_frame_type(ira, (IrInstSrcAnyFrameType *)instruction); | |
| 24374 | case IrInstSrcIdSliceType: | |
| 24375 | return ir_analyze_instruction_slice_type(ira, (IrInstSrcSliceType *)instruction); | |
| 24376 | case IrInstSrcIdAsm: | |
| 24377 | return ir_analyze_instruction_asm(ira, (IrInstSrcAsm *)instruction); | |
| 24378 | case IrInstSrcIdArrayType: | |
| 24379 | return ir_analyze_instruction_array_type(ira, (IrInstSrcArrayType *)instruction); | |
| 24380 | case IrInstSrcIdSizeOf: | |
| 24381 | return ir_analyze_instruction_size_of(ira, (IrInstSrcSizeOf *)instruction); | |
| 24382 | case IrInstSrcIdTestNonNull: | |
| 24383 | return ir_analyze_instruction_test_non_null(ira, (IrInstSrcTestNonNull *)instruction); | |
| 24384 | case IrInstSrcIdOptionalUnwrapPtr: | |
| 24385 | return ir_analyze_instruction_optional_unwrap_ptr(ira, (IrInstSrcOptionalUnwrapPtr *)instruction); | |
| 24386 | case IrInstSrcIdClz: | |
| 24387 | return ir_analyze_instruction_clz(ira, (IrInstSrcClz *)instruction); | |
| 24388 | case IrInstSrcIdCtz: | |
| 24389 | return ir_analyze_instruction_ctz(ira, (IrInstSrcCtz *)instruction); | |
| 24390 | case IrInstSrcIdPopCount: | |
| 24391 | return ir_analyze_instruction_pop_count(ira, (IrInstSrcPopCount *)instruction); | |
| 24392 | case IrInstSrcIdBswap: | |
| 24393 | return ir_analyze_instruction_bswap(ira, (IrInstSrcBswap *)instruction); | |
| 24394 | case IrInstSrcIdBitReverse: | |
| 24395 | return ir_analyze_instruction_bit_reverse(ira, (IrInstSrcBitReverse *)instruction); | |
| 24396 | case IrInstSrcIdSwitchBr: | |
| 24397 | return ir_analyze_instruction_switch_br(ira, (IrInstSrcSwitchBr *)instruction); | |
| 24398 | case IrInstSrcIdSwitchTarget: | |
| 24399 | return ir_analyze_instruction_switch_target(ira, (IrInstSrcSwitchTarget *)instruction); | |
| 24400 | case IrInstSrcIdSwitchVar: | |
| 24401 | return ir_analyze_instruction_switch_var(ira, (IrInstSrcSwitchVar *)instruction); | |
| 24402 | case IrInstSrcIdSwitchElseVar: | |
| 24403 | return ir_analyze_instruction_switch_else_var(ira, (IrInstSrcSwitchElseVar *)instruction); | |
| 24404 | case IrInstSrcIdImport: | |
| 24405 | return ir_analyze_instruction_import(ira, (IrInstSrcImport *)instruction); | |
| 24406 | case IrInstSrcIdRef: | |
| 24407 | return ir_analyze_instruction_ref(ira, (IrInstSrcRef *)instruction); | |
| 24408 | case IrInstSrcIdContainerInitList: | |
| 24409 | return ir_analyze_instruction_container_init_list(ira, (IrInstSrcContainerInitList *)instruction); | |
| 24410 | case IrInstSrcIdContainerInitFields: | |
| 24411 | return ir_analyze_instruction_container_init_fields(ira, (IrInstSrcContainerInitFields *)instruction); | |
| 24412 | case IrInstSrcIdCompileErr: | |
| 24413 | return ir_analyze_instruction_compile_err(ira, (IrInstSrcCompileErr *)instruction); | |
| 24414 | case IrInstSrcIdCompileLog: | |
| 24415 | return ir_analyze_instruction_compile_log(ira, (IrInstSrcCompileLog *)instruction); | |
| 24416 | case IrInstSrcIdErrName: | |
| 24417 | return ir_analyze_instruction_err_name(ira, (IrInstSrcErrName *)instruction); | |
| 24418 | case IrInstSrcIdTypeName: | |
| 24419 | return ir_analyze_instruction_type_name(ira, (IrInstSrcTypeName *)instruction); | |
| 24420 | case IrInstSrcIdCImport: | |
| 24421 | return ir_analyze_instruction_c_import(ira, (IrInstSrcCImport *)instruction); | |
| 24422 | case IrInstSrcIdCInclude: | |
| 24423 | return ir_analyze_instruction_c_include(ira, (IrInstSrcCInclude *)instruction); | |
| 24424 | case IrInstSrcIdCDefine: | |
| 24425 | return ir_analyze_instruction_c_define(ira, (IrInstSrcCDefine *)instruction); | |
| 24426 | case IrInstSrcIdCUndef: | |
| 24427 | return ir_analyze_instruction_c_undef(ira, (IrInstSrcCUndef *)instruction); | |
| 24428 | case IrInstSrcIdEmbedFile: | |
| 24429 | return ir_analyze_instruction_embed_file(ira, (IrInstSrcEmbedFile *)instruction); | |
| 24430 | case IrInstSrcIdCmpxchg: | |
| 24431 | return ir_analyze_instruction_cmpxchg(ira, (IrInstSrcCmpxchg *)instruction); | |
| 24432 | case IrInstSrcIdFence: | |
| 24433 | return ir_analyze_instruction_fence(ira, (IrInstSrcFence *)instruction); | |
| 24434 | case IrInstSrcIdReduce: | |
| 24435 | return ir_analyze_instruction_reduce(ira, (IrInstSrcReduce *)instruction); | |
| 24436 | case IrInstSrcIdTruncate: | |
| 24437 | return ir_analyze_instruction_truncate(ira, (IrInstSrcTruncate *)instruction); | |
| 24438 | case IrInstSrcIdIntCast: | |
| 24439 | return ir_analyze_instruction_int_cast(ira, (IrInstSrcIntCast *)instruction); | |
| 24440 | case IrInstSrcIdFloatCast: | |
| 24441 | return ir_analyze_instruction_float_cast(ira, (IrInstSrcFloatCast *)instruction); | |
| 24442 | case IrInstSrcIdErrSetCast: | |
| 24443 | return ir_analyze_instruction_err_set_cast(ira, (IrInstSrcErrSetCast *)instruction); | |
| 24444 | case IrInstSrcIdIntToFloat: | |
| 24445 | return ir_analyze_instruction_int_to_float(ira, (IrInstSrcIntToFloat *)instruction); | |
| 24446 | case IrInstSrcIdFloatToInt: | |
| 24447 | return ir_analyze_instruction_float_to_int(ira, (IrInstSrcFloatToInt *)instruction); | |
| 24448 | case IrInstSrcIdBoolToInt: | |
| 24449 | return ir_analyze_instruction_bool_to_int(ira, (IrInstSrcBoolToInt *)instruction); | |
| 24450 | case IrInstSrcIdVectorType: | |
| 24451 | return ir_analyze_instruction_vector_type(ira, (IrInstSrcVectorType *)instruction); | |
| 24452 | case IrInstSrcIdShuffleVector: | |
| 24453 | return ir_analyze_instruction_shuffle_vector(ira, (IrInstSrcShuffleVector *)instruction); | |
| 24454 | case IrInstSrcIdSplat: | |
| 24455 | return ir_analyze_instruction_splat(ira, (IrInstSrcSplat *)instruction); | |
| 24456 | case IrInstSrcIdBoolNot: | |
| 24457 | return ir_analyze_instruction_bool_not(ira, (IrInstSrcBoolNot *)instruction); | |
| 24458 | case IrInstSrcIdMemset: | |
| 24459 | return ir_analyze_instruction_memset(ira, (IrInstSrcMemset *)instruction); | |
| 24460 | case IrInstSrcIdMemcpy: | |
| 24461 | return ir_analyze_instruction_memcpy(ira, (IrInstSrcMemcpy *)instruction); | |
| 24462 | case IrInstSrcIdSlice: | |
| 24463 | return ir_analyze_instruction_slice(ira, (IrInstSrcSlice *)instruction); | |
| 24464 | case IrInstSrcIdBreakpoint: | |
| 24465 | return ir_analyze_instruction_breakpoint(ira, (IrInstSrcBreakpoint *)instruction); | |
| 24466 | case IrInstSrcIdReturnAddress: | |
| 24467 | return ir_analyze_instruction_return_address(ira, (IrInstSrcReturnAddress *)instruction); | |
| 24468 | case IrInstSrcIdFrameAddress: | |
| 24469 | return ir_analyze_instruction_frame_address(ira, (IrInstSrcFrameAddress *)instruction); | |
| 24470 | case IrInstSrcIdFrameHandle: | |
| 24471 | return ir_analyze_instruction_frame_handle(ira, (IrInstSrcFrameHandle *)instruction); | |
| 24472 | case IrInstSrcIdFrameType: | |
| 24473 | return ir_analyze_instruction_frame_type(ira, (IrInstSrcFrameType *)instruction); | |
| 24474 | case IrInstSrcIdFrameSize: | |
| 24475 | return ir_analyze_instruction_frame_size(ira, (IrInstSrcFrameSize *)instruction); | |
| 24476 | case IrInstSrcIdAlignOf: | |
| 24477 | return ir_analyze_instruction_align_of(ira, (IrInstSrcAlignOf *)instruction); | |
| 24478 | case IrInstSrcIdOverflowOp: | |
| 24479 | return ir_analyze_instruction_overflow_op(ira, (IrInstSrcOverflowOp *)instruction); | |
| 24480 | case IrInstSrcIdTestErr: | |
| 24481 | return ir_analyze_instruction_test_err(ira, (IrInstSrcTestErr *)instruction); | |
| 24482 | case IrInstSrcIdUnwrapErrCode: | |
| 24483 | return ir_analyze_instruction_unwrap_err_code(ira, (IrInstSrcUnwrapErrCode *)instruction); | |
| 24484 | case IrInstSrcIdUnwrapErrPayload: | |
| 24485 | return ir_analyze_instruction_unwrap_err_payload(ira, (IrInstSrcUnwrapErrPayload *)instruction); | |
| 24486 | case IrInstSrcIdFnProto: | |
| 24487 | return ir_analyze_instruction_fn_proto(ira, (IrInstSrcFnProto *)instruction); | |
| 24488 | case IrInstSrcIdTestComptime: | |
| 24489 | return ir_analyze_instruction_test_comptime(ira, (IrInstSrcTestComptime *)instruction); | |
| 24490 | case IrInstSrcIdCheckSwitchProngsUnderNo: | |
| 24491 | return ir_analyze_instruction_check_switch_prongs(ira, (IrInstSrcCheckSwitchProngs *)instruction, false); | |
| 24492 | case IrInstSrcIdCheckSwitchProngsUnderYes: | |
| 24493 | return ir_analyze_instruction_check_switch_prongs(ira, (IrInstSrcCheckSwitchProngs *)instruction, true); | |
| 24494 | case IrInstSrcIdCheckStatementIsVoid: | |
| 24495 | return ir_analyze_instruction_check_statement_is_void(ira, (IrInstSrcCheckStatementIsVoid *)instruction); | |
| 24496 | case IrInstSrcIdDeclRef: | |
| 24497 | return ir_analyze_instruction_decl_ref(ira, (IrInstSrcDeclRef *)instruction); | |
| 24498 | case IrInstSrcIdPanic: | |
| 24499 | return ir_analyze_instruction_panic(ira, (IrInstSrcPanic *)instruction); | |
| 24500 | case IrInstSrcIdPtrCast: | |
| 24501 | return ir_analyze_instruction_ptr_cast(ira, (IrInstSrcPtrCast *)instruction); | |
| 24502 | case IrInstSrcIdIntToPtr: | |
| 24503 | return ir_analyze_instruction_int_to_ptr(ira, (IrInstSrcIntToPtr *)instruction); | |
| 24504 | case IrInstSrcIdPtrToInt: | |
| 24505 | return ir_analyze_instruction_ptr_to_int(ira, (IrInstSrcPtrToInt *)instruction); | |
| 24506 | case IrInstSrcIdTagName: | |
| 24507 | return ir_analyze_instruction_enum_tag_name(ira, (IrInstSrcTagName *)instruction); | |
| 24508 | case IrInstSrcIdFieldParentPtr: | |
| 24509 | return ir_analyze_instruction_field_parent_ptr(ira, (IrInstSrcFieldParentPtr *)instruction); | |
| 24510 | case IrInstSrcIdOffsetOf: | |
| 24511 | return ir_analyze_instruction_offset_of(ira, (IrInstSrcOffsetOf *)instruction); | |
| 24512 | case IrInstSrcIdBitOffsetOf: | |
| 24513 | return ir_analyze_instruction_bit_offset_of(ira, (IrInstSrcBitOffsetOf *)instruction); | |
| 24514 | case IrInstSrcIdTypeInfo: | |
| 24515 | return ir_analyze_instruction_type_info(ira, (IrInstSrcTypeInfo *) instruction); | |
| 24516 | case IrInstSrcIdType: | |
| 24517 | return ir_analyze_instruction_type(ira, (IrInstSrcType *)instruction); | |
| 24518 | case IrInstSrcIdHasField: | |
| 24519 | return ir_analyze_instruction_has_field(ira, (IrInstSrcHasField *) instruction); | |
| 24520 | case IrInstSrcIdSetEvalBranchQuota: | |
| 24521 | return ir_analyze_instruction_set_eval_branch_quota(ira, (IrInstSrcSetEvalBranchQuota *)instruction); | |
| 24522 | case IrInstSrcIdPtrType: | |
| 24523 | return ir_analyze_instruction_ptr_type(ira, (IrInstSrcPtrType *)instruction); | |
| 24524 | case IrInstSrcIdPtrTypeSimple: | |
| 24525 | return ir_analyze_instruction_ptr_type_simple(ira, (IrInstSrcPtrTypeSimple *)instruction, false); | |
| 24526 | case IrInstSrcIdPtrTypeSimpleConst: | |
| 24527 | return ir_analyze_instruction_ptr_type_simple(ira, (IrInstSrcPtrTypeSimple *)instruction, true); | |
| 24528 | case IrInstSrcIdAlignCast: | |
| 24529 | return ir_analyze_instruction_align_cast(ira, (IrInstSrcAlignCast *)instruction); | |
| 24530 | case IrInstSrcIdImplicitCast: | |
| 24531 | return ir_analyze_instruction_implicit_cast(ira, (IrInstSrcImplicitCast *)instruction); | |
| 24532 | case IrInstSrcIdResolveResult: | |
| 24533 | return ir_analyze_instruction_resolve_result(ira, (IrInstSrcResolveResult *)instruction); | |
| 24534 | case IrInstSrcIdResetResult: | |
| 24535 | return ir_analyze_instruction_reset_result(ira, (IrInstSrcResetResult *)instruction); | |
| 24536 | case IrInstSrcIdSetAlignStack: | |
| 24537 | return ir_analyze_instruction_set_align_stack(ira, (IrInstSrcSetAlignStack *)instruction); | |
| 24538 | case IrInstSrcIdArgTypeAllowVarFalse: | |
| 24539 | return ir_analyze_instruction_arg_type(ira, (IrInstSrcArgType *)instruction, false); | |
| 24540 | case IrInstSrcIdArgTypeAllowVarTrue: | |
| 24541 | return ir_analyze_instruction_arg_type(ira, (IrInstSrcArgType *)instruction, true); | |
| 24542 | case IrInstSrcIdExport: | |
| 24543 | return ir_analyze_instruction_export(ira, (IrInstSrcExport *)instruction); | |
| 24544 | case IrInstSrcIdExtern: | |
| 24545 | return ir_analyze_instruction_extern(ira, (IrInstSrcExtern *)instruction); | |
| 24546 | case IrInstSrcIdErrorReturnTrace: | |
| 24547 | return ir_analyze_instruction_error_return_trace(ira, (IrInstSrcErrorReturnTrace *)instruction); | |
| 24548 | case IrInstSrcIdErrorUnion: | |
| 24549 | return ir_analyze_instruction_error_union(ira, (IrInstSrcErrorUnion *)instruction); | |
| 24550 | case IrInstSrcIdAtomicRmw: | |
| 24551 | return ir_analyze_instruction_atomic_rmw(ira, (IrInstSrcAtomicRmw *)instruction); | |
| 24552 | case IrInstSrcIdAtomicLoad: | |
| 24553 | return ir_analyze_instruction_atomic_load(ira, (IrInstSrcAtomicLoad *)instruction); | |
| 24554 | case IrInstSrcIdAtomicStore: | |
| 24555 | return ir_analyze_instruction_atomic_store(ira, (IrInstSrcAtomicStore *)instruction); | |
| 24556 | case IrInstSrcIdSaveErrRetAddr: | |
| 24557 | return ir_analyze_instruction_save_err_ret_addr(ira, (IrInstSrcSaveErrRetAddr *)instruction); | |
| 24558 | case IrInstSrcIdAddImplicitReturnType: | |
| 24559 | return ir_analyze_instruction_add_implicit_return_type(ira, (IrInstSrcAddImplicitReturnType *)instruction); | |
| 24560 | case IrInstSrcIdFloatOp: | |
| 24561 | return ir_analyze_instruction_float_op(ira, (IrInstSrcFloatOp *)instruction); | |
| 24562 | case IrInstSrcIdMulAdd: | |
| 24563 | return ir_analyze_instruction_mul_add(ira, (IrInstSrcMulAdd *)instruction); | |
| 24564 | case IrInstSrcIdIntToErr: | |
| 24565 | return ir_analyze_instruction_int_to_err(ira, (IrInstSrcIntToErr *)instruction); | |
| 24566 | case IrInstSrcIdErrToInt: | |
| 24567 | return ir_analyze_instruction_err_to_int(ira, (IrInstSrcErrToInt *)instruction); | |
| 24568 | case IrInstSrcIdIntToEnum: | |
| 24569 | return ir_analyze_instruction_int_to_enum(ira, (IrInstSrcIntToEnum *)instruction); | |
| 24570 | case IrInstSrcIdEnumToInt: | |
| 24571 | return ir_analyze_instruction_enum_to_int(ira, (IrInstSrcEnumToInt *)instruction); | |
| 24572 | case IrInstSrcIdCheckRuntimeScope: | |
| 24573 | return ir_analyze_instruction_check_runtime_scope(ira, (IrInstSrcCheckRuntimeScope *)instruction); | |
| 24574 | case IrInstSrcIdHasDecl: | |
| 24575 | return ir_analyze_instruction_has_decl(ira, (IrInstSrcHasDecl *)instruction); | |
| 24576 | case IrInstSrcIdUndeclaredIdent: | |
| 24577 | return ir_analyze_instruction_undeclared_ident(ira, (IrInstSrcUndeclaredIdent *)instruction); | |
| 24578 | case IrInstSrcIdAlloca: | |
| 24326 | case Stage1ZirInstIdReturn: | |
| 24327 | return ir_analyze_instruction_return(ira, (Stage1ZirInstReturn *)instruction); | |
| 24328 | case Stage1ZirInstIdConst: | |
| 24329 | return ir_analyze_instruction_const(ira, (Stage1ZirInstConst *)instruction); | |
| 24330 | case Stage1ZirInstIdUnOp: | |
| 24331 | return ir_analyze_instruction_un_op(ira, (Stage1ZirInstUnOp *)instruction); | |
| 24332 | case Stage1ZirInstIdBinOp: | |
| 24333 | return ir_analyze_instruction_bin_op(ira, (Stage1ZirInstBinOp *)instruction); | |
| 24334 | case Stage1ZirInstIdMergeErrSets: | |
| 24335 | return ir_analyze_instruction_merge_err_sets(ira, (Stage1ZirInstMergeErrSets *)instruction); | |
| 24336 | case Stage1ZirInstIdDeclVar: | |
| 24337 | return ir_analyze_instruction_decl_var(ira, (Stage1ZirInstDeclVar *)instruction); | |
| 24338 | case Stage1ZirInstIdLoadPtr: | |
| 24339 | return ir_analyze_instruction_load_ptr(ira, (Stage1ZirInstLoadPtr *)instruction); | |
| 24340 | case Stage1ZirInstIdStorePtr: | |
| 24341 | return ir_analyze_instruction_store_ptr(ira, (Stage1ZirInstStorePtr *)instruction); | |
| 24342 | case Stage1ZirInstIdElemPtr: | |
| 24343 | return ir_analyze_instruction_elem_ptr(ira, (Stage1ZirInstElemPtr *)instruction); | |
| 24344 | case Stage1ZirInstIdVarPtr: | |
| 24345 | return ir_analyze_instruction_var_ptr(ira, (Stage1ZirInstVarPtr *)instruction); | |
| 24346 | case Stage1ZirInstIdFieldPtr: | |
| 24347 | return ir_analyze_instruction_field_ptr(ira, (Stage1ZirInstFieldPtr *)instruction); | |
| 24348 | case Stage1ZirInstIdCall: | |
| 24349 | return ir_analyze_instruction_call(ira, (Stage1ZirInstCall *)instruction); | |
| 24350 | case Stage1ZirInstIdCallArgs: | |
| 24351 | return ir_analyze_instruction_call_args(ira, (Stage1ZirInstCallArgs *)instruction); | |
| 24352 | case Stage1ZirInstIdCallExtra: | |
| 24353 | return ir_analyze_instruction_call_extra(ira, (Stage1ZirInstCallExtra *)instruction); | |
| 24354 | case Stage1ZirInstIdAsyncCallExtra: | |
| 24355 | return ir_analyze_instruction_async_call_extra(ira, (Stage1ZirInstAsyncCallExtra *)instruction); | |
| 24356 | case Stage1ZirInstIdBr: | |
| 24357 | return ir_analyze_instruction_br(ira, (Stage1ZirInstBr *)instruction); | |
| 24358 | case Stage1ZirInstIdCondBr: | |
| 24359 | return ir_analyze_instruction_cond_br(ira, (Stage1ZirInstCondBr *)instruction); | |
| 24360 | case Stage1ZirInstIdUnreachable: | |
| 24361 | return ir_analyze_instruction_unreachable(ira, (Stage1ZirInstUnreachable *)instruction); | |
| 24362 | case Stage1ZirInstIdPhi: | |
| 24363 | return ir_analyze_instruction_phi(ira, (Stage1ZirInstPhi *)instruction); | |
| 24364 | case Stage1ZirInstIdTypeOf: | |
| 24365 | return ir_analyze_instruction_typeof(ira, (Stage1ZirInstTypeOf *)instruction); | |
| 24366 | case Stage1ZirInstIdSetCold: | |
| 24367 | return ir_analyze_instruction_set_cold(ira, (Stage1ZirInstSetCold *)instruction); | |
| 24368 | case Stage1ZirInstIdSetRuntimeSafety: | |
| 24369 | return ir_analyze_instruction_set_runtime_safety(ira, (Stage1ZirInstSetRuntimeSafety *)instruction); | |
| 24370 | case Stage1ZirInstIdSetFloatMode: | |
| 24371 | return ir_analyze_instruction_set_float_mode(ira, (Stage1ZirInstSetFloatMode *)instruction); | |
| 24372 | case Stage1ZirInstIdAnyFrameType: | |
| 24373 | return ir_analyze_instruction_any_frame_type(ira, (Stage1ZirInstAnyFrameType *)instruction); | |
| 24374 | case Stage1ZirInstIdSliceType: | |
| 24375 | return ir_analyze_instruction_slice_type(ira, (Stage1ZirInstSliceType *)instruction); | |
| 24376 | case Stage1ZirInstIdAsm: | |
| 24377 | return ir_analyze_instruction_asm(ira, (Stage1ZirInstAsm *)instruction); | |
| 24378 | case Stage1ZirInstIdArrayType: | |
| 24379 | return ir_analyze_instruction_array_type(ira, (Stage1ZirInstArrayType *)instruction); | |
| 24380 | case Stage1ZirInstIdSizeOf: | |
| 24381 | return ir_analyze_instruction_size_of(ira, (Stage1ZirInstSizeOf *)instruction); | |
| 24382 | case Stage1ZirInstIdTestNonNull: | |
| 24383 | return ir_analyze_instruction_test_non_null(ira, (Stage1ZirInstTestNonNull *)instruction); | |
| 24384 | case Stage1ZirInstIdOptionalUnwrapPtr: | |
| 24385 | return ir_analyze_instruction_optional_unwrap_ptr(ira, (Stage1ZirInstOptionalUnwrapPtr *)instruction); | |
| 24386 | case Stage1ZirInstIdClz: | |
| 24387 | return ir_analyze_instruction_clz(ira, (Stage1ZirInstClz *)instruction); | |
| 24388 | case Stage1ZirInstIdCtz: | |
| 24389 | return ir_analyze_instruction_ctz(ira, (Stage1ZirInstCtz *)instruction); | |
| 24390 | case Stage1ZirInstIdPopCount: | |
| 24391 | return ir_analyze_instruction_pop_count(ira, (Stage1ZirInstPopCount *)instruction); | |
| 24392 | case Stage1ZirInstIdBswap: | |
| 24393 | return ir_analyze_instruction_bswap(ira, (Stage1ZirInstBswap *)instruction); | |
| 24394 | case Stage1ZirInstIdBitReverse: | |
| 24395 | return ir_analyze_instruction_bit_reverse(ira, (Stage1ZirInstBitReverse *)instruction); | |
| 24396 | case Stage1ZirInstIdSwitchBr: | |
| 24397 | return ir_analyze_instruction_switch_br(ira, (Stage1ZirInstSwitchBr *)instruction); | |
| 24398 | case Stage1ZirInstIdSwitchTarget: | |
| 24399 | return ir_analyze_instruction_switch_target(ira, (Stage1ZirInstSwitchTarget *)instruction); | |
| 24400 | case Stage1ZirInstIdSwitchVar: | |
| 24401 | return ir_analyze_instruction_switch_var(ira, (Stage1ZirInstSwitchVar *)instruction); | |
| 24402 | case Stage1ZirInstIdSwitchElseVar: | |
| 24403 | return ir_analyze_instruction_switch_else_var(ira, (Stage1ZirInstSwitchElseVar *)instruction); | |
| 24404 | case Stage1ZirInstIdImport: | |
| 24405 | return ir_analyze_instruction_import(ira, (Stage1ZirInstImport *)instruction); | |
| 24406 | case Stage1ZirInstIdRef: | |
| 24407 | return ir_analyze_instruction_ref(ira, (Stage1ZirInstRef *)instruction); | |
| 24408 | case Stage1ZirInstIdContainerInitList: | |
| 24409 | return ir_analyze_instruction_container_init_list(ira, (Stage1ZirInstContainerInitList *)instruction); | |
| 24410 | case Stage1ZirInstIdContainerInitFields: | |
| 24411 | return ir_analyze_instruction_container_init_fields(ira, (Stage1ZirInstContainerInitFields *)instruction); | |
| 24412 | case Stage1ZirInstIdCompileErr: | |
| 24413 | return ir_analyze_instruction_compile_err(ira, (Stage1ZirInstCompileErr *)instruction); | |
| 24414 | case Stage1ZirInstIdCompileLog: | |
| 24415 | return ir_analyze_instruction_compile_log(ira, (Stage1ZirInstCompileLog *)instruction); | |
| 24416 | case Stage1ZirInstIdErrName: | |
| 24417 | return ir_analyze_instruction_err_name(ira, (Stage1ZirInstErrName *)instruction); | |
| 24418 | case Stage1ZirInstIdTypeName: | |
| 24419 | return ir_analyze_instruction_type_name(ira, (Stage1ZirInstTypeName *)instruction); | |
| 24420 | case Stage1ZirInstIdCImport: | |
| 24421 | return ir_analyze_instruction_c_import(ira, (Stage1ZirInstCImport *)instruction); | |
| 24422 | case Stage1ZirInstIdCInclude: | |
| 24423 | return ir_analyze_instruction_c_include(ira, (Stage1ZirInstCInclude *)instruction); | |
| 24424 | case Stage1ZirInstIdCDefine: | |
| 24425 | return ir_analyze_instruction_c_define(ira, (Stage1ZirInstCDefine *)instruction); | |
| 24426 | case Stage1ZirInstIdCUndef: | |
| 24427 | return ir_analyze_instruction_c_undef(ira, (Stage1ZirInstCUndef *)instruction); | |
| 24428 | case Stage1ZirInstIdEmbedFile: | |
| 24429 | return ir_analyze_instruction_embed_file(ira, (Stage1ZirInstEmbedFile *)instruction); | |
| 24430 | case Stage1ZirInstIdCmpxchg: | |
| 24431 | return ir_analyze_instruction_cmpxchg(ira, (Stage1ZirInstCmpxchg *)instruction); | |
| 24432 | case Stage1ZirInstIdFence: | |
| 24433 | return ir_analyze_instruction_fence(ira, (Stage1ZirInstFence *)instruction); | |
| 24434 | case Stage1ZirInstIdReduce: | |
| 24435 | return ir_analyze_instruction_reduce(ira, (Stage1ZirInstReduce *)instruction); | |
| 24436 | case Stage1ZirInstIdTruncate: | |
| 24437 | return ir_analyze_instruction_truncate(ira, (Stage1ZirInstTruncate *)instruction); | |
| 24438 | case Stage1ZirInstIdIntCast: | |
| 24439 | return ir_analyze_instruction_int_cast(ira, (Stage1ZirInstIntCast *)instruction); | |
| 24440 | case Stage1ZirInstIdFloatCast: | |
| 24441 | return ir_analyze_instruction_float_cast(ira, (Stage1ZirInstFloatCast *)instruction); | |
| 24442 | case Stage1ZirInstIdErrSetCast: | |
| 24443 | return ir_analyze_instruction_err_set_cast(ira, (Stage1ZirInstErrSetCast *)instruction); | |
| 24444 | case Stage1ZirInstIdIntToFloat: | |
| 24445 | return ir_analyze_instruction_int_to_float(ira, (Stage1ZirInstIntToFloat *)instruction); | |
| 24446 | case Stage1ZirInstIdFloatToInt: | |
| 24447 | return ir_analyze_instruction_float_to_int(ira, (Stage1ZirInstFloatToInt *)instruction); | |
| 24448 | case Stage1ZirInstIdBoolToInt: | |
| 24449 | return ir_analyze_instruction_bool_to_int(ira, (Stage1ZirInstBoolToInt *)instruction); | |
| 24450 | case Stage1ZirInstIdVectorType: | |
| 24451 | return ir_analyze_instruction_vector_type(ira, (Stage1ZirInstVectorType *)instruction); | |
| 24452 | case Stage1ZirInstIdShuffleVector: | |
| 24453 | return ir_analyze_instruction_shuffle_vector(ira, (Stage1ZirInstShuffleVector *)instruction); | |
| 24454 | case Stage1ZirInstIdSplat: | |
| 24455 | return ir_analyze_instruction_splat(ira, (Stage1ZirInstSplat *)instruction); | |
| 24456 | case Stage1ZirInstIdBoolNot: | |
| 24457 | return ir_analyze_instruction_bool_not(ira, (Stage1ZirInstBoolNot *)instruction); | |
| 24458 | case Stage1ZirInstIdMemset: | |
| 24459 | return ir_analyze_instruction_memset(ira, (Stage1ZirInstMemset *)instruction); | |
| 24460 | case Stage1ZirInstIdMemcpy: | |
| 24461 | return ir_analyze_instruction_memcpy(ira, (Stage1ZirInstMemcpy *)instruction); | |
| 24462 | case Stage1ZirInstIdSlice: | |
| 24463 | return ir_analyze_instruction_slice(ira, (Stage1ZirInstSlice *)instruction); | |
| 24464 | case Stage1ZirInstIdBreakpoint: | |
| 24465 | return ir_analyze_instruction_breakpoint(ira, (Stage1ZirInstBreakpoint *)instruction); | |
| 24466 | case Stage1ZirInstIdReturnAddress: | |
| 24467 | return ir_analyze_instruction_return_address(ira, (Stage1ZirInstReturnAddress *)instruction); | |
| 24468 | case Stage1ZirInstIdFrameAddress: | |
| 24469 | return ir_analyze_instruction_frame_address(ira, (Stage1ZirInstFrameAddress *)instruction); | |
| 24470 | case Stage1ZirInstIdFrameHandle: | |
| 24471 | return ir_analyze_instruction_frame_handle(ira, (Stage1ZirInstFrameHandle *)instruction); | |
| 24472 | case Stage1ZirInstIdFrameType: | |
| 24473 | return ir_analyze_instruction_frame_type(ira, (Stage1ZirInstFrameType *)instruction); | |
| 24474 | case Stage1ZirInstIdFrameSize: | |
| 24475 | return ir_analyze_instruction_frame_size(ira, (Stage1ZirInstFrameSize *)instruction); | |
| 24476 | case Stage1ZirInstIdAlignOf: | |
| 24477 | return ir_analyze_instruction_align_of(ira, (Stage1ZirInstAlignOf *)instruction); | |
| 24478 | case Stage1ZirInstIdOverflowOp: | |
| 24479 | return ir_analyze_instruction_overflow_op(ira, (Stage1ZirInstOverflowOp *)instruction); | |
| 24480 | case Stage1ZirInstIdTestErr: | |
| 24481 | return ir_analyze_instruction_test_err(ira, (Stage1ZirInstTestErr *)instruction); | |
| 24482 | case Stage1ZirInstIdUnwrapErrCode: | |
| 24483 | return ir_analyze_instruction_unwrap_err_code(ira, (Stage1ZirInstUnwrapErrCode *)instruction); | |
| 24484 | case Stage1ZirInstIdUnwrapErrPayload: | |
| 24485 | return ir_analyze_instruction_unwrap_err_payload(ira, (Stage1ZirInstUnwrapErrPayload *)instruction); | |
| 24486 | case Stage1ZirInstIdFnProto: | |
| 24487 | return ir_analyze_instruction_fn_proto(ira, (Stage1ZirInstFnProto *)instruction); | |
| 24488 | case Stage1ZirInstIdTestComptime: | |
| 24489 | return ir_analyze_instruction_test_comptime(ira, (Stage1ZirInstTestComptime *)instruction); | |
| 24490 | case Stage1ZirInstIdCheckSwitchProngsUnderNo: | |
| 24491 | return ir_analyze_instruction_check_switch_prongs(ira, (Stage1ZirInstCheckSwitchProngs *)instruction, false); | |
| 24492 | case Stage1ZirInstIdCheckSwitchProngsUnderYes: | |
| 24493 | return ir_analyze_instruction_check_switch_prongs(ira, (Stage1ZirInstCheckSwitchProngs *)instruction, true); | |
| 24494 | case Stage1ZirInstIdCheckStatementIsVoid: | |
| 24495 | return ir_analyze_instruction_check_statement_is_void(ira, (Stage1ZirInstCheckStatementIsVoid *)instruction); | |
| 24496 | case Stage1ZirInstIdDeclRef: | |
| 24497 | return ir_analyze_instruction_decl_ref(ira, (Stage1ZirInstDeclRef *)instruction); | |
| 24498 | case Stage1ZirInstIdPanic: | |
| 24499 | return ir_analyze_instruction_panic(ira, (Stage1ZirInstPanic *)instruction); | |
| 24500 | case Stage1ZirInstIdPtrCast: | |
| 24501 | return ir_analyze_instruction_ptr_cast(ira, (Stage1ZirInstPtrCast *)instruction); | |
| 24502 | case Stage1ZirInstIdIntToPtr: | |
| 24503 | return ir_analyze_instruction_int_to_ptr(ira, (Stage1ZirInstIntToPtr *)instruction); | |
| 24504 | case Stage1ZirInstIdPtrToInt: | |
| 24505 | return ir_analyze_instruction_ptr_to_int(ira, (Stage1ZirInstPtrToInt *)instruction); | |
| 24506 | case Stage1ZirInstIdTagName: | |
| 24507 | return ir_analyze_instruction_enum_tag_name(ira, (Stage1ZirInstTagName *)instruction); | |
| 24508 | case Stage1ZirInstIdFieldParentPtr: | |
| 24509 | return ir_analyze_instruction_field_parent_ptr(ira, (Stage1ZirInstFieldParentPtr *)instruction); | |
| 24510 | case Stage1ZirInstIdOffsetOf: | |
| 24511 | return ir_analyze_instruction_offset_of(ira, (Stage1ZirInstOffsetOf *)instruction); | |
| 24512 | case Stage1ZirInstIdBitOffsetOf: | |
| 24513 | return ir_analyze_instruction_bit_offset_of(ira, (Stage1ZirInstBitOffsetOf *)instruction); | |
| 24514 | case Stage1ZirInstIdTypeInfo: | |
| 24515 | return ir_analyze_instruction_type_info(ira, (Stage1ZirInstTypeInfo *) instruction); | |
| 24516 | case Stage1ZirInstIdType: | |
| 24517 | return ir_analyze_instruction_type(ira, (Stage1ZirInstType *)instruction); | |
| 24518 | case Stage1ZirInstIdHasField: | |
| 24519 | return ir_analyze_instruction_has_field(ira, (Stage1ZirInstHasField *) instruction); | |
| 24520 | case Stage1ZirInstIdSetEvalBranchQuota: | |
| 24521 | return ir_analyze_instruction_set_eval_branch_quota(ira, (Stage1ZirInstSetEvalBranchQuota *)instruction); | |
| 24522 | case Stage1ZirInstIdPtrType: | |
| 24523 | return ir_analyze_instruction_ptr_type(ira, (Stage1ZirInstPtrType *)instruction); | |
| 24524 | case Stage1ZirInstIdPtrTypeSimple: | |
| 24525 | return ir_analyze_instruction_ptr_type_simple(ira, (Stage1ZirInstPtrTypeSimple *)instruction, false); | |
| 24526 | case Stage1ZirInstIdPtrTypeSimpleConst: | |
| 24527 | return ir_analyze_instruction_ptr_type_simple(ira, (Stage1ZirInstPtrTypeSimple *)instruction, true); | |
| 24528 | case Stage1ZirInstIdAlignCast: | |
| 24529 | return ir_analyze_instruction_align_cast(ira, (Stage1ZirInstAlignCast *)instruction); | |
| 24530 | case Stage1ZirInstIdImplicitCast: | |
| 24531 | return ir_analyze_instruction_implicit_cast(ira, (Stage1ZirInstImplicitCast *)instruction); | |
| 24532 | case Stage1ZirInstIdResolveResult: | |
| 24533 | return ir_analyze_instruction_resolve_result(ira, (Stage1ZirInstResolveResult *)instruction); | |
| 24534 | case Stage1ZirInstIdResetResult: | |
| 24535 | return ir_analyze_instruction_reset_result(ira, (Stage1ZirInstResetResult *)instruction); | |
| 24536 | case Stage1ZirInstIdSetAlignStack: | |
| 24537 | return ir_analyze_instruction_set_align_stack(ira, (Stage1ZirInstSetAlignStack *)instruction); | |
| 24538 | case Stage1ZirInstIdArgTypeAllowVarFalse: | |
| 24539 | return ir_analyze_instruction_arg_type(ira, (Stage1ZirInstArgType *)instruction, false); | |
| 24540 | case Stage1ZirInstIdArgTypeAllowVarTrue: | |
| 24541 | return ir_analyze_instruction_arg_type(ira, (Stage1ZirInstArgType *)instruction, true); | |
| 24542 | case Stage1ZirInstIdExport: | |
| 24543 | return ir_analyze_instruction_export(ira, (Stage1ZirInstExport *)instruction); | |
| 24544 | case Stage1ZirInstIdExtern: | |
| 24545 | return ir_analyze_instruction_extern(ira, (Stage1ZirInstExtern *)instruction); | |
| 24546 | case Stage1ZirInstIdErrorReturnTrace: | |
| 24547 | return ir_analyze_instruction_error_return_trace(ira, (Stage1ZirInstErrorReturnTrace *)instruction); | |
| 24548 | case Stage1ZirInstIdErrorUnion: | |
| 24549 | return ir_analyze_instruction_error_union(ira, (Stage1ZirInstErrorUnion *)instruction); | |
| 24550 | case Stage1ZirInstIdAtomicRmw: | |
| 24551 | return ir_analyze_instruction_atomic_rmw(ira, (Stage1ZirInstAtomicRmw *)instruction); | |
| 24552 | case Stage1ZirInstIdAtomicLoad: | |
| 24553 | return ir_analyze_instruction_atomic_load(ira, (Stage1ZirInstAtomicLoad *)instruction); | |
| 24554 | case Stage1ZirInstIdAtomicStore: | |
| 24555 | return ir_analyze_instruction_atomic_store(ira, (Stage1ZirInstAtomicStore *)instruction); | |
| 24556 | case Stage1ZirInstIdSaveErrRetAddr: | |
| 24557 | return ir_analyze_instruction_save_err_ret_addr(ira, (Stage1ZirInstSaveErrRetAddr *)instruction); | |
| 24558 | case Stage1ZirInstIdAddImplicitReturnType: | |
| 24559 | return ir_analyze_instruction_add_implicit_return_type(ira, (Stage1ZirInstAddImplicitReturnType *)instruction); | |
| 24560 | case Stage1ZirInstIdFloatOp: | |
| 24561 | return ir_analyze_instruction_float_op(ira, (Stage1ZirInstFloatOp *)instruction); | |
| 24562 | case Stage1ZirInstIdMulAdd: | |
| 24563 | return ir_analyze_instruction_mul_add(ira, (Stage1ZirInstMulAdd *)instruction); | |
| 24564 | case Stage1ZirInstIdIntToErr: | |
| 24565 | return ir_analyze_instruction_int_to_err(ira, (Stage1ZirInstIntToErr *)instruction); | |
| 24566 | case Stage1ZirInstIdErrToInt: | |
| 24567 | return ir_analyze_instruction_err_to_int(ira, (Stage1ZirInstErrToInt *)instruction); | |
| 24568 | case Stage1ZirInstIdIntToEnum: | |
| 24569 | return ir_analyze_instruction_int_to_enum(ira, (Stage1ZirInstIntToEnum *)instruction); | |
| 24570 | case Stage1ZirInstIdEnumToInt: | |
| 24571 | return ir_analyze_instruction_enum_to_int(ira, (Stage1ZirInstEnumToInt *)instruction); | |
| 24572 | case Stage1ZirInstIdCheckRuntimeScope: | |
| 24573 | return ir_analyze_instruction_check_runtime_scope(ira, (Stage1ZirInstCheckRuntimeScope *)instruction); | |
| 24574 | case Stage1ZirInstIdHasDecl: | |
| 24575 | return ir_analyze_instruction_has_decl(ira, (Stage1ZirInstHasDecl *)instruction); | |
| 24576 | case Stage1ZirInstIdUndeclaredIdent: | |
| 24577 | return ir_analyze_instruction_undeclared_ident(ira, (Stage1ZirInstUndeclaredIdent *)instruction); | |
| 24578 | case Stage1ZirInstIdAlloca: | |
| 24579 | 24579 | return nullptr; |
| 24580 | case IrInstSrcIdEndExpr: | |
| 24581 | return ir_analyze_instruction_end_expr(ira, (IrInstSrcEndExpr *)instruction); | |
| 24582 | case IrInstSrcIdBitCast: | |
| 24583 | return ir_analyze_instruction_bit_cast_src(ira, (IrInstSrcBitCast *)instruction); | |
| 24584 | case IrInstSrcIdUnionInitNamedField: | |
| 24585 | return ir_analyze_instruction_union_init_named_field(ira, (IrInstSrcUnionInitNamedField *)instruction); | |
| 24586 | case IrInstSrcIdSuspendBegin: | |
| 24587 | return ir_analyze_instruction_suspend_begin(ira, (IrInstSrcSuspendBegin *)instruction); | |
| 24588 | case IrInstSrcIdSuspendFinish: | |
| 24589 | return ir_analyze_instruction_suspend_finish(ira, (IrInstSrcSuspendFinish *)instruction); | |
| 24590 | case IrInstSrcIdResume: | |
| 24591 | return ir_analyze_instruction_resume(ira, (IrInstSrcResume *)instruction); | |
| 24592 | case IrInstSrcIdAwait: | |
| 24593 | return ir_analyze_instruction_await(ira, (IrInstSrcAwait *)instruction); | |
| 24594 | case IrInstSrcIdSpillBegin: | |
| 24595 | return ir_analyze_instruction_spill_begin(ira, (IrInstSrcSpillBegin *)instruction); | |
| 24596 | case IrInstSrcIdSpillEnd: | |
| 24597 | return ir_analyze_instruction_spill_end(ira, (IrInstSrcSpillEnd *)instruction); | |
| 24598 | case IrInstSrcIdWasmMemorySize: | |
| 24599 | return ir_analyze_instruction_wasm_memory_size(ira, (IrInstSrcWasmMemorySize *)instruction); | |
| 24600 | case IrInstSrcIdWasmMemoryGrow: | |
| 24601 | return ir_analyze_instruction_wasm_memory_grow(ira, (IrInstSrcWasmMemoryGrow *)instruction); | |
| 24602 | case IrInstSrcIdSrc: | |
| 24603 | return ir_analyze_instruction_src(ira, (IrInstSrcSrc *)instruction); | |
| 24580 | case Stage1ZirInstIdEndExpr: | |
| 24581 | return ir_analyze_instruction_end_expr(ira, (Stage1ZirInstEndExpr *)instruction); | |
| 24582 | case Stage1ZirInstIdBitCast: | |
| 24583 | return ir_analyze_instruction_bit_cast_src(ira, (Stage1ZirInstBitCast *)instruction); | |
| 24584 | case Stage1ZirInstIdUnionInitNamedField: | |
| 24585 | return ir_analyze_instruction_union_init_named_field(ira, (Stage1ZirInstUnionInitNamedField *)instruction); | |
| 24586 | case Stage1ZirInstIdSuspendBegin: | |
| 24587 | return ir_analyze_instruction_suspend_begin(ira, (Stage1ZirInstSuspendBegin *)instruction); | |
| 24588 | case Stage1ZirInstIdSuspendFinish: | |
| 24589 | return ir_analyze_instruction_suspend_finish(ira, (Stage1ZirInstSuspendFinish *)instruction); | |
| 24590 | case Stage1ZirInstIdResume: | |
| 24591 | return ir_analyze_instruction_resume(ira, (Stage1ZirInstResume *)instruction); | |
| 24592 | case Stage1ZirInstIdAwait: | |
| 24593 | return ir_analyze_instruction_await(ira, (Stage1ZirInstAwait *)instruction); | |
| 24594 | case Stage1ZirInstIdSpillBegin: | |
| 24595 | return ir_analyze_instruction_spill_begin(ira, (Stage1ZirInstSpillBegin *)instruction); | |
| 24596 | case Stage1ZirInstIdSpillEnd: | |
| 24597 | return ir_analyze_instruction_spill_end(ira, (Stage1ZirInstSpillEnd *)instruction); | |
| 24598 | case Stage1ZirInstIdWasmMemorySize: | |
| 24599 | return ir_analyze_instruction_wasm_memory_size(ira, (Stage1ZirInstWasmMemorySize *)instruction); | |
| 24600 | case Stage1ZirInstIdWasmMemoryGrow: | |
| 24601 | return ir_analyze_instruction_wasm_memory_grow(ira, (Stage1ZirInstWasmMemoryGrow *)instruction); | |
| 24602 | case Stage1ZirInstIdSrc: | |
| 24603 | return ir_analyze_instruction_src(ira, (Stage1ZirInstSrc *)instruction); | |
| 24604 | 24604 | } |
| 24605 | 24605 | zig_unreachable(); |
| 24606 | 24606 | } |
| ... | ... | @@ -24630,7 +24630,7 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *stage1_zir, Stage1Air *stage1_a |
| 24630 | 24630 | ira->new_irb.exec = stage1_air; |
| 24631 | 24631 | |
| 24632 | 24632 | Stage1ZirBasicBlock *old_entry_bb = ira->zir->basic_block_list.at(0); |
| 24633 | IrBasicBlockGen *new_entry_bb = ir_get_new_bb(ira, old_entry_bb, nullptr); | |
| 24633 | Stage1AirBasicBlock *new_entry_bb = ir_get_new_bb(ira, old_entry_bb, nullptr); | |
| 24634 | 24634 | ira->new_irb.current_basic_block = new_entry_bb; |
| 24635 | 24635 | ira->old_bb_index = 0; |
| 24636 | 24636 | |
| ... | ... | @@ -24638,7 +24638,7 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *stage1_zir, Stage1Air *stage1_a |
| 24638 | 24638 | |
| 24639 | 24639 | if (result_ptr != nullptr) { |
| 24640 | 24640 | assert(result_ptr->type->id == ZigTypeIdPointer); |
| 24641 | IrInstGenConst *const_inst = ir_create_inst_noval<IrInstGenConst>( | |
| 24641 | Stage1AirInstConst *const_inst = ir_create_inst_noval<Stage1AirInstConst>( | |
| 24642 | 24642 | &ira->new_irb, stage1_air->begin_scope, stage1_air->source_node); |
| 24643 | 24643 | const_inst->base.value = result_ptr; |
| 24644 | 24644 | ira->return_ptr = &const_inst->base; |
| ... | ... | @@ -24650,7 +24650,7 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *stage1_zir, Stage1Air *stage1_a |
| 24650 | 24650 | } |
| 24651 | 24651 | |
| 24652 | 24652 | while (ira->old_bb_index < ira->zir->basic_block_list.length) { |
| 24653 | IrInstSrc *old_instruction = ira->zir_current_basic_block->instruction_list.at(ira->instruction_index); | |
| 24653 | Stage1ZirInst *old_instruction = ira->zir_current_basic_block->instruction_list.at(ira->instruction_index); | |
| 24654 | 24654 | |
| 24655 | 24655 | if (old_instruction->ref_count == 0 && !ir_inst_src_has_side_effects(old_instruction)) { |
| 24656 | 24656 | ira->instruction_index += 1; |
| ... | ... | @@ -24664,7 +24664,7 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *stage1_zir, Stage1Air *stage1_a |
| 24664 | 24664 | ir_print_inst_src(codegen, stderr, old_instruction, 0); |
| 24665 | 24665 | } |
| 24666 | 24666 | ira->suspend_source_instr = old_instruction; |
| 24667 | IrInstGen *new_instruction = ir_analyze_instruction_base(ira, old_instruction); | |
| 24667 | Stage1AirInst *new_instruction = ir_analyze_instruction_base(ira, old_instruction); | |
| 24668 | 24668 | if (new_instruction != nullptr) { |
| 24669 | 24669 | src_assert(new_instruction->value->type != nullptr || new_instruction->value->type != nullptr, old_instruction->source_node); |
| 24670 | 24670 | old_instruction->child = new_instruction; |
| ... | ... | @@ -24732,283 +24732,283 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *stage1_zir, Stage1Air *stage1_a |
| 24732 | 24732 | return res_type; |
| 24733 | 24733 | } |
| 24734 | 24734 | |
| 24735 | bool ir_inst_gen_has_side_effects(IrInstGen *instruction) { | |
| 24735 | bool ir_inst_gen_has_side_effects(Stage1AirInst *instruction) { | |
| 24736 | 24736 | switch (instruction->id) { |
| 24737 | case IrInstGenIdInvalid: | |
| 24737 | case Stage1AirInstIdInvalid: | |
| 24738 | 24738 | zig_unreachable(); |
| 24739 | case IrInstGenIdBr: | |
| 24740 | case IrInstGenIdCondBr: | |
| 24741 | case IrInstGenIdSwitchBr: | |
| 24742 | case IrInstGenIdDeclVar: | |
| 24743 | case IrInstGenIdStorePtr: | |
| 24744 | case IrInstGenIdVectorStoreElem: | |
| 24745 | case IrInstGenIdCall: | |
| 24746 | case IrInstGenIdReturn: | |
| 24747 | case IrInstGenIdUnreachable: | |
| 24748 | case IrInstGenIdFence: | |
| 24749 | case IrInstGenIdMemset: | |
| 24750 | case IrInstGenIdMemcpy: | |
| 24751 | case IrInstGenIdBreakpoint: | |
| 24752 | case IrInstGenIdOverflowOp: // TODO when we support multiple returns this can be side effect free | |
| 24753 | case IrInstGenIdPanic: | |
| 24754 | case IrInstGenIdSaveErrRetAddr: | |
| 24755 | case IrInstGenIdAtomicRmw: | |
| 24756 | case IrInstGenIdAtomicStore: | |
| 24757 | case IrInstGenIdCmpxchg: | |
| 24758 | case IrInstGenIdAssertZero: | |
| 24759 | case IrInstGenIdAssertNonNull: | |
| 24760 | case IrInstGenIdPtrOfArrayToSlice: | |
| 24761 | case IrInstGenIdSlice: | |
| 24762 | case IrInstGenIdOptionalWrap: | |
| 24763 | case IrInstGenIdVectorToArray: | |
| 24764 | case IrInstGenIdSuspendBegin: | |
| 24765 | case IrInstGenIdSuspendFinish: | |
| 24766 | case IrInstGenIdResume: | |
| 24767 | case IrInstGenIdAwait: | |
| 24768 | case IrInstGenIdSpillBegin: | |
| 24769 | case IrInstGenIdWasmMemoryGrow: | |
| 24770 | case IrInstGenIdExtern: | |
| 24739 | case Stage1AirInstIdBr: | |
| 24740 | case Stage1AirInstIdCondBr: | |
| 24741 | case Stage1AirInstIdSwitchBr: | |
| 24742 | case Stage1AirInstIdDeclVar: | |
| 24743 | case Stage1AirInstIdStorePtr: | |
| 24744 | case Stage1AirInstIdVectorStoreElem: | |
| 24745 | case Stage1AirInstIdCall: | |
| 24746 | case Stage1AirInstIdReturn: | |
| 24747 | case Stage1AirInstIdUnreachable: | |
| 24748 | case Stage1AirInstIdFence: | |
| 24749 | case Stage1AirInstIdMemset: | |
| 24750 | case Stage1AirInstIdMemcpy: | |
| 24751 | case Stage1AirInstIdBreakpoint: | |
| 24752 | case Stage1AirInstIdOverflowOp: // TODO when we support multiple returns this can be side effect free | |
| 24753 | case Stage1AirInstIdPanic: | |
| 24754 | case Stage1AirInstIdSaveErrRetAddr: | |
| 24755 | case Stage1AirInstIdAtomicRmw: | |
| 24756 | case Stage1AirInstIdAtomicStore: | |
| 24757 | case Stage1AirInstIdCmpxchg: | |
| 24758 | case Stage1AirInstIdAssertZero: | |
| 24759 | case Stage1AirInstIdAssertNonNull: | |
| 24760 | case Stage1AirInstIdPtrOfArrayToSlice: | |
| 24761 | case Stage1AirInstIdSlice: | |
| 24762 | case Stage1AirInstIdOptionalWrap: | |
| 24763 | case Stage1AirInstIdVectorToArray: | |
| 24764 | case Stage1AirInstIdSuspendBegin: | |
| 24765 | case Stage1AirInstIdSuspendFinish: | |
| 24766 | case Stage1AirInstIdResume: | |
| 24767 | case Stage1AirInstIdAwait: | |
| 24768 | case Stage1AirInstIdSpillBegin: | |
| 24769 | case Stage1AirInstIdWasmMemoryGrow: | |
| 24770 | case Stage1AirInstIdExtern: | |
| 24771 | 24771 | return true; |
| 24772 | 24772 | |
| 24773 | case IrInstGenIdPhi: | |
| 24774 | case IrInstGenIdBinOp: | |
| 24775 | case IrInstGenIdConst: | |
| 24776 | case IrInstGenIdCast: | |
| 24777 | case IrInstGenIdElemPtr: | |
| 24778 | case IrInstGenIdVarPtr: | |
| 24779 | case IrInstGenIdReturnPtr: | |
| 24780 | case IrInstGenIdStructFieldPtr: | |
| 24781 | case IrInstGenIdTestNonNull: | |
| 24782 | case IrInstGenIdClz: | |
| 24783 | case IrInstGenIdCtz: | |
| 24784 | case IrInstGenIdPopCount: | |
| 24785 | case IrInstGenIdBswap: | |
| 24786 | case IrInstGenIdBitReverse: | |
| 24787 | case IrInstGenIdUnionTag: | |
| 24788 | case IrInstGenIdTruncate: | |
| 24789 | case IrInstGenIdShuffleVector: | |
| 24790 | case IrInstGenIdSplat: | |
| 24791 | case IrInstGenIdBoolNot: | |
| 24792 | case IrInstGenIdReturnAddress: | |
| 24793 | case IrInstGenIdFrameAddress: | |
| 24794 | case IrInstGenIdFrameHandle: | |
| 24795 | case IrInstGenIdFrameSize: | |
| 24796 | case IrInstGenIdTestErr: | |
| 24797 | case IrInstGenIdPtrCast: | |
| 24798 | case IrInstGenIdBitCast: | |
| 24799 | case IrInstGenIdWidenOrShorten: | |
| 24800 | case IrInstGenIdPtrToInt: | |
| 24801 | case IrInstGenIdIntToPtr: | |
| 24802 | case IrInstGenIdIntToEnum: | |
| 24803 | case IrInstGenIdIntToErr: | |
| 24804 | case IrInstGenIdErrToInt: | |
| 24805 | case IrInstGenIdErrName: | |
| 24806 | case IrInstGenIdTagName: | |
| 24807 | case IrInstGenIdFieldParentPtr: | |
| 24808 | case IrInstGenIdAlignCast: | |
| 24809 | case IrInstGenIdErrorReturnTrace: | |
| 24810 | case IrInstGenIdFloatOp: | |
| 24811 | case IrInstGenIdMulAdd: | |
| 24812 | case IrInstGenIdAtomicLoad: | |
| 24813 | case IrInstGenIdArrayToVector: | |
| 24814 | case IrInstGenIdAlloca: | |
| 24815 | case IrInstGenIdSpillEnd: | |
| 24816 | case IrInstGenIdVectorExtractElem: | |
| 24817 | case IrInstGenIdBinaryNot: | |
| 24818 | case IrInstGenIdNegation: | |
| 24819 | case IrInstGenIdWasmMemorySize: | |
| 24820 | case IrInstGenIdReduce: | |
| 24773 | case Stage1AirInstIdPhi: | |
| 24774 | case Stage1AirInstIdBinOp: | |
| 24775 | case Stage1AirInstIdConst: | |
| 24776 | case Stage1AirInstIdCast: | |
| 24777 | case Stage1AirInstIdElemPtr: | |
| 24778 | case Stage1AirInstIdVarPtr: | |
| 24779 | case Stage1AirInstIdReturnPtr: | |
| 24780 | case Stage1AirInstIdStructFieldPtr: | |
| 24781 | case Stage1AirInstIdTestNonNull: | |
| 24782 | case Stage1AirInstIdClz: | |
| 24783 | case Stage1AirInstIdCtz: | |
| 24784 | case Stage1AirInstIdPopCount: | |
| 24785 | case Stage1AirInstIdBswap: | |
| 24786 | case Stage1AirInstIdBitReverse: | |
| 24787 | case Stage1AirInstIdUnionTag: | |
| 24788 | case Stage1AirInstIdTruncate: | |
| 24789 | case Stage1AirInstIdShuffleVector: | |
| 24790 | case Stage1AirInstIdSplat: | |
| 24791 | case Stage1AirInstIdBoolNot: | |
| 24792 | case Stage1AirInstIdReturnAddress: | |
| 24793 | case Stage1AirInstIdFrameAddress: | |
| 24794 | case Stage1AirInstIdFrameHandle: | |
| 24795 | case Stage1AirInstIdFrameSize: | |
| 24796 | case Stage1AirInstIdTestErr: | |
| 24797 | case Stage1AirInstIdPtrCast: | |
| 24798 | case Stage1AirInstIdBitCast: | |
| 24799 | case Stage1AirInstIdWidenOrShorten: | |
| 24800 | case Stage1AirInstIdPtrToInt: | |
| 24801 | case Stage1AirInstIdIntToPtr: | |
| 24802 | case Stage1AirInstIdIntToEnum: | |
| 24803 | case Stage1AirInstIdIntToErr: | |
| 24804 | case Stage1AirInstIdErrToInt: | |
| 24805 | case Stage1AirInstIdErrName: | |
| 24806 | case Stage1AirInstIdTagName: | |
| 24807 | case Stage1AirInstIdFieldParentPtr: | |
| 24808 | case Stage1AirInstIdAlignCast: | |
| 24809 | case Stage1AirInstIdErrorReturnTrace: | |
| 24810 | case Stage1AirInstIdFloatOp: | |
| 24811 | case Stage1AirInstIdMulAdd: | |
| 24812 | case Stage1AirInstIdAtomicLoad: | |
| 24813 | case Stage1AirInstIdArrayToVector: | |
| 24814 | case Stage1AirInstIdAlloca: | |
| 24815 | case Stage1AirInstIdSpillEnd: | |
| 24816 | case Stage1AirInstIdVectorExtractElem: | |
| 24817 | case Stage1AirInstIdBinaryNot: | |
| 24818 | case Stage1AirInstIdNegation: | |
| 24819 | case Stage1AirInstIdWasmMemorySize: | |
| 24820 | case Stage1AirInstIdReduce: | |
| 24821 | 24821 | return false; |
| 24822 | 24822 | |
| 24823 | case IrInstGenIdAsm: | |
| 24823 | case Stage1AirInstIdAsm: | |
| 24824 | 24824 | { |
| 24825 | IrInstGenAsm *asm_instruction = (IrInstGenAsm *)instruction; | |
| 24825 | Stage1AirInstAsm *asm_instruction = (Stage1AirInstAsm *)instruction; | |
| 24826 | 24826 | return asm_instruction->has_side_effects; |
| 24827 | 24827 | } |
| 24828 | case IrInstGenIdUnwrapErrPayload: | |
| 24828 | case Stage1AirInstIdUnwrapErrPayload: | |
| 24829 | 24829 | { |
| 24830 | IrInstGenUnwrapErrPayload *unwrap_err_payload_instruction = | |
| 24831 | (IrInstGenUnwrapErrPayload *)instruction; | |
| 24830 | Stage1AirInstUnwrapErrPayload *unwrap_err_payload_instruction = | |
| 24831 | (Stage1AirInstUnwrapErrPayload *)instruction; | |
| 24832 | 24832 | return unwrap_err_payload_instruction->safety_check_on || |
| 24833 | 24833 | unwrap_err_payload_instruction->initializing; |
| 24834 | 24834 | } |
| 24835 | case IrInstGenIdUnwrapErrCode: | |
| 24836 | return reinterpret_cast<IrInstGenUnwrapErrCode *>(instruction)->initializing; | |
| 24837 | case IrInstGenIdUnionFieldPtr: | |
| 24838 | return reinterpret_cast<IrInstGenUnionFieldPtr *>(instruction)->initializing; | |
| 24839 | case IrInstGenIdOptionalUnwrapPtr: | |
| 24840 | return reinterpret_cast<IrInstGenOptionalUnwrapPtr *>(instruction)->initializing; | |
| 24841 | case IrInstGenIdErrWrapPayload: | |
| 24842 | return reinterpret_cast<IrInstGenErrWrapPayload *>(instruction)->result_loc != nullptr; | |
| 24843 | case IrInstGenIdErrWrapCode: | |
| 24844 | return reinterpret_cast<IrInstGenErrWrapCode *>(instruction)->result_loc != nullptr; | |
| 24845 | case IrInstGenIdLoadPtr: | |
| 24846 | return reinterpret_cast<IrInstGenLoadPtr *>(instruction)->result_loc != nullptr; | |
| 24847 | case IrInstGenIdRef: | |
| 24848 | return reinterpret_cast<IrInstGenRef *>(instruction)->result_loc != nullptr; | |
| 24835 | case Stage1AirInstIdUnwrapErrCode: | |
| 24836 | return reinterpret_cast<Stage1AirInstUnwrapErrCode *>(instruction)->initializing; | |
| 24837 | case Stage1AirInstIdUnionFieldPtr: | |
| 24838 | return reinterpret_cast<Stage1AirInstUnionFieldPtr *>(instruction)->initializing; | |
| 24839 | case Stage1AirInstIdOptionalUnwrapPtr: | |
| 24840 | return reinterpret_cast<Stage1AirInstOptionalUnwrapPtr *>(instruction)->initializing; | |
| 24841 | case Stage1AirInstIdErrWrapPayload: | |
| 24842 | return reinterpret_cast<Stage1AirInstErrWrapPayload *>(instruction)->result_loc != nullptr; | |
| 24843 | case Stage1AirInstIdErrWrapCode: | |
| 24844 | return reinterpret_cast<Stage1AirInstErrWrapCode *>(instruction)->result_loc != nullptr; | |
| 24845 | case Stage1AirInstIdLoadPtr: | |
| 24846 | return reinterpret_cast<Stage1AirInstLoadPtr *>(instruction)->result_loc != nullptr; | |
| 24847 | case Stage1AirInstIdRef: | |
| 24848 | return reinterpret_cast<Stage1AirInstRef *>(instruction)->result_loc != nullptr; | |
| 24849 | 24849 | } |
| 24850 | 24850 | zig_unreachable(); |
| 24851 | 24851 | } |
| 24852 | 24852 | |
| 24853 | bool ir_inst_src_has_side_effects(IrInstSrc *instruction) { | |
| 24853 | bool ir_inst_src_has_side_effects(Stage1ZirInst *instruction) { | |
| 24854 | 24854 | switch (instruction->id) { |
| 24855 | case IrInstSrcIdInvalid: | |
| 24855 | case Stage1ZirInstIdInvalid: | |
| 24856 | 24856 | zig_unreachable(); |
| 24857 | case IrInstSrcIdBr: | |
| 24858 | case IrInstSrcIdCondBr: | |
| 24859 | case IrInstSrcIdSwitchBr: | |
| 24860 | case IrInstSrcIdDeclVar: | |
| 24861 | case IrInstSrcIdStorePtr: | |
| 24862 | case IrInstSrcIdCallExtra: | |
| 24863 | case IrInstSrcIdAsyncCallExtra: | |
| 24864 | case IrInstSrcIdCall: | |
| 24865 | case IrInstSrcIdCallArgs: | |
| 24866 | case IrInstSrcIdReturn: | |
| 24867 | case IrInstSrcIdUnreachable: | |
| 24868 | case IrInstSrcIdSetCold: | |
| 24869 | case IrInstSrcIdSetRuntimeSafety: | |
| 24870 | case IrInstSrcIdSetFloatMode: | |
| 24871 | case IrInstSrcIdImport: | |
| 24872 | case IrInstSrcIdCompileErr: | |
| 24873 | case IrInstSrcIdCompileLog: | |
| 24874 | case IrInstSrcIdCImport: | |
| 24875 | case IrInstSrcIdCInclude: | |
| 24876 | case IrInstSrcIdCDefine: | |
| 24877 | case IrInstSrcIdCUndef: | |
| 24878 | case IrInstSrcIdFence: | |
| 24879 | case IrInstSrcIdMemset: | |
| 24880 | case IrInstSrcIdMemcpy: | |
| 24881 | case IrInstSrcIdBreakpoint: | |
| 24882 | case IrInstSrcIdOverflowOp: // TODO when we support multiple returns this can be side effect free | |
| 24883 | case IrInstSrcIdCheckSwitchProngsUnderNo: | |
| 24884 | case IrInstSrcIdCheckSwitchProngsUnderYes: | |
| 24885 | case IrInstSrcIdCheckStatementIsVoid: | |
| 24886 | case IrInstSrcIdCheckRuntimeScope: | |
| 24887 | case IrInstSrcIdPanic: | |
| 24888 | case IrInstSrcIdSetEvalBranchQuota: | |
| 24889 | case IrInstSrcIdPtrType: | |
| 24890 | case IrInstSrcIdPtrTypeSimple: | |
| 24891 | case IrInstSrcIdPtrTypeSimpleConst: | |
| 24892 | case IrInstSrcIdSetAlignStack: | |
| 24893 | case IrInstSrcIdExport: | |
| 24894 | case IrInstSrcIdExtern: | |
| 24895 | case IrInstSrcIdSaveErrRetAddr: | |
| 24896 | case IrInstSrcIdAddImplicitReturnType: | |
| 24897 | case IrInstSrcIdAtomicRmw: | |
| 24898 | case IrInstSrcIdAtomicStore: | |
| 24899 | case IrInstSrcIdCmpxchg: | |
| 24900 | case IrInstSrcIdUndeclaredIdent: | |
| 24901 | case IrInstSrcIdEndExpr: | |
| 24902 | case IrInstSrcIdResetResult: | |
| 24903 | case IrInstSrcIdSuspendBegin: | |
| 24904 | case IrInstSrcIdSuspendFinish: | |
| 24905 | case IrInstSrcIdResume: | |
| 24906 | case IrInstSrcIdAwait: | |
| 24907 | case IrInstSrcIdSpillBegin: | |
| 24908 | case IrInstSrcIdWasmMemoryGrow: | |
| 24857 | case Stage1ZirInstIdBr: | |
| 24858 | case Stage1ZirInstIdCondBr: | |
| 24859 | case Stage1ZirInstIdSwitchBr: | |
| 24860 | case Stage1ZirInstIdDeclVar: | |
| 24861 | case Stage1ZirInstIdStorePtr: | |
| 24862 | case Stage1ZirInstIdCallExtra: | |
| 24863 | case Stage1ZirInstIdAsyncCallExtra: | |
| 24864 | case Stage1ZirInstIdCall: | |
| 24865 | case Stage1ZirInstIdCallArgs: | |
| 24866 | case Stage1ZirInstIdReturn: | |
| 24867 | case Stage1ZirInstIdUnreachable: | |
| 24868 | case Stage1ZirInstIdSetCold: | |
| 24869 | case Stage1ZirInstIdSetRuntimeSafety: | |
| 24870 | case Stage1ZirInstIdSetFloatMode: | |
| 24871 | case Stage1ZirInstIdImport: | |
| 24872 | case Stage1ZirInstIdCompileErr: | |
| 24873 | case Stage1ZirInstIdCompileLog: | |
| 24874 | case Stage1ZirInstIdCImport: | |
| 24875 | case Stage1ZirInstIdCInclude: | |
| 24876 | case Stage1ZirInstIdCDefine: | |
| 24877 | case Stage1ZirInstIdCUndef: | |
| 24878 | case Stage1ZirInstIdFence: | |
| 24879 | case Stage1ZirInstIdMemset: | |
| 24880 | case Stage1ZirInstIdMemcpy: | |
| 24881 | case Stage1ZirInstIdBreakpoint: | |
| 24882 | case Stage1ZirInstIdOverflowOp: // TODO when we support multiple returns this can be side effect free | |
| 24883 | case Stage1ZirInstIdCheckSwitchProngsUnderNo: | |
| 24884 | case Stage1ZirInstIdCheckSwitchProngsUnderYes: | |
| 24885 | case Stage1ZirInstIdCheckStatementIsVoid: | |
| 24886 | case Stage1ZirInstIdCheckRuntimeScope: | |
| 24887 | case Stage1ZirInstIdPanic: | |
| 24888 | case Stage1ZirInstIdSetEvalBranchQuota: | |
| 24889 | case Stage1ZirInstIdPtrType: | |
| 24890 | case Stage1ZirInstIdPtrTypeSimple: | |
| 24891 | case Stage1ZirInstIdPtrTypeSimpleConst: | |
| 24892 | case Stage1ZirInstIdSetAlignStack: | |
| 24893 | case Stage1ZirInstIdExport: | |
| 24894 | case Stage1ZirInstIdExtern: | |
| 24895 | case Stage1ZirInstIdSaveErrRetAddr: | |
| 24896 | case Stage1ZirInstIdAddImplicitReturnType: | |
| 24897 | case Stage1ZirInstIdAtomicRmw: | |
| 24898 | case Stage1ZirInstIdAtomicStore: | |
| 24899 | case Stage1ZirInstIdCmpxchg: | |
| 24900 | case Stage1ZirInstIdUndeclaredIdent: | |
| 24901 | case Stage1ZirInstIdEndExpr: | |
| 24902 | case Stage1ZirInstIdResetResult: | |
| 24903 | case Stage1ZirInstIdSuspendBegin: | |
| 24904 | case Stage1ZirInstIdSuspendFinish: | |
| 24905 | case Stage1ZirInstIdResume: | |
| 24906 | case Stage1ZirInstIdAwait: | |
| 24907 | case Stage1ZirInstIdSpillBegin: | |
| 24908 | case Stage1ZirInstIdWasmMemoryGrow: | |
| 24909 | 24909 | return true; |
| 24910 | 24910 | |
| 24911 | case IrInstSrcIdPhi: | |
| 24912 | case IrInstSrcIdUnOp: | |
| 24913 | case IrInstSrcIdBinOp: | |
| 24914 | case IrInstSrcIdMergeErrSets: | |
| 24915 | case IrInstSrcIdLoadPtr: | |
| 24916 | case IrInstSrcIdConst: | |
| 24917 | case IrInstSrcIdContainerInitList: | |
| 24918 | case IrInstSrcIdContainerInitFields: | |
| 24919 | case IrInstSrcIdUnionInitNamedField: | |
| 24920 | case IrInstSrcIdFieldPtr: | |
| 24921 | case IrInstSrcIdElemPtr: | |
| 24922 | case IrInstSrcIdVarPtr: | |
| 24923 | case IrInstSrcIdTypeOf: | |
| 24924 | case IrInstSrcIdArrayType: | |
| 24925 | case IrInstSrcIdSliceType: | |
| 24926 | case IrInstSrcIdAnyFrameType: | |
| 24927 | case IrInstSrcIdSizeOf: | |
| 24928 | case IrInstSrcIdTestNonNull: | |
| 24929 | case IrInstSrcIdOptionalUnwrapPtr: | |
| 24930 | case IrInstSrcIdClz: | |
| 24931 | case IrInstSrcIdCtz: | |
| 24932 | case IrInstSrcIdPopCount: | |
| 24933 | case IrInstSrcIdBswap: | |
| 24934 | case IrInstSrcIdBitReverse: | |
| 24935 | case IrInstSrcIdSwitchVar: | |
| 24936 | case IrInstSrcIdSwitchElseVar: | |
| 24937 | case IrInstSrcIdSwitchTarget: | |
| 24938 | case IrInstSrcIdRef: | |
| 24939 | case IrInstSrcIdEmbedFile: | |
| 24940 | case IrInstSrcIdTruncate: | |
| 24941 | case IrInstSrcIdVectorType: | |
| 24942 | case IrInstSrcIdShuffleVector: | |
| 24943 | case IrInstSrcIdSplat: | |
| 24944 | case IrInstSrcIdBoolNot: | |
| 24945 | case IrInstSrcIdSlice: | |
| 24946 | case IrInstSrcIdAlignOf: | |
| 24947 | case IrInstSrcIdReturnAddress: | |
| 24948 | case IrInstSrcIdFrameAddress: | |
| 24949 | case IrInstSrcIdFrameHandle: | |
| 24950 | case IrInstSrcIdFrameType: | |
| 24951 | case IrInstSrcIdFrameSize: | |
| 24952 | case IrInstSrcIdTestErr: | |
| 24953 | case IrInstSrcIdFnProto: | |
| 24954 | case IrInstSrcIdTestComptime: | |
| 24955 | case IrInstSrcIdPtrCast: | |
| 24956 | case IrInstSrcIdBitCast: | |
| 24957 | case IrInstSrcIdPtrToInt: | |
| 24958 | case IrInstSrcIdIntToPtr: | |
| 24959 | case IrInstSrcIdIntToEnum: | |
| 24960 | case IrInstSrcIdIntToErr: | |
| 24961 | case IrInstSrcIdErrToInt: | |
| 24962 | case IrInstSrcIdDeclRef: | |
| 24963 | case IrInstSrcIdErrName: | |
| 24964 | case IrInstSrcIdTypeName: | |
| 24965 | case IrInstSrcIdTagName: | |
| 24966 | case IrInstSrcIdFieldParentPtr: | |
| 24967 | case IrInstSrcIdOffsetOf: | |
| 24968 | case IrInstSrcIdBitOffsetOf: | |
| 24969 | case IrInstSrcIdTypeInfo: | |
| 24970 | case IrInstSrcIdType: | |
| 24971 | case IrInstSrcIdHasField: | |
| 24972 | case IrInstSrcIdAlignCast: | |
| 24973 | case IrInstSrcIdImplicitCast: | |
| 24974 | case IrInstSrcIdResolveResult: | |
| 24975 | case IrInstSrcIdArgTypeAllowVarFalse: | |
| 24976 | case IrInstSrcIdArgTypeAllowVarTrue: | |
| 24977 | case IrInstSrcIdErrorReturnTrace: | |
| 24978 | case IrInstSrcIdErrorUnion: | |
| 24979 | case IrInstSrcIdFloatOp: | |
| 24980 | case IrInstSrcIdMulAdd: | |
| 24981 | case IrInstSrcIdAtomicLoad: | |
| 24982 | case IrInstSrcIdIntCast: | |
| 24983 | case IrInstSrcIdFloatCast: | |
| 24984 | case IrInstSrcIdErrSetCast: | |
| 24985 | case IrInstSrcIdIntToFloat: | |
| 24986 | case IrInstSrcIdFloatToInt: | |
| 24987 | case IrInstSrcIdBoolToInt: | |
| 24988 | case IrInstSrcIdEnumToInt: | |
| 24989 | case IrInstSrcIdHasDecl: | |
| 24990 | case IrInstSrcIdAlloca: | |
| 24991 | case IrInstSrcIdSpillEnd: | |
| 24992 | case IrInstSrcIdWasmMemorySize: | |
| 24993 | case IrInstSrcIdSrc: | |
| 24994 | case IrInstSrcIdReduce: | |
| 24911 | case Stage1ZirInstIdPhi: | |
| 24912 | case Stage1ZirInstIdUnOp: | |
| 24913 | case Stage1ZirInstIdBinOp: | |
| 24914 | case Stage1ZirInstIdMergeErrSets: | |
| 24915 | case Stage1ZirInstIdLoadPtr: | |
| 24916 | case Stage1ZirInstIdConst: | |
| 24917 | case Stage1ZirInstIdContainerInitList: | |
| 24918 | case Stage1ZirInstIdContainerInitFields: | |
| 24919 | case Stage1ZirInstIdUnionInitNamedField: | |
| 24920 | case Stage1ZirInstIdFieldPtr: | |
| 24921 | case Stage1ZirInstIdElemPtr: | |
| 24922 | case Stage1ZirInstIdVarPtr: | |
| 24923 | case Stage1ZirInstIdTypeOf: | |
| 24924 | case Stage1ZirInstIdArrayType: | |
| 24925 | case Stage1ZirInstIdSliceType: | |
| 24926 | case Stage1ZirInstIdAnyFrameType: | |
| 24927 | case Stage1ZirInstIdSizeOf: | |
| 24928 | case Stage1ZirInstIdTestNonNull: | |
| 24929 | case Stage1ZirInstIdOptionalUnwrapPtr: | |
| 24930 | case Stage1ZirInstIdClz: | |
| 24931 | case Stage1ZirInstIdCtz: | |
| 24932 | case Stage1ZirInstIdPopCount: | |
| 24933 | case Stage1ZirInstIdBswap: | |
| 24934 | case Stage1ZirInstIdBitReverse: | |
| 24935 | case Stage1ZirInstIdSwitchVar: | |
| 24936 | case Stage1ZirInstIdSwitchElseVar: | |
| 24937 | case Stage1ZirInstIdSwitchTarget: | |
| 24938 | case Stage1ZirInstIdRef: | |
| 24939 | case Stage1ZirInstIdEmbedFile: | |
| 24940 | case Stage1ZirInstIdTruncate: | |
| 24941 | case Stage1ZirInstIdVectorType: | |
| 24942 | case Stage1ZirInstIdShuffleVector: | |
| 24943 | case Stage1ZirInstIdSplat: | |
| 24944 | case Stage1ZirInstIdBoolNot: | |
| 24945 | case Stage1ZirInstIdSlice: | |
| 24946 | case Stage1ZirInstIdAlignOf: | |
| 24947 | case Stage1ZirInstIdReturnAddress: | |
| 24948 | case Stage1ZirInstIdFrameAddress: | |
| 24949 | case Stage1ZirInstIdFrameHandle: | |
| 24950 | case Stage1ZirInstIdFrameType: | |
| 24951 | case Stage1ZirInstIdFrameSize: | |
| 24952 | case Stage1ZirInstIdTestErr: | |
| 24953 | case Stage1ZirInstIdFnProto: | |
| 24954 | case Stage1ZirInstIdTestComptime: | |
| 24955 | case Stage1ZirInstIdPtrCast: | |
| 24956 | case Stage1ZirInstIdBitCast: | |
| 24957 | case Stage1ZirInstIdPtrToInt: | |
| 24958 | case Stage1ZirInstIdIntToPtr: | |
| 24959 | case Stage1ZirInstIdIntToEnum: | |
| 24960 | case Stage1ZirInstIdIntToErr: | |
| 24961 | case Stage1ZirInstIdErrToInt: | |
| 24962 | case Stage1ZirInstIdDeclRef: | |
| 24963 | case Stage1ZirInstIdErrName: | |
| 24964 | case Stage1ZirInstIdTypeName: | |
| 24965 | case Stage1ZirInstIdTagName: | |
| 24966 | case Stage1ZirInstIdFieldParentPtr: | |
| 24967 | case Stage1ZirInstIdOffsetOf: | |
| 24968 | case Stage1ZirInstIdBitOffsetOf: | |
| 24969 | case Stage1ZirInstIdTypeInfo: | |
| 24970 | case Stage1ZirInstIdType: | |
| 24971 | case Stage1ZirInstIdHasField: | |
| 24972 | case Stage1ZirInstIdAlignCast: | |
| 24973 | case Stage1ZirInstIdImplicitCast: | |
| 24974 | case Stage1ZirInstIdResolveResult: | |
| 24975 | case Stage1ZirInstIdArgTypeAllowVarFalse: | |
| 24976 | case Stage1ZirInstIdArgTypeAllowVarTrue: | |
| 24977 | case Stage1ZirInstIdErrorReturnTrace: | |
| 24978 | case Stage1ZirInstIdErrorUnion: | |
| 24979 | case Stage1ZirInstIdFloatOp: | |
| 24980 | case Stage1ZirInstIdMulAdd: | |
| 24981 | case Stage1ZirInstIdAtomicLoad: | |
| 24982 | case Stage1ZirInstIdIntCast: | |
| 24983 | case Stage1ZirInstIdFloatCast: | |
| 24984 | case Stage1ZirInstIdErrSetCast: | |
| 24985 | case Stage1ZirInstIdIntToFloat: | |
| 24986 | case Stage1ZirInstIdFloatToInt: | |
| 24987 | case Stage1ZirInstIdBoolToInt: | |
| 24988 | case Stage1ZirInstIdEnumToInt: | |
| 24989 | case Stage1ZirInstIdHasDecl: | |
| 24990 | case Stage1ZirInstIdAlloca: | |
| 24991 | case Stage1ZirInstIdSpillEnd: | |
| 24992 | case Stage1ZirInstIdWasmMemorySize: | |
| 24993 | case Stage1ZirInstIdSrc: | |
| 24994 | case Stage1ZirInstIdReduce: | |
| 24995 | 24995 | return false; |
| 24996 | 24996 | |
| 24997 | case IrInstSrcIdAsm: | |
| 24997 | case Stage1ZirInstIdAsm: | |
| 24998 | 24998 | { |
| 24999 | IrInstSrcAsm *asm_instruction = (IrInstSrcAsm *)instruction; | |
| 24999 | Stage1ZirInstAsm *asm_instruction = (Stage1ZirInstAsm *)instruction; | |
| 25000 | 25000 | return asm_instruction->has_side_effects; |
| 25001 | 25001 | } |
| 25002 | 25002 | |
| 25003 | case IrInstSrcIdUnwrapErrPayload: | |
| 25003 | case Stage1ZirInstIdUnwrapErrPayload: | |
| 25004 | 25004 | { |
| 25005 | IrInstSrcUnwrapErrPayload *unwrap_err_payload_instruction = | |
| 25006 | (IrInstSrcUnwrapErrPayload *)instruction; | |
| 25005 | Stage1ZirInstUnwrapErrPayload *unwrap_err_payload_instruction = | |
| 25006 | (Stage1ZirInstUnwrapErrPayload *)instruction; | |
| 25007 | 25007 | return unwrap_err_payload_instruction->safety_check_on || |
| 25008 | 25008 | unwrap_err_payload_instruction->initializing; |
| 25009 | 25009 | } |
| 25010 | case IrInstSrcIdUnwrapErrCode: | |
| 25011 | return reinterpret_cast<IrInstSrcUnwrapErrCode *>(instruction)->initializing; | |
| 25010 | case Stage1ZirInstIdUnwrapErrCode: | |
| 25011 | return reinterpret_cast<Stage1ZirInstUnwrapErrCode *>(instruction)->initializing; | |
| 25012 | 25012 | } |
| 25013 | 25013 | zig_unreachable(); |
| 25014 | 25014 | } |
| ... | ... | @@ -25047,7 +25047,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La |
| 25047 | 25047 | param_info->type = nullptr; |
| 25048 | 25048 | return get_generic_fn_type(ira->codegen, &fn_type_id); |
| 25049 | 25049 | } else { |
| 25050 | IrInstGen *param_type_inst = lazy_fn_type->param_types[fn_type_id.next_param_index]; | |
| 25050 | Stage1AirInst *param_type_inst = lazy_fn_type->param_types[fn_type_id.next_param_index]; | |
| 25051 | 25051 | ZigType *param_type = ir_resolve_type(ira, param_type_inst); |
| 25052 | 25052 | if (type_is_invalid(param_type)) |
| 25053 | 25053 | return nullptr; |
| ... | ... | @@ -25257,7 +25257,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 25257 | 25257 | if (lazy_slice_type->sentinel != nullptr) { |
| 25258 | 25258 | if (type_is_invalid(lazy_slice_type->sentinel->value->type)) |
| 25259 | 25259 | return ErrorSemanticAnalyzeFail; |
| 25260 | IrInstGen *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type); | |
| 25260 | Stage1AirInst *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type); | |
| 25261 | 25261 | if (type_is_invalid(sentinel->value->type)) |
| 25262 | 25262 | return ErrorSemanticAnalyzeFail; |
| 25263 | 25263 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | ... | @@ -25336,7 +25336,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 25336 | 25336 | if (lazy_ptr_type->sentinel != nullptr) { |
| 25337 | 25337 | if (type_is_invalid(lazy_ptr_type->sentinel->value->type)) |
| 25338 | 25338 | return ErrorSemanticAnalyzeFail; |
| 25339 | IrInstGen *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type); | |
| 25339 | Stage1AirInst *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type); | |
| 25340 | 25340 | if (type_is_invalid(sentinel->value->type)) |
| 25341 | 25341 | return ErrorSemanticAnalyzeFail; |
| 25342 | 25342 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | ... | @@ -25500,7 +25500,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 25500 | 25500 | if (lazy_array_type->sentinel != nullptr) { |
| 25501 | 25501 | if (type_is_invalid(lazy_array_type->sentinel->value->type)) |
| 25502 | 25502 | return ErrorSemanticAnalyzeFail; |
| 25503 | IrInstGen *sentinel = ir_implicit_cast(ira, lazy_array_type->sentinel, elem_type); | |
| 25503 | Stage1AirInst *sentinel = ir_implicit_cast(ira, lazy_array_type->sentinel, elem_type); | |
| 25504 | 25504 | if (type_is_invalid(sentinel->value->type)) |
| 25505 | 25505 | return ErrorSemanticAnalyzeFail; |
| 25506 | 25506 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | ... | @@ -25691,8 +25691,8 @@ Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val) { |
| 25691 | 25691 | return ErrorNone; |
| 25692 | 25692 | } |
| 25693 | 25693 | |
| 25694 | void IrInstGen::src() { | |
| 25695 | IrInstGen *inst = this; | |
| 25694 | void Stage1AirInst::src() { | |
| 25695 | Stage1AirInst *inst = this; | |
| 25696 | 25696 | if (inst->source_node != nullptr) { |
| 25697 | 25697 | inst->source_node->src(); |
| 25698 | 25698 | } else { |
| ... | ... | @@ -25700,8 +25700,8 @@ void IrInstGen::src() { |
| 25700 | 25700 | } |
| 25701 | 25701 | } |
| 25702 | 25702 | |
| 25703 | void IrInstGen::dump() { | |
| 25704 | IrInstGen *inst = this; | |
| 25703 | void Stage1AirInst::dump() { | |
| 25704 | Stage1AirInst *inst = this; | |
| 25705 | 25705 | inst->src(); |
| 25706 | 25706 | if (inst->scope == nullptr) { |
| 25707 | 25707 | fprintf(stderr, "(null scope)\n"); |
src/stage1/ir.hpp+2-2| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | |
| 11 | 11 | #include "all_types.hpp" |
| 12 | 12 | |
| 13 | IrInstGen *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigFn *fn, | |
| 13 | Stage1AirInst *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigFn *fn, | |
| 14 | 14 | ZigType *var_type, const char *name_hint); |
| 15 | 15 | |
| 16 | 16 | Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| ... | ... | @@ -25,7 +25,7 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *stage1_zir, Stage1Air *stage1_a |
| 25 | 25 | ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *result_ptr, |
| 26 | 26 | ZigFn *fn); |
| 27 | 27 | |
| 28 | bool ir_inst_gen_has_side_effects(IrInstGen *inst); | |
| 28 | bool ir_inst_gen_has_side_effects(Stage1AirInst *inst); | |
| 29 | 29 | |
| 30 | 30 | struct IrAnalyze; |
| 31 | 31 | ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_val, |
src/stage1/ir_print.cpp+955-955| ... | ... | @@ -12,26 +12,26 @@ |
| 12 | 12 | #include "ir_print.hpp" |
| 13 | 13 | #include "os.hpp" |
| 14 | 14 | |
| 15 | static uint32_t hash_inst_src_ptr(IrInstSrc* instruction) { | |
| 15 | static uint32_t hash_inst_src_ptr(Stage1ZirInst* instruction) { | |
| 16 | 16 | return (uint32_t)(uintptr_t)instruction; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | static uint32_t hash_inst_gen_ptr(IrInstGen* instruction) { | |
| 19 | static uint32_t hash_inst_gen_ptr(Stage1AirInst* instruction) { | |
| 20 | 20 | return (uint32_t)(uintptr_t)instruction; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | static bool inst_src_ptr_eql(IrInstSrc* a, IrInstSrc* b) { | |
| 23 | static bool inst_src_ptr_eql(Stage1ZirInst* a, Stage1ZirInst* b) { | |
| 24 | 24 | return a == b; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | static bool inst_gen_ptr_eql(IrInstGen* a, IrInstGen* b) { | |
| 27 | static bool inst_gen_ptr_eql(Stage1AirInst* a, Stage1AirInst* b) { | |
| 28 | 28 | return a == b; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | using InstSetSrc = HashMap<IrInstSrc*, uint8_t, hash_inst_src_ptr, inst_src_ptr_eql>; | |
| 32 | using InstSetGen = HashMap<IrInstGen*, uint8_t, hash_inst_gen_ptr, inst_gen_ptr_eql>; | |
| 33 | using InstListSrc = ZigList<IrInstSrc*>; | |
| 34 | using InstListGen = ZigList<IrInstGen*>; | |
| 31 | using InstSetSrc = HashMap<Stage1ZirInst*, uint8_t, hash_inst_src_ptr, inst_src_ptr_eql>; | |
| 32 | using InstSetGen = HashMap<Stage1AirInst*, uint8_t, hash_inst_gen_ptr, inst_gen_ptr_eql>; | |
| 33 | using InstListSrc = ZigList<Stage1ZirInst*>; | |
| 34 | using InstListGen = ZigList<Stage1AirInst*>; | |
| 35 | 35 | |
| 36 | 36 | struct IrPrintSrc { |
| 37 | 37 | CodeGen *codegen; |
| ... | ... | @@ -54,8 +54,8 @@ struct IrPrintGen { |
| 54 | 54 | InstListGen pending; |
| 55 | 55 | }; |
| 56 | 56 | |
| 57 | static void ir_print_other_inst_src(IrPrintSrc *irp, IrInstSrc *inst); | |
| 58 | static void ir_print_other_inst_gen(IrPrintGen *irp, IrInstGen *inst); | |
| 57 | static void ir_print_other_inst_src(IrPrintSrc *irp, Stage1ZirInst *inst); | |
| 58 | static void ir_print_other_inst_gen(IrPrintGen *irp, Stage1AirInst *inst); | |
| 59 | 59 | |
| 60 | 60 | static void ir_print_call_modifier(FILE *f, CallModifier modifier) { |
| 61 | 61 | switch (modifier) { |
| ... | ... | @@ -87,473 +87,473 @@ static void ir_print_call_modifier(FILE *f, CallModifier modifier) { |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | const char* ir_inst_src_type_str(IrInstSrcId id) { | |
| 90 | const char* ir_inst_src_type_str(Stage1ZirInstId id) { | |
| 91 | 91 | switch (id) { |
| 92 | case IrInstSrcIdInvalid: | |
| 92 | case Stage1ZirInstIdInvalid: | |
| 93 | 93 | return "SrcInvalid"; |
| 94 | case IrInstSrcIdShuffleVector: | |
| 94 | case Stage1ZirInstIdShuffleVector: | |
| 95 | 95 | return "SrcShuffle"; |
| 96 | case IrInstSrcIdSplat: | |
| 96 | case Stage1ZirInstIdSplat: | |
| 97 | 97 | return "SrcSplat"; |
| 98 | case IrInstSrcIdDeclVar: | |
| 98 | case Stage1ZirInstIdDeclVar: | |
| 99 | 99 | return "SrcDeclVar"; |
| 100 | case IrInstSrcIdBr: | |
| 100 | case Stage1ZirInstIdBr: | |
| 101 | 101 | return "SrcBr"; |
| 102 | case IrInstSrcIdCondBr: | |
| 102 | case Stage1ZirInstIdCondBr: | |
| 103 | 103 | return "SrcCondBr"; |
| 104 | case IrInstSrcIdSwitchBr: | |
| 104 | case Stage1ZirInstIdSwitchBr: | |
| 105 | 105 | return "SrcSwitchBr"; |
| 106 | case IrInstSrcIdSwitchVar: | |
| 106 | case Stage1ZirInstIdSwitchVar: | |
| 107 | 107 | return "SrcSwitchVar"; |
| 108 | case IrInstSrcIdSwitchElseVar: | |
| 108 | case Stage1ZirInstIdSwitchElseVar: | |
| 109 | 109 | return "SrcSwitchElseVar"; |
| 110 | case IrInstSrcIdSwitchTarget: | |
| 110 | case Stage1ZirInstIdSwitchTarget: | |
| 111 | 111 | return "SrcSwitchTarget"; |
| 112 | case IrInstSrcIdPhi: | |
| 112 | case Stage1ZirInstIdPhi: | |
| 113 | 113 | return "SrcPhi"; |
| 114 | case IrInstSrcIdUnOp: | |
| 114 | case Stage1ZirInstIdUnOp: | |
| 115 | 115 | return "SrcUnOp"; |
| 116 | case IrInstSrcIdBinOp: | |
| 116 | case Stage1ZirInstIdBinOp: | |
| 117 | 117 | return "SrcBinOp"; |
| 118 | case IrInstSrcIdMergeErrSets: | |
| 118 | case Stage1ZirInstIdMergeErrSets: | |
| 119 | 119 | return "SrcMergeErrSets"; |
| 120 | case IrInstSrcIdLoadPtr: | |
| 120 | case Stage1ZirInstIdLoadPtr: | |
| 121 | 121 | return "SrcLoadPtr"; |
| 122 | case IrInstSrcIdStorePtr: | |
| 122 | case Stage1ZirInstIdStorePtr: | |
| 123 | 123 | return "SrcStorePtr"; |
| 124 | case IrInstSrcIdFieldPtr: | |
| 124 | case Stage1ZirInstIdFieldPtr: | |
| 125 | 125 | return "SrcFieldPtr"; |
| 126 | case IrInstSrcIdElemPtr: | |
| 126 | case Stage1ZirInstIdElemPtr: | |
| 127 | 127 | return "SrcElemPtr"; |
| 128 | case IrInstSrcIdVarPtr: | |
| 128 | case Stage1ZirInstIdVarPtr: | |
| 129 | 129 | return "SrcVarPtr"; |
| 130 | case IrInstSrcIdCallExtra: | |
| 130 | case Stage1ZirInstIdCallExtra: | |
| 131 | 131 | return "SrcCallExtra"; |
| 132 | case IrInstSrcIdAsyncCallExtra: | |
| 132 | case Stage1ZirInstIdAsyncCallExtra: | |
| 133 | 133 | return "SrcAsyncCallExtra"; |
| 134 | case IrInstSrcIdCall: | |
| 134 | case Stage1ZirInstIdCall: | |
| 135 | 135 | return "SrcCall"; |
| 136 | case IrInstSrcIdCallArgs: | |
| 136 | case Stage1ZirInstIdCallArgs: | |
| 137 | 137 | return "SrcCallArgs"; |
| 138 | case IrInstSrcIdConst: | |
| 138 | case Stage1ZirInstIdConst: | |
| 139 | 139 | return "SrcConst"; |
| 140 | case IrInstSrcIdReturn: | |
| 140 | case Stage1ZirInstIdReturn: | |
| 141 | 141 | return "SrcReturn"; |
| 142 | case IrInstSrcIdContainerInitList: | |
| 142 | case Stage1ZirInstIdContainerInitList: | |
| 143 | 143 | return "SrcContainerInitList"; |
| 144 | case IrInstSrcIdContainerInitFields: | |
| 144 | case Stage1ZirInstIdContainerInitFields: | |
| 145 | 145 | return "SrcContainerInitFields"; |
| 146 | case IrInstSrcIdUnreachable: | |
| 146 | case Stage1ZirInstIdUnreachable: | |
| 147 | 147 | return "SrcUnreachable"; |
| 148 | case IrInstSrcIdTypeOf: | |
| 148 | case Stage1ZirInstIdTypeOf: | |
| 149 | 149 | return "SrcTypeOf"; |
| 150 | case IrInstSrcIdSetCold: | |
| 150 | case Stage1ZirInstIdSetCold: | |
| 151 | 151 | return "SrcSetCold"; |
| 152 | case IrInstSrcIdSetRuntimeSafety: | |
| 152 | case Stage1ZirInstIdSetRuntimeSafety: | |
| 153 | 153 | return "SrcSetRuntimeSafety"; |
| 154 | case IrInstSrcIdSetFloatMode: | |
| 154 | case Stage1ZirInstIdSetFloatMode: | |
| 155 | 155 | return "SrcSetFloatMode"; |
| 156 | case IrInstSrcIdArrayType: | |
| 156 | case Stage1ZirInstIdArrayType: | |
| 157 | 157 | return "SrcArrayType"; |
| 158 | case IrInstSrcIdAnyFrameType: | |
| 158 | case Stage1ZirInstIdAnyFrameType: | |
| 159 | 159 | return "SrcAnyFrameType"; |
| 160 | case IrInstSrcIdSliceType: | |
| 160 | case Stage1ZirInstIdSliceType: | |
| 161 | 161 | return "SrcSliceType"; |
| 162 | case IrInstSrcIdAsm: | |
| 162 | case Stage1ZirInstIdAsm: | |
| 163 | 163 | return "SrcAsm"; |
| 164 | case IrInstSrcIdSizeOf: | |
| 164 | case Stage1ZirInstIdSizeOf: | |
| 165 | 165 | return "SrcSizeOf"; |
| 166 | case IrInstSrcIdTestNonNull: | |
| 166 | case Stage1ZirInstIdTestNonNull: | |
| 167 | 167 | return "SrcTestNonNull"; |
| 168 | case IrInstSrcIdOptionalUnwrapPtr: | |
| 168 | case Stage1ZirInstIdOptionalUnwrapPtr: | |
| 169 | 169 | return "SrcOptionalUnwrapPtr"; |
| 170 | case IrInstSrcIdClz: | |
| 170 | case Stage1ZirInstIdClz: | |
| 171 | 171 | return "SrcClz"; |
| 172 | case IrInstSrcIdCtz: | |
| 172 | case Stage1ZirInstIdCtz: | |
| 173 | 173 | return "SrcCtz"; |
| 174 | case IrInstSrcIdPopCount: | |
| 174 | case Stage1ZirInstIdPopCount: | |
| 175 | 175 | return "SrcPopCount"; |
| 176 | case IrInstSrcIdBswap: | |
| 176 | case Stage1ZirInstIdBswap: | |
| 177 | 177 | return "SrcBswap"; |
| 178 | case IrInstSrcIdBitReverse: | |
| 178 | case Stage1ZirInstIdBitReverse: | |
| 179 | 179 | return "SrcBitReverse"; |
| 180 | case IrInstSrcIdImport: | |
| 180 | case Stage1ZirInstIdImport: | |
| 181 | 181 | return "SrcImport"; |
| 182 | case IrInstSrcIdCImport: | |
| 182 | case Stage1ZirInstIdCImport: | |
| 183 | 183 | return "SrcCImport"; |
| 184 | case IrInstSrcIdCInclude: | |
| 184 | case Stage1ZirInstIdCInclude: | |
| 185 | 185 | return "SrcCInclude"; |
| 186 | case IrInstSrcIdCDefine: | |
| 186 | case Stage1ZirInstIdCDefine: | |
| 187 | 187 | return "SrcCDefine"; |
| 188 | case IrInstSrcIdCUndef: | |
| 188 | case Stage1ZirInstIdCUndef: | |
| 189 | 189 | return "SrcCUndef"; |
| 190 | case IrInstSrcIdRef: | |
| 190 | case Stage1ZirInstIdRef: | |
| 191 | 191 | return "SrcRef"; |
| 192 | case IrInstSrcIdCompileErr: | |
| 192 | case Stage1ZirInstIdCompileErr: | |
| 193 | 193 | return "SrcCompileErr"; |
| 194 | case IrInstSrcIdCompileLog: | |
| 194 | case Stage1ZirInstIdCompileLog: | |
| 195 | 195 | return "SrcCompileLog"; |
| 196 | case IrInstSrcIdErrName: | |
| 196 | case Stage1ZirInstIdErrName: | |
| 197 | 197 | return "SrcErrName"; |
| 198 | case IrInstSrcIdEmbedFile: | |
| 198 | case Stage1ZirInstIdEmbedFile: | |
| 199 | 199 | return "SrcEmbedFile"; |
| 200 | case IrInstSrcIdCmpxchg: | |
| 200 | case Stage1ZirInstIdCmpxchg: | |
| 201 | 201 | return "SrcCmpxchg"; |
| 202 | case IrInstSrcIdFence: | |
| 202 | case Stage1ZirInstIdFence: | |
| 203 | 203 | return "SrcFence"; |
| 204 | case IrInstSrcIdReduce: | |
| 204 | case Stage1ZirInstIdReduce: | |
| 205 | 205 | return "SrcReduce"; |
| 206 | case IrInstSrcIdTruncate: | |
| 206 | case Stage1ZirInstIdTruncate: | |
| 207 | 207 | return "SrcTruncate"; |
| 208 | case IrInstSrcIdIntCast: | |
| 208 | case Stage1ZirInstIdIntCast: | |
| 209 | 209 | return "SrcIntCast"; |
| 210 | case IrInstSrcIdFloatCast: | |
| 210 | case Stage1ZirInstIdFloatCast: | |
| 211 | 211 | return "SrcFloatCast"; |
| 212 | case IrInstSrcIdIntToFloat: | |
| 212 | case Stage1ZirInstIdIntToFloat: | |
| 213 | 213 | return "SrcIntToFloat"; |
| 214 | case IrInstSrcIdFloatToInt: | |
| 214 | case Stage1ZirInstIdFloatToInt: | |
| 215 | 215 | return "SrcFloatToInt"; |
| 216 | case IrInstSrcIdBoolToInt: | |
| 216 | case Stage1ZirInstIdBoolToInt: | |
| 217 | 217 | return "SrcBoolToInt"; |
| 218 | case IrInstSrcIdVectorType: | |
| 218 | case Stage1ZirInstIdVectorType: | |
| 219 | 219 | return "SrcVectorType"; |
| 220 | case IrInstSrcIdBoolNot: | |
| 220 | case Stage1ZirInstIdBoolNot: | |
| 221 | 221 | return "SrcBoolNot"; |
| 222 | case IrInstSrcIdMemset: | |
| 222 | case Stage1ZirInstIdMemset: | |
| 223 | 223 | return "SrcMemset"; |
| 224 | case IrInstSrcIdMemcpy: | |
| 224 | case Stage1ZirInstIdMemcpy: | |
| 225 | 225 | return "SrcMemcpy"; |
| 226 | case IrInstSrcIdSlice: | |
| 226 | case Stage1ZirInstIdSlice: | |
| 227 | 227 | return "SrcSlice"; |
| 228 | case IrInstSrcIdBreakpoint: | |
| 228 | case Stage1ZirInstIdBreakpoint: | |
| 229 | 229 | return "SrcBreakpoint"; |
| 230 | case IrInstSrcIdReturnAddress: | |
| 230 | case Stage1ZirInstIdReturnAddress: | |
| 231 | 231 | return "SrcReturnAddress"; |
| 232 | case IrInstSrcIdFrameAddress: | |
| 232 | case Stage1ZirInstIdFrameAddress: | |
| 233 | 233 | return "SrcFrameAddress"; |
| 234 | case IrInstSrcIdFrameHandle: | |
| 234 | case Stage1ZirInstIdFrameHandle: | |
| 235 | 235 | return "SrcFrameHandle"; |
| 236 | case IrInstSrcIdFrameType: | |
| 236 | case Stage1ZirInstIdFrameType: | |
| 237 | 237 | return "SrcFrameType"; |
| 238 | case IrInstSrcIdFrameSize: | |
| 238 | case Stage1ZirInstIdFrameSize: | |
| 239 | 239 | return "SrcFrameSize"; |
| 240 | case IrInstSrcIdAlignOf: | |
| 240 | case Stage1ZirInstIdAlignOf: | |
| 241 | 241 | return "SrcAlignOf"; |
| 242 | case IrInstSrcIdOverflowOp: | |
| 242 | case Stage1ZirInstIdOverflowOp: | |
| 243 | 243 | return "SrcOverflowOp"; |
| 244 | case IrInstSrcIdTestErr: | |
| 244 | case Stage1ZirInstIdTestErr: | |
| 245 | 245 | return "SrcTestErr"; |
| 246 | case IrInstSrcIdMulAdd: | |
| 246 | case Stage1ZirInstIdMulAdd: | |
| 247 | 247 | return "SrcMulAdd"; |
| 248 | case IrInstSrcIdFloatOp: | |
| 248 | case Stage1ZirInstIdFloatOp: | |
| 249 | 249 | return "SrcFloatOp"; |
| 250 | case IrInstSrcIdUnwrapErrCode: | |
| 250 | case Stage1ZirInstIdUnwrapErrCode: | |
| 251 | 251 | return "SrcUnwrapErrCode"; |
| 252 | case IrInstSrcIdUnwrapErrPayload: | |
| 252 | case Stage1ZirInstIdUnwrapErrPayload: | |
| 253 | 253 | return "SrcUnwrapErrPayload"; |
| 254 | case IrInstSrcIdFnProto: | |
| 254 | case Stage1ZirInstIdFnProto: | |
| 255 | 255 | return "SrcFnProto"; |
| 256 | case IrInstSrcIdTestComptime: | |
| 256 | case Stage1ZirInstIdTestComptime: | |
| 257 | 257 | return "SrcTestComptime"; |
| 258 | case IrInstSrcIdPtrCast: | |
| 258 | case Stage1ZirInstIdPtrCast: | |
| 259 | 259 | return "SrcPtrCast"; |
| 260 | case IrInstSrcIdBitCast: | |
| 260 | case Stage1ZirInstIdBitCast: | |
| 261 | 261 | return "SrcBitCast"; |
| 262 | case IrInstSrcIdIntToPtr: | |
| 262 | case Stage1ZirInstIdIntToPtr: | |
| 263 | 263 | return "SrcIntToPtr"; |
| 264 | case IrInstSrcIdPtrToInt: | |
| 264 | case Stage1ZirInstIdPtrToInt: | |
| 265 | 265 | return "SrcPtrToInt"; |
| 266 | case IrInstSrcIdIntToEnum: | |
| 266 | case Stage1ZirInstIdIntToEnum: | |
| 267 | 267 | return "SrcIntToEnum"; |
| 268 | case IrInstSrcIdEnumToInt: | |
| 268 | case Stage1ZirInstIdEnumToInt: | |
| 269 | 269 | return "SrcEnumToInt"; |
| 270 | case IrInstSrcIdIntToErr: | |
| 270 | case Stage1ZirInstIdIntToErr: | |
| 271 | 271 | return "SrcIntToErr"; |
| 272 | case IrInstSrcIdErrToInt: | |
| 272 | case Stage1ZirInstIdErrToInt: | |
| 273 | 273 | return "SrcErrToInt"; |
| 274 | case IrInstSrcIdCheckSwitchProngsUnderNo: | |
| 274 | case Stage1ZirInstIdCheckSwitchProngsUnderNo: | |
| 275 | 275 | return "SrcCheckSwitchProngsUnderNo"; |
| 276 | case IrInstSrcIdCheckSwitchProngsUnderYes: | |
| 276 | case Stage1ZirInstIdCheckSwitchProngsUnderYes: | |
| 277 | 277 | return "SrcCheckSwitchProngsUnderYes"; |
| 278 | case IrInstSrcIdCheckStatementIsVoid: | |
| 278 | case Stage1ZirInstIdCheckStatementIsVoid: | |
| 279 | 279 | return "SrcCheckStatementIsVoid"; |
| 280 | case IrInstSrcIdTypeName: | |
| 280 | case Stage1ZirInstIdTypeName: | |
| 281 | 281 | return "SrcTypeName"; |
| 282 | case IrInstSrcIdDeclRef: | |
| 282 | case Stage1ZirInstIdDeclRef: | |
| 283 | 283 | return "SrcDeclRef"; |
| 284 | case IrInstSrcIdPanic: | |
| 284 | case Stage1ZirInstIdPanic: | |
| 285 | 285 | return "SrcPanic"; |
| 286 | case IrInstSrcIdTagName: | |
| 286 | case Stage1ZirInstIdTagName: | |
| 287 | 287 | return "SrcTagName"; |
| 288 | case IrInstSrcIdFieldParentPtr: | |
| 288 | case Stage1ZirInstIdFieldParentPtr: | |
| 289 | 289 | return "SrcFieldParentPtr"; |
| 290 | case IrInstSrcIdOffsetOf: | |
| 290 | case Stage1ZirInstIdOffsetOf: | |
| 291 | 291 | return "SrcOffsetOf"; |
| 292 | case IrInstSrcIdBitOffsetOf: | |
| 292 | case Stage1ZirInstIdBitOffsetOf: | |
| 293 | 293 | return "SrcBitOffsetOf"; |
| 294 | case IrInstSrcIdTypeInfo: | |
| 294 | case Stage1ZirInstIdTypeInfo: | |
| 295 | 295 | return "SrcTypeInfo"; |
| 296 | case IrInstSrcIdType: | |
| 296 | case Stage1ZirInstIdType: | |
| 297 | 297 | return "SrcType"; |
| 298 | case IrInstSrcIdHasField: | |
| 298 | case Stage1ZirInstIdHasField: | |
| 299 | 299 | return "SrcHasField"; |
| 300 | case IrInstSrcIdSetEvalBranchQuota: | |
| 300 | case Stage1ZirInstIdSetEvalBranchQuota: | |
| 301 | 301 | return "SrcSetEvalBranchQuota"; |
| 302 | case IrInstSrcIdPtrType: | |
| 302 | case Stage1ZirInstIdPtrType: | |
| 303 | 303 | return "SrcPtrType"; |
| 304 | case IrInstSrcIdPtrTypeSimple: | |
| 304 | case Stage1ZirInstIdPtrTypeSimple: | |
| 305 | 305 | return "SrcPtrTypeSimple"; |
| 306 | case IrInstSrcIdPtrTypeSimpleConst: | |
| 306 | case Stage1ZirInstIdPtrTypeSimpleConst: | |
| 307 | 307 | return "SrcPtrTypeSimpleConst"; |
| 308 | case IrInstSrcIdAlignCast: | |
| 308 | case Stage1ZirInstIdAlignCast: | |
| 309 | 309 | return "SrcAlignCast"; |
| 310 | case IrInstSrcIdImplicitCast: | |
| 310 | case Stage1ZirInstIdImplicitCast: | |
| 311 | 311 | return "SrcImplicitCast"; |
| 312 | case IrInstSrcIdResolveResult: | |
| 312 | case Stage1ZirInstIdResolveResult: | |
| 313 | 313 | return "SrcResolveResult"; |
| 314 | case IrInstSrcIdResetResult: | |
| 314 | case Stage1ZirInstIdResetResult: | |
| 315 | 315 | return "SrcResetResult"; |
| 316 | case IrInstSrcIdSetAlignStack: | |
| 316 | case Stage1ZirInstIdSetAlignStack: | |
| 317 | 317 | return "SrcSetAlignStack"; |
| 318 | case IrInstSrcIdArgTypeAllowVarFalse: | |
| 318 | case Stage1ZirInstIdArgTypeAllowVarFalse: | |
| 319 | 319 | return "SrcArgTypeAllowVarFalse"; |
| 320 | case IrInstSrcIdArgTypeAllowVarTrue: | |
| 320 | case Stage1ZirInstIdArgTypeAllowVarTrue: | |
| 321 | 321 | return "SrcArgTypeAllowVarTrue"; |
| 322 | case IrInstSrcIdExport: | |
| 322 | case Stage1ZirInstIdExport: | |
| 323 | 323 | return "SrcExport"; |
| 324 | case IrInstSrcIdExtern: | |
| 324 | case Stage1ZirInstIdExtern: | |
| 325 | 325 | return "SrcExtern"; |
| 326 | case IrInstSrcIdErrorReturnTrace: | |
| 326 | case Stage1ZirInstIdErrorReturnTrace: | |
| 327 | 327 | return "SrcErrorReturnTrace"; |
| 328 | case IrInstSrcIdErrorUnion: | |
| 328 | case Stage1ZirInstIdErrorUnion: | |
| 329 | 329 | return "SrcErrorUnion"; |
| 330 | case IrInstSrcIdAtomicRmw: | |
| 330 | case Stage1ZirInstIdAtomicRmw: | |
| 331 | 331 | return "SrcAtomicRmw"; |
| 332 | case IrInstSrcIdAtomicLoad: | |
| 332 | case Stage1ZirInstIdAtomicLoad: | |
| 333 | 333 | return "SrcAtomicLoad"; |
| 334 | case IrInstSrcIdAtomicStore: | |
| 334 | case Stage1ZirInstIdAtomicStore: | |
| 335 | 335 | return "SrcAtomicStore"; |
| 336 | case IrInstSrcIdSaveErrRetAddr: | |
| 336 | case Stage1ZirInstIdSaveErrRetAddr: | |
| 337 | 337 | return "SrcSaveErrRetAddr"; |
| 338 | case IrInstSrcIdAddImplicitReturnType: | |
| 338 | case Stage1ZirInstIdAddImplicitReturnType: | |
| 339 | 339 | return "SrcAddImplicitReturnType"; |
| 340 | case IrInstSrcIdErrSetCast: | |
| 340 | case Stage1ZirInstIdErrSetCast: | |
| 341 | 341 | return "SrcErrSetCast"; |
| 342 | case IrInstSrcIdCheckRuntimeScope: | |
| 342 | case Stage1ZirInstIdCheckRuntimeScope: | |
| 343 | 343 | return "SrcCheckRuntimeScope"; |
| 344 | case IrInstSrcIdHasDecl: | |
| 344 | case Stage1ZirInstIdHasDecl: | |
| 345 | 345 | return "SrcHasDecl"; |
| 346 | case IrInstSrcIdUndeclaredIdent: | |
| 346 | case Stage1ZirInstIdUndeclaredIdent: | |
| 347 | 347 | return "SrcUndeclaredIdent"; |
| 348 | case IrInstSrcIdAlloca: | |
| 348 | case Stage1ZirInstIdAlloca: | |
| 349 | 349 | return "SrcAlloca"; |
| 350 | case IrInstSrcIdEndExpr: | |
| 350 | case Stage1ZirInstIdEndExpr: | |
| 351 | 351 | return "SrcEndExpr"; |
| 352 | case IrInstSrcIdUnionInitNamedField: | |
| 352 | case Stage1ZirInstIdUnionInitNamedField: | |
| 353 | 353 | return "SrcUnionInitNamedField"; |
| 354 | case IrInstSrcIdSuspendBegin: | |
| 354 | case Stage1ZirInstIdSuspendBegin: | |
| 355 | 355 | return "SrcSuspendBegin"; |
| 356 | case IrInstSrcIdSuspendFinish: | |
| 356 | case Stage1ZirInstIdSuspendFinish: | |
| 357 | 357 | return "SrcSuspendFinish"; |
| 358 | case IrInstSrcIdAwait: | |
| 358 | case Stage1ZirInstIdAwait: | |
| 359 | 359 | return "SrcAwaitSr"; |
| 360 | case IrInstSrcIdResume: | |
| 360 | case Stage1ZirInstIdResume: | |
| 361 | 361 | return "SrcResume"; |
| 362 | case IrInstSrcIdSpillBegin: | |
| 362 | case Stage1ZirInstIdSpillBegin: | |
| 363 | 363 | return "SrcSpillBegin"; |
| 364 | case IrInstSrcIdSpillEnd: | |
| 364 | case Stage1ZirInstIdSpillEnd: | |
| 365 | 365 | return "SrcSpillEnd"; |
| 366 | case IrInstSrcIdWasmMemorySize: | |
| 366 | case Stage1ZirInstIdWasmMemorySize: | |
| 367 | 367 | return "SrcWasmMemorySize"; |
| 368 | case IrInstSrcIdWasmMemoryGrow: | |
| 368 | case Stage1ZirInstIdWasmMemoryGrow: | |
| 369 | 369 | return "SrcWasmMemoryGrow"; |
| 370 | case IrInstSrcIdSrc: | |
| 370 | case Stage1ZirInstIdSrc: | |
| 371 | 371 | return "SrcSrc"; |
| 372 | 372 | } |
| 373 | 373 | zig_unreachable(); |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | const char* ir_inst_gen_type_str(IrInstGenId id) { | |
| 376 | const char* ir_inst_gen_type_str(Stage1AirInstId id) { | |
| 377 | 377 | switch (id) { |
| 378 | case IrInstGenIdInvalid: | |
| 378 | case Stage1AirInstIdInvalid: | |
| 379 | 379 | return "GenInvalid"; |
| 380 | case IrInstGenIdShuffleVector: | |
| 380 | case Stage1AirInstIdShuffleVector: | |
| 381 | 381 | return "GenShuffle"; |
| 382 | case IrInstGenIdSplat: | |
| 382 | case Stage1AirInstIdSplat: | |
| 383 | 383 | return "GenSplat"; |
| 384 | case IrInstGenIdDeclVar: | |
| 384 | case Stage1AirInstIdDeclVar: | |
| 385 | 385 | return "GenDeclVar"; |
| 386 | case IrInstGenIdBr: | |
| 386 | case Stage1AirInstIdBr: | |
| 387 | 387 | return "GenBr"; |
| 388 | case IrInstGenIdCondBr: | |
| 388 | case Stage1AirInstIdCondBr: | |
| 389 | 389 | return "GenCondBr"; |
| 390 | case IrInstGenIdSwitchBr: | |
| 390 | case Stage1AirInstIdSwitchBr: | |
| 391 | 391 | return "GenSwitchBr"; |
| 392 | case IrInstGenIdPhi: | |
| 392 | case Stage1AirInstIdPhi: | |
| 393 | 393 | return "GenPhi"; |
| 394 | case IrInstGenIdBinOp: | |
| 394 | case Stage1AirInstIdBinOp: | |
| 395 | 395 | return "GenBinOp"; |
| 396 | case IrInstGenIdLoadPtr: | |
| 396 | case Stage1AirInstIdLoadPtr: | |
| 397 | 397 | return "GenLoadPtr"; |
| 398 | case IrInstGenIdStorePtr: | |
| 398 | case Stage1AirInstIdStorePtr: | |
| 399 | 399 | return "GenStorePtr"; |
| 400 | case IrInstGenIdVectorStoreElem: | |
| 400 | case Stage1AirInstIdVectorStoreElem: | |
| 401 | 401 | return "GenVectorStoreElem"; |
| 402 | case IrInstGenIdStructFieldPtr: | |
| 402 | case Stage1AirInstIdStructFieldPtr: | |
| 403 | 403 | return "GenStructFieldPtr"; |
| 404 | case IrInstGenIdUnionFieldPtr: | |
| 404 | case Stage1AirInstIdUnionFieldPtr: | |
| 405 | 405 | return "GenUnionFieldPtr"; |
| 406 | case IrInstGenIdElemPtr: | |
| 406 | case Stage1AirInstIdElemPtr: | |
| 407 | 407 | return "GenElemPtr"; |
| 408 | case IrInstGenIdVarPtr: | |
| 408 | case Stage1AirInstIdVarPtr: | |
| 409 | 409 | return "GenVarPtr"; |
| 410 | case IrInstGenIdReturnPtr: | |
| 410 | case Stage1AirInstIdReturnPtr: | |
| 411 | 411 | return "GenReturnPtr"; |
| 412 | case IrInstGenIdCall: | |
| 412 | case Stage1AirInstIdCall: | |
| 413 | 413 | return "GenCall"; |
| 414 | case IrInstGenIdConst: | |
| 414 | case Stage1AirInstIdConst: | |
| 415 | 415 | return "GenConst"; |
| 416 | case IrInstGenIdReturn: | |
| 416 | case Stage1AirInstIdReturn: | |
| 417 | 417 | return "GenReturn"; |
| 418 | case IrInstGenIdCast: | |
| 418 | case Stage1AirInstIdCast: | |
| 419 | 419 | return "GenCast"; |
| 420 | case IrInstGenIdUnreachable: | |
| 420 | case Stage1AirInstIdUnreachable: | |
| 421 | 421 | return "GenUnreachable"; |
| 422 | case IrInstGenIdAsm: | |
| 422 | case Stage1AirInstIdAsm: | |
| 423 | 423 | return "GenAsm"; |
| 424 | case IrInstGenIdTestNonNull: | |
| 424 | case Stage1AirInstIdTestNonNull: | |
| 425 | 425 | return "GenTestNonNull"; |
| 426 | case IrInstGenIdOptionalUnwrapPtr: | |
| 426 | case Stage1AirInstIdOptionalUnwrapPtr: | |
| 427 | 427 | return "GenOptionalUnwrapPtr"; |
| 428 | case IrInstGenIdOptionalWrap: | |
| 428 | case Stage1AirInstIdOptionalWrap: | |
| 429 | 429 | return "GenOptionalWrap"; |
| 430 | case IrInstGenIdUnionTag: | |
| 430 | case Stage1AirInstIdUnionTag: | |
| 431 | 431 | return "GenUnionTag"; |
| 432 | case IrInstGenIdClz: | |
| 432 | case Stage1AirInstIdClz: | |
| 433 | 433 | return "GenClz"; |
| 434 | case IrInstGenIdCtz: | |
| 434 | case Stage1AirInstIdCtz: | |
| 435 | 435 | return "GenCtz"; |
| 436 | case IrInstGenIdPopCount: | |
| 436 | case Stage1AirInstIdPopCount: | |
| 437 | 437 | return "GenPopCount"; |
| 438 | case IrInstGenIdBswap: | |
| 438 | case Stage1AirInstIdBswap: | |
| 439 | 439 | return "GenBswap"; |
| 440 | case IrInstGenIdBitReverse: | |
| 440 | case Stage1AirInstIdBitReverse: | |
| 441 | 441 | return "GenBitReverse"; |
| 442 | case IrInstGenIdRef: | |
| 442 | case Stage1AirInstIdRef: | |
| 443 | 443 | return "GenRef"; |
| 444 | case IrInstGenIdErrName: | |
| 444 | case Stage1AirInstIdErrName: | |
| 445 | 445 | return "GenErrName"; |
| 446 | case IrInstGenIdCmpxchg: | |
| 446 | case Stage1AirInstIdCmpxchg: | |
| 447 | 447 | return "GenCmpxchg"; |
| 448 | case IrInstGenIdFence: | |
| 448 | case Stage1AirInstIdFence: | |
| 449 | 449 | return "GenFence"; |
| 450 | case IrInstGenIdReduce: | |
| 450 | case Stage1AirInstIdReduce: | |
| 451 | 451 | return "GenReduce"; |
| 452 | case IrInstGenIdTruncate: | |
| 452 | case Stage1AirInstIdTruncate: | |
| 453 | 453 | return "GenTruncate"; |
| 454 | case IrInstGenIdBoolNot: | |
| 454 | case Stage1AirInstIdBoolNot: | |
| 455 | 455 | return "GenBoolNot"; |
| 456 | case IrInstGenIdMemset: | |
| 456 | case Stage1AirInstIdMemset: | |
| 457 | 457 | return "GenMemset"; |
| 458 | case IrInstGenIdMemcpy: | |
| 458 | case Stage1AirInstIdMemcpy: | |
| 459 | 459 | return "GenMemcpy"; |
| 460 | case IrInstGenIdSlice: | |
| 460 | case Stage1AirInstIdSlice: | |
| 461 | 461 | return "GenSlice"; |
| 462 | case IrInstGenIdBreakpoint: | |
| 462 | case Stage1AirInstIdBreakpoint: | |
| 463 | 463 | return "GenBreakpoint"; |
| 464 | case IrInstGenIdReturnAddress: | |
| 464 | case Stage1AirInstIdReturnAddress: | |
| 465 | 465 | return "GenReturnAddress"; |
| 466 | case IrInstGenIdFrameAddress: | |
| 466 | case Stage1AirInstIdFrameAddress: | |
| 467 | 467 | return "GenFrameAddress"; |
| 468 | case IrInstGenIdFrameHandle: | |
| 468 | case Stage1AirInstIdFrameHandle: | |
| 469 | 469 | return "GenFrameHandle"; |
| 470 | case IrInstGenIdFrameSize: | |
| 470 | case Stage1AirInstIdFrameSize: | |
| 471 | 471 | return "GenFrameSize"; |
| 472 | case IrInstGenIdOverflowOp: | |
| 472 | case Stage1AirInstIdOverflowOp: | |
| 473 | 473 | return "GenOverflowOp"; |
| 474 | case IrInstGenIdTestErr: | |
| 474 | case Stage1AirInstIdTestErr: | |
| 475 | 475 | return "GenTestErr"; |
| 476 | case IrInstGenIdMulAdd: | |
| 476 | case Stage1AirInstIdMulAdd: | |
| 477 | 477 | return "GenMulAdd"; |
| 478 | case IrInstGenIdFloatOp: | |
| 478 | case Stage1AirInstIdFloatOp: | |
| 479 | 479 | return "GenFloatOp"; |
| 480 | case IrInstGenIdUnwrapErrCode: | |
| 480 | case Stage1AirInstIdUnwrapErrCode: | |
| 481 | 481 | return "GenUnwrapErrCode"; |
| 482 | case IrInstGenIdUnwrapErrPayload: | |
| 482 | case Stage1AirInstIdUnwrapErrPayload: | |
| 483 | 483 | return "GenUnwrapErrPayload"; |
| 484 | case IrInstGenIdErrWrapCode: | |
| 484 | case Stage1AirInstIdErrWrapCode: | |
| 485 | 485 | return "GenErrWrapCode"; |
| 486 | case IrInstGenIdErrWrapPayload: | |
| 486 | case Stage1AirInstIdErrWrapPayload: | |
| 487 | 487 | return "GenErrWrapPayload"; |
| 488 | case IrInstGenIdPtrCast: | |
| 488 | case Stage1AirInstIdPtrCast: | |
| 489 | 489 | return "GenPtrCast"; |
| 490 | case IrInstGenIdBitCast: | |
| 490 | case Stage1AirInstIdBitCast: | |
| 491 | 491 | return "GenBitCast"; |
| 492 | case IrInstGenIdWidenOrShorten: | |
| 492 | case Stage1AirInstIdWidenOrShorten: | |
| 493 | 493 | return "GenWidenOrShorten"; |
| 494 | case IrInstGenIdIntToPtr: | |
| 494 | case Stage1AirInstIdIntToPtr: | |
| 495 | 495 | return "GenIntToPtr"; |
| 496 | case IrInstGenIdPtrToInt: | |
| 496 | case Stage1AirInstIdPtrToInt: | |
| 497 | 497 | return "GenPtrToInt"; |
| 498 | case IrInstGenIdIntToEnum: | |
| 498 | case Stage1AirInstIdIntToEnum: | |
| 499 | 499 | return "GenIntToEnum"; |
| 500 | case IrInstGenIdIntToErr: | |
| 500 | case Stage1AirInstIdIntToErr: | |
| 501 | 501 | return "GenIntToErr"; |
| 502 | case IrInstGenIdErrToInt: | |
| 502 | case Stage1AirInstIdErrToInt: | |
| 503 | 503 | return "GenErrToInt"; |
| 504 | case IrInstGenIdPanic: | |
| 504 | case Stage1AirInstIdPanic: | |
| 505 | 505 | return "GenPanic"; |
| 506 | case IrInstGenIdTagName: | |
| 506 | case Stage1AirInstIdTagName: | |
| 507 | 507 | return "GenTagName"; |
| 508 | case IrInstGenIdFieldParentPtr: | |
| 508 | case Stage1AirInstIdFieldParentPtr: | |
| 509 | 509 | return "GenFieldParentPtr"; |
| 510 | case IrInstGenIdAlignCast: | |
| 510 | case Stage1AirInstIdAlignCast: | |
| 511 | 511 | return "GenAlignCast"; |
| 512 | case IrInstGenIdErrorReturnTrace: | |
| 512 | case Stage1AirInstIdErrorReturnTrace: | |
| 513 | 513 | return "GenErrorReturnTrace"; |
| 514 | case IrInstGenIdAtomicRmw: | |
| 514 | case Stage1AirInstIdAtomicRmw: | |
| 515 | 515 | return "GenAtomicRmw"; |
| 516 | case IrInstGenIdAtomicLoad: | |
| 516 | case Stage1AirInstIdAtomicLoad: | |
| 517 | 517 | return "GenAtomicLoad"; |
| 518 | case IrInstGenIdAtomicStore: | |
| 518 | case Stage1AirInstIdAtomicStore: | |
| 519 | 519 | return "GenAtomicStore"; |
| 520 | case IrInstGenIdSaveErrRetAddr: | |
| 520 | case Stage1AirInstIdSaveErrRetAddr: | |
| 521 | 521 | return "GenSaveErrRetAddr"; |
| 522 | case IrInstGenIdVectorToArray: | |
| 522 | case Stage1AirInstIdVectorToArray: | |
| 523 | 523 | return "GenVectorToArray"; |
| 524 | case IrInstGenIdArrayToVector: | |
| 524 | case Stage1AirInstIdArrayToVector: | |
| 525 | 525 | return "GenArrayToVector"; |
| 526 | case IrInstGenIdAssertZero: | |
| 526 | case Stage1AirInstIdAssertZero: | |
| 527 | 527 | return "GenAssertZero"; |
| 528 | case IrInstGenIdAssertNonNull: | |
| 528 | case Stage1AirInstIdAssertNonNull: | |
| 529 | 529 | return "GenAssertNonNull"; |
| 530 | case IrInstGenIdAlloca: | |
| 530 | case Stage1AirInstIdAlloca: | |
| 531 | 531 | return "GenAlloca"; |
| 532 | case IrInstGenIdPtrOfArrayToSlice: | |
| 532 | case Stage1AirInstIdPtrOfArrayToSlice: | |
| 533 | 533 | return "GenPtrOfArrayToSlice"; |
| 534 | case IrInstGenIdSuspendBegin: | |
| 534 | case Stage1AirInstIdSuspendBegin: | |
| 535 | 535 | return "GenSuspendBegin"; |
| 536 | case IrInstGenIdSuspendFinish: | |
| 536 | case Stage1AirInstIdSuspendFinish: | |
| 537 | 537 | return "GenSuspendFinish"; |
| 538 | case IrInstGenIdAwait: | |
| 538 | case Stage1AirInstIdAwait: | |
| 539 | 539 | return "GenAwait"; |
| 540 | case IrInstGenIdResume: | |
| 540 | case Stage1AirInstIdResume: | |
| 541 | 541 | return "GenResume"; |
| 542 | case IrInstGenIdSpillBegin: | |
| 542 | case Stage1AirInstIdSpillBegin: | |
| 543 | 543 | return "GenSpillBegin"; |
| 544 | case IrInstGenIdSpillEnd: | |
| 544 | case Stage1AirInstIdSpillEnd: | |
| 545 | 545 | return "GenSpillEnd"; |
| 546 | case IrInstGenIdVectorExtractElem: | |
| 546 | case Stage1AirInstIdVectorExtractElem: | |
| 547 | 547 | return "GenVectorExtractElem"; |
| 548 | case IrInstGenIdBinaryNot: | |
| 548 | case Stage1AirInstIdBinaryNot: | |
| 549 | 549 | return "GenBinaryNot"; |
| 550 | case IrInstGenIdNegation: | |
| 550 | case Stage1AirInstIdNegation: | |
| 551 | 551 | return "GenNegation"; |
| 552 | case IrInstGenIdWasmMemorySize: | |
| 552 | case Stage1AirInstIdWasmMemorySize: | |
| 553 | 553 | return "GenWasmMemorySize"; |
| 554 | case IrInstGenIdWasmMemoryGrow: | |
| 554 | case Stage1AirInstIdWasmMemoryGrow: | |
| 555 | 555 | return "GenWasmMemoryGrow"; |
| 556 | case IrInstGenIdExtern: | |
| 556 | case Stage1AirInstIdExtern: | |
| 557 | 557 | return "GenExtrern"; |
| 558 | 558 | } |
| 559 | 559 | zig_unreachable(); |
| ... | ... | @@ -571,12 +571,12 @@ static void ir_print_indent_gen(IrPrintGen *irp) { |
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | static void ir_print_prefix_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trailing) { | |
| 574 | static void ir_print_prefix_src(IrPrintSrc *irp, Stage1ZirInst *instruction, bool trailing) { | |
| 575 | 575 | ir_print_indent_src(irp); |
| 576 | 576 | const char mark = trailing ? ':' : '#'; |
| 577 | 577 | const char *type_name; |
| 578 | if (instruction->id == IrInstSrcIdConst) { | |
| 579 | type_name = buf_ptr(&reinterpret_cast<IrInstSrcConst *>(instruction)->value->type->name); | |
| 578 | if (instruction->id == Stage1ZirInstIdConst) { | |
| 579 | type_name = buf_ptr(&reinterpret_cast<Stage1ZirInstConst *>(instruction)->value->type->name); | |
| 580 | 580 | } else { |
| 581 | 581 | type_name = "(unknown)"; |
| 582 | 582 | } |
| ... | ... | @@ -586,7 +586,7 @@ static void ir_print_prefix_src(IrPrintSrc *irp, IrInstSrc *instruction, bool tr |
| 586 | 586 | ir_inst_src_type_str(instruction->id), type_name, ref_count); |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | static void ir_print_prefix_gen(IrPrintGen *irp, IrInstGen *instruction, bool trailing) { | |
| 589 | static void ir_print_prefix_gen(IrPrintGen *irp, Stage1AirInst *instruction, bool trailing) { | |
| 590 | 590 | ir_print_indent_gen(irp); |
| 591 | 591 | const char mark = trailing ? ':' : '#'; |
| 592 | 592 | const char *type_name = instruction->value->type ? buf_ptr(&instruction->value->type->name) : "(unknown)"; |
| ... | ... | @@ -596,11 +596,11 @@ static void ir_print_prefix_gen(IrPrintGen *irp, IrInstGen *instruction, bool tr |
| 596 | 596 | ir_inst_gen_type_str(instruction->id), type_name, ref_count); |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | static void ir_print_var_src(IrPrintSrc *irp, IrInstSrc *inst) { | |
| 599 | static void ir_print_var_src(IrPrintSrc *irp, Stage1ZirInst *inst) { | |
| 600 | 600 | fprintf(irp->f, "#%" PRIu32 "", inst->debug_id); |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | static void ir_print_var_gen(IrPrintGen *irp, IrInstGen *inst) { | |
| 603 | static void ir_print_var_gen(IrPrintGen *irp, Stage1AirInst *inst) { | |
| 604 | 604 | fprintf(irp->f, "#%" PRIu32 "", inst->debug_id); |
| 605 | 605 | if (irp->printed.maybe_get(inst) == nullptr) { |
| 606 | 606 | irp->printed.put(inst, 0); |
| ... | ... | @@ -608,7 +608,7 @@ static void ir_print_var_gen(IrPrintGen *irp, IrInstGen *inst) { |
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | static void ir_print_other_inst_src(IrPrintSrc *irp, IrInstSrc *inst) { | |
| 611 | static void ir_print_other_inst_src(IrPrintSrc *irp, Stage1ZirInst *inst) { | |
| 612 | 612 | if (inst == nullptr) { |
| 613 | 613 | fprintf(irp->f, "(null)"); |
| 614 | 614 | return; |
| ... | ... | @@ -623,7 +623,7 @@ static void ir_print_const_value(CodeGen *g, FILE *f, ZigValue *const_val) { |
| 623 | 623 | fprintf(f, "%s", buf_ptr(&buf)); |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | static void ir_print_other_inst_gen(IrPrintGen *irp, IrInstGen *inst) { | |
| 626 | static void ir_print_other_inst_gen(IrPrintGen *irp, Stage1AirInst *inst) { | |
| 627 | 627 | if (inst == nullptr) { |
| 628 | 628 | fprintf(irp->f, "(null)"); |
| 629 | 629 | } else { |
| ... | ... | @@ -639,7 +639,7 @@ static void ir_print_other_block(IrPrintSrc *irp, Stage1ZirBasicBlock *bb) { |
| 639 | 639 | } |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | static void ir_print_other_block_gen(IrPrintGen *irp, IrBasicBlockGen *bb) { | |
| 642 | static void ir_print_other_block_gen(IrPrintGen *irp, Stage1AirBasicBlock *bb) { | |
| 643 | 643 | if (bb == nullptr) { |
| 644 | 644 | fprintf(irp->f, "(null block)"); |
| 645 | 645 | } else { |
| ... | ... | @@ -647,21 +647,21 @@ static void ir_print_other_block_gen(IrPrintGen *irp, IrBasicBlockGen *bb) { |
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | static void ir_print_return_src(IrPrintSrc *irp, IrInstSrcReturn *inst) { | |
| 650 | static void ir_print_return_src(IrPrintSrc *irp, Stage1ZirInstReturn *inst) { | |
| 651 | 651 | fprintf(irp->f, "return "); |
| 652 | 652 | ir_print_other_inst_src(irp, inst->operand); |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | static void ir_print_return_gen(IrPrintGen *irp, IrInstGenReturn *inst) { | |
| 655 | static void ir_print_return_gen(IrPrintGen *irp, Stage1AirInstReturn *inst) { | |
| 656 | 656 | fprintf(irp->f, "return "); |
| 657 | 657 | ir_print_other_inst_gen(irp, inst->operand); |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | static void ir_print_const(IrPrintSrc *irp, IrInstSrcConst *const_instruction) { | |
| 660 | static void ir_print_const(IrPrintSrc *irp, Stage1ZirInstConst *const_instruction) { | |
| 661 | 661 | ir_print_const_value(irp->codegen, irp->f, const_instruction->value); |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | static void ir_print_const(IrPrintGen *irp, IrInstGenConst *const_instruction) { | |
| 664 | static void ir_print_const(IrPrintGen *irp, Stage1AirInstConst *const_instruction) { | |
| 665 | 665 | ir_print_const_value(irp->codegen, irp->f, const_instruction->base.value); |
| 666 | 666 | } |
| 667 | 667 | |
| ... | ... | @@ -751,12 +751,12 @@ static const char *ir_un_op_id_str(IrUnOp op_id) { |
| 751 | 751 | zig_unreachable(); |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | static void ir_print_un_op(IrPrintSrc *irp, IrInstSrcUnOp *inst) { | |
| 754 | static void ir_print_un_op(IrPrintSrc *irp, Stage1ZirInstUnOp *inst) { | |
| 755 | 755 | fprintf(irp->f, "%s ", ir_un_op_id_str(inst->op_id)); |
| 756 | 756 | ir_print_other_inst_src(irp, inst->value); |
| 757 | 757 | } |
| 758 | 758 | |
| 759 | static void ir_print_bin_op(IrPrintSrc *irp, IrInstSrcBinOp *bin_op_instruction) { | |
| 759 | static void ir_print_bin_op(IrPrintSrc *irp, Stage1ZirInstBinOp *bin_op_instruction) { | |
| 760 | 760 | ir_print_other_inst_src(irp, bin_op_instruction->op1); |
| 761 | 761 | fprintf(irp->f, " %s ", ir_bin_op_id_str(bin_op_instruction->op_id)); |
| 762 | 762 | ir_print_other_inst_src(irp, bin_op_instruction->op2); |
| ... | ... | @@ -765,7 +765,7 @@ static void ir_print_bin_op(IrPrintSrc *irp, IrInstSrcBinOp *bin_op_instruction) |
| 765 | 765 | } |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | static void ir_print_bin_op(IrPrintGen *irp, IrInstGenBinOp *bin_op_instruction) { | |
| 768 | static void ir_print_bin_op(IrPrintGen *irp, Stage1AirInstBinOp *bin_op_instruction) { | |
| 769 | 769 | ir_print_other_inst_gen(irp, bin_op_instruction->op1); |
| 770 | 770 | fprintf(irp->f, " %s ", ir_bin_op_id_str(bin_op_instruction->op_id)); |
| 771 | 771 | ir_print_other_inst_gen(irp, bin_op_instruction->op2); |
| ... | ... | @@ -774,7 +774,7 @@ static void ir_print_bin_op(IrPrintGen *irp, IrInstGenBinOp *bin_op_instruction) |
| 774 | 774 | } |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | static void ir_print_merge_err_sets(IrPrintSrc *irp, IrInstSrcMergeErrSets *instruction) { | |
| 777 | static void ir_print_merge_err_sets(IrPrintSrc *irp, Stage1ZirInstMergeErrSets *instruction) { | |
| 778 | 778 | ir_print_other_inst_src(irp, instruction->op1); |
| 779 | 779 | fprintf(irp->f, " || "); |
| 780 | 780 | ir_print_other_inst_src(irp, instruction->op2); |
| ... | ... | @@ -783,7 +783,7 @@ static void ir_print_merge_err_sets(IrPrintSrc *irp, IrInstSrcMergeErrSets *inst |
| 783 | 783 | } |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | static void ir_print_decl_var_src(IrPrintSrc *irp, IrInstSrcDeclVar *decl_var_instruction) { | |
| 786 | static void ir_print_decl_var_src(IrPrintSrc *irp, Stage1ZirInstDeclVar *decl_var_instruction) { | |
| 787 | 787 | const char *var_or_const = decl_var_instruction->var->gen_is_const ? "const" : "var"; |
| 788 | 788 | const char *name = decl_var_instruction->var->name; |
| 789 | 789 | if (decl_var_instruction->var_type) { |
| ... | ... | @@ -820,7 +820,7 @@ static const char *cast_op_str(CastOp op) { |
| 820 | 820 | zig_unreachable(); |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | static void ir_print_cast(IrPrintGen *irp, IrInstGenCast *cast_instruction) { | |
| 823 | static void ir_print_cast(IrPrintGen *irp, Stage1AirInstCast *cast_instruction) { | |
| 824 | 824 | fprintf(irp->f, "%s cast ", cast_op_str(cast_instruction->cast_op)); |
| 825 | 825 | ir_print_other_inst_gen(irp, cast_instruction->value); |
| 826 | 826 | } |
| ... | ... | @@ -882,7 +882,7 @@ static void ir_print_result_loc(IrPrintSrc *irp, ResultLoc *result_loc) { |
| 882 | 882 | zig_unreachable(); |
| 883 | 883 | } |
| 884 | 884 | |
| 885 | static void ir_print_call_extra(IrPrintSrc *irp, IrInstSrcCallExtra *instruction) { | |
| 885 | static void ir_print_call_extra(IrPrintSrc *irp, Stage1ZirInstCallExtra *instruction) { | |
| 886 | 886 | fprintf(irp->f, "opts="); |
| 887 | 887 | ir_print_other_inst_src(irp, instruction->options); |
| 888 | 888 | fprintf(irp->f, ", fn="); |
| ... | ... | @@ -893,7 +893,7 @@ static void ir_print_call_extra(IrPrintSrc *irp, IrInstSrcCallExtra *instruction |
| 893 | 893 | ir_print_result_loc(irp, instruction->result_loc); |
| 894 | 894 | } |
| 895 | 895 | |
| 896 | static void ir_print_async_call_extra(IrPrintSrc *irp, IrInstSrcAsyncCallExtra *instruction) { | |
| 896 | static void ir_print_async_call_extra(IrPrintSrc *irp, Stage1ZirInstAsyncCallExtra *instruction) { | |
| 897 | 897 | fprintf(irp->f, "modifier="); |
| 898 | 898 | ir_print_call_modifier(irp->f, instruction->modifier); |
| 899 | 899 | fprintf(irp->f, ", fn="); |
| ... | ... | @@ -910,14 +910,14 @@ static void ir_print_async_call_extra(IrPrintSrc *irp, IrInstSrcAsyncCallExtra * |
| 910 | 910 | ir_print_result_loc(irp, instruction->result_loc); |
| 911 | 911 | } |
| 912 | 912 | |
| 913 | static void ir_print_call_args(IrPrintSrc *irp, IrInstSrcCallArgs *instruction) { | |
| 913 | static void ir_print_call_args(IrPrintSrc *irp, Stage1ZirInstCallArgs *instruction) { | |
| 914 | 914 | fprintf(irp->f, "opts="); |
| 915 | 915 | ir_print_other_inst_src(irp, instruction->options); |
| 916 | 916 | fprintf(irp->f, ", fn="); |
| 917 | 917 | ir_print_other_inst_src(irp, instruction->fn_ref); |
| 918 | 918 | fprintf(irp->f, ", args=("); |
| 919 | 919 | for (size_t i = 0; i < instruction->args_len; i += 1) { |
| 920 | IrInstSrc *arg = instruction->args_ptr[i]; | |
| 920 | Stage1ZirInst *arg = instruction->args_ptr[i]; | |
| 921 | 921 | if (i != 0) |
| 922 | 922 | fprintf(irp->f, ", "); |
| 923 | 923 | ir_print_other_inst_src(irp, arg); |
| ... | ... | @@ -926,7 +926,7 @@ static void ir_print_call_args(IrPrintSrc *irp, IrInstSrcCallArgs *instruction) |
| 926 | 926 | ir_print_result_loc(irp, instruction->result_loc); |
| 927 | 927 | } |
| 928 | 928 | |
| 929 | static void ir_print_call_src(IrPrintSrc *irp, IrInstSrcCall *call_instruction) { | |
| 929 | static void ir_print_call_src(IrPrintSrc *irp, Stage1ZirInstCall *call_instruction) { | |
| 930 | 930 | ir_print_call_modifier(irp->f, call_instruction->modifier); |
| 931 | 931 | if (call_instruction->fn_entry) { |
| 932 | 932 | fprintf(irp->f, "%s", buf_ptr(&call_instruction->fn_entry->symbol_name)); |
| ... | ... | @@ -936,7 +936,7 @@ static void ir_print_call_src(IrPrintSrc *irp, IrInstSrcCall *call_instruction) |
| 936 | 936 | } |
| 937 | 937 | fprintf(irp->f, "("); |
| 938 | 938 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { |
| 939 | IrInstSrc *arg = call_instruction->args[i]; | |
| 939 | Stage1ZirInst *arg = call_instruction->args[i]; | |
| 940 | 940 | if (i != 0) |
| 941 | 941 | fprintf(irp->f, ", "); |
| 942 | 942 | ir_print_other_inst_src(irp, arg); |
| ... | ... | @@ -945,7 +945,7 @@ static void ir_print_call_src(IrPrintSrc *irp, IrInstSrcCall *call_instruction) |
| 945 | 945 | ir_print_result_loc(irp, call_instruction->result_loc); |
| 946 | 946 | } |
| 947 | 947 | |
| 948 | static void ir_print_call_gen(IrPrintGen *irp, IrInstGenCall *call_instruction) { | |
| 948 | static void ir_print_call_gen(IrPrintGen *irp, Stage1AirInstCall *call_instruction) { | |
| 949 | 949 | ir_print_call_modifier(irp->f, call_instruction->modifier); |
| 950 | 950 | if (call_instruction->fn_entry) { |
| 951 | 951 | fprintf(irp->f, "%s", buf_ptr(&call_instruction->fn_entry->symbol_name)); |
| ... | ... | @@ -955,7 +955,7 @@ static void ir_print_call_gen(IrPrintGen *irp, IrInstGenCall *call_instruction) |
| 955 | 955 | } |
| 956 | 956 | fprintf(irp->f, "("); |
| 957 | 957 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { |
| 958 | IrInstGen *arg = call_instruction->args[i]; | |
| 958 | Stage1AirInst *arg = call_instruction->args[i]; | |
| 959 | 959 | if (i != 0) |
| 960 | 960 | fprintf(irp->f, ", "); |
| 961 | 961 | ir_print_other_inst_gen(irp, arg); |
| ... | ... | @@ -964,7 +964,7 @@ static void ir_print_call_gen(IrPrintGen *irp, IrInstGenCall *call_instruction) |
| 964 | 964 | ir_print_other_inst_gen(irp, call_instruction->result_loc); |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | static void ir_print_cond_br(IrPrintSrc *irp, IrInstSrcCondBr *inst) { | |
| 967 | static void ir_print_cond_br(IrPrintSrc *irp, Stage1ZirInstCondBr *inst) { | |
| 968 | 968 | fprintf(irp->f, "if ("); |
| 969 | 969 | ir_print_other_inst_src(irp, inst->condition); |
| 970 | 970 | fprintf(irp->f, ") "); |
| ... | ... | @@ -977,7 +977,7 @@ static void ir_print_cond_br(IrPrintSrc *irp, IrInstSrcCondBr *inst) { |
| 977 | 977 | } |
| 978 | 978 | } |
| 979 | 979 | |
| 980 | static void ir_print_cond_br(IrPrintGen *irp, IrInstGenCondBr *inst) { | |
| 980 | static void ir_print_cond_br(IrPrintGen *irp, Stage1AirInstCondBr *inst) { | |
| 981 | 981 | fprintf(irp->f, "if ("); |
| 982 | 982 | ir_print_other_inst_gen(irp, inst->condition); |
| 983 | 983 | fprintf(irp->f, ") "); |
| ... | ... | @@ -986,7 +986,7 @@ static void ir_print_cond_br(IrPrintGen *irp, IrInstGenCondBr *inst) { |
| 986 | 986 | ir_print_other_block_gen(irp, inst->else_block); |
| 987 | 987 | } |
| 988 | 988 | |
| 989 | static void ir_print_br(IrPrintSrc *irp, IrInstSrcBr *br_instruction) { | |
| 989 | static void ir_print_br(IrPrintSrc *irp, Stage1ZirInstBr *br_instruction) { | |
| 990 | 990 | fprintf(irp->f, "goto "); |
| 991 | 991 | ir_print_other_block(irp, br_instruction->dest_block); |
| 992 | 992 | if (br_instruction->is_comptime != nullptr) { |
| ... | ... | @@ -995,17 +995,17 @@ static void ir_print_br(IrPrintSrc *irp, IrInstSrcBr *br_instruction) { |
| 995 | 995 | } |
| 996 | 996 | } |
| 997 | 997 | |
| 998 | static void ir_print_br(IrPrintGen *irp, IrInstGenBr *inst) { | |
| 998 | static void ir_print_br(IrPrintGen *irp, Stage1AirInstBr *inst) { | |
| 999 | 999 | fprintf(irp->f, "goto "); |
| 1000 | 1000 | ir_print_other_block_gen(irp, inst->dest_block); |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | static void ir_print_phi(IrPrintSrc *irp, IrInstSrcPhi *phi_instruction) { | |
| 1003 | static void ir_print_phi(IrPrintSrc *irp, Stage1ZirInstPhi *phi_instruction) { | |
| 1004 | 1004 | assert(phi_instruction->incoming_count != 0); |
| 1005 | 1005 | assert(phi_instruction->incoming_count != SIZE_MAX); |
| 1006 | 1006 | for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) { |
| 1007 | 1007 | Stage1ZirBasicBlock *incoming_block = phi_instruction->incoming_blocks[i]; |
| 1008 | IrInstSrc *incoming_value = phi_instruction->incoming_values[i]; | |
| 1008 | Stage1ZirInst *incoming_value = phi_instruction->incoming_values[i]; | |
| 1009 | 1009 | if (i != 0) |
| 1010 | 1010 | fprintf(irp->f, " "); |
| 1011 | 1011 | ir_print_other_block(irp, incoming_block); |
| ... | ... | @@ -1014,12 +1014,12 @@ static void ir_print_phi(IrPrintSrc *irp, IrInstSrcPhi *phi_instruction) { |
| 1014 | 1014 | } |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | static void ir_print_phi(IrPrintGen *irp, IrInstGenPhi *phi_instruction) { | |
| 1017 | static void ir_print_phi(IrPrintGen *irp, Stage1AirInstPhi *phi_instruction) { | |
| 1018 | 1018 | assert(phi_instruction->incoming_count != 0); |
| 1019 | 1019 | assert(phi_instruction->incoming_count != SIZE_MAX); |
| 1020 | 1020 | for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) { |
| 1021 | IrBasicBlockGen *incoming_block = phi_instruction->incoming_blocks[i]; | |
| 1022 | IrInstGen *incoming_value = phi_instruction->incoming_values[i]; | |
| 1021 | Stage1AirBasicBlock *incoming_block = phi_instruction->incoming_blocks[i]; | |
| 1022 | Stage1AirInst *incoming_value = phi_instruction->incoming_values[i]; | |
| 1023 | 1023 | if (i != 0) |
| 1024 | 1024 | fprintf(irp->f, " "); |
| 1025 | 1025 | ir_print_other_block_gen(irp, incoming_block); |
| ... | ... | @@ -1028,13 +1028,13 @@ static void ir_print_phi(IrPrintGen *irp, IrInstGenPhi *phi_instruction) { |
| 1028 | 1028 | } |
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | static void ir_print_container_init_list(IrPrintSrc *irp, IrInstSrcContainerInitList *instruction) { | |
| 1031 | static void ir_print_container_init_list(IrPrintSrc *irp, Stage1ZirInstContainerInitList *instruction) { | |
| 1032 | 1032 | fprintf(irp->f, "{"); |
| 1033 | 1033 | if (instruction->item_count > 50) { |
| 1034 | 1034 | fprintf(irp->f, "...(%" ZIG_PRI_usize " items)...", instruction->item_count); |
| 1035 | 1035 | } else { |
| 1036 | 1036 | for (size_t i = 0; i < instruction->item_count; i += 1) { |
| 1037 | IrInstSrc *result_loc = instruction->elem_result_loc_list[i]; | |
| 1037 | Stage1ZirInst *result_loc = instruction->elem_result_loc_list[i]; | |
| 1038 | 1038 | if (i != 0) |
| 1039 | 1039 | fprintf(irp->f, ", "); |
| 1040 | 1040 | ir_print_other_inst_src(irp, result_loc); |
| ... | ... | @@ -1044,10 +1044,10 @@ static void ir_print_container_init_list(IrPrintSrc *irp, IrInstSrcContainerInit |
| 1044 | 1044 | ir_print_other_inst_src(irp, instruction->result_loc); |
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | static void ir_print_container_init_fields(IrPrintSrc *irp, IrInstSrcContainerInitFields *instruction) { | |
| 1047 | static void ir_print_container_init_fields(IrPrintSrc *irp, Stage1ZirInstContainerInitFields *instruction) { | |
| 1048 | 1048 | fprintf(irp->f, "{"); |
| 1049 | 1049 | for (size_t i = 0; i < instruction->field_count; i += 1) { |
| 1050 | IrInstSrcContainerInitFieldsField *field = &instruction->fields[i]; | |
| 1050 | Stage1ZirInstContainerInitFieldsField *field = &instruction->fields[i]; | |
| 1051 | 1051 | const char *comma = (i == 0) ? "" : ", "; |
| 1052 | 1052 | fprintf(irp->f, "%s.%s = ", comma, buf_ptr(field->name)); |
| 1053 | 1053 | ir_print_other_inst_src(irp, field->result_loc); |
| ... | ... | @@ -1056,15 +1056,15 @@ static void ir_print_container_init_fields(IrPrintSrc *irp, IrInstSrcContainerIn |
| 1056 | 1056 | ir_print_other_inst_src(irp, instruction->result_loc); |
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | static void ir_print_unreachable(IrPrintSrc *irp, IrInstSrcUnreachable *instruction) { | |
| 1059 | static void ir_print_unreachable(IrPrintSrc *irp, Stage1ZirInstUnreachable *instruction) { | |
| 1060 | 1060 | fprintf(irp->f, "unreachable"); |
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | static void ir_print_unreachable(IrPrintGen *irp, IrInstGenUnreachable *instruction) { | |
| 1063 | static void ir_print_unreachable(IrPrintGen *irp, Stage1AirInstUnreachable *instruction) { | |
| 1064 | 1064 | fprintf(irp->f, "unreachable"); |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | static void ir_print_elem_ptr(IrPrintSrc *irp, IrInstSrcElemPtr *instruction) { | |
| 1067 | static void ir_print_elem_ptr(IrPrintSrc *irp, Stage1ZirInstElemPtr *instruction) { | |
| 1068 | 1068 | fprintf(irp->f, "&"); |
| 1069 | 1069 | ir_print_other_inst_src(irp, instruction->array_ptr); |
| 1070 | 1070 | fprintf(irp->f, "["); |
| ... | ... | @@ -1075,7 +1075,7 @@ static void ir_print_elem_ptr(IrPrintSrc *irp, IrInstSrcElemPtr *instruction) { |
| 1075 | 1075 | } |
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | static void ir_print_elem_ptr(IrPrintGen *irp, IrInstGenElemPtr *instruction) { | |
| 1078 | static void ir_print_elem_ptr(IrPrintGen *irp, Stage1AirInstElemPtr *instruction) { | |
| 1079 | 1079 | fprintf(irp->f, "&"); |
| 1080 | 1080 | ir_print_other_inst_gen(irp, instruction->array_ptr); |
| 1081 | 1081 | fprintf(irp->f, "["); |
| ... | ... | @@ -1086,45 +1086,45 @@ static void ir_print_elem_ptr(IrPrintGen *irp, IrInstGenElemPtr *instruction) { |
| 1086 | 1086 | } |
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | static void ir_print_var_ptr(IrPrintSrc *irp, IrInstSrcVarPtr *instruction) { | |
| 1089 | static void ir_print_var_ptr(IrPrintSrc *irp, Stage1ZirInstVarPtr *instruction) { | |
| 1090 | 1090 | fprintf(irp->f, "&%s", instruction->var->name); |
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | static void ir_print_var_ptr(IrPrintGen *irp, IrInstGenVarPtr *instruction) { | |
| 1093 | static void ir_print_var_ptr(IrPrintGen *irp, Stage1AirInstVarPtr *instruction) { | |
| 1094 | 1094 | fprintf(irp->f, "&%s", instruction->var->name); |
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | static void ir_print_return_ptr(IrPrintGen *irp, IrInstGenReturnPtr *instruction) { | |
| 1097 | static void ir_print_return_ptr(IrPrintGen *irp, Stage1AirInstReturnPtr *instruction) { | |
| 1098 | 1098 | fprintf(irp->f, "@ReturnPtr"); |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | static void ir_print_load_ptr(IrPrintSrc *irp, IrInstSrcLoadPtr *instruction) { | |
| 1101 | static void ir_print_load_ptr(IrPrintSrc *irp, Stage1ZirInstLoadPtr *instruction) { | |
| 1102 | 1102 | ir_print_other_inst_src(irp, instruction->ptr); |
| 1103 | 1103 | fprintf(irp->f, ".*"); |
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | static void ir_print_load_ptr_gen(IrPrintGen *irp, IrInstGenLoadPtr *instruction) { | |
| 1106 | static void ir_print_load_ptr_gen(IrPrintGen *irp, Stage1AirInstLoadPtr *instruction) { | |
| 1107 | 1107 | fprintf(irp->f, "loadptr("); |
| 1108 | 1108 | ir_print_other_inst_gen(irp, instruction->ptr); |
| 1109 | 1109 | fprintf(irp->f, ")result="); |
| 1110 | 1110 | ir_print_other_inst_gen(irp, instruction->result_loc); |
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | static void ir_print_store_ptr(IrPrintSrc *irp, IrInstSrcStorePtr *instruction) { | |
| 1113 | static void ir_print_store_ptr(IrPrintSrc *irp, Stage1ZirInstStorePtr *instruction) { | |
| 1114 | 1114 | fprintf(irp->f, "*"); |
| 1115 | 1115 | ir_print_var_src(irp, instruction->ptr); |
| 1116 | 1116 | fprintf(irp->f, " = "); |
| 1117 | 1117 | ir_print_other_inst_src(irp, instruction->value); |
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | static void ir_print_store_ptr(IrPrintGen *irp, IrInstGenStorePtr *instruction) { | |
| 1120 | static void ir_print_store_ptr(IrPrintGen *irp, Stage1AirInstStorePtr *instruction) { | |
| 1121 | 1121 | fprintf(irp->f, "*"); |
| 1122 | 1122 | ir_print_var_gen(irp, instruction->ptr); |
| 1123 | 1123 | fprintf(irp->f, " = "); |
| 1124 | 1124 | ir_print_other_inst_gen(irp, instruction->value); |
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | static void ir_print_vector_store_elem(IrPrintGen *irp, IrInstGenVectorStoreElem *instruction) { | |
| 1127 | static void ir_print_vector_store_elem(IrPrintGen *irp, Stage1AirInstVectorStoreElem *instruction) { | |
| 1128 | 1128 | fprintf(irp->f, "vector_ptr="); |
| 1129 | 1129 | ir_print_var_gen(irp, instruction->vector_ptr); |
| 1130 | 1130 | fprintf(irp->f, ",index="); |
| ... | ... | @@ -1133,7 +1133,7 @@ static void ir_print_vector_store_elem(IrPrintGen *irp, IrInstGenVectorStoreElem |
| 1133 | 1133 | ir_print_other_inst_gen(irp, instruction->value); |
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | static void ir_print_typeof(IrPrintSrc *irp, IrInstSrcTypeOf *instruction) { | |
| 1136 | static void ir_print_typeof(IrPrintSrc *irp, Stage1ZirInstTypeOf *instruction) { | |
| 1137 | 1137 | fprintf(irp->f, "@TypeOf("); |
| 1138 | 1138 | if (instruction->value_count == 1) { |
| 1139 | 1139 | ir_print_other_inst_src(irp, instruction->value.scalar); |
| ... | ... | @@ -1145,17 +1145,17 @@ static void ir_print_typeof(IrPrintSrc *irp, IrInstSrcTypeOf *instruction) { |
| 1145 | 1145 | fprintf(irp->f, ")"); |
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | static void ir_print_binary_not(IrPrintGen *irp, IrInstGenBinaryNot *instruction) { | |
| 1148 | static void ir_print_binary_not(IrPrintGen *irp, Stage1AirInstBinaryNot *instruction) { | |
| 1149 | 1149 | fprintf(irp->f, "~"); |
| 1150 | 1150 | ir_print_other_inst_gen(irp, instruction->operand); |
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | static void ir_print_negation(IrPrintGen *irp, IrInstGenNegation *instruction) { | |
| 1153 | static void ir_print_negation(IrPrintGen *irp, Stage1AirInstNegation *instruction) { | |
| 1154 | 1154 | fprintf(irp->f, instruction->wrapping ? "-%%" : "-"); |
| 1155 | 1155 | ir_print_other_inst_gen(irp, instruction->operand); |
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | static void ir_print_field_ptr(IrPrintSrc *irp, IrInstSrcFieldPtr *instruction) { | |
| 1158 | static void ir_print_field_ptr(IrPrintSrc *irp, Stage1ZirInstFieldPtr *instruction) { | |
| 1159 | 1159 | if (instruction->field_name_buffer) { |
| 1160 | 1160 | fprintf(irp->f, "fieldptr "); |
| 1161 | 1161 | ir_print_other_inst_src(irp, instruction->container_ptr); |
| ... | ... | @@ -1170,33 +1170,33 @@ static void ir_print_field_ptr(IrPrintSrc *irp, IrInstSrcFieldPtr *instruction) |
| 1170 | 1170 | } |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | static void ir_print_struct_field_ptr(IrPrintGen *irp, IrInstGenStructFieldPtr *instruction) { | |
| 1173 | static void ir_print_struct_field_ptr(IrPrintGen *irp, Stage1AirInstStructFieldPtr *instruction) { | |
| 1174 | 1174 | fprintf(irp->f, "@StructFieldPtr(&"); |
| 1175 | 1175 | ir_print_other_inst_gen(irp, instruction->struct_ptr); |
| 1176 | 1176 | fprintf(irp->f, ".%s", buf_ptr(instruction->field->name)); |
| 1177 | 1177 | fprintf(irp->f, ")"); |
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | static void ir_print_union_field_ptr(IrPrintGen *irp, IrInstGenUnionFieldPtr *instruction) { | |
| 1180 | static void ir_print_union_field_ptr(IrPrintGen *irp, Stage1AirInstUnionFieldPtr *instruction) { | |
| 1181 | 1181 | fprintf(irp->f, "@UnionFieldPtr(&"); |
| 1182 | 1182 | ir_print_other_inst_gen(irp, instruction->union_ptr); |
| 1183 | 1183 | fprintf(irp->f, ".%s", buf_ptr(instruction->field->enum_field->name)); |
| 1184 | 1184 | fprintf(irp->f, ")"); |
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | static void ir_print_set_cold(IrPrintSrc *irp, IrInstSrcSetCold *instruction) { | |
| 1187 | static void ir_print_set_cold(IrPrintSrc *irp, Stage1ZirInstSetCold *instruction) { | |
| 1188 | 1188 | fprintf(irp->f, "@setCold("); |
| 1189 | 1189 | ir_print_other_inst_src(irp, instruction->is_cold); |
| 1190 | 1190 | fprintf(irp->f, ")"); |
| 1191 | 1191 | } |
| 1192 | 1192 | |
| 1193 | static void ir_print_set_runtime_safety(IrPrintSrc *irp, IrInstSrcSetRuntimeSafety *instruction) { | |
| 1193 | static void ir_print_set_runtime_safety(IrPrintSrc *irp, Stage1ZirInstSetRuntimeSafety *instruction) { | |
| 1194 | 1194 | fprintf(irp->f, "@setRuntimeSafety("); |
| 1195 | 1195 | ir_print_other_inst_src(irp, instruction->safety_on); |
| 1196 | 1196 | fprintf(irp->f, ")"); |
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | static void ir_print_set_float_mode(IrPrintSrc *irp, IrInstSrcSetFloatMode *instruction) { | |
| 1199 | static void ir_print_set_float_mode(IrPrintSrc *irp, Stage1ZirInstSetFloatMode *instruction) { | |
| 1200 | 1200 | fprintf(irp->f, "@setFloatMode("); |
| 1201 | 1201 | ir_print_other_inst_src(irp, instruction->scope_value); |
| 1202 | 1202 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1204,7 +1204,7 @@ static void ir_print_set_float_mode(IrPrintSrc *irp, IrInstSrcSetFloatMode *inst |
| 1204 | 1204 | fprintf(irp->f, ")"); |
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | static void ir_print_array_type(IrPrintSrc *irp, IrInstSrcArrayType *instruction) { | |
| 1207 | static void ir_print_array_type(IrPrintSrc *irp, Stage1ZirInstArrayType *instruction) { | |
| 1208 | 1208 | fprintf(irp->f, "["); |
| 1209 | 1209 | ir_print_other_inst_src(irp, instruction->size); |
| 1210 | 1210 | if (instruction->sentinel != nullptr) { |
| ... | ... | @@ -1215,13 +1215,13 @@ static void ir_print_array_type(IrPrintSrc *irp, IrInstSrcArrayType *instruction |
| 1215 | 1215 | ir_print_other_inst_src(irp, instruction->child_type); |
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | static void ir_print_slice_type(IrPrintSrc *irp, IrInstSrcSliceType *instruction) { | |
| 1218 | static void ir_print_slice_type(IrPrintSrc *irp, Stage1ZirInstSliceType *instruction) { | |
| 1219 | 1219 | const char *const_kw = instruction->is_const ? "const " : ""; |
| 1220 | 1220 | fprintf(irp->f, "[]%s", const_kw); |
| 1221 | 1221 | ir_print_other_inst_src(irp, instruction->child_type); |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | static void ir_print_any_frame_type(IrPrintSrc *irp, IrInstSrcAnyFrameType *instruction) { | |
| 1224 | static void ir_print_any_frame_type(IrPrintSrc *irp, Stage1ZirInstAnyFrameType *instruction) { | |
| 1225 | 1225 | if (instruction->payload_type == nullptr) { |
| 1226 | 1226 | fprintf(irp->f, "anyframe"); |
| 1227 | 1227 | } else { |
| ... | ... | @@ -1230,7 +1230,7 @@ static void ir_print_any_frame_type(IrPrintSrc *irp, IrInstSrcAnyFrameType *inst |
| 1230 | 1230 | } |
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | static void ir_print_asm_src(IrPrintSrc *irp, IrInstSrcAsm *instruction) { | |
| 1233 | static void ir_print_asm_src(IrPrintSrc *irp, Stage1ZirInstAsm *instruction) { | |
| 1234 | 1234 | assert(instruction->base.source_node->type == NodeTypeAsmExpr); |
| 1235 | 1235 | AstNodeAsmExpr *asm_expr = &instruction->base.source_node->data.asm_expr; |
| 1236 | 1236 | const char *volatile_kw = instruction->has_side_effects ? " volatile" : ""; |
| ... | ... | @@ -1273,7 +1273,7 @@ static void ir_print_asm_src(IrPrintSrc *irp, IrInstSrcAsm *instruction) { |
| 1273 | 1273 | fprintf(irp->f, ")"); |
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | static void ir_print_asm_gen(IrPrintGen *irp, IrInstGenAsm *instruction) { | |
| 1276 | static void ir_print_asm_gen(IrPrintGen *irp, Stage1AirInstAsm *instruction) { | |
| 1277 | 1277 | assert(instruction->base.source_node->type == NodeTypeAsmExpr); |
| 1278 | 1278 | AstNodeAsmExpr *asm_expr = &instruction->base.source_node->data.asm_expr; |
| 1279 | 1279 | const char *volatile_kw = instruction->has_side_effects ? " volatile" : ""; |
| ... | ... | @@ -1315,7 +1315,7 @@ static void ir_print_asm_gen(IrPrintGen *irp, IrInstGenAsm *instruction) { |
| 1315 | 1315 | fprintf(irp->f, ")"); |
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | static void ir_print_size_of(IrPrintSrc *irp, IrInstSrcSizeOf *instruction) { | |
| 1318 | static void ir_print_size_of(IrPrintSrc *irp, Stage1ZirInstSizeOf *instruction) { | |
| 1319 | 1319 | if (instruction->bit_size) |
| 1320 | 1320 | fprintf(irp->f, "@bitSizeOf("); |
| 1321 | 1321 | else |
| ... | ... | @@ -1324,17 +1324,17 @@ static void ir_print_size_of(IrPrintSrc *irp, IrInstSrcSizeOf *instruction) { |
| 1324 | 1324 | fprintf(irp->f, ")"); |
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | static void ir_print_test_non_null(IrPrintSrc *irp, IrInstSrcTestNonNull *instruction) { | |
| 1327 | static void ir_print_test_non_null(IrPrintSrc *irp, Stage1ZirInstTestNonNull *instruction) { | |
| 1328 | 1328 | ir_print_other_inst_src(irp, instruction->value); |
| 1329 | 1329 | fprintf(irp->f, " != null"); |
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | static void ir_print_test_non_null(IrPrintGen *irp, IrInstGenTestNonNull *instruction) { | |
| 1332 | static void ir_print_test_non_null(IrPrintGen *irp, Stage1AirInstTestNonNull *instruction) { | |
| 1333 | 1333 | ir_print_other_inst_gen(irp, instruction->value); |
| 1334 | 1334 | fprintf(irp->f, " != null"); |
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | static void ir_print_optional_unwrap_ptr(IrPrintSrc *irp, IrInstSrcOptionalUnwrapPtr *instruction) { | |
| 1337 | static void ir_print_optional_unwrap_ptr(IrPrintSrc *irp, Stage1ZirInstOptionalUnwrapPtr *instruction) { | |
| 1338 | 1338 | fprintf(irp->f, "&"); |
| 1339 | 1339 | ir_print_other_inst_src(irp, instruction->base_ptr); |
| 1340 | 1340 | fprintf(irp->f, ".*.?"); |
| ... | ... | @@ -1343,7 +1343,7 @@ static void ir_print_optional_unwrap_ptr(IrPrintSrc *irp, IrInstSrcOptionalUnwra |
| 1343 | 1343 | } |
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | static void ir_print_optional_unwrap_ptr(IrPrintGen *irp, IrInstGenOptionalUnwrapPtr *instruction) { | |
| 1346 | static void ir_print_optional_unwrap_ptr(IrPrintGen *irp, Stage1AirInstOptionalUnwrapPtr *instruction) { | |
| 1347 | 1347 | fprintf(irp->f, "&"); |
| 1348 | 1348 | ir_print_other_inst_gen(irp, instruction->base_ptr); |
| 1349 | 1349 | fprintf(irp->f, ".*.?"); |
| ... | ... | @@ -1352,7 +1352,7 @@ static void ir_print_optional_unwrap_ptr(IrPrintGen *irp, IrInstGenOptionalUnwra |
| 1352 | 1352 | } |
| 1353 | 1353 | } |
| 1354 | 1354 | |
| 1355 | static void ir_print_clz(IrPrintSrc *irp, IrInstSrcClz *instruction) { | |
| 1355 | static void ir_print_clz(IrPrintSrc *irp, Stage1ZirInstClz *instruction) { | |
| 1356 | 1356 | fprintf(irp->f, "@clz("); |
| 1357 | 1357 | ir_print_other_inst_src(irp, instruction->type); |
| 1358 | 1358 | fprintf(irp->f, ","); |
| ... | ... | @@ -1360,13 +1360,13 @@ static void ir_print_clz(IrPrintSrc *irp, IrInstSrcClz *instruction) { |
| 1360 | 1360 | fprintf(irp->f, ")"); |
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | static void ir_print_clz(IrPrintGen *irp, IrInstGenClz *instruction) { | |
| 1363 | static void ir_print_clz(IrPrintGen *irp, Stage1AirInstClz *instruction) { | |
| 1364 | 1364 | fprintf(irp->f, "@clz("); |
| 1365 | 1365 | ir_print_other_inst_gen(irp, instruction->op); |
| 1366 | 1366 | fprintf(irp->f, ")"); |
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | static void ir_print_ctz(IrPrintSrc *irp, IrInstSrcCtz *instruction) { | |
| 1369 | static void ir_print_ctz(IrPrintSrc *irp, Stage1ZirInstCtz *instruction) { | |
| 1370 | 1370 | fprintf(irp->f, "@ctz("); |
| 1371 | 1371 | ir_print_other_inst_src(irp, instruction->type); |
| 1372 | 1372 | fprintf(irp->f, ","); |
| ... | ... | @@ -1374,13 +1374,13 @@ static void ir_print_ctz(IrPrintSrc *irp, IrInstSrcCtz *instruction) { |
| 1374 | 1374 | fprintf(irp->f, ")"); |
| 1375 | 1375 | } |
| 1376 | 1376 | |
| 1377 | static void ir_print_ctz(IrPrintGen *irp, IrInstGenCtz *instruction) { | |
| 1377 | static void ir_print_ctz(IrPrintGen *irp, Stage1AirInstCtz *instruction) { | |
| 1378 | 1378 | fprintf(irp->f, "@ctz("); |
| 1379 | 1379 | ir_print_other_inst_gen(irp, instruction->op); |
| 1380 | 1380 | fprintf(irp->f, ")"); |
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | static void ir_print_pop_count(IrPrintSrc *irp, IrInstSrcPopCount *instruction) { | |
| 1383 | static void ir_print_pop_count(IrPrintSrc *irp, Stage1ZirInstPopCount *instruction) { | |
| 1384 | 1384 | fprintf(irp->f, "@popCount("); |
| 1385 | 1385 | ir_print_other_inst_src(irp, instruction->type); |
| 1386 | 1386 | fprintf(irp->f, ","); |
| ... | ... | @@ -1388,13 +1388,13 @@ static void ir_print_pop_count(IrPrintSrc *irp, IrInstSrcPopCount *instruction) |
| 1388 | 1388 | fprintf(irp->f, ")"); |
| 1389 | 1389 | } |
| 1390 | 1390 | |
| 1391 | static void ir_print_pop_count(IrPrintGen *irp, IrInstGenPopCount *instruction) { | |
| 1391 | static void ir_print_pop_count(IrPrintGen *irp, Stage1AirInstPopCount *instruction) { | |
| 1392 | 1392 | fprintf(irp->f, "@popCount("); |
| 1393 | 1393 | ir_print_other_inst_gen(irp, instruction->op); |
| 1394 | 1394 | fprintf(irp->f, ")"); |
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | static void ir_print_bswap(IrPrintSrc *irp, IrInstSrcBswap *instruction) { | |
| 1397 | static void ir_print_bswap(IrPrintSrc *irp, Stage1ZirInstBswap *instruction) { | |
| 1398 | 1398 | fprintf(irp->f, "@byteSwap("); |
| 1399 | 1399 | ir_print_other_inst_src(irp, instruction->type); |
| 1400 | 1400 | fprintf(irp->f, ","); |
| ... | ... | @@ -1402,13 +1402,13 @@ static void ir_print_bswap(IrPrintSrc *irp, IrInstSrcBswap *instruction) { |
| 1402 | 1402 | fprintf(irp->f, ")"); |
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | static void ir_print_bswap(IrPrintGen *irp, IrInstGenBswap *instruction) { | |
| 1405 | static void ir_print_bswap(IrPrintGen *irp, Stage1AirInstBswap *instruction) { | |
| 1406 | 1406 | fprintf(irp->f, "@byteSwap("); |
| 1407 | 1407 | ir_print_other_inst_gen(irp, instruction->op); |
| 1408 | 1408 | fprintf(irp->f, ")"); |
| 1409 | 1409 | } |
| 1410 | 1410 | |
| 1411 | static void ir_print_bit_reverse(IrPrintSrc *irp, IrInstSrcBitReverse *instruction) { | |
| 1411 | static void ir_print_bit_reverse(IrPrintSrc *irp, Stage1ZirInstBitReverse *instruction) { | |
| 1412 | 1412 | fprintf(irp->f, "@bitReverse("); |
| 1413 | 1413 | ir_print_other_inst_src(irp, instruction->type); |
| 1414 | 1414 | fprintf(irp->f, ","); |
| ... | ... | @@ -1416,18 +1416,18 @@ static void ir_print_bit_reverse(IrPrintSrc *irp, IrInstSrcBitReverse *instructi |
| 1416 | 1416 | fprintf(irp->f, ")"); |
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | static void ir_print_bit_reverse(IrPrintGen *irp, IrInstGenBitReverse *instruction) { | |
| 1419 | static void ir_print_bit_reverse(IrPrintGen *irp, Stage1AirInstBitReverse *instruction) { | |
| 1420 | 1420 | fprintf(irp->f, "@bitReverse("); |
| 1421 | 1421 | ir_print_other_inst_gen(irp, instruction->op); |
| 1422 | 1422 | fprintf(irp->f, ")"); |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | static void ir_print_switch_br(IrPrintSrc *irp, IrInstSrcSwitchBr *instruction) { | |
| 1425 | static void ir_print_switch_br(IrPrintSrc *irp, Stage1ZirInstSwitchBr *instruction) { | |
| 1426 | 1426 | fprintf(irp->f, "switch ("); |
| 1427 | 1427 | ir_print_other_inst_src(irp, instruction->target_value); |
| 1428 | 1428 | fprintf(irp->f, ") "); |
| 1429 | 1429 | for (size_t i = 0; i < instruction->case_count; i += 1) { |
| 1430 | IrInstSrcSwitchBrCase *this_case = &instruction->cases[i]; | |
| 1430 | Stage1ZirInstSwitchBrCase *this_case = &instruction->cases[i]; | |
| 1431 | 1431 | ir_print_other_inst_src(irp, this_case->value); |
| 1432 | 1432 | fprintf(irp->f, " => "); |
| 1433 | 1433 | ir_print_other_block(irp, this_case->block); |
| ... | ... | @@ -1441,12 +1441,12 @@ static void ir_print_switch_br(IrPrintSrc *irp, IrInstSrcSwitchBr *instruction) |
| 1441 | 1441 | } |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | static void ir_print_switch_br(IrPrintGen *irp, IrInstGenSwitchBr *instruction) { | |
| 1444 | static void ir_print_switch_br(IrPrintGen *irp, Stage1AirInstSwitchBr *instruction) { | |
| 1445 | 1445 | fprintf(irp->f, "switch ("); |
| 1446 | 1446 | ir_print_other_inst_gen(irp, instruction->target_value); |
| 1447 | 1447 | fprintf(irp->f, ") "); |
| 1448 | 1448 | for (size_t i = 0; i < instruction->case_count; i += 1) { |
| 1449 | IrInstGenSwitchBrCase *this_case = &instruction->cases[i]; | |
| 1449 | Stage1AirInstSwitchBrCase *this_case = &instruction->cases[i]; | |
| 1450 | 1450 | ir_print_other_inst_gen(irp, this_case->value); |
| 1451 | 1451 | fprintf(irp->f, " => "); |
| 1452 | 1452 | ir_print_other_block_gen(irp, this_case->block); |
| ... | ... | @@ -1456,7 +1456,7 @@ static void ir_print_switch_br(IrPrintGen *irp, IrInstGenSwitchBr *instruction) |
| 1456 | 1456 | ir_print_other_block_gen(irp, instruction->else_block); |
| 1457 | 1457 | } |
| 1458 | 1458 | |
| 1459 | static void ir_print_switch_var(IrPrintSrc *irp, IrInstSrcSwitchVar *instruction) { | |
| 1459 | static void ir_print_switch_var(IrPrintSrc *irp, Stage1ZirInstSwitchVar *instruction) { | |
| 1460 | 1460 | fprintf(irp->f, "switchvar "); |
| 1461 | 1461 | ir_print_other_inst_src(irp, instruction->target_value_ptr); |
| 1462 | 1462 | for (size_t i = 0; i < instruction->prongs_len; i += 1) { |
| ... | ... | @@ -1465,79 +1465,79 @@ static void ir_print_switch_var(IrPrintSrc *irp, IrInstSrcSwitchVar *instruction |
| 1465 | 1465 | } |
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | static void ir_print_switch_else_var(IrPrintSrc *irp, IrInstSrcSwitchElseVar *instruction) { | |
| 1468 | static void ir_print_switch_else_var(IrPrintSrc *irp, Stage1ZirInstSwitchElseVar *instruction) { | |
| 1469 | 1469 | fprintf(irp->f, "switchelsevar "); |
| 1470 | 1470 | ir_print_other_inst_src(irp, &instruction->switch_br->base); |
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | static void ir_print_switch_target(IrPrintSrc *irp, IrInstSrcSwitchTarget *instruction) { | |
| 1473 | static void ir_print_switch_target(IrPrintSrc *irp, Stage1ZirInstSwitchTarget *instruction) { | |
| 1474 | 1474 | fprintf(irp->f, "switchtarget "); |
| 1475 | 1475 | ir_print_other_inst_src(irp, instruction->target_value_ptr); |
| 1476 | 1476 | } |
| 1477 | 1477 | |
| 1478 | static void ir_print_union_tag(IrPrintGen *irp, IrInstGenUnionTag *instruction) { | |
| 1478 | static void ir_print_union_tag(IrPrintGen *irp, Stage1AirInstUnionTag *instruction) { | |
| 1479 | 1479 | fprintf(irp->f, "uniontag "); |
| 1480 | 1480 | ir_print_other_inst_gen(irp, instruction->value); |
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | static void ir_print_import(IrPrintSrc *irp, IrInstSrcImport *instruction) { | |
| 1483 | static void ir_print_import(IrPrintSrc *irp, Stage1ZirInstImport *instruction) { | |
| 1484 | 1484 | fprintf(irp->f, "@import("); |
| 1485 | 1485 | ir_print_other_inst_src(irp, instruction->name); |
| 1486 | 1486 | fprintf(irp->f, ")"); |
| 1487 | 1487 | } |
| 1488 | 1488 | |
| 1489 | static void ir_print_ref(IrPrintSrc *irp, IrInstSrcRef *instruction) { | |
| 1489 | static void ir_print_ref(IrPrintSrc *irp, Stage1ZirInstRef *instruction) { | |
| 1490 | 1490 | fprintf(irp->f, "ref "); |
| 1491 | 1491 | ir_print_other_inst_src(irp, instruction->value); |
| 1492 | 1492 | } |
| 1493 | 1493 | |
| 1494 | static void ir_print_ref_gen(IrPrintGen *irp, IrInstGenRef *instruction) { | |
| 1494 | static void ir_print_ref_gen(IrPrintGen *irp, Stage1AirInstRef *instruction) { | |
| 1495 | 1495 | fprintf(irp->f, "@ref("); |
| 1496 | 1496 | ir_print_other_inst_gen(irp, instruction->operand); |
| 1497 | 1497 | fprintf(irp->f, ")result="); |
| 1498 | 1498 | ir_print_other_inst_gen(irp, instruction->result_loc); |
| 1499 | 1499 | } |
| 1500 | 1500 | |
| 1501 | static void ir_print_compile_err(IrPrintSrc *irp, IrInstSrcCompileErr *instruction) { | |
| 1501 | static void ir_print_compile_err(IrPrintSrc *irp, Stage1ZirInstCompileErr *instruction) { | |
| 1502 | 1502 | fprintf(irp->f, "@compileError("); |
| 1503 | 1503 | ir_print_other_inst_src(irp, instruction->msg); |
| 1504 | 1504 | fprintf(irp->f, ")"); |
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | static void ir_print_compile_log(IrPrintSrc *irp, IrInstSrcCompileLog *instruction) { | |
| 1507 | static void ir_print_compile_log(IrPrintSrc *irp, Stage1ZirInstCompileLog *instruction) { | |
| 1508 | 1508 | fprintf(irp->f, "@compileLog("); |
| 1509 | 1509 | for (size_t i = 0; i < instruction->msg_count; i += 1) { |
| 1510 | 1510 | if (i != 0) |
| 1511 | 1511 | fprintf(irp->f, ","); |
| 1512 | IrInstSrc *msg = instruction->msg_list[i]; | |
| 1512 | Stage1ZirInst *msg = instruction->msg_list[i]; | |
| 1513 | 1513 | ir_print_other_inst_src(irp, msg); |
| 1514 | 1514 | } |
| 1515 | 1515 | fprintf(irp->f, ")"); |
| 1516 | 1516 | } |
| 1517 | 1517 | |
| 1518 | static void ir_print_err_name(IrPrintSrc *irp, IrInstSrcErrName *instruction) { | |
| 1518 | static void ir_print_err_name(IrPrintSrc *irp, Stage1ZirInstErrName *instruction) { | |
| 1519 | 1519 | fprintf(irp->f, "@errorName("); |
| 1520 | 1520 | ir_print_other_inst_src(irp, instruction->value); |
| 1521 | 1521 | fprintf(irp->f, ")"); |
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | static void ir_print_err_name(IrPrintGen *irp, IrInstGenErrName *instruction) { | |
| 1524 | static void ir_print_err_name(IrPrintGen *irp, Stage1AirInstErrName *instruction) { | |
| 1525 | 1525 | fprintf(irp->f, "@errorName("); |
| 1526 | 1526 | ir_print_other_inst_gen(irp, instruction->value); |
| 1527 | 1527 | fprintf(irp->f, ")"); |
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | static void ir_print_c_import(IrPrintSrc *irp, IrInstSrcCImport *instruction) { | |
| 1530 | static void ir_print_c_import(IrPrintSrc *irp, Stage1ZirInstCImport *instruction) { | |
| 1531 | 1531 | fprintf(irp->f, "@cImport(...)"); |
| 1532 | 1532 | } |
| 1533 | 1533 | |
| 1534 | static void ir_print_c_include(IrPrintSrc *irp, IrInstSrcCInclude *instruction) { | |
| 1534 | static void ir_print_c_include(IrPrintSrc *irp, Stage1ZirInstCInclude *instruction) { | |
| 1535 | 1535 | fprintf(irp->f, "@cInclude("); |
| 1536 | 1536 | ir_print_other_inst_src(irp, instruction->name); |
| 1537 | 1537 | fprintf(irp->f, ")"); |
| 1538 | 1538 | } |
| 1539 | 1539 | |
| 1540 | static void ir_print_c_define(IrPrintSrc *irp, IrInstSrcCDefine *instruction) { | |
| 1540 | static void ir_print_c_define(IrPrintSrc *irp, Stage1ZirInstCDefine *instruction) { | |
| 1541 | 1541 | fprintf(irp->f, "@cDefine("); |
| 1542 | 1542 | ir_print_other_inst_src(irp, instruction->name); |
| 1543 | 1543 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1545,19 +1545,19 @@ static void ir_print_c_define(IrPrintSrc *irp, IrInstSrcCDefine *instruction) { |
| 1545 | 1545 | fprintf(irp->f, ")"); |
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | static void ir_print_c_undef(IrPrintSrc *irp, IrInstSrcCUndef *instruction) { | |
| 1548 | static void ir_print_c_undef(IrPrintSrc *irp, Stage1ZirInstCUndef *instruction) { | |
| 1549 | 1549 | fprintf(irp->f, "@cUndef("); |
| 1550 | 1550 | ir_print_other_inst_src(irp, instruction->name); |
| 1551 | 1551 | fprintf(irp->f, ")"); |
| 1552 | 1552 | } |
| 1553 | 1553 | |
| 1554 | static void ir_print_embed_file(IrPrintSrc *irp, IrInstSrcEmbedFile *instruction) { | |
| 1554 | static void ir_print_embed_file(IrPrintSrc *irp, Stage1ZirInstEmbedFile *instruction) { | |
| 1555 | 1555 | fprintf(irp->f, "@embedFile("); |
| 1556 | 1556 | ir_print_other_inst_src(irp, instruction->name); |
| 1557 | 1557 | fprintf(irp->f, ")"); |
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | static void ir_print_cmpxchg_src(IrPrintSrc *irp, IrInstSrcCmpxchg *instruction) { | |
| 1560 | static void ir_print_cmpxchg_src(IrPrintSrc *irp, Stage1ZirInstCmpxchg *instruction) { | |
| 1561 | 1561 | fprintf(irp->f, "@cmpxchg("); |
| 1562 | 1562 | ir_print_other_inst_src(irp, instruction->ptr); |
| 1563 | 1563 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1572,7 +1572,7 @@ static void ir_print_cmpxchg_src(IrPrintSrc *irp, IrInstSrcCmpxchg *instruction) |
| 1572 | 1572 | ir_print_result_loc(irp, instruction->result_loc); |
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | static void ir_print_cmpxchg_gen(IrPrintGen *irp, IrInstGenCmpxchg *instruction) { | |
| 1575 | static void ir_print_cmpxchg_gen(IrPrintGen *irp, Stage1AirInstCmpxchg *instruction) { | |
| 1576 | 1576 | fprintf(irp->f, "@cmpxchg("); |
| 1577 | 1577 | ir_print_other_inst_gen(irp, instruction->ptr); |
| 1578 | 1578 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1583,13 +1583,13 @@ static void ir_print_cmpxchg_gen(IrPrintGen *irp, IrInstGenCmpxchg *instruction) |
| 1583 | 1583 | ir_print_other_inst_gen(irp, instruction->result_loc); |
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | static void ir_print_fence(IrPrintSrc *irp, IrInstSrcFence *instruction) { | |
| 1586 | static void ir_print_fence(IrPrintSrc *irp, Stage1ZirInstFence *instruction) { | |
| 1587 | 1587 | fprintf(irp->f, "@fence("); |
| 1588 | 1588 | ir_print_other_inst_src(irp, instruction->order); |
| 1589 | 1589 | fprintf(irp->f, ")"); |
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | static void ir_print_reduce(IrPrintSrc *irp, IrInstSrcReduce *instruction) { | |
| 1592 | static void ir_print_reduce(IrPrintSrc *irp, Stage1ZirInstReduce *instruction) { | |
| 1593 | 1593 | fprintf(irp->f, "@reduce("); |
| 1594 | 1594 | ir_print_other_inst_src(irp, instruction->op); |
| 1595 | 1595 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1609,7 +1609,7 @@ static const char *atomic_order_str(AtomicOrder order) { |
| 1609 | 1609 | zig_unreachable(); |
| 1610 | 1610 | } |
| 1611 | 1611 | |
| 1612 | static void ir_print_fence(IrPrintGen *irp, IrInstGenFence *instruction) { | |
| 1612 | static void ir_print_fence(IrPrintGen *irp, Stage1AirInstFence *instruction) { | |
| 1613 | 1613 | fprintf(irp->f, "fence %s", atomic_order_str(instruction->order)); |
| 1614 | 1614 | } |
| 1615 | 1615 | |
| ... | ... | @@ -1626,13 +1626,13 @@ static const char *reduce_op_str(ReduceOp op) { |
| 1626 | 1626 | zig_unreachable(); |
| 1627 | 1627 | } |
| 1628 | 1628 | |
| 1629 | static void ir_print_reduce(IrPrintGen *irp, IrInstGenReduce *instruction) { | |
| 1629 | static void ir_print_reduce(IrPrintGen *irp, Stage1AirInstReduce *instruction) { | |
| 1630 | 1630 | fprintf(irp->f, "@reduce(.%s, ", reduce_op_str(instruction->op)); |
| 1631 | 1631 | ir_print_other_inst_gen(irp, instruction->value); |
| 1632 | 1632 | fprintf(irp->f, ")"); |
| 1633 | 1633 | } |
| 1634 | 1634 | |
| 1635 | static void ir_print_truncate(IrPrintSrc *irp, IrInstSrcTruncate *instruction) { | |
| 1635 | static void ir_print_truncate(IrPrintSrc *irp, Stage1ZirInstTruncate *instruction) { | |
| 1636 | 1636 | fprintf(irp->f, "@truncate("); |
| 1637 | 1637 | ir_print_other_inst_src(irp, instruction->dest_type); |
| 1638 | 1638 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1640,13 +1640,13 @@ static void ir_print_truncate(IrPrintSrc *irp, IrInstSrcTruncate *instruction) { |
| 1640 | 1640 | fprintf(irp->f, ")"); |
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | static void ir_print_truncate(IrPrintGen *irp, IrInstGenTruncate *instruction) { | |
| 1643 | static void ir_print_truncate(IrPrintGen *irp, Stage1AirInstTruncate *instruction) { | |
| 1644 | 1644 | fprintf(irp->f, "@truncate("); |
| 1645 | 1645 | ir_print_other_inst_gen(irp, instruction->target); |
| 1646 | 1646 | fprintf(irp->f, ")"); |
| 1647 | 1647 | } |
| 1648 | 1648 | |
| 1649 | static void ir_print_int_cast(IrPrintSrc *irp, IrInstSrcIntCast *instruction) { | |
| 1649 | static void ir_print_int_cast(IrPrintSrc *irp, Stage1ZirInstIntCast *instruction) { | |
| 1650 | 1650 | fprintf(irp->f, "@intCast("); |
| 1651 | 1651 | ir_print_other_inst_src(irp, instruction->dest_type); |
| 1652 | 1652 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1654,7 +1654,7 @@ static void ir_print_int_cast(IrPrintSrc *irp, IrInstSrcIntCast *instruction) { |
| 1654 | 1654 | fprintf(irp->f, ")"); |
| 1655 | 1655 | } |
| 1656 | 1656 | |
| 1657 | static void ir_print_float_cast(IrPrintSrc *irp, IrInstSrcFloatCast *instruction) { | |
| 1657 | static void ir_print_float_cast(IrPrintSrc *irp, Stage1ZirInstFloatCast *instruction) { | |
| 1658 | 1658 | fprintf(irp->f, "@floatCast("); |
| 1659 | 1659 | ir_print_other_inst_src(irp, instruction->dest_type); |
| 1660 | 1660 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1662,7 +1662,7 @@ static void ir_print_float_cast(IrPrintSrc *irp, IrInstSrcFloatCast *instruction |
| 1662 | 1662 | fprintf(irp->f, ")"); |
| 1663 | 1663 | } |
| 1664 | 1664 | |
| 1665 | static void ir_print_err_set_cast(IrPrintSrc *irp, IrInstSrcErrSetCast *instruction) { | |
| 1665 | static void ir_print_err_set_cast(IrPrintSrc *irp, Stage1ZirInstErrSetCast *instruction) { | |
| 1666 | 1666 | fprintf(irp->f, "@errSetCast("); |
| 1667 | 1667 | ir_print_other_inst_src(irp, instruction->dest_type); |
| 1668 | 1668 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1670,7 +1670,7 @@ static void ir_print_err_set_cast(IrPrintSrc *irp, IrInstSrcErrSetCast *instruct |
| 1670 | 1670 | fprintf(irp->f, ")"); |
| 1671 | 1671 | } |
| 1672 | 1672 | |
| 1673 | static void ir_print_int_to_float(IrPrintSrc *irp, IrInstSrcIntToFloat *instruction) { | |
| 1673 | static void ir_print_int_to_float(IrPrintSrc *irp, Stage1ZirInstIntToFloat *instruction) { | |
| 1674 | 1674 | fprintf(irp->f, "@intToFloat("); |
| 1675 | 1675 | ir_print_other_inst_src(irp, instruction->dest_type); |
| 1676 | 1676 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1678,7 +1678,7 @@ static void ir_print_int_to_float(IrPrintSrc *irp, IrInstSrcIntToFloat *instruct |
| 1678 | 1678 | fprintf(irp->f, ")"); |
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | static void ir_print_float_to_int(IrPrintSrc *irp, IrInstSrcFloatToInt *instruction) { | |
| 1681 | static void ir_print_float_to_int(IrPrintSrc *irp, Stage1ZirInstFloatToInt *instruction) { | |
| 1682 | 1682 | fprintf(irp->f, "@floatToInt("); |
| 1683 | 1683 | ir_print_other_inst_src(irp, instruction->dest_type); |
| 1684 | 1684 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1686,13 +1686,13 @@ static void ir_print_float_to_int(IrPrintSrc *irp, IrInstSrcFloatToInt *instruct |
| 1686 | 1686 | fprintf(irp->f, ")"); |
| 1687 | 1687 | } |
| 1688 | 1688 | |
| 1689 | static void ir_print_bool_to_int(IrPrintSrc *irp, IrInstSrcBoolToInt *instruction) { | |
| 1689 | static void ir_print_bool_to_int(IrPrintSrc *irp, Stage1ZirInstBoolToInt *instruction) { | |
| 1690 | 1690 | fprintf(irp->f, "@boolToInt("); |
| 1691 | 1691 | ir_print_other_inst_src(irp, instruction->target); |
| 1692 | 1692 | fprintf(irp->f, ")"); |
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | static void ir_print_vector_type(IrPrintSrc *irp, IrInstSrcVectorType *instruction) { | |
| 1695 | static void ir_print_vector_type(IrPrintSrc *irp, Stage1ZirInstVectorType *instruction) { | |
| 1696 | 1696 | fprintf(irp->f, "@Vector("); |
| 1697 | 1697 | ir_print_other_inst_src(irp, instruction->len); |
| 1698 | 1698 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1700,7 +1700,7 @@ static void ir_print_vector_type(IrPrintSrc *irp, IrInstSrcVectorType *instructi |
| 1700 | 1700 | fprintf(irp->f, ")"); |
| 1701 | 1701 | } |
| 1702 | 1702 | |
| 1703 | static void ir_print_shuffle_vector(IrPrintSrc *irp, IrInstSrcShuffleVector *instruction) { | |
| 1703 | static void ir_print_shuffle_vector(IrPrintSrc *irp, Stage1ZirInstShuffleVector *instruction) { | |
| 1704 | 1704 | fprintf(irp->f, "@shuffle("); |
| 1705 | 1705 | ir_print_other_inst_src(irp, instruction->scalar_type); |
| 1706 | 1706 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1712,7 +1712,7 @@ static void ir_print_shuffle_vector(IrPrintSrc *irp, IrInstSrcShuffleVector *ins |
| 1712 | 1712 | fprintf(irp->f, ")"); |
| 1713 | 1713 | } |
| 1714 | 1714 | |
| 1715 | static void ir_print_shuffle_vector(IrPrintGen *irp, IrInstGenShuffleVector *instruction) { | |
| 1715 | static void ir_print_shuffle_vector(IrPrintGen *irp, Stage1AirInstShuffleVector *instruction) { | |
| 1716 | 1716 | fprintf(irp->f, "@shuffle("); |
| 1717 | 1717 | ir_print_other_inst_gen(irp, instruction->a); |
| 1718 | 1718 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1722,7 +1722,7 @@ static void ir_print_shuffle_vector(IrPrintGen *irp, IrInstGenShuffleVector *ins |
| 1722 | 1722 | fprintf(irp->f, ")"); |
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | static void ir_print_splat_src(IrPrintSrc *irp, IrInstSrcSplat *instruction) { | |
| 1725 | static void ir_print_splat_src(IrPrintSrc *irp, Stage1ZirInstSplat *instruction) { | |
| 1726 | 1726 | fprintf(irp->f, "@splat("); |
| 1727 | 1727 | ir_print_other_inst_src(irp, instruction->len); |
| 1728 | 1728 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1730,35 +1730,35 @@ static void ir_print_splat_src(IrPrintSrc *irp, IrInstSrcSplat *instruction) { |
| 1730 | 1730 | fprintf(irp->f, ")"); |
| 1731 | 1731 | } |
| 1732 | 1732 | |
| 1733 | static void ir_print_splat_gen(IrPrintGen *irp, IrInstGenSplat *instruction) { | |
| 1733 | static void ir_print_splat_gen(IrPrintGen *irp, Stage1AirInstSplat *instruction) { | |
| 1734 | 1734 | fprintf(irp->f, "@splat("); |
| 1735 | 1735 | ir_print_other_inst_gen(irp, instruction->scalar); |
| 1736 | 1736 | fprintf(irp->f, ")"); |
| 1737 | 1737 | } |
| 1738 | 1738 | |
| 1739 | static void ir_print_bool_not(IrPrintSrc *irp, IrInstSrcBoolNot *instruction) { | |
| 1739 | static void ir_print_bool_not(IrPrintSrc *irp, Stage1ZirInstBoolNot *instruction) { | |
| 1740 | 1740 | fprintf(irp->f, "! "); |
| 1741 | 1741 | ir_print_other_inst_src(irp, instruction->value); |
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | static void ir_print_bool_not(IrPrintGen *irp, IrInstGenBoolNot *instruction) { | |
| 1744 | static void ir_print_bool_not(IrPrintGen *irp, Stage1AirInstBoolNot *instruction) { | |
| 1745 | 1745 | fprintf(irp->f, "! "); |
| 1746 | 1746 | ir_print_other_inst_gen(irp, instruction->value); |
| 1747 | 1747 | } |
| 1748 | 1748 | |
| 1749 | static void ir_print_wasm_memory_size(IrPrintSrc *irp, IrInstSrcWasmMemorySize *instruction) { | |
| 1749 | static void ir_print_wasm_memory_size(IrPrintSrc *irp, Stage1ZirInstWasmMemorySize *instruction) { | |
| 1750 | 1750 | fprintf(irp->f, "@wasmMemorySize("); |
| 1751 | 1751 | ir_print_other_inst_src(irp, instruction->index); |
| 1752 | 1752 | fprintf(irp->f, ")"); |
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | static void ir_print_wasm_memory_size(IrPrintGen *irp, IrInstGenWasmMemorySize *instruction) { | |
| 1755 | static void ir_print_wasm_memory_size(IrPrintGen *irp, Stage1AirInstWasmMemorySize *instruction) { | |
| 1756 | 1756 | fprintf(irp->f, "@wasmMemorySize("); |
| 1757 | 1757 | ir_print_other_inst_gen(irp, instruction->index); |
| 1758 | 1758 | fprintf(irp->f, ")"); |
| 1759 | 1759 | } |
| 1760 | 1760 | |
| 1761 | static void ir_print_wasm_memory_grow(IrPrintSrc *irp, IrInstSrcWasmMemoryGrow *instruction) { | |
| 1761 | static void ir_print_wasm_memory_grow(IrPrintSrc *irp, Stage1ZirInstWasmMemoryGrow *instruction) { | |
| 1762 | 1762 | fprintf(irp->f, "@wasmMemoryGrow("); |
| 1763 | 1763 | ir_print_other_inst_src(irp, instruction->index); |
| 1764 | 1764 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1766,7 +1766,7 @@ static void ir_print_wasm_memory_grow(IrPrintSrc *irp, IrInstSrcWasmMemoryGrow * |
| 1766 | 1766 | fprintf(irp->f, ")"); |
| 1767 | 1767 | } |
| 1768 | 1768 | |
| 1769 | static void ir_print_wasm_memory_grow(IrPrintGen *irp, IrInstGenWasmMemoryGrow *instruction) { | |
| 1769 | static void ir_print_wasm_memory_grow(IrPrintGen *irp, Stage1AirInstWasmMemoryGrow *instruction) { | |
| 1770 | 1770 | fprintf(irp->f, "@wasmMemoryGrow("); |
| 1771 | 1771 | ir_print_other_inst_gen(irp, instruction->index); |
| 1772 | 1772 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1774,11 +1774,11 @@ static void ir_print_wasm_memory_grow(IrPrintGen *irp, IrInstGenWasmMemoryGrow * |
| 1774 | 1774 | fprintf(irp->f, ")"); |
| 1775 | 1775 | } |
| 1776 | 1776 | |
| 1777 | static void ir_print_builtin_src(IrPrintSrc *irp, IrInstSrcSrc *instruction) { | |
| 1777 | static void ir_print_builtin_src(IrPrintSrc *irp, Stage1ZirInstSrc *instruction) { | |
| 1778 | 1778 | fprintf(irp->f, "@src()"); |
| 1779 | 1779 | } |
| 1780 | 1780 | |
| 1781 | static void ir_print_memset(IrPrintSrc *irp, IrInstSrcMemset *instruction) { | |
| 1781 | static void ir_print_memset(IrPrintSrc *irp, Stage1ZirInstMemset *instruction) { | |
| 1782 | 1782 | fprintf(irp->f, "@memset("); |
| 1783 | 1783 | ir_print_other_inst_src(irp, instruction->dest_ptr); |
| 1784 | 1784 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1788,7 +1788,7 @@ static void ir_print_memset(IrPrintSrc *irp, IrInstSrcMemset *instruction) { |
| 1788 | 1788 | fprintf(irp->f, ")"); |
| 1789 | 1789 | } |
| 1790 | 1790 | |
| 1791 | static void ir_print_memset(IrPrintGen *irp, IrInstGenMemset *instruction) { | |
| 1791 | static void ir_print_memset(IrPrintGen *irp, Stage1AirInstMemset *instruction) { | |
| 1792 | 1792 | fprintf(irp->f, "@memset("); |
| 1793 | 1793 | ir_print_other_inst_gen(irp, instruction->dest_ptr); |
| 1794 | 1794 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1798,7 +1798,7 @@ static void ir_print_memset(IrPrintGen *irp, IrInstGenMemset *instruction) { |
| 1798 | 1798 | fprintf(irp->f, ")"); |
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | static void ir_print_memcpy(IrPrintSrc *irp, IrInstSrcMemcpy *instruction) { | |
| 1801 | static void ir_print_memcpy(IrPrintSrc *irp, Stage1ZirInstMemcpy *instruction) { | |
| 1802 | 1802 | fprintf(irp->f, "@memcpy("); |
| 1803 | 1803 | ir_print_other_inst_src(irp, instruction->dest_ptr); |
| 1804 | 1804 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1808,7 +1808,7 @@ static void ir_print_memcpy(IrPrintSrc *irp, IrInstSrcMemcpy *instruction) { |
| 1808 | 1808 | fprintf(irp->f, ")"); |
| 1809 | 1809 | } |
| 1810 | 1810 | |
| 1811 | static void ir_print_memcpy(IrPrintGen *irp, IrInstGenMemcpy *instruction) { | |
| 1811 | static void ir_print_memcpy(IrPrintGen *irp, Stage1AirInstMemcpy *instruction) { | |
| 1812 | 1812 | fprintf(irp->f, "@memcpy("); |
| 1813 | 1813 | ir_print_other_inst_gen(irp, instruction->dest_ptr); |
| 1814 | 1814 | fprintf(irp->f, ", "); |
| ... | ... | @@ -1818,7 +1818,7 @@ static void ir_print_memcpy(IrPrintGen *irp, IrInstGenMemcpy *instruction) { |
| 1818 | 1818 | fprintf(irp->f, ")"); |
| 1819 | 1819 | } |
| 1820 | 1820 | |
| 1821 | static void ir_print_slice_src(IrPrintSrc *irp, IrInstSrcSlice *instruction) { | |
| 1821 | static void ir_print_slice_src(IrPrintSrc *irp, Stage1ZirInstSlice *instruction) { | |
| 1822 | 1822 | ir_print_other_inst_src(irp, instruction->ptr); |
| 1823 | 1823 | fprintf(irp->f, "["); |
| 1824 | 1824 | ir_print_other_inst_src(irp, instruction->start); |
| ... | ... | @@ -1829,7 +1829,7 @@ static void ir_print_slice_src(IrPrintSrc *irp, IrInstSrcSlice *instruction) { |
| 1829 | 1829 | ir_print_result_loc(irp, instruction->result_loc); |
| 1830 | 1830 | } |
| 1831 | 1831 | |
| 1832 | static void ir_print_slice_gen(IrPrintGen *irp, IrInstGenSlice *instruction) { | |
| 1832 | static void ir_print_slice_gen(IrPrintGen *irp, Stage1AirInstSlice *instruction) { | |
| 1833 | 1833 | ir_print_other_inst_gen(irp, instruction->ptr); |
| 1834 | 1834 | fprintf(irp->f, "["); |
| 1835 | 1835 | ir_print_other_inst_gen(irp, instruction->start); |
| ... | ... | @@ -1840,63 +1840,63 @@ static void ir_print_slice_gen(IrPrintGen *irp, IrInstGenSlice *instruction) { |
| 1840 | 1840 | ir_print_other_inst_gen(irp, instruction->result_loc); |
| 1841 | 1841 | } |
| 1842 | 1842 | |
| 1843 | static void ir_print_breakpoint(IrPrintSrc *irp, IrInstSrcBreakpoint *instruction) { | |
| 1843 | static void ir_print_breakpoint(IrPrintSrc *irp, Stage1ZirInstBreakpoint *instruction) { | |
| 1844 | 1844 | fprintf(irp->f, "@breakpoint()"); |
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | static void ir_print_breakpoint(IrPrintGen *irp, IrInstGenBreakpoint *instruction) { | |
| 1847 | static void ir_print_breakpoint(IrPrintGen *irp, Stage1AirInstBreakpoint *instruction) { | |
| 1848 | 1848 | fprintf(irp->f, "@breakpoint()"); |
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | static void ir_print_frame_address(IrPrintSrc *irp, IrInstSrcFrameAddress *instruction) { | |
| 1851 | static void ir_print_frame_address(IrPrintSrc *irp, Stage1ZirInstFrameAddress *instruction) { | |
| 1852 | 1852 | fprintf(irp->f, "@frameAddress()"); |
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | static void ir_print_frame_address(IrPrintGen *irp, IrInstGenFrameAddress *instruction) { | |
| 1855 | static void ir_print_frame_address(IrPrintGen *irp, Stage1AirInstFrameAddress *instruction) { | |
| 1856 | 1856 | fprintf(irp->f, "@frameAddress()"); |
| 1857 | 1857 | } |
| 1858 | 1858 | |
| 1859 | static void ir_print_handle(IrPrintSrc *irp, IrInstSrcFrameHandle *instruction) { | |
| 1859 | static void ir_print_handle(IrPrintSrc *irp, Stage1ZirInstFrameHandle *instruction) { | |
| 1860 | 1860 | fprintf(irp->f, "@frame()"); |
| 1861 | 1861 | } |
| 1862 | 1862 | |
| 1863 | static void ir_print_handle(IrPrintGen *irp, IrInstGenFrameHandle *instruction) { | |
| 1863 | static void ir_print_handle(IrPrintGen *irp, Stage1AirInstFrameHandle *instruction) { | |
| 1864 | 1864 | fprintf(irp->f, "@frame()"); |
| 1865 | 1865 | } |
| 1866 | 1866 | |
| 1867 | static void ir_print_frame_type(IrPrintSrc *irp, IrInstSrcFrameType *instruction) { | |
| 1867 | static void ir_print_frame_type(IrPrintSrc *irp, Stage1ZirInstFrameType *instruction) { | |
| 1868 | 1868 | fprintf(irp->f, "@Frame("); |
| 1869 | 1869 | ir_print_other_inst_src(irp, instruction->fn); |
| 1870 | 1870 | fprintf(irp->f, ")"); |
| 1871 | 1871 | } |
| 1872 | 1872 | |
| 1873 | static void ir_print_frame_size_src(IrPrintSrc *irp, IrInstSrcFrameSize *instruction) { | |
| 1873 | static void ir_print_frame_size_src(IrPrintSrc *irp, Stage1ZirInstFrameSize *instruction) { | |
| 1874 | 1874 | fprintf(irp->f, "@frameSize("); |
| 1875 | 1875 | ir_print_other_inst_src(irp, instruction->fn); |
| 1876 | 1876 | fprintf(irp->f, ")"); |
| 1877 | 1877 | } |
| 1878 | 1878 | |
| 1879 | static void ir_print_frame_size_gen(IrPrintGen *irp, IrInstGenFrameSize *instruction) { | |
| 1879 | static void ir_print_frame_size_gen(IrPrintGen *irp, Stage1AirInstFrameSize *instruction) { | |
| 1880 | 1880 | fprintf(irp->f, "@frameSize("); |
| 1881 | 1881 | ir_print_other_inst_gen(irp, instruction->fn); |
| 1882 | 1882 | fprintf(irp->f, ")"); |
| 1883 | 1883 | } |
| 1884 | 1884 | |
| 1885 | static void ir_print_return_address(IrPrintSrc *irp, IrInstSrcReturnAddress *instruction) { | |
| 1885 | static void ir_print_return_address(IrPrintSrc *irp, Stage1ZirInstReturnAddress *instruction) { | |
| 1886 | 1886 | fprintf(irp->f, "@returnAddress()"); |
| 1887 | 1887 | } |
| 1888 | 1888 | |
| 1889 | static void ir_print_return_address(IrPrintGen *irp, IrInstGenReturnAddress *instruction) { | |
| 1889 | static void ir_print_return_address(IrPrintGen *irp, Stage1AirInstReturnAddress *instruction) { | |
| 1890 | 1890 | fprintf(irp->f, "@returnAddress()"); |
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | static void ir_print_align_of(IrPrintSrc *irp, IrInstSrcAlignOf *instruction) { | |
| 1893 | static void ir_print_align_of(IrPrintSrc *irp, Stage1ZirInstAlignOf *instruction) { | |
| 1894 | 1894 | fprintf(irp->f, "@alignOf("); |
| 1895 | 1895 | ir_print_other_inst_src(irp, instruction->type_value); |
| 1896 | 1896 | fprintf(irp->f, ")"); |
| 1897 | 1897 | } |
| 1898 | 1898 | |
| 1899 | static void ir_print_overflow_op(IrPrintSrc *irp, IrInstSrcOverflowOp *instruction) { | |
| 1899 | static void ir_print_overflow_op(IrPrintSrc *irp, Stage1ZirInstOverflowOp *instruction) { | |
| 1900 | 1900 | switch (instruction->op) { |
| 1901 | 1901 | case IrOverflowOpAdd: |
| 1902 | 1902 | fprintf(irp->f, "@addWithOverflow("); |
| ... | ... | @@ -1921,7 +1921,7 @@ static void ir_print_overflow_op(IrPrintSrc *irp, IrInstSrcOverflowOp *instructi |
| 1921 | 1921 | fprintf(irp->f, ")"); |
| 1922 | 1922 | } |
| 1923 | 1923 | |
| 1924 | static void ir_print_overflow_op(IrPrintGen *irp, IrInstGenOverflowOp *instruction) { | |
| 1924 | static void ir_print_overflow_op(IrPrintGen *irp, Stage1AirInstOverflowOp *instruction) { | |
| 1925 | 1925 | switch (instruction->op) { |
| 1926 | 1926 | case IrOverflowOpAdd: |
| 1927 | 1927 | fprintf(irp->f, "@addWithOverflow("); |
| ... | ... | @@ -1944,64 +1944,64 @@ static void ir_print_overflow_op(IrPrintGen *irp, IrInstGenOverflowOp *instructi |
| 1944 | 1944 | fprintf(irp->f, ")"); |
| 1945 | 1945 | } |
| 1946 | 1946 | |
| 1947 | static void ir_print_test_err_src(IrPrintSrc *irp, IrInstSrcTestErr *instruction) { | |
| 1947 | static void ir_print_test_err_src(IrPrintSrc *irp, Stage1ZirInstTestErr *instruction) { | |
| 1948 | 1948 | fprintf(irp->f, "@testError("); |
| 1949 | 1949 | ir_print_other_inst_src(irp, instruction->base_ptr); |
| 1950 | 1950 | fprintf(irp->f, ")"); |
| 1951 | 1951 | } |
| 1952 | 1952 | |
| 1953 | static void ir_print_test_err_gen(IrPrintGen *irp, IrInstGenTestErr *instruction) { | |
| 1953 | static void ir_print_test_err_gen(IrPrintGen *irp, Stage1AirInstTestErr *instruction) { | |
| 1954 | 1954 | fprintf(irp->f, "@testError("); |
| 1955 | 1955 | ir_print_other_inst_gen(irp, instruction->err_union); |
| 1956 | 1956 | fprintf(irp->f, ")"); |
| 1957 | 1957 | } |
| 1958 | 1958 | |
| 1959 | static void ir_print_unwrap_err_code(IrPrintSrc *irp, IrInstSrcUnwrapErrCode *instruction) { | |
| 1959 | static void ir_print_unwrap_err_code(IrPrintSrc *irp, Stage1ZirInstUnwrapErrCode *instruction) { | |
| 1960 | 1960 | fprintf(irp->f, "UnwrapErrorCode("); |
| 1961 | 1961 | ir_print_other_inst_src(irp, instruction->err_union_ptr); |
| 1962 | 1962 | fprintf(irp->f, ")"); |
| 1963 | 1963 | } |
| 1964 | 1964 | |
| 1965 | static void ir_print_unwrap_err_code(IrPrintGen *irp, IrInstGenUnwrapErrCode *instruction) { | |
| 1965 | static void ir_print_unwrap_err_code(IrPrintGen *irp, Stage1AirInstUnwrapErrCode *instruction) { | |
| 1966 | 1966 | fprintf(irp->f, "UnwrapErrorCode("); |
| 1967 | 1967 | ir_print_other_inst_gen(irp, instruction->err_union_ptr); |
| 1968 | 1968 | fprintf(irp->f, ")"); |
| 1969 | 1969 | } |
| 1970 | 1970 | |
| 1971 | static void ir_print_unwrap_err_payload(IrPrintSrc *irp, IrInstSrcUnwrapErrPayload *instruction) { | |
| 1971 | static void ir_print_unwrap_err_payload(IrPrintSrc *irp, Stage1ZirInstUnwrapErrPayload *instruction) { | |
| 1972 | 1972 | fprintf(irp->f, "ErrorUnionFieldPayload("); |
| 1973 | 1973 | ir_print_other_inst_src(irp, instruction->value); |
| 1974 | 1974 | fprintf(irp->f, ")safety=%d,init=%d",instruction->safety_check_on, instruction->initializing); |
| 1975 | 1975 | } |
| 1976 | 1976 | |
| 1977 | static void ir_print_unwrap_err_payload(IrPrintGen *irp, IrInstGenUnwrapErrPayload *instruction) { | |
| 1977 | static void ir_print_unwrap_err_payload(IrPrintGen *irp, Stage1AirInstUnwrapErrPayload *instruction) { | |
| 1978 | 1978 | fprintf(irp->f, "ErrorUnionFieldPayload("); |
| 1979 | 1979 | ir_print_other_inst_gen(irp, instruction->value); |
| 1980 | 1980 | fprintf(irp->f, ")safety=%d,init=%d",instruction->safety_check_on, instruction->initializing); |
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | static void ir_print_optional_wrap(IrPrintGen *irp, IrInstGenOptionalWrap *instruction) { | |
| 1983 | static void ir_print_optional_wrap(IrPrintGen *irp, Stage1AirInstOptionalWrap *instruction) { | |
| 1984 | 1984 | fprintf(irp->f, "@optionalWrap("); |
| 1985 | 1985 | ir_print_other_inst_gen(irp, instruction->operand); |
| 1986 | 1986 | fprintf(irp->f, ")result="); |
| 1987 | 1987 | ir_print_other_inst_gen(irp, instruction->result_loc); |
| 1988 | 1988 | } |
| 1989 | 1989 | |
| 1990 | static void ir_print_err_wrap_code(IrPrintGen *irp, IrInstGenErrWrapCode *instruction) { | |
| 1990 | static void ir_print_err_wrap_code(IrPrintGen *irp, Stage1AirInstErrWrapCode *instruction) { | |
| 1991 | 1991 | fprintf(irp->f, "@errWrapCode("); |
| 1992 | 1992 | ir_print_other_inst_gen(irp, instruction->operand); |
| 1993 | 1993 | fprintf(irp->f, ")result="); |
| 1994 | 1994 | ir_print_other_inst_gen(irp, instruction->result_loc); |
| 1995 | 1995 | } |
| 1996 | 1996 | |
| 1997 | static void ir_print_err_wrap_payload(IrPrintGen *irp, IrInstGenErrWrapPayload *instruction) { | |
| 1997 | static void ir_print_err_wrap_payload(IrPrintGen *irp, Stage1AirInstErrWrapPayload *instruction) { | |
| 1998 | 1998 | fprintf(irp->f, "@errWrapPayload("); |
| 1999 | 1999 | ir_print_other_inst_gen(irp, instruction->operand); |
| 2000 | 2000 | fprintf(irp->f, ")result="); |
| 2001 | 2001 | ir_print_other_inst_gen(irp, instruction->result_loc); |
| 2002 | 2002 | } |
| 2003 | 2003 | |
| 2004 | static void ir_print_fn_proto(IrPrintSrc *irp, IrInstSrcFnProto *instruction) { | |
| 2004 | static void ir_print_fn_proto(IrPrintSrc *irp, Stage1ZirInstFnProto *instruction) { | |
| 2005 | 2005 | fprintf(irp->f, "fn("); |
| 2006 | 2006 | for (size_t i = 0; i < instruction->base.source_node->data.fn_proto.params.length; i += 1) { |
| 2007 | 2007 | if (i != 0) |
| ... | ... | @@ -2022,13 +2022,13 @@ static void ir_print_fn_proto(IrPrintSrc *irp, IrInstSrcFnProto *instruction) { |
| 2022 | 2022 | ir_print_other_inst_src(irp, instruction->return_type); |
| 2023 | 2023 | } |
| 2024 | 2024 | |
| 2025 | static void ir_print_test_comptime(IrPrintSrc *irp, IrInstSrcTestComptime *instruction) { | |
| 2025 | static void ir_print_test_comptime(IrPrintSrc *irp, Stage1ZirInstTestComptime *instruction) { | |
| 2026 | 2026 | fprintf(irp->f, "@testComptime("); |
| 2027 | 2027 | ir_print_other_inst_src(irp, instruction->value); |
| 2028 | 2028 | fprintf(irp->f, ")"); |
| 2029 | 2029 | } |
| 2030 | 2030 | |
| 2031 | static void ir_print_ptr_cast_src(IrPrintSrc *irp, IrInstSrcPtrCast *instruction) { | |
| 2031 | static void ir_print_ptr_cast_src(IrPrintSrc *irp, Stage1ZirInstPtrCast *instruction) { | |
| 2032 | 2032 | fprintf(irp->f, "@ptrCast("); |
| 2033 | 2033 | if (instruction->dest_type) { |
| 2034 | 2034 | ir_print_other_inst_src(irp, instruction->dest_type); |
| ... | ... | @@ -2038,51 +2038,51 @@ static void ir_print_ptr_cast_src(IrPrintSrc *irp, IrInstSrcPtrCast *instruction |
| 2038 | 2038 | fprintf(irp->f, ")"); |
| 2039 | 2039 | } |
| 2040 | 2040 | |
| 2041 | static void ir_print_ptr_cast_gen(IrPrintGen *irp, IrInstGenPtrCast *instruction) { | |
| 2041 | static void ir_print_ptr_cast_gen(IrPrintGen *irp, Stage1AirInstPtrCast *instruction) { | |
| 2042 | 2042 | fprintf(irp->f, "@ptrCast("); |
| 2043 | 2043 | ir_print_other_inst_gen(irp, instruction->ptr); |
| 2044 | 2044 | fprintf(irp->f, ")"); |
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | static void ir_print_implicit_cast(IrPrintSrc *irp, IrInstSrcImplicitCast *instruction) { | |
| 2047 | static void ir_print_implicit_cast(IrPrintSrc *irp, Stage1ZirInstImplicitCast *instruction) { | |
| 2048 | 2048 | fprintf(irp->f, "@implicitCast("); |
| 2049 | 2049 | ir_print_other_inst_src(irp, instruction->operand); |
| 2050 | 2050 | fprintf(irp->f, ")result="); |
| 2051 | 2051 | ir_print_result_loc(irp, &instruction->result_loc_cast->base); |
| 2052 | 2052 | } |
| 2053 | 2053 | |
| 2054 | static void ir_print_bit_cast_src(IrPrintSrc *irp, IrInstSrcBitCast *instruction) { | |
| 2054 | static void ir_print_bit_cast_src(IrPrintSrc *irp, Stage1ZirInstBitCast *instruction) { | |
| 2055 | 2055 | fprintf(irp->f, "@bitCast("); |
| 2056 | 2056 | ir_print_other_inst_src(irp, instruction->operand); |
| 2057 | 2057 | fprintf(irp->f, ")result="); |
| 2058 | 2058 | ir_print_result_loc(irp, &instruction->result_loc_bit_cast->base); |
| 2059 | 2059 | } |
| 2060 | 2060 | |
| 2061 | static void ir_print_bit_cast_gen(IrPrintGen *irp, IrInstGenBitCast *instruction) { | |
| 2061 | static void ir_print_bit_cast_gen(IrPrintGen *irp, Stage1AirInstBitCast *instruction) { | |
| 2062 | 2062 | fprintf(irp->f, "@bitCast("); |
| 2063 | 2063 | ir_print_other_inst_gen(irp, instruction->operand); |
| 2064 | 2064 | fprintf(irp->f, ")"); |
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | static void ir_print_widen_or_shorten(IrPrintGen *irp, IrInstGenWidenOrShorten *instruction) { | |
| 2067 | static void ir_print_widen_or_shorten(IrPrintGen *irp, Stage1AirInstWidenOrShorten *instruction) { | |
| 2068 | 2068 | fprintf(irp->f, "WidenOrShorten("); |
| 2069 | 2069 | ir_print_other_inst_gen(irp, instruction->target); |
| 2070 | 2070 | fprintf(irp->f, ")"); |
| 2071 | 2071 | } |
| 2072 | 2072 | |
| 2073 | static void ir_print_ptr_to_int(IrPrintSrc *irp, IrInstSrcPtrToInt *instruction) { | |
| 2073 | static void ir_print_ptr_to_int(IrPrintSrc *irp, Stage1ZirInstPtrToInt *instruction) { | |
| 2074 | 2074 | fprintf(irp->f, "@ptrToInt("); |
| 2075 | 2075 | ir_print_other_inst_src(irp, instruction->target); |
| 2076 | 2076 | fprintf(irp->f, ")"); |
| 2077 | 2077 | } |
| 2078 | 2078 | |
| 2079 | static void ir_print_ptr_to_int(IrPrintGen *irp, IrInstGenPtrToInt *instruction) { | |
| 2079 | static void ir_print_ptr_to_int(IrPrintGen *irp, Stage1AirInstPtrToInt *instruction) { | |
| 2080 | 2080 | fprintf(irp->f, "@ptrToInt("); |
| 2081 | 2081 | ir_print_other_inst_gen(irp, instruction->target); |
| 2082 | 2082 | fprintf(irp->f, ")"); |
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | static void ir_print_int_to_ptr(IrPrintSrc *irp, IrInstSrcIntToPtr *instruction) { | |
| 2085 | static void ir_print_int_to_ptr(IrPrintSrc *irp, Stage1ZirInstIntToPtr *instruction) { | |
| 2086 | 2086 | fprintf(irp->f, "@intToPtr("); |
| 2087 | 2087 | ir_print_other_inst_src(irp, instruction->dest_type); |
| 2088 | 2088 | fprintf(irp->f, ","); |
| ... | ... | @@ -2090,13 +2090,13 @@ static void ir_print_int_to_ptr(IrPrintSrc *irp, IrInstSrcIntToPtr *instruction) |
| 2090 | 2090 | fprintf(irp->f, ")"); |
| 2091 | 2091 | } |
| 2092 | 2092 | |
| 2093 | static void ir_print_int_to_ptr(IrPrintGen *irp, IrInstGenIntToPtr *instruction) { | |
| 2093 | static void ir_print_int_to_ptr(IrPrintGen *irp, Stage1AirInstIntToPtr *instruction) { | |
| 2094 | 2094 | fprintf(irp->f, "@intToPtr("); |
| 2095 | 2095 | ir_print_other_inst_gen(irp, instruction->target); |
| 2096 | 2096 | fprintf(irp->f, ")"); |
| 2097 | 2097 | } |
| 2098 | 2098 | |
| 2099 | static void ir_print_int_to_enum(IrPrintSrc *irp, IrInstSrcIntToEnum *instruction) { | |
| 2099 | static void ir_print_int_to_enum(IrPrintSrc *irp, Stage1ZirInstIntToEnum *instruction) { | |
| 2100 | 2100 | fprintf(irp->f, "@intToEnum("); |
| 2101 | 2101 | ir_print_other_inst_src(irp, instruction->dest_type); |
| 2102 | 2102 | fprintf(irp->f, ","); |
| ... | ... | @@ -2104,19 +2104,19 @@ static void ir_print_int_to_enum(IrPrintSrc *irp, IrInstSrcIntToEnum *instructio |
| 2104 | 2104 | fprintf(irp->f, ")"); |
| 2105 | 2105 | } |
| 2106 | 2106 | |
| 2107 | static void ir_print_int_to_enum(IrPrintGen *irp, IrInstGenIntToEnum *instruction) { | |
| 2107 | static void ir_print_int_to_enum(IrPrintGen *irp, Stage1AirInstIntToEnum *instruction) { | |
| 2108 | 2108 | fprintf(irp->f, "@intToEnum("); |
| 2109 | 2109 | ir_print_other_inst_gen(irp, instruction->target); |
| 2110 | 2110 | fprintf(irp->f, ")"); |
| 2111 | 2111 | } |
| 2112 | 2112 | |
| 2113 | static void ir_print_enum_to_int(IrPrintSrc *irp, IrInstSrcEnumToInt *instruction) { | |
| 2113 | static void ir_print_enum_to_int(IrPrintSrc *irp, Stage1ZirInstEnumToInt *instruction) { | |
| 2114 | 2114 | fprintf(irp->f, "@enumToInt("); |
| 2115 | 2115 | ir_print_other_inst_src(irp, instruction->target); |
| 2116 | 2116 | fprintf(irp->f, ")"); |
| 2117 | 2117 | } |
| 2118 | 2118 | |
| 2119 | static void ir_print_check_runtime_scope(IrPrintSrc *irp, IrInstSrcCheckRuntimeScope *instruction) { | |
| 2119 | static void ir_print_check_runtime_scope(IrPrintSrc *irp, Stage1ZirInstCheckRuntimeScope *instruction) { | |
| 2120 | 2120 | fprintf(irp->f, "@checkRuntimeScope("); |
| 2121 | 2121 | ir_print_other_inst_src(irp, instruction->scope_is_comptime); |
| 2122 | 2122 | fprintf(irp->f, ","); |
| ... | ... | @@ -2124,49 +2124,49 @@ static void ir_print_check_runtime_scope(IrPrintSrc *irp, IrInstSrcCheckRuntimeS |
| 2124 | 2124 | fprintf(irp->f, ")"); |
| 2125 | 2125 | } |
| 2126 | 2126 | |
| 2127 | static void ir_print_array_to_vector(IrPrintGen *irp, IrInstGenArrayToVector *instruction) { | |
| 2127 | static void ir_print_array_to_vector(IrPrintGen *irp, Stage1AirInstArrayToVector *instruction) { | |
| 2128 | 2128 | fprintf(irp->f, "ArrayToVector("); |
| 2129 | 2129 | ir_print_other_inst_gen(irp, instruction->array); |
| 2130 | 2130 | fprintf(irp->f, ")"); |
| 2131 | 2131 | } |
| 2132 | 2132 | |
| 2133 | static void ir_print_vector_to_array(IrPrintGen *irp, IrInstGenVectorToArray *instruction) { | |
| 2133 | static void ir_print_vector_to_array(IrPrintGen *irp, Stage1AirInstVectorToArray *instruction) { | |
| 2134 | 2134 | fprintf(irp->f, "VectorToArray("); |
| 2135 | 2135 | ir_print_other_inst_gen(irp, instruction->vector); |
| 2136 | 2136 | fprintf(irp->f, ")result="); |
| 2137 | 2137 | ir_print_other_inst_gen(irp, instruction->result_loc); |
| 2138 | 2138 | } |
| 2139 | 2139 | |
| 2140 | static void ir_print_ptr_of_array_to_slice(IrPrintGen *irp, IrInstGenPtrOfArrayToSlice *instruction) { | |
| 2140 | static void ir_print_ptr_of_array_to_slice(IrPrintGen *irp, Stage1AirInstPtrOfArrayToSlice *instruction) { | |
| 2141 | 2141 | fprintf(irp->f, "PtrOfArrayToSlice("); |
| 2142 | 2142 | ir_print_other_inst_gen(irp, instruction->operand); |
| 2143 | 2143 | fprintf(irp->f, ")result="); |
| 2144 | 2144 | ir_print_other_inst_gen(irp, instruction->result_loc); |
| 2145 | 2145 | } |
| 2146 | 2146 | |
| 2147 | static void ir_print_assert_zero(IrPrintGen *irp, IrInstGenAssertZero *instruction) { | |
| 2147 | static void ir_print_assert_zero(IrPrintGen *irp, Stage1AirInstAssertZero *instruction) { | |
| 2148 | 2148 | fprintf(irp->f, "AssertZero("); |
| 2149 | 2149 | ir_print_other_inst_gen(irp, instruction->target); |
| 2150 | 2150 | fprintf(irp->f, ")"); |
| 2151 | 2151 | } |
| 2152 | 2152 | |
| 2153 | static void ir_print_assert_non_null(IrPrintGen *irp, IrInstGenAssertNonNull *instruction) { | |
| 2153 | static void ir_print_assert_non_null(IrPrintGen *irp, Stage1AirInstAssertNonNull *instruction) { | |
| 2154 | 2154 | fprintf(irp->f, "AssertNonNull("); |
| 2155 | 2155 | ir_print_other_inst_gen(irp, instruction->target); |
| 2156 | 2156 | fprintf(irp->f, ")"); |
| 2157 | 2157 | } |
| 2158 | 2158 | |
| 2159 | static void ir_print_alloca_src(IrPrintSrc *irp, IrInstSrcAlloca *instruction) { | |
| 2159 | static void ir_print_alloca_src(IrPrintSrc *irp, Stage1ZirInstAlloca *instruction) { | |
| 2160 | 2160 | fprintf(irp->f, "Alloca(align="); |
| 2161 | 2161 | ir_print_other_inst_src(irp, instruction->align); |
| 2162 | 2162 | fprintf(irp->f, ",name=%s)", instruction->name_hint); |
| 2163 | 2163 | } |
| 2164 | 2164 | |
| 2165 | static void ir_print_alloca_gen(IrPrintGen *irp, IrInstGenAlloca *instruction) { | |
| 2165 | static void ir_print_alloca_gen(IrPrintGen *irp, Stage1AirInstAlloca *instruction) { | |
| 2166 | 2166 | fprintf(irp->f, "Alloca(align=%" PRIu32 ",name=%s)", instruction->align, instruction->name_hint); |
| 2167 | 2167 | } |
| 2168 | 2168 | |
| 2169 | static void ir_print_end_expr(IrPrintSrc *irp, IrInstSrcEndExpr *instruction) { | |
| 2169 | static void ir_print_end_expr(IrPrintSrc *irp, Stage1ZirInstEndExpr *instruction) { | |
| 2170 | 2170 | fprintf(irp->f, "EndExpr(result="); |
| 2171 | 2171 | ir_print_result_loc(irp, instruction->result_loc); |
| 2172 | 2172 | fprintf(irp->f, ",value="); |
| ... | ... | @@ -2174,27 +2174,27 @@ static void ir_print_end_expr(IrPrintSrc *irp, IrInstSrcEndExpr *instruction) { |
| 2174 | 2174 | fprintf(irp->f, ")"); |
| 2175 | 2175 | } |
| 2176 | 2176 | |
| 2177 | static void ir_print_int_to_err(IrPrintSrc *irp, IrInstSrcIntToErr *instruction) { | |
| 2177 | static void ir_print_int_to_err(IrPrintSrc *irp, Stage1ZirInstIntToErr *instruction) { | |
| 2178 | 2178 | fprintf(irp->f, "inttoerr "); |
| 2179 | 2179 | ir_print_other_inst_src(irp, instruction->target); |
| 2180 | 2180 | } |
| 2181 | 2181 | |
| 2182 | static void ir_print_int_to_err(IrPrintGen *irp, IrInstGenIntToErr *instruction) { | |
| 2182 | static void ir_print_int_to_err(IrPrintGen *irp, Stage1AirInstIntToErr *instruction) { | |
| 2183 | 2183 | fprintf(irp->f, "inttoerr "); |
| 2184 | 2184 | ir_print_other_inst_gen(irp, instruction->target); |
| 2185 | 2185 | } |
| 2186 | 2186 | |
| 2187 | static void ir_print_err_to_int(IrPrintSrc *irp, IrInstSrcErrToInt *instruction) { | |
| 2187 | static void ir_print_err_to_int(IrPrintSrc *irp, Stage1ZirInstErrToInt *instruction) { | |
| 2188 | 2188 | fprintf(irp->f, "errtoint "); |
| 2189 | 2189 | ir_print_other_inst_src(irp, instruction->target); |
| 2190 | 2190 | } |
| 2191 | 2191 | |
| 2192 | static void ir_print_err_to_int(IrPrintGen *irp, IrInstGenErrToInt *instruction) { | |
| 2192 | static void ir_print_err_to_int(IrPrintGen *irp, Stage1AirInstErrToInt *instruction) { | |
| 2193 | 2193 | fprintf(irp->f, "errtoint "); |
| 2194 | 2194 | ir_print_other_inst_gen(irp, instruction->target); |
| 2195 | 2195 | } |
| 2196 | 2196 | |
| 2197 | static void ir_print_check_switch_prongs(IrPrintSrc *irp, IrInstSrcCheckSwitchProngs *instruction, | |
| 2197 | static void ir_print_check_switch_prongs(IrPrintSrc *irp, Stage1ZirInstCheckSwitchProngs *instruction, | |
| 2198 | 2198 | bool have_underscore_prong) |
| 2199 | 2199 | { |
| 2200 | 2200 | fprintf(irp->f, "@checkSwitchProngs("); |
| ... | ... | @@ -2213,28 +2213,28 @@ static void ir_print_check_switch_prongs(IrPrintSrc *irp, IrInstSrcCheckSwitchPr |
| 2213 | 2213 | fprintf(irp->f, " _:%s", have_under_str); |
| 2214 | 2214 | } |
| 2215 | 2215 | |
| 2216 | static void ir_print_check_statement_is_void(IrPrintSrc *irp, IrInstSrcCheckStatementIsVoid *instruction) { | |
| 2216 | static void ir_print_check_statement_is_void(IrPrintSrc *irp, Stage1ZirInstCheckStatementIsVoid *instruction) { | |
| 2217 | 2217 | fprintf(irp->f, "@checkStatementIsVoid("); |
| 2218 | 2218 | ir_print_other_inst_src(irp, instruction->statement_value); |
| 2219 | 2219 | fprintf(irp->f, ")"); |
| 2220 | 2220 | } |
| 2221 | 2221 | |
| 2222 | static void ir_print_type_name(IrPrintSrc *irp, IrInstSrcTypeName *instruction) { | |
| 2222 | static void ir_print_type_name(IrPrintSrc *irp, Stage1ZirInstTypeName *instruction) { | |
| 2223 | 2223 | fprintf(irp->f, "typename "); |
| 2224 | 2224 | ir_print_other_inst_src(irp, instruction->type_value); |
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | static void ir_print_tag_name(IrPrintSrc *irp, IrInstSrcTagName *instruction) { | |
| 2227 | static void ir_print_tag_name(IrPrintSrc *irp, Stage1ZirInstTagName *instruction) { | |
| 2228 | 2228 | fprintf(irp->f, "tagname "); |
| 2229 | 2229 | ir_print_other_inst_src(irp, instruction->target); |
| 2230 | 2230 | } |
| 2231 | 2231 | |
| 2232 | static void ir_print_tag_name(IrPrintGen *irp, IrInstGenTagName *instruction) { | |
| 2232 | static void ir_print_tag_name(IrPrintGen *irp, Stage1AirInstTagName *instruction) { | |
| 2233 | 2233 | fprintf(irp->f, "tagname "); |
| 2234 | 2234 | ir_print_other_inst_gen(irp, instruction->target); |
| 2235 | 2235 | } |
| 2236 | 2236 | |
| 2237 | static void ir_print_ptr_type(IrPrintSrc *irp, IrInstSrcPtrType *instruction) { | |
| 2237 | static void ir_print_ptr_type(IrPrintSrc *irp, Stage1ZirInstPtrType *instruction) { | |
| 2238 | 2238 | fprintf(irp->f, "&"); |
| 2239 | 2239 | if (instruction->align_value != nullptr) { |
| 2240 | 2240 | fprintf(irp->f, "align("); |
| ... | ... | @@ -2248,7 +2248,7 @@ static void ir_print_ptr_type(IrPrintSrc *irp, IrInstSrcPtrType *instruction) { |
| 2248 | 2248 | ir_print_other_inst_src(irp, instruction->child_type); |
| 2249 | 2249 | } |
| 2250 | 2250 | |
| 2251 | static void ir_print_ptr_type_simple(IrPrintSrc *irp, IrInstSrcPtrTypeSimple *instruction, | |
| 2251 | static void ir_print_ptr_type_simple(IrPrintSrc *irp, Stage1ZirInstPtrTypeSimple *instruction, | |
| 2252 | 2252 | bool is_const) |
| 2253 | 2253 | { |
| 2254 | 2254 | fprintf(irp->f, "&"); |
| ... | ... | @@ -2257,24 +2257,24 @@ static void ir_print_ptr_type_simple(IrPrintSrc *irp, IrInstSrcPtrTypeSimple *in |
| 2257 | 2257 | ir_print_other_inst_src(irp, instruction->child_type); |
| 2258 | 2258 | } |
| 2259 | 2259 | |
| 2260 | static void ir_print_decl_ref(IrPrintSrc *irp, IrInstSrcDeclRef *instruction) { | |
| 2260 | static void ir_print_decl_ref(IrPrintSrc *irp, Stage1ZirInstDeclRef *instruction) { | |
| 2261 | 2261 | const char *ptr_str = (instruction->lval != LValNone) ? "ptr " : ""; |
| 2262 | 2262 | fprintf(irp->f, "declref %s%s", ptr_str, buf_ptr(instruction->tld->name)); |
| 2263 | 2263 | } |
| 2264 | 2264 | |
| 2265 | static void ir_print_panic(IrPrintSrc *irp, IrInstSrcPanic *instruction) { | |
| 2265 | static void ir_print_panic(IrPrintSrc *irp, Stage1ZirInstPanic *instruction) { | |
| 2266 | 2266 | fprintf(irp->f, "@panic("); |
| 2267 | 2267 | ir_print_other_inst_src(irp, instruction->msg); |
| 2268 | 2268 | fprintf(irp->f, ")"); |
| 2269 | 2269 | } |
| 2270 | 2270 | |
| 2271 | static void ir_print_panic(IrPrintGen *irp, IrInstGenPanic *instruction) { | |
| 2271 | static void ir_print_panic(IrPrintGen *irp, Stage1AirInstPanic *instruction) { | |
| 2272 | 2272 | fprintf(irp->f, "@panic("); |
| 2273 | 2273 | ir_print_other_inst_gen(irp, instruction->msg); |
| 2274 | 2274 | fprintf(irp->f, ")"); |
| 2275 | 2275 | } |
| 2276 | 2276 | |
| 2277 | static void ir_print_field_parent_ptr(IrPrintSrc *irp, IrInstSrcFieldParentPtr *instruction) { | |
| 2277 | static void ir_print_field_parent_ptr(IrPrintSrc *irp, Stage1ZirInstFieldParentPtr *instruction) { | |
| 2278 | 2278 | fprintf(irp->f, "@fieldParentPtr("); |
| 2279 | 2279 | ir_print_other_inst_src(irp, instruction->type_value); |
| 2280 | 2280 | fprintf(irp->f, ","); |
| ... | ... | @@ -2284,13 +2284,13 @@ static void ir_print_field_parent_ptr(IrPrintSrc *irp, IrInstSrcFieldParentPtr * |
| 2284 | 2284 | fprintf(irp->f, ")"); |
| 2285 | 2285 | } |
| 2286 | 2286 | |
| 2287 | static void ir_print_field_parent_ptr(IrPrintGen *irp, IrInstGenFieldParentPtr *instruction) { | |
| 2287 | static void ir_print_field_parent_ptr(IrPrintGen *irp, Stage1AirInstFieldParentPtr *instruction) { | |
| 2288 | 2288 | fprintf(irp->f, "@fieldParentPtr(%s,", buf_ptr(instruction->field->name)); |
| 2289 | 2289 | ir_print_other_inst_gen(irp, instruction->field_ptr); |
| 2290 | 2290 | fprintf(irp->f, ")"); |
| 2291 | 2291 | } |
| 2292 | 2292 | |
| 2293 | static void ir_print_offset_of(IrPrintSrc *irp, IrInstSrcOffsetOf *instruction) { | |
| 2293 | static void ir_print_offset_of(IrPrintSrc *irp, Stage1ZirInstOffsetOf *instruction) { | |
| 2294 | 2294 | fprintf(irp->f, "@offset_of("); |
| 2295 | 2295 | ir_print_other_inst_src(irp, instruction->type_value); |
| 2296 | 2296 | fprintf(irp->f, ","); |
| ... | ... | @@ -2298,7 +2298,7 @@ static void ir_print_offset_of(IrPrintSrc *irp, IrInstSrcOffsetOf *instruction) |
| 2298 | 2298 | fprintf(irp->f, ")"); |
| 2299 | 2299 | } |
| 2300 | 2300 | |
| 2301 | static void ir_print_bit_offset_of(IrPrintSrc *irp, IrInstSrcBitOffsetOf *instruction) { | |
| 2301 | static void ir_print_bit_offset_of(IrPrintSrc *irp, Stage1ZirInstBitOffsetOf *instruction) { | |
| 2302 | 2302 | fprintf(irp->f, "@bit_offset_of("); |
| 2303 | 2303 | ir_print_other_inst_src(irp, instruction->type_value); |
| 2304 | 2304 | fprintf(irp->f, ","); |
| ... | ... | @@ -2306,19 +2306,19 @@ static void ir_print_bit_offset_of(IrPrintSrc *irp, IrInstSrcBitOffsetOf *instru |
| 2306 | 2306 | fprintf(irp->f, ")"); |
| 2307 | 2307 | } |
| 2308 | 2308 | |
| 2309 | static void ir_print_type_info(IrPrintSrc *irp, IrInstSrcTypeInfo *instruction) { | |
| 2309 | static void ir_print_type_info(IrPrintSrc *irp, Stage1ZirInstTypeInfo *instruction) { | |
| 2310 | 2310 | fprintf(irp->f, "@typeInfo("); |
| 2311 | 2311 | ir_print_other_inst_src(irp, instruction->type_value); |
| 2312 | 2312 | fprintf(irp->f, ")"); |
| 2313 | 2313 | } |
| 2314 | 2314 | |
| 2315 | static void ir_print_type(IrPrintSrc *irp, IrInstSrcType *instruction) { | |
| 2315 | static void ir_print_type(IrPrintSrc *irp, Stage1ZirInstType *instruction) { | |
| 2316 | 2316 | fprintf(irp->f, "@Type("); |
| 2317 | 2317 | ir_print_other_inst_src(irp, instruction->type_info); |
| 2318 | 2318 | fprintf(irp->f, ")"); |
| 2319 | 2319 | } |
| 2320 | 2320 | |
| 2321 | static void ir_print_has_field(IrPrintSrc *irp, IrInstSrcHasField *instruction) { | |
| 2321 | static void ir_print_has_field(IrPrintSrc *irp, Stage1ZirInstHasField *instruction) { | |
| 2322 | 2322 | fprintf(irp->f, "@hasField("); |
| 2323 | 2323 | ir_print_other_inst_src(irp, instruction->container_type); |
| 2324 | 2324 | fprintf(irp->f, ","); |
| ... | ... | @@ -2326,13 +2326,13 @@ static void ir_print_has_field(IrPrintSrc *irp, IrInstSrcHasField *instruction) |
| 2326 | 2326 | fprintf(irp->f, ")"); |
| 2327 | 2327 | } |
| 2328 | 2328 | |
| 2329 | static void ir_print_set_eval_branch_quota(IrPrintSrc *irp, IrInstSrcSetEvalBranchQuota *instruction) { | |
| 2329 | static void ir_print_set_eval_branch_quota(IrPrintSrc *irp, Stage1ZirInstSetEvalBranchQuota *instruction) { | |
| 2330 | 2330 | fprintf(irp->f, "@setEvalBranchQuota("); |
| 2331 | 2331 | ir_print_other_inst_src(irp, instruction->new_quota); |
| 2332 | 2332 | fprintf(irp->f, ")"); |
| 2333 | 2333 | } |
| 2334 | 2334 | |
| 2335 | static void ir_print_align_cast(IrPrintSrc *irp, IrInstSrcAlignCast *instruction) { | |
| 2335 | static void ir_print_align_cast(IrPrintSrc *irp, Stage1ZirInstAlignCast *instruction) { | |
| 2336 | 2336 | fprintf(irp->f, "@alignCast("); |
| 2337 | 2337 | ir_print_other_inst_src(irp, instruction->align_bytes); |
| 2338 | 2338 | fprintf(irp->f, ","); |
| ... | ... | @@ -2340,31 +2340,31 @@ static void ir_print_align_cast(IrPrintSrc *irp, IrInstSrcAlignCast *instruction |
| 2340 | 2340 | fprintf(irp->f, ")"); |
| 2341 | 2341 | } |
| 2342 | 2342 | |
| 2343 | static void ir_print_align_cast(IrPrintGen *irp, IrInstGenAlignCast *instruction) { | |
| 2343 | static void ir_print_align_cast(IrPrintGen *irp, Stage1AirInstAlignCast *instruction) { | |
| 2344 | 2344 | fprintf(irp->f, "@alignCast("); |
| 2345 | 2345 | ir_print_other_inst_gen(irp, instruction->target); |
| 2346 | 2346 | fprintf(irp->f, ")"); |
| 2347 | 2347 | } |
| 2348 | 2348 | |
| 2349 | static void ir_print_resolve_result(IrPrintSrc *irp, IrInstSrcResolveResult *instruction) { | |
| 2349 | static void ir_print_resolve_result(IrPrintSrc *irp, Stage1ZirInstResolveResult *instruction) { | |
| 2350 | 2350 | fprintf(irp->f, "ResolveResult("); |
| 2351 | 2351 | ir_print_result_loc(irp, instruction->result_loc); |
| 2352 | 2352 | fprintf(irp->f, ")"); |
| 2353 | 2353 | } |
| 2354 | 2354 | |
| 2355 | static void ir_print_reset_result(IrPrintSrc *irp, IrInstSrcResetResult *instruction) { | |
| 2355 | static void ir_print_reset_result(IrPrintSrc *irp, Stage1ZirInstResetResult *instruction) { | |
| 2356 | 2356 | fprintf(irp->f, "ResetResult("); |
| 2357 | 2357 | ir_print_result_loc(irp, instruction->result_loc); |
| 2358 | 2358 | fprintf(irp->f, ")"); |
| 2359 | 2359 | } |
| 2360 | 2360 | |
| 2361 | static void ir_print_set_align_stack(IrPrintSrc *irp, IrInstSrcSetAlignStack *instruction) { | |
| 2361 | static void ir_print_set_align_stack(IrPrintSrc *irp, Stage1ZirInstSetAlignStack *instruction) { | |
| 2362 | 2362 | fprintf(irp->f, "@setAlignStack("); |
| 2363 | 2363 | ir_print_other_inst_src(irp, instruction->align_bytes); |
| 2364 | 2364 | fprintf(irp->f, ")"); |
| 2365 | 2365 | } |
| 2366 | 2366 | |
| 2367 | static void ir_print_arg_type(IrPrintSrc *irp, IrInstSrcArgType *instruction, bool allow_var) { | |
| 2367 | static void ir_print_arg_type(IrPrintSrc *irp, Stage1ZirInstArgType *instruction, bool allow_var) { | |
| 2368 | 2368 | fprintf(irp->f, "@ArgType("); |
| 2369 | 2369 | ir_print_other_inst_src(irp, instruction->fn_type); |
| 2370 | 2370 | fprintf(irp->f, ","); |
| ... | ... | @@ -2378,7 +2378,7 @@ static void ir_print_arg_type(IrPrintSrc *irp, IrInstSrcArgType *instruction, bo |
| 2378 | 2378 | fprintf(irp->f, ")"); |
| 2379 | 2379 | } |
| 2380 | 2380 | |
| 2381 | static void ir_print_export(IrPrintSrc *irp, IrInstSrcExport *instruction) { | |
| 2381 | static void ir_print_export(IrPrintSrc *irp, Stage1ZirInstExport *instruction) { | |
| 2382 | 2382 | fprintf(irp->f, "@export("); |
| 2383 | 2383 | ir_print_other_inst_src(irp, instruction->target); |
| 2384 | 2384 | fprintf(irp->f, ","); |
| ... | ... | @@ -2386,11 +2386,11 @@ static void ir_print_export(IrPrintSrc *irp, IrInstSrcExport *instruction) { |
| 2386 | 2386 | fprintf(irp->f, ")"); |
| 2387 | 2387 | } |
| 2388 | 2388 | |
| 2389 | static void ir_print_extern(IrPrintGen *irp, IrInstGenExtern *instruction) { | |
| 2389 | static void ir_print_extern(IrPrintGen *irp, Stage1AirInstExtern *instruction) { | |
| 2390 | 2390 | fprintf(irp->f, "@extern(...)"); |
| 2391 | 2391 | } |
| 2392 | 2392 | |
| 2393 | static void ir_print_extern(IrPrintSrc *irp, IrInstSrcExtern *instruction) { | |
| 2393 | static void ir_print_extern(IrPrintSrc *irp, Stage1ZirInstExtern *instruction) { | |
| 2394 | 2394 | fprintf(irp->f, "@extern("); |
| 2395 | 2395 | ir_print_other_inst_src(irp, instruction->type); |
| 2396 | 2396 | fprintf(irp->f, ","); |
| ... | ... | @@ -2398,7 +2398,7 @@ static void ir_print_extern(IrPrintSrc *irp, IrInstSrcExtern *instruction) { |
| 2398 | 2398 | fprintf(irp->f, ")"); |
| 2399 | 2399 | } |
| 2400 | 2400 | |
| 2401 | static void ir_print_error_return_trace(IrPrintSrc *irp, IrInstSrcErrorReturnTrace *instruction) { | |
| 2401 | static void ir_print_error_return_trace(IrPrintSrc *irp, Stage1ZirInstErrorReturnTrace *instruction) { | |
| 2402 | 2402 | fprintf(irp->f, "@errorReturnTrace("); |
| 2403 | 2403 | switch (instruction->optional) { |
| 2404 | 2404 | case IrInstErrorReturnTraceNull: |
| ... | ... | @@ -2411,7 +2411,7 @@ static void ir_print_error_return_trace(IrPrintSrc *irp, IrInstSrcErrorReturnTra |
| 2411 | 2411 | fprintf(irp->f, ")"); |
| 2412 | 2412 | } |
| 2413 | 2413 | |
| 2414 | static void ir_print_error_return_trace(IrPrintGen *irp, IrInstGenErrorReturnTrace *instruction) { | |
| 2414 | static void ir_print_error_return_trace(IrPrintGen *irp, Stage1AirInstErrorReturnTrace *instruction) { | |
| 2415 | 2415 | fprintf(irp->f, "@errorReturnTrace("); |
| 2416 | 2416 | switch (instruction->optional) { |
| 2417 | 2417 | case IrInstErrorReturnTraceNull: |
| ... | ... | @@ -2424,13 +2424,13 @@ static void ir_print_error_return_trace(IrPrintGen *irp, IrInstGenErrorReturnTra |
| 2424 | 2424 | fprintf(irp->f, ")"); |
| 2425 | 2425 | } |
| 2426 | 2426 | |
| 2427 | static void ir_print_error_union(IrPrintSrc *irp, IrInstSrcErrorUnion *instruction) { | |
| 2427 | static void ir_print_error_union(IrPrintSrc *irp, Stage1ZirInstErrorUnion *instruction) { | |
| 2428 | 2428 | ir_print_other_inst_src(irp, instruction->err_set); |
| 2429 | 2429 | fprintf(irp->f, "!"); |
| 2430 | 2430 | ir_print_other_inst_src(irp, instruction->payload); |
| 2431 | 2431 | } |
| 2432 | 2432 | |
| 2433 | static void ir_print_atomic_rmw(IrPrintSrc *irp, IrInstSrcAtomicRmw *instruction) { | |
| 2433 | static void ir_print_atomic_rmw(IrPrintSrc *irp, Stage1ZirInstAtomicRmw *instruction) { | |
| 2434 | 2434 | fprintf(irp->f, "@atomicRmw("); |
| 2435 | 2435 | ir_print_other_inst_src(irp, instruction->operand_type); |
| 2436 | 2436 | fprintf(irp->f, ","); |
| ... | ... | @@ -2444,7 +2444,7 @@ static void ir_print_atomic_rmw(IrPrintSrc *irp, IrInstSrcAtomicRmw *instruction |
| 2444 | 2444 | fprintf(irp->f, ")"); |
| 2445 | 2445 | } |
| 2446 | 2446 | |
| 2447 | static void ir_print_atomic_rmw(IrPrintGen *irp, IrInstGenAtomicRmw *instruction) { | |
| 2447 | static void ir_print_atomic_rmw(IrPrintGen *irp, Stage1AirInstAtomicRmw *instruction) { | |
| 2448 | 2448 | fprintf(irp->f, "@atomicRmw("); |
| 2449 | 2449 | ir_print_other_inst_gen(irp, instruction->ptr); |
| 2450 | 2450 | fprintf(irp->f, ",[TODO print op],"); |
| ... | ... | @@ -2452,7 +2452,7 @@ static void ir_print_atomic_rmw(IrPrintGen *irp, IrInstGenAtomicRmw *instruction |
| 2452 | 2452 | fprintf(irp->f, ",%s)", atomic_order_str(instruction->ordering)); |
| 2453 | 2453 | } |
| 2454 | 2454 | |
| 2455 | static void ir_print_atomic_load(IrPrintSrc *irp, IrInstSrcAtomicLoad *instruction) { | |
| 2455 | static void ir_print_atomic_load(IrPrintSrc *irp, Stage1ZirInstAtomicLoad *instruction) { | |
| 2456 | 2456 | fprintf(irp->f, "@atomicLoad("); |
| 2457 | 2457 | ir_print_other_inst_src(irp, instruction->operand_type); |
| 2458 | 2458 | fprintf(irp->f, ","); |
| ... | ... | @@ -2462,13 +2462,13 @@ static void ir_print_atomic_load(IrPrintSrc *irp, IrInstSrcAtomicLoad *instructi |
| 2462 | 2462 | fprintf(irp->f, ")"); |
| 2463 | 2463 | } |
| 2464 | 2464 | |
| 2465 | static void ir_print_atomic_load(IrPrintGen *irp, IrInstGenAtomicLoad *instruction) { | |
| 2465 | static void ir_print_atomic_load(IrPrintGen *irp, Stage1AirInstAtomicLoad *instruction) { | |
| 2466 | 2466 | fprintf(irp->f, "@atomicLoad("); |
| 2467 | 2467 | ir_print_other_inst_gen(irp, instruction->ptr); |
| 2468 | 2468 | fprintf(irp->f, ",%s)", atomic_order_str(instruction->ordering)); |
| 2469 | 2469 | } |
| 2470 | 2470 | |
| 2471 | static void ir_print_atomic_store(IrPrintSrc *irp, IrInstSrcAtomicStore *instruction) { | |
| 2471 | static void ir_print_atomic_store(IrPrintSrc *irp, Stage1ZirInstAtomicStore *instruction) { | |
| 2472 | 2472 | fprintf(irp->f, "@atomicStore("); |
| 2473 | 2473 | ir_print_other_inst_src(irp, instruction->operand_type); |
| 2474 | 2474 | fprintf(irp->f, ","); |
| ... | ... | @@ -2480,7 +2480,7 @@ static void ir_print_atomic_store(IrPrintSrc *irp, IrInstSrcAtomicStore *instruc |
| 2480 | 2480 | fprintf(irp->f, ")"); |
| 2481 | 2481 | } |
| 2482 | 2482 | |
| 2483 | static void ir_print_atomic_store(IrPrintGen *irp, IrInstGenAtomicStore *instruction) { | |
| 2483 | static void ir_print_atomic_store(IrPrintGen *irp, Stage1AirInstAtomicStore *instruction) { | |
| 2484 | 2484 | fprintf(irp->f, "@atomicStore("); |
| 2485 | 2485 | ir_print_other_inst_gen(irp, instruction->ptr); |
| 2486 | 2486 | fprintf(irp->f, ","); |
| ... | ... | @@ -2489,33 +2489,33 @@ static void ir_print_atomic_store(IrPrintGen *irp, IrInstGenAtomicStore *instruc |
| 2489 | 2489 | } |
| 2490 | 2490 | |
| 2491 | 2491 | |
| 2492 | static void ir_print_save_err_ret_addr(IrPrintSrc *irp, IrInstSrcSaveErrRetAddr *instruction) { | |
| 2492 | static void ir_print_save_err_ret_addr(IrPrintSrc *irp, Stage1ZirInstSaveErrRetAddr *instruction) { | |
| 2493 | 2493 | fprintf(irp->f, "@saveErrRetAddr()"); |
| 2494 | 2494 | } |
| 2495 | 2495 | |
| 2496 | static void ir_print_save_err_ret_addr(IrPrintGen *irp, IrInstGenSaveErrRetAddr *instruction) { | |
| 2496 | static void ir_print_save_err_ret_addr(IrPrintGen *irp, Stage1AirInstSaveErrRetAddr *instruction) { | |
| 2497 | 2497 | fprintf(irp->f, "@saveErrRetAddr()"); |
| 2498 | 2498 | } |
| 2499 | 2499 | |
| 2500 | static void ir_print_add_implicit_return_type(IrPrintSrc *irp, IrInstSrcAddImplicitReturnType *instruction) { | |
| 2500 | static void ir_print_add_implicit_return_type(IrPrintSrc *irp, Stage1ZirInstAddImplicitReturnType *instruction) { | |
| 2501 | 2501 | fprintf(irp->f, "@addImplicitReturnType("); |
| 2502 | 2502 | ir_print_other_inst_src(irp, instruction->value); |
| 2503 | 2503 | fprintf(irp->f, ")"); |
| 2504 | 2504 | } |
| 2505 | 2505 | |
| 2506 | static void ir_print_float_op(IrPrintSrc *irp, IrInstSrcFloatOp *instruction) { | |
| 2506 | static void ir_print_float_op(IrPrintSrc *irp, Stage1ZirInstFloatOp *instruction) { | |
| 2507 | 2507 | fprintf(irp->f, "@%s(", float_op_to_name(instruction->fn_id)); |
| 2508 | 2508 | ir_print_other_inst_src(irp, instruction->operand); |
| 2509 | 2509 | fprintf(irp->f, ")"); |
| 2510 | 2510 | } |
| 2511 | 2511 | |
| 2512 | static void ir_print_float_op(IrPrintGen *irp, IrInstGenFloatOp *instruction) { | |
| 2512 | static void ir_print_float_op(IrPrintGen *irp, Stage1AirInstFloatOp *instruction) { | |
| 2513 | 2513 | fprintf(irp->f, "@%s(", float_op_to_name(instruction->fn_id)); |
| 2514 | 2514 | ir_print_other_inst_gen(irp, instruction->operand); |
| 2515 | 2515 | fprintf(irp->f, ")"); |
| 2516 | 2516 | } |
| 2517 | 2517 | |
| 2518 | static void ir_print_mul_add(IrPrintSrc *irp, IrInstSrcMulAdd *instruction) { | |
| 2518 | static void ir_print_mul_add(IrPrintSrc *irp, Stage1ZirInstMulAdd *instruction) { | |
| 2519 | 2519 | fprintf(irp->f, "@mulAdd("); |
| 2520 | 2520 | ir_print_other_inst_src(irp, instruction->type_value); |
| 2521 | 2521 | fprintf(irp->f, ","); |
| ... | ... | @@ -2527,7 +2527,7 @@ static void ir_print_mul_add(IrPrintSrc *irp, IrInstSrcMulAdd *instruction) { |
| 2527 | 2527 | fprintf(irp->f, ")"); |
| 2528 | 2528 | } |
| 2529 | 2529 | |
| 2530 | static void ir_print_mul_add(IrPrintGen *irp, IrInstGenMulAdd *instruction) { | |
| 2530 | static void ir_print_mul_add(IrPrintGen *irp, Stage1AirInstMulAdd *instruction) { | |
| 2531 | 2531 | fprintf(irp->f, "@mulAdd("); |
| 2532 | 2532 | ir_print_other_inst_gen(irp, instruction->op1); |
| 2533 | 2533 | fprintf(irp->f, ","); |
| ... | ... | @@ -2537,7 +2537,7 @@ static void ir_print_mul_add(IrPrintGen *irp, IrInstGenMulAdd *instruction) { |
| 2537 | 2537 | fprintf(irp->f, ")"); |
| 2538 | 2538 | } |
| 2539 | 2539 | |
| 2540 | static void ir_print_decl_var_gen(IrPrintGen *irp, IrInstGenDeclVar *decl_var_instruction) { | |
| 2540 | static void ir_print_decl_var_gen(IrPrintGen *irp, Stage1AirInstDeclVar *decl_var_instruction) { | |
| 2541 | 2541 | ZigVar *var = decl_var_instruction->var; |
| 2542 | 2542 | const char *var_or_const = decl_var_instruction->var->gen_is_const ? "const" : "var"; |
| 2543 | 2543 | const char *name = decl_var_instruction->var->name; |
| ... | ... | @@ -2547,7 +2547,7 @@ static void ir_print_decl_var_gen(IrPrintGen *irp, IrInstGenDeclVar *decl_var_in |
| 2547 | 2547 | ir_print_other_inst_gen(irp, decl_var_instruction->var_ptr); |
| 2548 | 2548 | } |
| 2549 | 2549 | |
| 2550 | static void ir_print_has_decl(IrPrintSrc *irp, IrInstSrcHasDecl *instruction) { | |
| 2550 | static void ir_print_has_decl(IrPrintSrc *irp, Stage1ZirInstHasDecl *instruction) { | |
| 2551 | 2551 | fprintf(irp->f, "@hasDecl("); |
| 2552 | 2552 | ir_print_other_inst_src(irp, instruction->container); |
| 2553 | 2553 | fprintf(irp->f, ","); |
| ... | ... | @@ -2555,11 +2555,11 @@ static void ir_print_has_decl(IrPrintSrc *irp, IrInstSrcHasDecl *instruction) { |
| 2555 | 2555 | fprintf(irp->f, ")"); |
| 2556 | 2556 | } |
| 2557 | 2557 | |
| 2558 | static void ir_print_undeclared_ident(IrPrintSrc *irp, IrInstSrcUndeclaredIdent *instruction) { | |
| 2558 | static void ir_print_undeclared_ident(IrPrintSrc *irp, Stage1ZirInstUndeclaredIdent *instruction) { | |
| 2559 | 2559 | fprintf(irp->f, "@undeclaredIdent(%s)", buf_ptr(instruction->name)); |
| 2560 | 2560 | } |
| 2561 | 2561 | |
| 2562 | static void ir_print_union_init_named_field(IrPrintSrc *irp, IrInstSrcUnionInitNamedField *instruction) { | |
| 2562 | static void ir_print_union_init_named_field(IrPrintSrc *irp, Stage1ZirInstUnionInitNamedField *instruction) { | |
| 2563 | 2563 | fprintf(irp->f, "@unionInit("); |
| 2564 | 2564 | ir_print_other_inst_src(irp, instruction->union_type); |
| 2565 | 2565 | fprintf(irp->f, ", "); |
| ... | ... | @@ -2571,33 +2571,33 @@ static void ir_print_union_init_named_field(IrPrintSrc *irp, IrInstSrcUnionInitN |
| 2571 | 2571 | fprintf(irp->f, ")"); |
| 2572 | 2572 | } |
| 2573 | 2573 | |
| 2574 | static void ir_print_suspend_begin(IrPrintSrc *irp, IrInstSrcSuspendBegin *instruction) { | |
| 2574 | static void ir_print_suspend_begin(IrPrintSrc *irp, Stage1ZirInstSuspendBegin *instruction) { | |
| 2575 | 2575 | fprintf(irp->f, "@suspendBegin()"); |
| 2576 | 2576 | } |
| 2577 | 2577 | |
| 2578 | static void ir_print_suspend_begin(IrPrintGen *irp, IrInstGenSuspendBegin *instruction) { | |
| 2578 | static void ir_print_suspend_begin(IrPrintGen *irp, Stage1AirInstSuspendBegin *instruction) { | |
| 2579 | 2579 | fprintf(irp->f, "@suspendBegin()"); |
| 2580 | 2580 | } |
| 2581 | 2581 | |
| 2582 | static void ir_print_suspend_finish(IrPrintSrc *irp, IrInstSrcSuspendFinish *instruction) { | |
| 2582 | static void ir_print_suspend_finish(IrPrintSrc *irp, Stage1ZirInstSuspendFinish *instruction) { | |
| 2583 | 2583 | fprintf(irp->f, "@suspendFinish()"); |
| 2584 | 2584 | } |
| 2585 | 2585 | |
| 2586 | static void ir_print_suspend_finish(IrPrintGen *irp, IrInstGenSuspendFinish *instruction) { | |
| 2586 | static void ir_print_suspend_finish(IrPrintGen *irp, Stage1AirInstSuspendFinish *instruction) { | |
| 2587 | 2587 | fprintf(irp->f, "@suspendFinish()"); |
| 2588 | 2588 | } |
| 2589 | 2589 | |
| 2590 | static void ir_print_resume(IrPrintSrc *irp, IrInstSrcResume *instruction) { | |
| 2590 | static void ir_print_resume(IrPrintSrc *irp, Stage1ZirInstResume *instruction) { | |
| 2591 | 2591 | fprintf(irp->f, "resume "); |
| 2592 | 2592 | ir_print_other_inst_src(irp, instruction->frame); |
| 2593 | 2593 | } |
| 2594 | 2594 | |
| 2595 | static void ir_print_resume(IrPrintGen *irp, IrInstGenResume *instruction) { | |
| 2595 | static void ir_print_resume(IrPrintGen *irp, Stage1AirInstResume *instruction) { | |
| 2596 | 2596 | fprintf(irp->f, "resume "); |
| 2597 | 2597 | ir_print_other_inst_gen(irp, instruction->frame); |
| 2598 | 2598 | } |
| 2599 | 2599 | |
| 2600 | static void ir_print_await_src(IrPrintSrc *irp, IrInstSrcAwait *instruction) { | |
| 2600 | static void ir_print_await_src(IrPrintSrc *irp, Stage1ZirInstAwait *instruction) { | |
| 2601 | 2601 | fprintf(irp->f, "@await("); |
| 2602 | 2602 | ir_print_other_inst_src(irp, instruction->frame); |
| 2603 | 2603 | fprintf(irp->f, ","); |
| ... | ... | @@ -2605,7 +2605,7 @@ static void ir_print_await_src(IrPrintSrc *irp, IrInstSrcAwait *instruction) { |
| 2605 | 2605 | fprintf(irp->f, ")"); |
| 2606 | 2606 | } |
| 2607 | 2607 | |
| 2608 | static void ir_print_await_gen(IrPrintGen *irp, IrInstGenAwait *instruction) { | |
| 2608 | static void ir_print_await_gen(IrPrintGen *irp, Stage1AirInstAwait *instruction) { | |
| 2609 | 2609 | fprintf(irp->f, "@await("); |
| 2610 | 2610 | ir_print_other_inst_gen(irp, instruction->frame); |
| 2611 | 2611 | fprintf(irp->f, ","); |
| ... | ... | @@ -2613,31 +2613,31 @@ static void ir_print_await_gen(IrPrintGen *irp, IrInstGenAwait *instruction) { |
| 2613 | 2613 | fprintf(irp->f, ")"); |
| 2614 | 2614 | } |
| 2615 | 2615 | |
| 2616 | static void ir_print_spill_begin(IrPrintSrc *irp, IrInstSrcSpillBegin *instruction) { | |
| 2616 | static void ir_print_spill_begin(IrPrintSrc *irp, Stage1ZirInstSpillBegin *instruction) { | |
| 2617 | 2617 | fprintf(irp->f, "@spillBegin("); |
| 2618 | 2618 | ir_print_other_inst_src(irp, instruction->operand); |
| 2619 | 2619 | fprintf(irp->f, ")"); |
| 2620 | 2620 | } |
| 2621 | 2621 | |
| 2622 | static void ir_print_spill_begin(IrPrintGen *irp, IrInstGenSpillBegin *instruction) { | |
| 2622 | static void ir_print_spill_begin(IrPrintGen *irp, Stage1AirInstSpillBegin *instruction) { | |
| 2623 | 2623 | fprintf(irp->f, "@spillBegin("); |
| 2624 | 2624 | ir_print_other_inst_gen(irp, instruction->operand); |
| 2625 | 2625 | fprintf(irp->f, ")"); |
| 2626 | 2626 | } |
| 2627 | 2627 | |
| 2628 | static void ir_print_spill_end(IrPrintSrc *irp, IrInstSrcSpillEnd *instruction) { | |
| 2628 | static void ir_print_spill_end(IrPrintSrc *irp, Stage1ZirInstSpillEnd *instruction) { | |
| 2629 | 2629 | fprintf(irp->f, "@spillEnd("); |
| 2630 | 2630 | ir_print_other_inst_src(irp, &instruction->begin->base); |
| 2631 | 2631 | fprintf(irp->f, ")"); |
| 2632 | 2632 | } |
| 2633 | 2633 | |
| 2634 | static void ir_print_spill_end(IrPrintGen *irp, IrInstGenSpillEnd *instruction) { | |
| 2634 | static void ir_print_spill_end(IrPrintGen *irp, Stage1AirInstSpillEnd *instruction) { | |
| 2635 | 2635 | fprintf(irp->f, "@spillEnd("); |
| 2636 | 2636 | ir_print_other_inst_gen(irp, &instruction->begin->base); |
| 2637 | 2637 | fprintf(irp->f, ")"); |
| 2638 | 2638 | } |
| 2639 | 2639 | |
| 2640 | static void ir_print_vector_extract_elem(IrPrintGen *irp, IrInstGenVectorExtractElem *instruction) { | |
| 2640 | static void ir_print_vector_extract_elem(IrPrintGen *irp, Stage1AirInstVectorExtractElem *instruction) { | |
| 2641 | 2641 | fprintf(irp->f, "@vectorExtractElem("); |
| 2642 | 2642 | ir_print_other_inst_gen(irp, instruction->vector); |
| 2643 | 2643 | fprintf(irp->f, ","); |
| ... | ... | @@ -2645,703 +2645,703 @@ static void ir_print_vector_extract_elem(IrPrintGen *irp, IrInstGenVectorExtract |
| 2645 | 2645 | fprintf(irp->f, ")"); |
| 2646 | 2646 | } |
| 2647 | 2647 | |
| 2648 | static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trailing) { | |
| 2648 | static void ir_print_inst_src(IrPrintSrc *irp, Stage1ZirInst *instruction, bool trailing) { | |
| 2649 | 2649 | ir_print_prefix_src(irp, instruction, trailing); |
| 2650 | 2650 | switch (instruction->id) { |
| 2651 | case IrInstSrcIdInvalid: | |
| 2651 | case Stage1ZirInstIdInvalid: | |
| 2652 | 2652 | zig_unreachable(); |
| 2653 | case IrInstSrcIdReturn: | |
| 2654 | ir_print_return_src(irp, (IrInstSrcReturn *)instruction); | |
| 2653 | case Stage1ZirInstIdReturn: | |
| 2654 | ir_print_return_src(irp, (Stage1ZirInstReturn *)instruction); | |
| 2655 | 2655 | break; |
| 2656 | case IrInstSrcIdConst: | |
| 2657 | ir_print_const(irp, (IrInstSrcConst *)instruction); | |
| 2656 | case Stage1ZirInstIdConst: | |
| 2657 | ir_print_const(irp, (Stage1ZirInstConst *)instruction); | |
| 2658 | 2658 | break; |
| 2659 | case IrInstSrcIdBinOp: | |
| 2660 | ir_print_bin_op(irp, (IrInstSrcBinOp *)instruction); | |
| 2659 | case Stage1ZirInstIdBinOp: | |
| 2660 | ir_print_bin_op(irp, (Stage1ZirInstBinOp *)instruction); | |
| 2661 | 2661 | break; |
| 2662 | case IrInstSrcIdMergeErrSets: | |
| 2663 | ir_print_merge_err_sets(irp, (IrInstSrcMergeErrSets *)instruction); | |
| 2662 | case Stage1ZirInstIdMergeErrSets: | |
| 2663 | ir_print_merge_err_sets(irp, (Stage1ZirInstMergeErrSets *)instruction); | |
| 2664 | 2664 | break; |
| 2665 | case IrInstSrcIdDeclVar: | |
| 2666 | ir_print_decl_var_src(irp, (IrInstSrcDeclVar *)instruction); | |
| 2665 | case Stage1ZirInstIdDeclVar: | |
| 2666 | ir_print_decl_var_src(irp, (Stage1ZirInstDeclVar *)instruction); | |
| 2667 | 2667 | break; |
| 2668 | case IrInstSrcIdCallExtra: | |
| 2669 | ir_print_call_extra(irp, (IrInstSrcCallExtra *)instruction); | |
| 2668 | case Stage1ZirInstIdCallExtra: | |
| 2669 | ir_print_call_extra(irp, (Stage1ZirInstCallExtra *)instruction); | |
| 2670 | 2670 | break; |
| 2671 | case IrInstSrcIdAsyncCallExtra: | |
| 2672 | ir_print_async_call_extra(irp, (IrInstSrcAsyncCallExtra *)instruction); | |
| 2671 | case Stage1ZirInstIdAsyncCallExtra: | |
| 2672 | ir_print_async_call_extra(irp, (Stage1ZirInstAsyncCallExtra *)instruction); | |
| 2673 | 2673 | break; |
| 2674 | case IrInstSrcIdCall: | |
| 2675 | ir_print_call_src(irp, (IrInstSrcCall *)instruction); | |
| 2674 | case Stage1ZirInstIdCall: | |
| 2675 | ir_print_call_src(irp, (Stage1ZirInstCall *)instruction); | |
| 2676 | 2676 | break; |
| 2677 | case IrInstSrcIdCallArgs: | |
| 2678 | ir_print_call_args(irp, (IrInstSrcCallArgs *)instruction); | |
| 2677 | case Stage1ZirInstIdCallArgs: | |
| 2678 | ir_print_call_args(irp, (Stage1ZirInstCallArgs *)instruction); | |
| 2679 | 2679 | break; |
| 2680 | case IrInstSrcIdUnOp: | |
| 2681 | ir_print_un_op(irp, (IrInstSrcUnOp *)instruction); | |
| 2680 | case Stage1ZirInstIdUnOp: | |
| 2681 | ir_print_un_op(irp, (Stage1ZirInstUnOp *)instruction); | |
| 2682 | 2682 | break; |
| 2683 | case IrInstSrcIdCondBr: | |
| 2684 | ir_print_cond_br(irp, (IrInstSrcCondBr *)instruction); | |
| 2683 | case Stage1ZirInstIdCondBr: | |
| 2684 | ir_print_cond_br(irp, (Stage1ZirInstCondBr *)instruction); | |
| 2685 | 2685 | break; |
| 2686 | case IrInstSrcIdBr: | |
| 2687 | ir_print_br(irp, (IrInstSrcBr *)instruction); | |
| 2686 | case Stage1ZirInstIdBr: | |
| 2687 | ir_print_br(irp, (Stage1ZirInstBr *)instruction); | |
| 2688 | 2688 | break; |
| 2689 | case IrInstSrcIdPhi: | |
| 2690 | ir_print_phi(irp, (IrInstSrcPhi *)instruction); | |
| 2689 | case Stage1ZirInstIdPhi: | |
| 2690 | ir_print_phi(irp, (Stage1ZirInstPhi *)instruction); | |
| 2691 | 2691 | break; |
| 2692 | case IrInstSrcIdContainerInitList: | |
| 2693 | ir_print_container_init_list(irp, (IrInstSrcContainerInitList *)instruction); | |
| 2692 | case Stage1ZirInstIdContainerInitList: | |
| 2693 | ir_print_container_init_list(irp, (Stage1ZirInstContainerInitList *)instruction); | |
| 2694 | 2694 | break; |
| 2695 | case IrInstSrcIdContainerInitFields: | |
| 2696 | ir_print_container_init_fields(irp, (IrInstSrcContainerInitFields *)instruction); | |
| 2695 | case Stage1ZirInstIdContainerInitFields: | |
| 2696 | ir_print_container_init_fields(irp, (Stage1ZirInstContainerInitFields *)instruction); | |
| 2697 | 2697 | break; |
| 2698 | case IrInstSrcIdUnreachable: | |
| 2699 | ir_print_unreachable(irp, (IrInstSrcUnreachable *)instruction); | |
| 2698 | case Stage1ZirInstIdUnreachable: | |
| 2699 | ir_print_unreachable(irp, (Stage1ZirInstUnreachable *)instruction); | |
| 2700 | 2700 | break; |
| 2701 | case IrInstSrcIdElemPtr: | |
| 2702 | ir_print_elem_ptr(irp, (IrInstSrcElemPtr *)instruction); | |
| 2701 | case Stage1ZirInstIdElemPtr: | |
| 2702 | ir_print_elem_ptr(irp, (Stage1ZirInstElemPtr *)instruction); | |
| 2703 | 2703 | break; |
| 2704 | case IrInstSrcIdVarPtr: | |
| 2705 | ir_print_var_ptr(irp, (IrInstSrcVarPtr *)instruction); | |
| 2704 | case Stage1ZirInstIdVarPtr: | |
| 2705 | ir_print_var_ptr(irp, (Stage1ZirInstVarPtr *)instruction); | |
| 2706 | 2706 | break; |
| 2707 | case IrInstSrcIdLoadPtr: | |
| 2708 | ir_print_load_ptr(irp, (IrInstSrcLoadPtr *)instruction); | |
| 2707 | case Stage1ZirInstIdLoadPtr: | |
| 2708 | ir_print_load_ptr(irp, (Stage1ZirInstLoadPtr *)instruction); | |
| 2709 | 2709 | break; |
| 2710 | case IrInstSrcIdStorePtr: | |
| 2711 | ir_print_store_ptr(irp, (IrInstSrcStorePtr *)instruction); | |
| 2710 | case Stage1ZirInstIdStorePtr: | |
| 2711 | ir_print_store_ptr(irp, (Stage1ZirInstStorePtr *)instruction); | |
| 2712 | 2712 | break; |
| 2713 | case IrInstSrcIdTypeOf: | |
| 2714 | ir_print_typeof(irp, (IrInstSrcTypeOf *)instruction); | |
| 2713 | case Stage1ZirInstIdTypeOf: | |
| 2714 | ir_print_typeof(irp, (Stage1ZirInstTypeOf *)instruction); | |
| 2715 | 2715 | break; |
| 2716 | case IrInstSrcIdFieldPtr: | |
| 2717 | ir_print_field_ptr(irp, (IrInstSrcFieldPtr *)instruction); | |
| 2716 | case Stage1ZirInstIdFieldPtr: | |
| 2717 | ir_print_field_ptr(irp, (Stage1ZirInstFieldPtr *)instruction); | |
| 2718 | 2718 | break; |
| 2719 | case IrInstSrcIdSetCold: | |
| 2720 | ir_print_set_cold(irp, (IrInstSrcSetCold *)instruction); | |
| 2719 | case Stage1ZirInstIdSetCold: | |
| 2720 | ir_print_set_cold(irp, (Stage1ZirInstSetCold *)instruction); | |
| 2721 | 2721 | break; |
| 2722 | case IrInstSrcIdSetRuntimeSafety: | |
| 2723 | ir_print_set_runtime_safety(irp, (IrInstSrcSetRuntimeSafety *)instruction); | |
| 2722 | case Stage1ZirInstIdSetRuntimeSafety: | |
| 2723 | ir_print_set_runtime_safety(irp, (Stage1ZirInstSetRuntimeSafety *)instruction); | |
| 2724 | 2724 | break; |
| 2725 | case IrInstSrcIdSetFloatMode: | |
| 2726 | ir_print_set_float_mode(irp, (IrInstSrcSetFloatMode *)instruction); | |
| 2725 | case Stage1ZirInstIdSetFloatMode: | |
| 2726 | ir_print_set_float_mode(irp, (Stage1ZirInstSetFloatMode *)instruction); | |
| 2727 | 2727 | break; |
| 2728 | case IrInstSrcIdArrayType: | |
| 2729 | ir_print_array_type(irp, (IrInstSrcArrayType *)instruction); | |
| 2728 | case Stage1ZirInstIdArrayType: | |
| 2729 | ir_print_array_type(irp, (Stage1ZirInstArrayType *)instruction); | |
| 2730 | 2730 | break; |
| 2731 | case IrInstSrcIdSliceType: | |
| 2732 | ir_print_slice_type(irp, (IrInstSrcSliceType *)instruction); | |
| 2731 | case Stage1ZirInstIdSliceType: | |
| 2732 | ir_print_slice_type(irp, (Stage1ZirInstSliceType *)instruction); | |
| 2733 | 2733 | break; |
| 2734 | case IrInstSrcIdAnyFrameType: | |
| 2735 | ir_print_any_frame_type(irp, (IrInstSrcAnyFrameType *)instruction); | |
| 2734 | case Stage1ZirInstIdAnyFrameType: | |
| 2735 | ir_print_any_frame_type(irp, (Stage1ZirInstAnyFrameType *)instruction); | |
| 2736 | 2736 | break; |
| 2737 | case IrInstSrcIdAsm: | |
| 2738 | ir_print_asm_src(irp, (IrInstSrcAsm *)instruction); | |
| 2737 | case Stage1ZirInstIdAsm: | |
| 2738 | ir_print_asm_src(irp, (Stage1ZirInstAsm *)instruction); | |
| 2739 | 2739 | break; |
| 2740 | case IrInstSrcIdSizeOf: | |
| 2741 | ir_print_size_of(irp, (IrInstSrcSizeOf *)instruction); | |
| 2740 | case Stage1ZirInstIdSizeOf: | |
| 2741 | ir_print_size_of(irp, (Stage1ZirInstSizeOf *)instruction); | |
| 2742 | 2742 | break; |
| 2743 | case IrInstSrcIdTestNonNull: | |
| 2744 | ir_print_test_non_null(irp, (IrInstSrcTestNonNull *)instruction); | |
| 2743 | case Stage1ZirInstIdTestNonNull: | |
| 2744 | ir_print_test_non_null(irp, (Stage1ZirInstTestNonNull *)instruction); | |
| 2745 | 2745 | break; |
| 2746 | case IrInstSrcIdOptionalUnwrapPtr: | |
| 2747 | ir_print_optional_unwrap_ptr(irp, (IrInstSrcOptionalUnwrapPtr *)instruction); | |
| 2746 | case Stage1ZirInstIdOptionalUnwrapPtr: | |
| 2747 | ir_print_optional_unwrap_ptr(irp, (Stage1ZirInstOptionalUnwrapPtr *)instruction); | |
| 2748 | 2748 | break; |
| 2749 | case IrInstSrcIdPopCount: | |
| 2750 | ir_print_pop_count(irp, (IrInstSrcPopCount *)instruction); | |
| 2749 | case Stage1ZirInstIdPopCount: | |
| 2750 | ir_print_pop_count(irp, (Stage1ZirInstPopCount *)instruction); | |
| 2751 | 2751 | break; |
| 2752 | case IrInstSrcIdCtz: | |
| 2753 | ir_print_ctz(irp, (IrInstSrcCtz *)instruction); | |
| 2752 | case Stage1ZirInstIdCtz: | |
| 2753 | ir_print_ctz(irp, (Stage1ZirInstCtz *)instruction); | |
| 2754 | 2754 | break; |
| 2755 | case IrInstSrcIdBswap: | |
| 2756 | ir_print_bswap(irp, (IrInstSrcBswap *)instruction); | |
| 2755 | case Stage1ZirInstIdBswap: | |
| 2756 | ir_print_bswap(irp, (Stage1ZirInstBswap *)instruction); | |
| 2757 | 2757 | break; |
| 2758 | case IrInstSrcIdBitReverse: | |
| 2759 | ir_print_bit_reverse(irp, (IrInstSrcBitReverse *)instruction); | |
| 2758 | case Stage1ZirInstIdBitReverse: | |
| 2759 | ir_print_bit_reverse(irp, (Stage1ZirInstBitReverse *)instruction); | |
| 2760 | 2760 | break; |
| 2761 | case IrInstSrcIdSwitchBr: | |
| 2762 | ir_print_switch_br(irp, (IrInstSrcSwitchBr *)instruction); | |
| 2761 | case Stage1ZirInstIdSwitchBr: | |
| 2762 | ir_print_switch_br(irp, (Stage1ZirInstSwitchBr *)instruction); | |
| 2763 | 2763 | break; |
| 2764 | case IrInstSrcIdSwitchVar: | |
| 2765 | ir_print_switch_var(irp, (IrInstSrcSwitchVar *)instruction); | |
| 2764 | case Stage1ZirInstIdSwitchVar: | |
| 2765 | ir_print_switch_var(irp, (Stage1ZirInstSwitchVar *)instruction); | |
| 2766 | 2766 | break; |
| 2767 | case IrInstSrcIdSwitchElseVar: | |
| 2768 | ir_print_switch_else_var(irp, (IrInstSrcSwitchElseVar *)instruction); | |
| 2767 | case Stage1ZirInstIdSwitchElseVar: | |
| 2768 | ir_print_switch_else_var(irp, (Stage1ZirInstSwitchElseVar *)instruction); | |
| 2769 | 2769 | break; |
| 2770 | case IrInstSrcIdSwitchTarget: | |
| 2771 | ir_print_switch_target(irp, (IrInstSrcSwitchTarget *)instruction); | |
| 2770 | case Stage1ZirInstIdSwitchTarget: | |
| 2771 | ir_print_switch_target(irp, (Stage1ZirInstSwitchTarget *)instruction); | |
| 2772 | 2772 | break; |
| 2773 | case IrInstSrcIdImport: | |
| 2774 | ir_print_import(irp, (IrInstSrcImport *)instruction); | |
| 2773 | case Stage1ZirInstIdImport: | |
| 2774 | ir_print_import(irp, (Stage1ZirInstImport *)instruction); | |
| 2775 | 2775 | break; |
| 2776 | case IrInstSrcIdRef: | |
| 2777 | ir_print_ref(irp, (IrInstSrcRef *)instruction); | |
| 2776 | case Stage1ZirInstIdRef: | |
| 2777 | ir_print_ref(irp, (Stage1ZirInstRef *)instruction); | |
| 2778 | 2778 | break; |
| 2779 | case IrInstSrcIdCompileErr: | |
| 2780 | ir_print_compile_err(irp, (IrInstSrcCompileErr *)instruction); | |
| 2779 | case Stage1ZirInstIdCompileErr: | |
| 2780 | ir_print_compile_err(irp, (Stage1ZirInstCompileErr *)instruction); | |
| 2781 | 2781 | break; |
| 2782 | case IrInstSrcIdCompileLog: | |
| 2783 | ir_print_compile_log(irp, (IrInstSrcCompileLog *)instruction); | |
| 2782 | case Stage1ZirInstIdCompileLog: | |
| 2783 | ir_print_compile_log(irp, (Stage1ZirInstCompileLog *)instruction); | |
| 2784 | 2784 | break; |
| 2785 | case IrInstSrcIdErrName: | |
| 2786 | ir_print_err_name(irp, (IrInstSrcErrName *)instruction); | |
| 2785 | case Stage1ZirInstIdErrName: | |
| 2786 | ir_print_err_name(irp, (Stage1ZirInstErrName *)instruction); | |
| 2787 | 2787 | break; |
| 2788 | case IrInstSrcIdCImport: | |
| 2789 | ir_print_c_import(irp, (IrInstSrcCImport *)instruction); | |
| 2788 | case Stage1ZirInstIdCImport: | |
| 2789 | ir_print_c_import(irp, (Stage1ZirInstCImport *)instruction); | |
| 2790 | 2790 | break; |
| 2791 | case IrInstSrcIdCInclude: | |
| 2792 | ir_print_c_include(irp, (IrInstSrcCInclude *)instruction); | |
| 2791 | case Stage1ZirInstIdCInclude: | |
| 2792 | ir_print_c_include(irp, (Stage1ZirInstCInclude *)instruction); | |
| 2793 | 2793 | break; |
| 2794 | case IrInstSrcIdCDefine: | |
| 2795 | ir_print_c_define(irp, (IrInstSrcCDefine *)instruction); | |
| 2794 | case Stage1ZirInstIdCDefine: | |
| 2795 | ir_print_c_define(irp, (Stage1ZirInstCDefine *)instruction); | |
| 2796 | 2796 | break; |
| 2797 | case IrInstSrcIdCUndef: | |
| 2798 | ir_print_c_undef(irp, (IrInstSrcCUndef *)instruction); | |
| 2797 | case Stage1ZirInstIdCUndef: | |
| 2798 | ir_print_c_undef(irp, (Stage1ZirInstCUndef *)instruction); | |
| 2799 | 2799 | break; |
| 2800 | case IrInstSrcIdEmbedFile: | |
| 2801 | ir_print_embed_file(irp, (IrInstSrcEmbedFile *)instruction); | |
| 2800 | case Stage1ZirInstIdEmbedFile: | |
| 2801 | ir_print_embed_file(irp, (Stage1ZirInstEmbedFile *)instruction); | |
| 2802 | 2802 | break; |
| 2803 | case IrInstSrcIdCmpxchg: | |
| 2804 | ir_print_cmpxchg_src(irp, (IrInstSrcCmpxchg *)instruction); | |
| 2803 | case Stage1ZirInstIdCmpxchg: | |
| 2804 | ir_print_cmpxchg_src(irp, (Stage1ZirInstCmpxchg *)instruction); | |
| 2805 | 2805 | break; |
| 2806 | case IrInstSrcIdFence: | |
| 2807 | ir_print_fence(irp, (IrInstSrcFence *)instruction); | |
| 2806 | case Stage1ZirInstIdFence: | |
| 2807 | ir_print_fence(irp, (Stage1ZirInstFence *)instruction); | |
| 2808 | 2808 | break; |
| 2809 | case IrInstSrcIdReduce: | |
| 2810 | ir_print_reduce(irp, (IrInstSrcReduce *)instruction); | |
| 2809 | case Stage1ZirInstIdReduce: | |
| 2810 | ir_print_reduce(irp, (Stage1ZirInstReduce *)instruction); | |
| 2811 | 2811 | break; |
| 2812 | case IrInstSrcIdTruncate: | |
| 2813 | ir_print_truncate(irp, (IrInstSrcTruncate *)instruction); | |
| 2812 | case Stage1ZirInstIdTruncate: | |
| 2813 | ir_print_truncate(irp, (Stage1ZirInstTruncate *)instruction); | |
| 2814 | 2814 | break; |
| 2815 | case IrInstSrcIdIntCast: | |
| 2816 | ir_print_int_cast(irp, (IrInstSrcIntCast *)instruction); | |
| 2815 | case Stage1ZirInstIdIntCast: | |
| 2816 | ir_print_int_cast(irp, (Stage1ZirInstIntCast *)instruction); | |
| 2817 | 2817 | break; |
| 2818 | case IrInstSrcIdFloatCast: | |
| 2819 | ir_print_float_cast(irp, (IrInstSrcFloatCast *)instruction); | |
| 2818 | case Stage1ZirInstIdFloatCast: | |
| 2819 | ir_print_float_cast(irp, (Stage1ZirInstFloatCast *)instruction); | |
| 2820 | 2820 | break; |
| 2821 | case IrInstSrcIdErrSetCast: | |
| 2822 | ir_print_err_set_cast(irp, (IrInstSrcErrSetCast *)instruction); | |
| 2821 | case Stage1ZirInstIdErrSetCast: | |
| 2822 | ir_print_err_set_cast(irp, (Stage1ZirInstErrSetCast *)instruction); | |
| 2823 | 2823 | break; |
| 2824 | case IrInstSrcIdIntToFloat: | |
| 2825 | ir_print_int_to_float(irp, (IrInstSrcIntToFloat *)instruction); | |
| 2824 | case Stage1ZirInstIdIntToFloat: | |
| 2825 | ir_print_int_to_float(irp, (Stage1ZirInstIntToFloat *)instruction); | |
| 2826 | 2826 | break; |
| 2827 | case IrInstSrcIdFloatToInt: | |
| 2828 | ir_print_float_to_int(irp, (IrInstSrcFloatToInt *)instruction); | |
| 2827 | case Stage1ZirInstIdFloatToInt: | |
| 2828 | ir_print_float_to_int(irp, (Stage1ZirInstFloatToInt *)instruction); | |
| 2829 | 2829 | break; |
| 2830 | case IrInstSrcIdBoolToInt: | |
| 2831 | ir_print_bool_to_int(irp, (IrInstSrcBoolToInt *)instruction); | |
| 2830 | case Stage1ZirInstIdBoolToInt: | |
| 2831 | ir_print_bool_to_int(irp, (Stage1ZirInstBoolToInt *)instruction); | |
| 2832 | 2832 | break; |
| 2833 | case IrInstSrcIdVectorType: | |
| 2834 | ir_print_vector_type(irp, (IrInstSrcVectorType *)instruction); | |
| 2833 | case Stage1ZirInstIdVectorType: | |
| 2834 | ir_print_vector_type(irp, (Stage1ZirInstVectorType *)instruction); | |
| 2835 | 2835 | break; |
| 2836 | case IrInstSrcIdShuffleVector: | |
| 2837 | ir_print_shuffle_vector(irp, (IrInstSrcShuffleVector *)instruction); | |
| 2836 | case Stage1ZirInstIdShuffleVector: | |
| 2837 | ir_print_shuffle_vector(irp, (Stage1ZirInstShuffleVector *)instruction); | |
| 2838 | 2838 | break; |
| 2839 | case IrInstSrcIdSplat: | |
| 2840 | ir_print_splat_src(irp, (IrInstSrcSplat *)instruction); | |
| 2839 | case Stage1ZirInstIdSplat: | |
| 2840 | ir_print_splat_src(irp, (Stage1ZirInstSplat *)instruction); | |
| 2841 | 2841 | break; |
| 2842 | case IrInstSrcIdBoolNot: | |
| 2843 | ir_print_bool_not(irp, (IrInstSrcBoolNot *)instruction); | |
| 2842 | case Stage1ZirInstIdBoolNot: | |
| 2843 | ir_print_bool_not(irp, (Stage1ZirInstBoolNot *)instruction); | |
| 2844 | 2844 | break; |
| 2845 | case IrInstSrcIdMemset: | |
| 2846 | ir_print_memset(irp, (IrInstSrcMemset *)instruction); | |
| 2845 | case Stage1ZirInstIdMemset: | |
| 2846 | ir_print_memset(irp, (Stage1ZirInstMemset *)instruction); | |
| 2847 | 2847 | break; |
| 2848 | case IrInstSrcIdMemcpy: | |
| 2849 | ir_print_memcpy(irp, (IrInstSrcMemcpy *)instruction); | |
| 2848 | case Stage1ZirInstIdMemcpy: | |
| 2849 | ir_print_memcpy(irp, (Stage1ZirInstMemcpy *)instruction); | |
| 2850 | 2850 | break; |
| 2851 | case IrInstSrcIdSlice: | |
| 2852 | ir_print_slice_src(irp, (IrInstSrcSlice *)instruction); | |
| 2851 | case Stage1ZirInstIdSlice: | |
| 2852 | ir_print_slice_src(irp, (Stage1ZirInstSlice *)instruction); | |
| 2853 | 2853 | break; |
| 2854 | case IrInstSrcIdBreakpoint: | |
| 2855 | ir_print_breakpoint(irp, (IrInstSrcBreakpoint *)instruction); | |
| 2854 | case Stage1ZirInstIdBreakpoint: | |
| 2855 | ir_print_breakpoint(irp, (Stage1ZirInstBreakpoint *)instruction); | |
| 2856 | 2856 | break; |
| 2857 | case IrInstSrcIdReturnAddress: | |
| 2858 | ir_print_return_address(irp, (IrInstSrcReturnAddress *)instruction); | |
| 2857 | case Stage1ZirInstIdReturnAddress: | |
| 2858 | ir_print_return_address(irp, (Stage1ZirInstReturnAddress *)instruction); | |
| 2859 | 2859 | break; |
| 2860 | case IrInstSrcIdFrameAddress: | |
| 2861 | ir_print_frame_address(irp, (IrInstSrcFrameAddress *)instruction); | |
| 2860 | case Stage1ZirInstIdFrameAddress: | |
| 2861 | ir_print_frame_address(irp, (Stage1ZirInstFrameAddress *)instruction); | |
| 2862 | 2862 | break; |
| 2863 | case IrInstSrcIdFrameHandle: | |
| 2864 | ir_print_handle(irp, (IrInstSrcFrameHandle *)instruction); | |
| 2863 | case Stage1ZirInstIdFrameHandle: | |
| 2864 | ir_print_handle(irp, (Stage1ZirInstFrameHandle *)instruction); | |
| 2865 | 2865 | break; |
| 2866 | case IrInstSrcIdFrameType: | |
| 2867 | ir_print_frame_type(irp, (IrInstSrcFrameType *)instruction); | |
| 2866 | case Stage1ZirInstIdFrameType: | |
| 2867 | ir_print_frame_type(irp, (Stage1ZirInstFrameType *)instruction); | |
| 2868 | 2868 | break; |
| 2869 | case IrInstSrcIdFrameSize: | |
| 2870 | ir_print_frame_size_src(irp, (IrInstSrcFrameSize *)instruction); | |
| 2869 | case Stage1ZirInstIdFrameSize: | |
| 2870 | ir_print_frame_size_src(irp, (Stage1ZirInstFrameSize *)instruction); | |
| 2871 | 2871 | break; |
| 2872 | case IrInstSrcIdAlignOf: | |
| 2873 | ir_print_align_of(irp, (IrInstSrcAlignOf *)instruction); | |
| 2872 | case Stage1ZirInstIdAlignOf: | |
| 2873 | ir_print_align_of(irp, (Stage1ZirInstAlignOf *)instruction); | |
| 2874 | 2874 | break; |
| 2875 | case IrInstSrcIdOverflowOp: | |
| 2876 | ir_print_overflow_op(irp, (IrInstSrcOverflowOp *)instruction); | |
| 2875 | case Stage1ZirInstIdOverflowOp: | |
| 2876 | ir_print_overflow_op(irp, (Stage1ZirInstOverflowOp *)instruction); | |
| 2877 | 2877 | break; |
| 2878 | case IrInstSrcIdTestErr: | |
| 2879 | ir_print_test_err_src(irp, (IrInstSrcTestErr *)instruction); | |
| 2878 | case Stage1ZirInstIdTestErr: | |
| 2879 | ir_print_test_err_src(irp, (Stage1ZirInstTestErr *)instruction); | |
| 2880 | 2880 | break; |
| 2881 | case IrInstSrcIdUnwrapErrCode: | |
| 2882 | ir_print_unwrap_err_code(irp, (IrInstSrcUnwrapErrCode *)instruction); | |
| 2881 | case Stage1ZirInstIdUnwrapErrCode: | |
| 2882 | ir_print_unwrap_err_code(irp, (Stage1ZirInstUnwrapErrCode *)instruction); | |
| 2883 | 2883 | break; |
| 2884 | case IrInstSrcIdUnwrapErrPayload: | |
| 2885 | ir_print_unwrap_err_payload(irp, (IrInstSrcUnwrapErrPayload *)instruction); | |
| 2884 | case Stage1ZirInstIdUnwrapErrPayload: | |
| 2885 | ir_print_unwrap_err_payload(irp, (Stage1ZirInstUnwrapErrPayload *)instruction); | |
| 2886 | 2886 | break; |
| 2887 | case IrInstSrcIdFnProto: | |
| 2888 | ir_print_fn_proto(irp, (IrInstSrcFnProto *)instruction); | |
| 2887 | case Stage1ZirInstIdFnProto: | |
| 2888 | ir_print_fn_proto(irp, (Stage1ZirInstFnProto *)instruction); | |
| 2889 | 2889 | break; |
| 2890 | case IrInstSrcIdTestComptime: | |
| 2891 | ir_print_test_comptime(irp, (IrInstSrcTestComptime *)instruction); | |
| 2890 | case Stage1ZirInstIdTestComptime: | |
| 2891 | ir_print_test_comptime(irp, (Stage1ZirInstTestComptime *)instruction); | |
| 2892 | 2892 | break; |
| 2893 | case IrInstSrcIdPtrCast: | |
| 2894 | ir_print_ptr_cast_src(irp, (IrInstSrcPtrCast *)instruction); | |
| 2893 | case Stage1ZirInstIdPtrCast: | |
| 2894 | ir_print_ptr_cast_src(irp, (Stage1ZirInstPtrCast *)instruction); | |
| 2895 | 2895 | break; |
| 2896 | case IrInstSrcIdBitCast: | |
| 2897 | ir_print_bit_cast_src(irp, (IrInstSrcBitCast *)instruction); | |
| 2896 | case Stage1ZirInstIdBitCast: | |
| 2897 | ir_print_bit_cast_src(irp, (Stage1ZirInstBitCast *)instruction); | |
| 2898 | 2898 | break; |
| 2899 | case IrInstSrcIdPtrToInt: | |
| 2900 | ir_print_ptr_to_int(irp, (IrInstSrcPtrToInt *)instruction); | |
| 2899 | case Stage1ZirInstIdPtrToInt: | |
| 2900 | ir_print_ptr_to_int(irp, (Stage1ZirInstPtrToInt *)instruction); | |
| 2901 | 2901 | break; |
| 2902 | case IrInstSrcIdIntToPtr: | |
| 2903 | ir_print_int_to_ptr(irp, (IrInstSrcIntToPtr *)instruction); | |
| 2902 | case Stage1ZirInstIdIntToPtr: | |
| 2903 | ir_print_int_to_ptr(irp, (Stage1ZirInstIntToPtr *)instruction); | |
| 2904 | 2904 | break; |
| 2905 | case IrInstSrcIdIntToEnum: | |
| 2906 | ir_print_int_to_enum(irp, (IrInstSrcIntToEnum *)instruction); | |
| 2905 | case Stage1ZirInstIdIntToEnum: | |
| 2906 | ir_print_int_to_enum(irp, (Stage1ZirInstIntToEnum *)instruction); | |
| 2907 | 2907 | break; |
| 2908 | case IrInstSrcIdIntToErr: | |
| 2909 | ir_print_int_to_err(irp, (IrInstSrcIntToErr *)instruction); | |
| 2908 | case Stage1ZirInstIdIntToErr: | |
| 2909 | ir_print_int_to_err(irp, (Stage1ZirInstIntToErr *)instruction); | |
| 2910 | 2910 | break; |
| 2911 | case IrInstSrcIdErrToInt: | |
| 2912 | ir_print_err_to_int(irp, (IrInstSrcErrToInt *)instruction); | |
| 2911 | case Stage1ZirInstIdErrToInt: | |
| 2912 | ir_print_err_to_int(irp, (Stage1ZirInstErrToInt *)instruction); | |
| 2913 | 2913 | break; |
| 2914 | case IrInstSrcIdCheckSwitchProngsUnderNo: | |
| 2915 | ir_print_check_switch_prongs(irp, (IrInstSrcCheckSwitchProngs *)instruction, false); | |
| 2914 | case Stage1ZirInstIdCheckSwitchProngsUnderNo: | |
| 2915 | ir_print_check_switch_prongs(irp, (Stage1ZirInstCheckSwitchProngs *)instruction, false); | |
| 2916 | 2916 | break; |
| 2917 | case IrInstSrcIdCheckSwitchProngsUnderYes: | |
| 2918 | ir_print_check_switch_prongs(irp, (IrInstSrcCheckSwitchProngs *)instruction, true); | |
| 2917 | case Stage1ZirInstIdCheckSwitchProngsUnderYes: | |
| 2918 | ir_print_check_switch_prongs(irp, (Stage1ZirInstCheckSwitchProngs *)instruction, true); | |
| 2919 | 2919 | break; |
| 2920 | case IrInstSrcIdCheckStatementIsVoid: | |
| 2921 | ir_print_check_statement_is_void(irp, (IrInstSrcCheckStatementIsVoid *)instruction); | |
| 2920 | case Stage1ZirInstIdCheckStatementIsVoid: | |
| 2921 | ir_print_check_statement_is_void(irp, (Stage1ZirInstCheckStatementIsVoid *)instruction); | |
| 2922 | 2922 | break; |
| 2923 | case IrInstSrcIdTypeName: | |
| 2924 | ir_print_type_name(irp, (IrInstSrcTypeName *)instruction); | |
| 2923 | case Stage1ZirInstIdTypeName: | |
| 2924 | ir_print_type_name(irp, (Stage1ZirInstTypeName *)instruction); | |
| 2925 | 2925 | break; |
| 2926 | case IrInstSrcIdTagName: | |
| 2927 | ir_print_tag_name(irp, (IrInstSrcTagName *)instruction); | |
| 2926 | case Stage1ZirInstIdTagName: | |
| 2927 | ir_print_tag_name(irp, (Stage1ZirInstTagName *)instruction); | |
| 2928 | 2928 | break; |
| 2929 | case IrInstSrcIdPtrType: | |
| 2930 | ir_print_ptr_type(irp, (IrInstSrcPtrType *)instruction); | |
| 2929 | case Stage1ZirInstIdPtrType: | |
| 2930 | ir_print_ptr_type(irp, (Stage1ZirInstPtrType *)instruction); | |
| 2931 | 2931 | break; |
| 2932 | case IrInstSrcIdPtrTypeSimple: | |
| 2933 | ir_print_ptr_type_simple(irp, (IrInstSrcPtrTypeSimple *)instruction, false); | |
| 2932 | case Stage1ZirInstIdPtrTypeSimple: | |
| 2933 | ir_print_ptr_type_simple(irp, (Stage1ZirInstPtrTypeSimple *)instruction, false); | |
| 2934 | 2934 | break; |
| 2935 | case IrInstSrcIdPtrTypeSimpleConst: | |
| 2936 | ir_print_ptr_type_simple(irp, (IrInstSrcPtrTypeSimple *)instruction, true); | |
| 2935 | case Stage1ZirInstIdPtrTypeSimpleConst: | |
| 2936 | ir_print_ptr_type_simple(irp, (Stage1ZirInstPtrTypeSimple *)instruction, true); | |
| 2937 | 2937 | break; |
| 2938 | case IrInstSrcIdDeclRef: | |
| 2939 | ir_print_decl_ref(irp, (IrInstSrcDeclRef *)instruction); | |
| 2938 | case Stage1ZirInstIdDeclRef: | |
| 2939 | ir_print_decl_ref(irp, (Stage1ZirInstDeclRef *)instruction); | |
| 2940 | 2940 | break; |
| 2941 | case IrInstSrcIdPanic: | |
| 2942 | ir_print_panic(irp, (IrInstSrcPanic *)instruction); | |
| 2941 | case Stage1ZirInstIdPanic: | |
| 2942 | ir_print_panic(irp, (Stage1ZirInstPanic *)instruction); | |
| 2943 | 2943 | break; |
| 2944 | case IrInstSrcIdFieldParentPtr: | |
| 2945 | ir_print_field_parent_ptr(irp, (IrInstSrcFieldParentPtr *)instruction); | |
| 2944 | case Stage1ZirInstIdFieldParentPtr: | |
| 2945 | ir_print_field_parent_ptr(irp, (Stage1ZirInstFieldParentPtr *)instruction); | |
| 2946 | 2946 | break; |
| 2947 | case IrInstSrcIdOffsetOf: | |
| 2948 | ir_print_offset_of(irp, (IrInstSrcOffsetOf *)instruction); | |
| 2947 | case Stage1ZirInstIdOffsetOf: | |
| 2948 | ir_print_offset_of(irp, (Stage1ZirInstOffsetOf *)instruction); | |
| 2949 | 2949 | break; |
| 2950 | case IrInstSrcIdBitOffsetOf: | |
| 2951 | ir_print_bit_offset_of(irp, (IrInstSrcBitOffsetOf *)instruction); | |
| 2950 | case Stage1ZirInstIdBitOffsetOf: | |
| 2951 | ir_print_bit_offset_of(irp, (Stage1ZirInstBitOffsetOf *)instruction); | |
| 2952 | 2952 | break; |
| 2953 | case IrInstSrcIdTypeInfo: | |
| 2954 | ir_print_type_info(irp, (IrInstSrcTypeInfo *)instruction); | |
| 2953 | case Stage1ZirInstIdTypeInfo: | |
| 2954 | ir_print_type_info(irp, (Stage1ZirInstTypeInfo *)instruction); | |
| 2955 | 2955 | break; |
| 2956 | case IrInstSrcIdType: | |
| 2957 | ir_print_type(irp, (IrInstSrcType *)instruction); | |
| 2956 | case Stage1ZirInstIdType: | |
| 2957 | ir_print_type(irp, (Stage1ZirInstType *)instruction); | |
| 2958 | 2958 | break; |
| 2959 | case IrInstSrcIdHasField: | |
| 2960 | ir_print_has_field(irp, (IrInstSrcHasField *)instruction); | |
| 2959 | case Stage1ZirInstIdHasField: | |
| 2960 | ir_print_has_field(irp, (Stage1ZirInstHasField *)instruction); | |
| 2961 | 2961 | break; |
| 2962 | case IrInstSrcIdSetEvalBranchQuota: | |
| 2963 | ir_print_set_eval_branch_quota(irp, (IrInstSrcSetEvalBranchQuota *)instruction); | |
| 2962 | case Stage1ZirInstIdSetEvalBranchQuota: | |
| 2963 | ir_print_set_eval_branch_quota(irp, (Stage1ZirInstSetEvalBranchQuota *)instruction); | |
| 2964 | 2964 | break; |
| 2965 | case IrInstSrcIdAlignCast: | |
| 2966 | ir_print_align_cast(irp, (IrInstSrcAlignCast *)instruction); | |
| 2965 | case Stage1ZirInstIdAlignCast: | |
| 2966 | ir_print_align_cast(irp, (Stage1ZirInstAlignCast *)instruction); | |
| 2967 | 2967 | break; |
| 2968 | case IrInstSrcIdImplicitCast: | |
| 2969 | ir_print_implicit_cast(irp, (IrInstSrcImplicitCast *)instruction); | |
| 2968 | case Stage1ZirInstIdImplicitCast: | |
| 2969 | ir_print_implicit_cast(irp, (Stage1ZirInstImplicitCast *)instruction); | |
| 2970 | 2970 | break; |
| 2971 | case IrInstSrcIdResolveResult: | |
| 2972 | ir_print_resolve_result(irp, (IrInstSrcResolveResult *)instruction); | |
| 2971 | case Stage1ZirInstIdResolveResult: | |
| 2972 | ir_print_resolve_result(irp, (Stage1ZirInstResolveResult *)instruction); | |
| 2973 | 2973 | break; |
| 2974 | case IrInstSrcIdResetResult: | |
| 2975 | ir_print_reset_result(irp, (IrInstSrcResetResult *)instruction); | |
| 2974 | case Stage1ZirInstIdResetResult: | |
| 2975 | ir_print_reset_result(irp, (Stage1ZirInstResetResult *)instruction); | |
| 2976 | 2976 | break; |
| 2977 | case IrInstSrcIdSetAlignStack: | |
| 2978 | ir_print_set_align_stack(irp, (IrInstSrcSetAlignStack *)instruction); | |
| 2977 | case Stage1ZirInstIdSetAlignStack: | |
| 2978 | ir_print_set_align_stack(irp, (Stage1ZirInstSetAlignStack *)instruction); | |
| 2979 | 2979 | break; |
| 2980 | case IrInstSrcIdArgTypeAllowVarFalse: | |
| 2981 | ir_print_arg_type(irp, (IrInstSrcArgType *)instruction, false); | |
| 2980 | case Stage1ZirInstIdArgTypeAllowVarFalse: | |
| 2981 | ir_print_arg_type(irp, (Stage1ZirInstArgType *)instruction, false); | |
| 2982 | 2982 | break; |
| 2983 | case IrInstSrcIdArgTypeAllowVarTrue: | |
| 2984 | ir_print_arg_type(irp, (IrInstSrcArgType *)instruction, true); | |
| 2983 | case Stage1ZirInstIdArgTypeAllowVarTrue: | |
| 2984 | ir_print_arg_type(irp, (Stage1ZirInstArgType *)instruction, true); | |
| 2985 | 2985 | break; |
| 2986 | case IrInstSrcIdExport: | |
| 2987 | ir_print_export(irp, (IrInstSrcExport *)instruction); | |
| 2986 | case Stage1ZirInstIdExport: | |
| 2987 | ir_print_export(irp, (Stage1ZirInstExport *)instruction); | |
| 2988 | 2988 | break; |
| 2989 | case IrInstSrcIdExtern: | |
| 2990 | ir_print_extern(irp, (IrInstSrcExtern*)instruction); | |
| 2989 | case Stage1ZirInstIdExtern: | |
| 2990 | ir_print_extern(irp, (Stage1ZirInstExtern*)instruction); | |
| 2991 | 2991 | break; |
| 2992 | case IrInstSrcIdErrorReturnTrace: | |
| 2993 | ir_print_error_return_trace(irp, (IrInstSrcErrorReturnTrace *)instruction); | |
| 2992 | case Stage1ZirInstIdErrorReturnTrace: | |
| 2993 | ir_print_error_return_trace(irp, (Stage1ZirInstErrorReturnTrace *)instruction); | |
| 2994 | 2994 | break; |
| 2995 | case IrInstSrcIdErrorUnion: | |
| 2996 | ir_print_error_union(irp, (IrInstSrcErrorUnion *)instruction); | |
| 2995 | case Stage1ZirInstIdErrorUnion: | |
| 2996 | ir_print_error_union(irp, (Stage1ZirInstErrorUnion *)instruction); | |
| 2997 | 2997 | break; |
| 2998 | case IrInstSrcIdAtomicRmw: | |
| 2999 | ir_print_atomic_rmw(irp, (IrInstSrcAtomicRmw *)instruction); | |
| 2998 | case Stage1ZirInstIdAtomicRmw: | |
| 2999 | ir_print_atomic_rmw(irp, (Stage1ZirInstAtomicRmw *)instruction); | |
| 3000 | 3000 | break; |
| 3001 | case IrInstSrcIdSaveErrRetAddr: | |
| 3002 | ir_print_save_err_ret_addr(irp, (IrInstSrcSaveErrRetAddr *)instruction); | |
| 3001 | case Stage1ZirInstIdSaveErrRetAddr: | |
| 3002 | ir_print_save_err_ret_addr(irp, (Stage1ZirInstSaveErrRetAddr *)instruction); | |
| 3003 | 3003 | break; |
| 3004 | case IrInstSrcIdAddImplicitReturnType: | |
| 3005 | ir_print_add_implicit_return_type(irp, (IrInstSrcAddImplicitReturnType *)instruction); | |
| 3004 | case Stage1ZirInstIdAddImplicitReturnType: | |
| 3005 | ir_print_add_implicit_return_type(irp, (Stage1ZirInstAddImplicitReturnType *)instruction); | |
| 3006 | 3006 | break; |
| 3007 | case IrInstSrcIdFloatOp: | |
| 3008 | ir_print_float_op(irp, (IrInstSrcFloatOp *)instruction); | |
| 3007 | case Stage1ZirInstIdFloatOp: | |
| 3008 | ir_print_float_op(irp, (Stage1ZirInstFloatOp *)instruction); | |
| 3009 | 3009 | break; |
| 3010 | case IrInstSrcIdMulAdd: | |
| 3011 | ir_print_mul_add(irp, (IrInstSrcMulAdd *)instruction); | |
| 3010 | case Stage1ZirInstIdMulAdd: | |
| 3011 | ir_print_mul_add(irp, (Stage1ZirInstMulAdd *)instruction); | |
| 3012 | 3012 | break; |
| 3013 | case IrInstSrcIdAtomicLoad: | |
| 3014 | ir_print_atomic_load(irp, (IrInstSrcAtomicLoad *)instruction); | |
| 3013 | case Stage1ZirInstIdAtomicLoad: | |
| 3014 | ir_print_atomic_load(irp, (Stage1ZirInstAtomicLoad *)instruction); | |
| 3015 | 3015 | break; |
| 3016 | case IrInstSrcIdAtomicStore: | |
| 3017 | ir_print_atomic_store(irp, (IrInstSrcAtomicStore *)instruction); | |
| 3016 | case Stage1ZirInstIdAtomicStore: | |
| 3017 | ir_print_atomic_store(irp, (Stage1ZirInstAtomicStore *)instruction); | |
| 3018 | 3018 | break; |
| 3019 | case IrInstSrcIdEnumToInt: | |
| 3020 | ir_print_enum_to_int(irp, (IrInstSrcEnumToInt *)instruction); | |
| 3019 | case Stage1ZirInstIdEnumToInt: | |
| 3020 | ir_print_enum_to_int(irp, (Stage1ZirInstEnumToInt *)instruction); | |
| 3021 | 3021 | break; |
| 3022 | case IrInstSrcIdCheckRuntimeScope: | |
| 3023 | ir_print_check_runtime_scope(irp, (IrInstSrcCheckRuntimeScope *)instruction); | |
| 3022 | case Stage1ZirInstIdCheckRuntimeScope: | |
| 3023 | ir_print_check_runtime_scope(irp, (Stage1ZirInstCheckRuntimeScope *)instruction); | |
| 3024 | 3024 | break; |
| 3025 | case IrInstSrcIdHasDecl: | |
| 3026 | ir_print_has_decl(irp, (IrInstSrcHasDecl *)instruction); | |
| 3025 | case Stage1ZirInstIdHasDecl: | |
| 3026 | ir_print_has_decl(irp, (Stage1ZirInstHasDecl *)instruction); | |
| 3027 | 3027 | break; |
| 3028 | case IrInstSrcIdUndeclaredIdent: | |
| 3029 | ir_print_undeclared_ident(irp, (IrInstSrcUndeclaredIdent *)instruction); | |
| 3028 | case Stage1ZirInstIdUndeclaredIdent: | |
| 3029 | ir_print_undeclared_ident(irp, (Stage1ZirInstUndeclaredIdent *)instruction); | |
| 3030 | 3030 | break; |
| 3031 | case IrInstSrcIdAlloca: | |
| 3032 | ir_print_alloca_src(irp, (IrInstSrcAlloca *)instruction); | |
| 3031 | case Stage1ZirInstIdAlloca: | |
| 3032 | ir_print_alloca_src(irp, (Stage1ZirInstAlloca *)instruction); | |
| 3033 | 3033 | break; |
| 3034 | case IrInstSrcIdEndExpr: | |
| 3035 | ir_print_end_expr(irp, (IrInstSrcEndExpr *)instruction); | |
| 3034 | case Stage1ZirInstIdEndExpr: | |
| 3035 | ir_print_end_expr(irp, (Stage1ZirInstEndExpr *)instruction); | |
| 3036 | 3036 | break; |
| 3037 | case IrInstSrcIdUnionInitNamedField: | |
| 3038 | ir_print_union_init_named_field(irp, (IrInstSrcUnionInitNamedField *)instruction); | |
| 3037 | case Stage1ZirInstIdUnionInitNamedField: | |
| 3038 | ir_print_union_init_named_field(irp, (Stage1ZirInstUnionInitNamedField *)instruction); | |
| 3039 | 3039 | break; |
| 3040 | case IrInstSrcIdSuspendBegin: | |
| 3041 | ir_print_suspend_begin(irp, (IrInstSrcSuspendBegin *)instruction); | |
| 3040 | case Stage1ZirInstIdSuspendBegin: | |
| 3041 | ir_print_suspend_begin(irp, (Stage1ZirInstSuspendBegin *)instruction); | |
| 3042 | 3042 | break; |
| 3043 | case IrInstSrcIdSuspendFinish: | |
| 3044 | ir_print_suspend_finish(irp, (IrInstSrcSuspendFinish *)instruction); | |
| 3043 | case Stage1ZirInstIdSuspendFinish: | |
| 3044 | ir_print_suspend_finish(irp, (Stage1ZirInstSuspendFinish *)instruction); | |
| 3045 | 3045 | break; |
| 3046 | case IrInstSrcIdResume: | |
| 3047 | ir_print_resume(irp, (IrInstSrcResume *)instruction); | |
| 3046 | case Stage1ZirInstIdResume: | |
| 3047 | ir_print_resume(irp, (Stage1ZirInstResume *)instruction); | |
| 3048 | 3048 | break; |
| 3049 | case IrInstSrcIdAwait: | |
| 3050 | ir_print_await_src(irp, (IrInstSrcAwait *)instruction); | |
| 3049 | case Stage1ZirInstIdAwait: | |
| 3050 | ir_print_await_src(irp, (Stage1ZirInstAwait *)instruction); | |
| 3051 | 3051 | break; |
| 3052 | case IrInstSrcIdSpillBegin: | |
| 3053 | ir_print_spill_begin(irp, (IrInstSrcSpillBegin *)instruction); | |
| 3052 | case Stage1ZirInstIdSpillBegin: | |
| 3053 | ir_print_spill_begin(irp, (Stage1ZirInstSpillBegin *)instruction); | |
| 3054 | 3054 | break; |
| 3055 | case IrInstSrcIdSpillEnd: | |
| 3056 | ir_print_spill_end(irp, (IrInstSrcSpillEnd *)instruction); | |
| 3055 | case Stage1ZirInstIdSpillEnd: | |
| 3056 | ir_print_spill_end(irp, (Stage1ZirInstSpillEnd *)instruction); | |
| 3057 | 3057 | break; |
| 3058 | case IrInstSrcIdClz: | |
| 3059 | ir_print_clz(irp, (IrInstSrcClz *)instruction); | |
| 3058 | case Stage1ZirInstIdClz: | |
| 3059 | ir_print_clz(irp, (Stage1ZirInstClz *)instruction); | |
| 3060 | 3060 | break; |
| 3061 | case IrInstSrcIdWasmMemorySize: | |
| 3062 | ir_print_wasm_memory_size(irp, (IrInstSrcWasmMemorySize *)instruction); | |
| 3061 | case Stage1ZirInstIdWasmMemorySize: | |
| 3062 | ir_print_wasm_memory_size(irp, (Stage1ZirInstWasmMemorySize *)instruction); | |
| 3063 | 3063 | break; |
| 3064 | case IrInstSrcIdWasmMemoryGrow: | |
| 3065 | ir_print_wasm_memory_grow(irp, (IrInstSrcWasmMemoryGrow *)instruction); | |
| 3064 | case Stage1ZirInstIdWasmMemoryGrow: | |
| 3065 | ir_print_wasm_memory_grow(irp, (Stage1ZirInstWasmMemoryGrow *)instruction); | |
| 3066 | 3066 | break; |
| 3067 | case IrInstSrcIdSrc: | |
| 3068 | ir_print_builtin_src(irp, (IrInstSrcSrc *)instruction); | |
| 3067 | case Stage1ZirInstIdSrc: | |
| 3068 | ir_print_builtin_src(irp, (Stage1ZirInstSrc *)instruction); | |
| 3069 | 3069 | break; |
| 3070 | 3070 | } |
| 3071 | 3071 | fprintf(irp->f, "\n"); |
| 3072 | 3072 | } |
| 3073 | 3073 | |
| 3074 | static void ir_print_inst_gen(IrPrintGen *irp, IrInstGen *instruction, bool trailing) { | |
| 3074 | static void ir_print_inst_gen(IrPrintGen *irp, Stage1AirInst *instruction, bool trailing) { | |
| 3075 | 3075 | ir_print_prefix_gen(irp, instruction, trailing); |
| 3076 | 3076 | switch (instruction->id) { |
| 3077 | case IrInstGenIdInvalid: | |
| 3077 | case Stage1AirInstIdInvalid: | |
| 3078 | 3078 | zig_unreachable(); |
| 3079 | case IrInstGenIdReturn: | |
| 3080 | ir_print_return_gen(irp, (IrInstGenReturn *)instruction); | |
| 3079 | case Stage1AirInstIdReturn: | |
| 3080 | ir_print_return_gen(irp, (Stage1AirInstReturn *)instruction); | |
| 3081 | 3081 | break; |
| 3082 | case IrInstGenIdConst: | |
| 3083 | ir_print_const(irp, (IrInstGenConst *)instruction); | |
| 3082 | case Stage1AirInstIdConst: | |
| 3083 | ir_print_const(irp, (Stage1AirInstConst *)instruction); | |
| 3084 | 3084 | break; |
| 3085 | case IrInstGenIdBinOp: | |
| 3086 | ir_print_bin_op(irp, (IrInstGenBinOp *)instruction); | |
| 3085 | case Stage1AirInstIdBinOp: | |
| 3086 | ir_print_bin_op(irp, (Stage1AirInstBinOp *)instruction); | |
| 3087 | 3087 | break; |
| 3088 | case IrInstGenIdDeclVar: | |
| 3089 | ir_print_decl_var_gen(irp, (IrInstGenDeclVar *)instruction); | |
| 3088 | case Stage1AirInstIdDeclVar: | |
| 3089 | ir_print_decl_var_gen(irp, (Stage1AirInstDeclVar *)instruction); | |
| 3090 | 3090 | break; |
| 3091 | case IrInstGenIdCast: | |
| 3092 | ir_print_cast(irp, (IrInstGenCast *)instruction); | |
| 3091 | case Stage1AirInstIdCast: | |
| 3092 | ir_print_cast(irp, (Stage1AirInstCast *)instruction); | |
| 3093 | 3093 | break; |
| 3094 | case IrInstGenIdCall: | |
| 3095 | ir_print_call_gen(irp, (IrInstGenCall *)instruction); | |
| 3094 | case Stage1AirInstIdCall: | |
| 3095 | ir_print_call_gen(irp, (Stage1AirInstCall *)instruction); | |
| 3096 | 3096 | break; |
| 3097 | case IrInstGenIdCondBr: | |
| 3098 | ir_print_cond_br(irp, (IrInstGenCondBr *)instruction); | |
| 3097 | case Stage1AirInstIdCondBr: | |
| 3098 | ir_print_cond_br(irp, (Stage1AirInstCondBr *)instruction); | |
| 3099 | 3099 | break; |
| 3100 | case IrInstGenIdBr: | |
| 3101 | ir_print_br(irp, (IrInstGenBr *)instruction); | |
| 3100 | case Stage1AirInstIdBr: | |
| 3101 | ir_print_br(irp, (Stage1AirInstBr *)instruction); | |
| 3102 | 3102 | break; |
| 3103 | case IrInstGenIdPhi: | |
| 3104 | ir_print_phi(irp, (IrInstGenPhi *)instruction); | |
| 3103 | case Stage1AirInstIdPhi: | |
| 3104 | ir_print_phi(irp, (Stage1AirInstPhi *)instruction); | |
| 3105 | 3105 | break; |
| 3106 | case IrInstGenIdUnreachable: | |
| 3107 | ir_print_unreachable(irp, (IrInstGenUnreachable *)instruction); | |
| 3106 | case Stage1AirInstIdUnreachable: | |
| 3107 | ir_print_unreachable(irp, (Stage1AirInstUnreachable *)instruction); | |
| 3108 | 3108 | break; |
| 3109 | case IrInstGenIdElemPtr: | |
| 3110 | ir_print_elem_ptr(irp, (IrInstGenElemPtr *)instruction); | |
| 3109 | case Stage1AirInstIdElemPtr: | |
| 3110 | ir_print_elem_ptr(irp, (Stage1AirInstElemPtr *)instruction); | |
| 3111 | 3111 | break; |
| 3112 | case IrInstGenIdVarPtr: | |
| 3113 | ir_print_var_ptr(irp, (IrInstGenVarPtr *)instruction); | |
| 3112 | case Stage1AirInstIdVarPtr: | |
| 3113 | ir_print_var_ptr(irp, (Stage1AirInstVarPtr *)instruction); | |
| 3114 | 3114 | break; |
| 3115 | case IrInstGenIdReturnPtr: | |
| 3116 | ir_print_return_ptr(irp, (IrInstGenReturnPtr *)instruction); | |
| 3115 | case Stage1AirInstIdReturnPtr: | |
| 3116 | ir_print_return_ptr(irp, (Stage1AirInstReturnPtr *)instruction); | |
| 3117 | 3117 | break; |
| 3118 | case IrInstGenIdLoadPtr: | |
| 3119 | ir_print_load_ptr_gen(irp, (IrInstGenLoadPtr *)instruction); | |
| 3118 | case Stage1AirInstIdLoadPtr: | |
| 3119 | ir_print_load_ptr_gen(irp, (Stage1AirInstLoadPtr *)instruction); | |
| 3120 | 3120 | break; |
| 3121 | case IrInstGenIdStorePtr: | |
| 3122 | ir_print_store_ptr(irp, (IrInstGenStorePtr *)instruction); | |
| 3121 | case Stage1AirInstIdStorePtr: | |
| 3122 | ir_print_store_ptr(irp, (Stage1AirInstStorePtr *)instruction); | |
| 3123 | 3123 | break; |
| 3124 | case IrInstGenIdStructFieldPtr: | |
| 3125 | ir_print_struct_field_ptr(irp, (IrInstGenStructFieldPtr *)instruction); | |
| 3124 | case Stage1AirInstIdStructFieldPtr: | |
| 3125 | ir_print_struct_field_ptr(irp, (Stage1AirInstStructFieldPtr *)instruction); | |
| 3126 | 3126 | break; |
| 3127 | case IrInstGenIdUnionFieldPtr: | |
| 3128 | ir_print_union_field_ptr(irp, (IrInstGenUnionFieldPtr *)instruction); | |
| 3127 | case Stage1AirInstIdUnionFieldPtr: | |
| 3128 | ir_print_union_field_ptr(irp, (Stage1AirInstUnionFieldPtr *)instruction); | |
| 3129 | 3129 | break; |
| 3130 | case IrInstGenIdAsm: | |
| 3131 | ir_print_asm_gen(irp, (IrInstGenAsm *)instruction); | |
| 3130 | case Stage1AirInstIdAsm: | |
| 3131 | ir_print_asm_gen(irp, (Stage1AirInstAsm *)instruction); | |
| 3132 | 3132 | break; |
| 3133 | case IrInstGenIdTestNonNull: | |
| 3134 | ir_print_test_non_null(irp, (IrInstGenTestNonNull *)instruction); | |
| 3133 | case Stage1AirInstIdTestNonNull: | |
| 3134 | ir_print_test_non_null(irp, (Stage1AirInstTestNonNull *)instruction); | |
| 3135 | 3135 | break; |
| 3136 | case IrInstGenIdOptionalUnwrapPtr: | |
| 3137 | ir_print_optional_unwrap_ptr(irp, (IrInstGenOptionalUnwrapPtr *)instruction); | |
| 3136 | case Stage1AirInstIdOptionalUnwrapPtr: | |
| 3137 | ir_print_optional_unwrap_ptr(irp, (Stage1AirInstOptionalUnwrapPtr *)instruction); | |
| 3138 | 3138 | break; |
| 3139 | case IrInstGenIdPopCount: | |
| 3140 | ir_print_pop_count(irp, (IrInstGenPopCount *)instruction); | |
| 3139 | case Stage1AirInstIdPopCount: | |
| 3140 | ir_print_pop_count(irp, (Stage1AirInstPopCount *)instruction); | |
| 3141 | 3141 | break; |
| 3142 | case IrInstGenIdClz: | |
| 3143 | ir_print_clz(irp, (IrInstGenClz *)instruction); | |
| 3142 | case Stage1AirInstIdClz: | |
| 3143 | ir_print_clz(irp, (Stage1AirInstClz *)instruction); | |
| 3144 | 3144 | break; |
| 3145 | case IrInstGenIdCtz: | |
| 3146 | ir_print_ctz(irp, (IrInstGenCtz *)instruction); | |
| 3145 | case Stage1AirInstIdCtz: | |
| 3146 | ir_print_ctz(irp, (Stage1AirInstCtz *)instruction); | |
| 3147 | 3147 | break; |
| 3148 | case IrInstGenIdBswap: | |
| 3149 | ir_print_bswap(irp, (IrInstGenBswap *)instruction); | |
| 3148 | case Stage1AirInstIdBswap: | |
| 3149 | ir_print_bswap(irp, (Stage1AirInstBswap *)instruction); | |
| 3150 | 3150 | break; |
| 3151 | case IrInstGenIdBitReverse: | |
| 3152 | ir_print_bit_reverse(irp, (IrInstGenBitReverse *)instruction); | |
| 3151 | case Stage1AirInstIdBitReverse: | |
| 3152 | ir_print_bit_reverse(irp, (Stage1AirInstBitReverse *)instruction); | |
| 3153 | 3153 | break; |
| 3154 | case IrInstGenIdSwitchBr: | |
| 3155 | ir_print_switch_br(irp, (IrInstGenSwitchBr *)instruction); | |
| 3154 | case Stage1AirInstIdSwitchBr: | |
| 3155 | ir_print_switch_br(irp, (Stage1AirInstSwitchBr *)instruction); | |
| 3156 | 3156 | break; |
| 3157 | case IrInstGenIdUnionTag: | |
| 3158 | ir_print_union_tag(irp, (IrInstGenUnionTag *)instruction); | |
| 3157 | case Stage1AirInstIdUnionTag: | |
| 3158 | ir_print_union_tag(irp, (Stage1AirInstUnionTag *)instruction); | |
| 3159 | 3159 | break; |
| 3160 | case IrInstGenIdRef: | |
| 3161 | ir_print_ref_gen(irp, (IrInstGenRef *)instruction); | |
| 3160 | case Stage1AirInstIdRef: | |
| 3161 | ir_print_ref_gen(irp, (Stage1AirInstRef *)instruction); | |
| 3162 | 3162 | break; |
| 3163 | case IrInstGenIdErrName: | |
| 3164 | ir_print_err_name(irp, (IrInstGenErrName *)instruction); | |
| 3163 | case Stage1AirInstIdErrName: | |
| 3164 | ir_print_err_name(irp, (Stage1AirInstErrName *)instruction); | |
| 3165 | 3165 | break; |
| 3166 | case IrInstGenIdCmpxchg: | |
| 3167 | ir_print_cmpxchg_gen(irp, (IrInstGenCmpxchg *)instruction); | |
| 3166 | case Stage1AirInstIdCmpxchg: | |
| 3167 | ir_print_cmpxchg_gen(irp, (Stage1AirInstCmpxchg *)instruction); | |
| 3168 | 3168 | break; |
| 3169 | case IrInstGenIdFence: | |
| 3170 | ir_print_fence(irp, (IrInstGenFence *)instruction); | |
| 3169 | case Stage1AirInstIdFence: | |
| 3170 | ir_print_fence(irp, (Stage1AirInstFence *)instruction); | |
| 3171 | 3171 | break; |
| 3172 | case IrInstGenIdReduce: | |
| 3173 | ir_print_reduce(irp, (IrInstGenReduce *)instruction); | |
| 3172 | case Stage1AirInstIdReduce: | |
| 3173 | ir_print_reduce(irp, (Stage1AirInstReduce *)instruction); | |
| 3174 | 3174 | break; |
| 3175 | case IrInstGenIdTruncate: | |
| 3176 | ir_print_truncate(irp, (IrInstGenTruncate *)instruction); | |
| 3175 | case Stage1AirInstIdTruncate: | |
| 3176 | ir_print_truncate(irp, (Stage1AirInstTruncate *)instruction); | |
| 3177 | 3177 | break; |
| 3178 | case IrInstGenIdShuffleVector: | |
| 3179 | ir_print_shuffle_vector(irp, (IrInstGenShuffleVector *)instruction); | |
| 3178 | case Stage1AirInstIdShuffleVector: | |
| 3179 | ir_print_shuffle_vector(irp, (Stage1AirInstShuffleVector *)instruction); | |
| 3180 | 3180 | break; |
| 3181 | case IrInstGenIdSplat: | |
| 3182 | ir_print_splat_gen(irp, (IrInstGenSplat *)instruction); | |
| 3181 | case Stage1AirInstIdSplat: | |
| 3182 | ir_print_splat_gen(irp, (Stage1AirInstSplat *)instruction); | |
| 3183 | 3183 | break; |
| 3184 | case IrInstGenIdBoolNot: | |
| 3185 | ir_print_bool_not(irp, (IrInstGenBoolNot *)instruction); | |
| 3184 | case Stage1AirInstIdBoolNot: | |
| 3185 | ir_print_bool_not(irp, (Stage1AirInstBoolNot *)instruction); | |
| 3186 | 3186 | break; |
| 3187 | case IrInstGenIdMemset: | |
| 3188 | ir_print_memset(irp, (IrInstGenMemset *)instruction); | |
| 3187 | case Stage1AirInstIdMemset: | |
| 3188 | ir_print_memset(irp, (Stage1AirInstMemset *)instruction); | |
| 3189 | 3189 | break; |
| 3190 | case IrInstGenIdMemcpy: | |
| 3191 | ir_print_memcpy(irp, (IrInstGenMemcpy *)instruction); | |
| 3190 | case Stage1AirInstIdMemcpy: | |
| 3191 | ir_print_memcpy(irp, (Stage1AirInstMemcpy *)instruction); | |
| 3192 | 3192 | break; |
| 3193 | case IrInstGenIdSlice: | |
| 3194 | ir_print_slice_gen(irp, (IrInstGenSlice *)instruction); | |
| 3193 | case Stage1AirInstIdSlice: | |
| 3194 | ir_print_slice_gen(irp, (Stage1AirInstSlice *)instruction); | |
| 3195 | 3195 | break; |
| 3196 | case IrInstGenIdBreakpoint: | |
| 3197 | ir_print_breakpoint(irp, (IrInstGenBreakpoint *)instruction); | |
| 3196 | case Stage1AirInstIdBreakpoint: | |
| 3197 | ir_print_breakpoint(irp, (Stage1AirInstBreakpoint *)instruction); | |
| 3198 | 3198 | break; |
| 3199 | case IrInstGenIdReturnAddress: | |
| 3200 | ir_print_return_address(irp, (IrInstGenReturnAddress *)instruction); | |
| 3199 | case Stage1AirInstIdReturnAddress: | |
| 3200 | ir_print_return_address(irp, (Stage1AirInstReturnAddress *)instruction); | |
| 3201 | 3201 | break; |
| 3202 | case IrInstGenIdFrameAddress: | |
| 3203 | ir_print_frame_address(irp, (IrInstGenFrameAddress *)instruction); | |
| 3202 | case Stage1AirInstIdFrameAddress: | |
| 3203 | ir_print_frame_address(irp, (Stage1AirInstFrameAddress *)instruction); | |
| 3204 | 3204 | break; |
| 3205 | case IrInstGenIdFrameHandle: | |
| 3206 | ir_print_handle(irp, (IrInstGenFrameHandle *)instruction); | |
| 3205 | case Stage1AirInstIdFrameHandle: | |
| 3206 | ir_print_handle(irp, (Stage1AirInstFrameHandle *)instruction); | |
| 3207 | 3207 | break; |
| 3208 | case IrInstGenIdFrameSize: | |
| 3209 | ir_print_frame_size_gen(irp, (IrInstGenFrameSize *)instruction); | |
| 3208 | case Stage1AirInstIdFrameSize: | |
| 3209 | ir_print_frame_size_gen(irp, (Stage1AirInstFrameSize *)instruction); | |
| 3210 | 3210 | break; |
| 3211 | case IrInstGenIdOverflowOp: | |
| 3212 | ir_print_overflow_op(irp, (IrInstGenOverflowOp *)instruction); | |
| 3211 | case Stage1AirInstIdOverflowOp: | |
| 3212 | ir_print_overflow_op(irp, (Stage1AirInstOverflowOp *)instruction); | |
| 3213 | 3213 | break; |
| 3214 | case IrInstGenIdTestErr: | |
| 3215 | ir_print_test_err_gen(irp, (IrInstGenTestErr *)instruction); | |
| 3214 | case Stage1AirInstIdTestErr: | |
| 3215 | ir_print_test_err_gen(irp, (Stage1AirInstTestErr *)instruction); | |
| 3216 | 3216 | break; |
| 3217 | case IrInstGenIdUnwrapErrCode: | |
| 3218 | ir_print_unwrap_err_code(irp, (IrInstGenUnwrapErrCode *)instruction); | |
| 3217 | case Stage1AirInstIdUnwrapErrCode: | |
| 3218 | ir_print_unwrap_err_code(irp, (Stage1AirInstUnwrapErrCode *)instruction); | |
| 3219 | 3219 | break; |
| 3220 | case IrInstGenIdUnwrapErrPayload: | |
| 3221 | ir_print_unwrap_err_payload(irp, (IrInstGenUnwrapErrPayload *)instruction); | |
| 3220 | case Stage1AirInstIdUnwrapErrPayload: | |
| 3221 | ir_print_unwrap_err_payload(irp, (Stage1AirInstUnwrapErrPayload *)instruction); | |
| 3222 | 3222 | break; |
| 3223 | case IrInstGenIdOptionalWrap: | |
| 3224 | ir_print_optional_wrap(irp, (IrInstGenOptionalWrap *)instruction); | |
| 3223 | case Stage1AirInstIdOptionalWrap: | |
| 3224 | ir_print_optional_wrap(irp, (Stage1AirInstOptionalWrap *)instruction); | |
| 3225 | 3225 | break; |
| 3226 | case IrInstGenIdErrWrapCode: | |
| 3227 | ir_print_err_wrap_code(irp, (IrInstGenErrWrapCode *)instruction); | |
| 3226 | case Stage1AirInstIdErrWrapCode: | |
| 3227 | ir_print_err_wrap_code(irp, (Stage1AirInstErrWrapCode *)instruction); | |
| 3228 | 3228 | break; |
| 3229 | case IrInstGenIdErrWrapPayload: | |
| 3230 | ir_print_err_wrap_payload(irp, (IrInstGenErrWrapPayload *)instruction); | |
| 3229 | case Stage1AirInstIdErrWrapPayload: | |
| 3230 | ir_print_err_wrap_payload(irp, (Stage1AirInstErrWrapPayload *)instruction); | |
| 3231 | 3231 | break; |
| 3232 | case IrInstGenIdPtrCast: | |
| 3233 | ir_print_ptr_cast_gen(irp, (IrInstGenPtrCast *)instruction); | |
| 3232 | case Stage1AirInstIdPtrCast: | |
| 3233 | ir_print_ptr_cast_gen(irp, (Stage1AirInstPtrCast *)instruction); | |
| 3234 | 3234 | break; |
| 3235 | case IrInstGenIdBitCast: | |
| 3236 | ir_print_bit_cast_gen(irp, (IrInstGenBitCast *)instruction); | |
| 3235 | case Stage1AirInstIdBitCast: | |
| 3236 | ir_print_bit_cast_gen(irp, (Stage1AirInstBitCast *)instruction); | |
| 3237 | 3237 | break; |
| 3238 | case IrInstGenIdWidenOrShorten: | |
| 3239 | ir_print_widen_or_shorten(irp, (IrInstGenWidenOrShorten *)instruction); | |
| 3238 | case Stage1AirInstIdWidenOrShorten: | |
| 3239 | ir_print_widen_or_shorten(irp, (Stage1AirInstWidenOrShorten *)instruction); | |
| 3240 | 3240 | break; |
| 3241 | case IrInstGenIdPtrToInt: | |
| 3242 | ir_print_ptr_to_int(irp, (IrInstGenPtrToInt *)instruction); | |
| 3241 | case Stage1AirInstIdPtrToInt: | |
| 3242 | ir_print_ptr_to_int(irp, (Stage1AirInstPtrToInt *)instruction); | |
| 3243 | 3243 | break; |
| 3244 | case IrInstGenIdIntToPtr: | |
| 3245 | ir_print_int_to_ptr(irp, (IrInstGenIntToPtr *)instruction); | |
| 3244 | case Stage1AirInstIdIntToPtr: | |
| 3245 | ir_print_int_to_ptr(irp, (Stage1AirInstIntToPtr *)instruction); | |
| 3246 | 3246 | break; |
| 3247 | case IrInstGenIdIntToEnum: | |
| 3248 | ir_print_int_to_enum(irp, (IrInstGenIntToEnum *)instruction); | |
| 3247 | case Stage1AirInstIdIntToEnum: | |
| 3248 | ir_print_int_to_enum(irp, (Stage1AirInstIntToEnum *)instruction); | |
| 3249 | 3249 | break; |
| 3250 | case IrInstGenIdIntToErr: | |
| 3251 | ir_print_int_to_err(irp, (IrInstGenIntToErr *)instruction); | |
| 3250 | case Stage1AirInstIdIntToErr: | |
| 3251 | ir_print_int_to_err(irp, (Stage1AirInstIntToErr *)instruction); | |
| 3252 | 3252 | break; |
| 3253 | case IrInstGenIdErrToInt: | |
| 3254 | ir_print_err_to_int(irp, (IrInstGenErrToInt *)instruction); | |
| 3253 | case Stage1AirInstIdErrToInt: | |
| 3254 | ir_print_err_to_int(irp, (Stage1AirInstErrToInt *)instruction); | |
| 3255 | 3255 | break; |
| 3256 | case IrInstGenIdTagName: | |
| 3257 | ir_print_tag_name(irp, (IrInstGenTagName *)instruction); | |
| 3256 | case Stage1AirInstIdTagName: | |
| 3257 | ir_print_tag_name(irp, (Stage1AirInstTagName *)instruction); | |
| 3258 | 3258 | break; |
| 3259 | case IrInstGenIdPanic: | |
| 3260 | ir_print_panic(irp, (IrInstGenPanic *)instruction); | |
| 3259 | case Stage1AirInstIdPanic: | |
| 3260 | ir_print_panic(irp, (Stage1AirInstPanic *)instruction); | |
| 3261 | 3261 | break; |
| 3262 | case IrInstGenIdFieldParentPtr: | |
| 3263 | ir_print_field_parent_ptr(irp, (IrInstGenFieldParentPtr *)instruction); | |
| 3262 | case Stage1AirInstIdFieldParentPtr: | |
| 3263 | ir_print_field_parent_ptr(irp, (Stage1AirInstFieldParentPtr *)instruction); | |
| 3264 | 3264 | break; |
| 3265 | case IrInstGenIdAlignCast: | |
| 3266 | ir_print_align_cast(irp, (IrInstGenAlignCast *)instruction); | |
| 3265 | case Stage1AirInstIdAlignCast: | |
| 3266 | ir_print_align_cast(irp, (Stage1AirInstAlignCast *)instruction); | |
| 3267 | 3267 | break; |
| 3268 | case IrInstGenIdErrorReturnTrace: | |
| 3269 | ir_print_error_return_trace(irp, (IrInstGenErrorReturnTrace *)instruction); | |
| 3268 | case Stage1AirInstIdErrorReturnTrace: | |
| 3269 | ir_print_error_return_trace(irp, (Stage1AirInstErrorReturnTrace *)instruction); | |
| 3270 | 3270 | break; |
| 3271 | case IrInstGenIdAtomicRmw: | |
| 3272 | ir_print_atomic_rmw(irp, (IrInstGenAtomicRmw *)instruction); | |
| 3271 | case Stage1AirInstIdAtomicRmw: | |
| 3272 | ir_print_atomic_rmw(irp, (Stage1AirInstAtomicRmw *)instruction); | |
| 3273 | 3273 | break; |
| 3274 | case IrInstGenIdSaveErrRetAddr: | |
| 3275 | ir_print_save_err_ret_addr(irp, (IrInstGenSaveErrRetAddr *)instruction); | |
| 3274 | case Stage1AirInstIdSaveErrRetAddr: | |
| 3275 | ir_print_save_err_ret_addr(irp, (Stage1AirInstSaveErrRetAddr *)instruction); | |
| 3276 | 3276 | break; |
| 3277 | case IrInstGenIdFloatOp: | |
| 3278 | ir_print_float_op(irp, (IrInstGenFloatOp *)instruction); | |
| 3277 | case Stage1AirInstIdFloatOp: | |
| 3278 | ir_print_float_op(irp, (Stage1AirInstFloatOp *)instruction); | |
| 3279 | 3279 | break; |
| 3280 | case IrInstGenIdMulAdd: | |
| 3281 | ir_print_mul_add(irp, (IrInstGenMulAdd *)instruction); | |
| 3280 | case Stage1AirInstIdMulAdd: | |
| 3281 | ir_print_mul_add(irp, (Stage1AirInstMulAdd *)instruction); | |
| 3282 | 3282 | break; |
| 3283 | case IrInstGenIdAtomicLoad: | |
| 3284 | ir_print_atomic_load(irp, (IrInstGenAtomicLoad *)instruction); | |
| 3283 | case Stage1AirInstIdAtomicLoad: | |
| 3284 | ir_print_atomic_load(irp, (Stage1AirInstAtomicLoad *)instruction); | |
| 3285 | 3285 | break; |
| 3286 | case IrInstGenIdAtomicStore: | |
| 3287 | ir_print_atomic_store(irp, (IrInstGenAtomicStore *)instruction); | |
| 3286 | case Stage1AirInstIdAtomicStore: | |
| 3287 | ir_print_atomic_store(irp, (Stage1AirInstAtomicStore *)instruction); | |
| 3288 | 3288 | break; |
| 3289 | case IrInstGenIdArrayToVector: | |
| 3290 | ir_print_array_to_vector(irp, (IrInstGenArrayToVector *)instruction); | |
| 3289 | case Stage1AirInstIdArrayToVector: | |
| 3290 | ir_print_array_to_vector(irp, (Stage1AirInstArrayToVector *)instruction); | |
| 3291 | 3291 | break; |
| 3292 | case IrInstGenIdVectorToArray: | |
| 3293 | ir_print_vector_to_array(irp, (IrInstGenVectorToArray *)instruction); | |
| 3292 | case Stage1AirInstIdVectorToArray: | |
| 3293 | ir_print_vector_to_array(irp, (Stage1AirInstVectorToArray *)instruction); | |
| 3294 | 3294 | break; |
| 3295 | case IrInstGenIdPtrOfArrayToSlice: | |
| 3296 | ir_print_ptr_of_array_to_slice(irp, (IrInstGenPtrOfArrayToSlice *)instruction); | |
| 3295 | case Stage1AirInstIdPtrOfArrayToSlice: | |
| 3296 | ir_print_ptr_of_array_to_slice(irp, (Stage1AirInstPtrOfArrayToSlice *)instruction); | |
| 3297 | 3297 | break; |
| 3298 | case IrInstGenIdAssertZero: | |
| 3299 | ir_print_assert_zero(irp, (IrInstGenAssertZero *)instruction); | |
| 3298 | case Stage1AirInstIdAssertZero: | |
| 3299 | ir_print_assert_zero(irp, (Stage1AirInstAssertZero *)instruction); | |
| 3300 | 3300 | break; |
| 3301 | case IrInstGenIdAssertNonNull: | |
| 3302 | ir_print_assert_non_null(irp, (IrInstGenAssertNonNull *)instruction); | |
| 3301 | case Stage1AirInstIdAssertNonNull: | |
| 3302 | ir_print_assert_non_null(irp, (Stage1AirInstAssertNonNull *)instruction); | |
| 3303 | 3303 | break; |
| 3304 | case IrInstGenIdAlloca: | |
| 3305 | ir_print_alloca_gen(irp, (IrInstGenAlloca *)instruction); | |
| 3304 | case Stage1AirInstIdAlloca: | |
| 3305 | ir_print_alloca_gen(irp, (Stage1AirInstAlloca *)instruction); | |
| 3306 | 3306 | break; |
| 3307 | case IrInstGenIdSuspendBegin: | |
| 3308 | ir_print_suspend_begin(irp, (IrInstGenSuspendBegin *)instruction); | |
| 3307 | case Stage1AirInstIdSuspendBegin: | |
| 3308 | ir_print_suspend_begin(irp, (Stage1AirInstSuspendBegin *)instruction); | |
| 3309 | 3309 | break; |
| 3310 | case IrInstGenIdSuspendFinish: | |
| 3311 | ir_print_suspend_finish(irp, (IrInstGenSuspendFinish *)instruction); | |
| 3310 | case Stage1AirInstIdSuspendFinish: | |
| 3311 | ir_print_suspend_finish(irp, (Stage1AirInstSuspendFinish *)instruction); | |
| 3312 | 3312 | break; |
| 3313 | case IrInstGenIdResume: | |
| 3314 | ir_print_resume(irp, (IrInstGenResume *)instruction); | |
| 3313 | case Stage1AirInstIdResume: | |
| 3314 | ir_print_resume(irp, (Stage1AirInstResume *)instruction); | |
| 3315 | 3315 | break; |
| 3316 | case IrInstGenIdAwait: | |
| 3317 | ir_print_await_gen(irp, (IrInstGenAwait *)instruction); | |
| 3316 | case Stage1AirInstIdAwait: | |
| 3317 | ir_print_await_gen(irp, (Stage1AirInstAwait *)instruction); | |
| 3318 | 3318 | break; |
| 3319 | case IrInstGenIdSpillBegin: | |
| 3320 | ir_print_spill_begin(irp, (IrInstGenSpillBegin *)instruction); | |
| 3319 | case Stage1AirInstIdSpillBegin: | |
| 3320 | ir_print_spill_begin(irp, (Stage1AirInstSpillBegin *)instruction); | |
| 3321 | 3321 | break; |
| 3322 | case IrInstGenIdSpillEnd: | |
| 3323 | ir_print_spill_end(irp, (IrInstGenSpillEnd *)instruction); | |
| 3322 | case Stage1AirInstIdSpillEnd: | |
| 3323 | ir_print_spill_end(irp, (Stage1AirInstSpillEnd *)instruction); | |
| 3324 | 3324 | break; |
| 3325 | case IrInstGenIdVectorExtractElem: | |
| 3326 | ir_print_vector_extract_elem(irp, (IrInstGenVectorExtractElem *)instruction); | |
| 3325 | case Stage1AirInstIdVectorExtractElem: | |
| 3326 | ir_print_vector_extract_elem(irp, (Stage1AirInstVectorExtractElem *)instruction); | |
| 3327 | 3327 | break; |
| 3328 | case IrInstGenIdVectorStoreElem: | |
| 3329 | ir_print_vector_store_elem(irp, (IrInstGenVectorStoreElem *)instruction); | |
| 3328 | case Stage1AirInstIdVectorStoreElem: | |
| 3329 | ir_print_vector_store_elem(irp, (Stage1AirInstVectorStoreElem *)instruction); | |
| 3330 | 3330 | break; |
| 3331 | case IrInstGenIdBinaryNot: | |
| 3332 | ir_print_binary_not(irp, (IrInstGenBinaryNot *)instruction); | |
| 3331 | case Stage1AirInstIdBinaryNot: | |
| 3332 | ir_print_binary_not(irp, (Stage1AirInstBinaryNot *)instruction); | |
| 3333 | 3333 | break; |
| 3334 | case IrInstGenIdNegation: | |
| 3335 | ir_print_negation(irp, (IrInstGenNegation *)instruction); | |
| 3334 | case Stage1AirInstIdNegation: | |
| 3335 | ir_print_negation(irp, (Stage1AirInstNegation *)instruction); | |
| 3336 | 3336 | break; |
| 3337 | case IrInstGenIdWasmMemorySize: | |
| 3338 | ir_print_wasm_memory_size(irp, (IrInstGenWasmMemorySize *)instruction); | |
| 3337 | case Stage1AirInstIdWasmMemorySize: | |
| 3338 | ir_print_wasm_memory_size(irp, (Stage1AirInstWasmMemorySize *)instruction); | |
| 3339 | 3339 | break; |
| 3340 | case IrInstGenIdWasmMemoryGrow: | |
| 3341 | ir_print_wasm_memory_grow(irp, (IrInstGenWasmMemoryGrow *)instruction); | |
| 3340 | case Stage1AirInstIdWasmMemoryGrow: | |
| 3341 | ir_print_wasm_memory_grow(irp, (Stage1AirInstWasmMemoryGrow *)instruction); | |
| 3342 | 3342 | break; |
| 3343 | case IrInstGenIdExtern: | |
| 3344 | ir_print_extern(irp, (IrInstGenExtern *)instruction); | |
| 3343 | case Stage1AirInstIdExtern: | |
| 3344 | ir_print_extern(irp, (Stage1AirInstExtern *)instruction); | |
| 3345 | 3345 | break; |
| 3346 | 3346 | |
| 3347 | 3347 | } |
| ... | ... | @@ -3351,15 +3351,15 @@ static void ir_print_inst_gen(IrPrintGen *irp, IrInstGen *instruction, bool trai |
| 3351 | 3351 | static void irp_print_basic_block_src(IrPrintSrc *irp, Stage1ZirBasicBlock *current_block) { |
| 3352 | 3352 | fprintf(irp->f, "%s_%" PRIu32 ":\n", current_block->name_hint, current_block->debug_id); |
| 3353 | 3353 | for (size_t instr_i = 0; instr_i < current_block->instruction_list.length; instr_i += 1) { |
| 3354 | IrInstSrc *instruction = current_block->instruction_list.at(instr_i); | |
| 3354 | Stage1ZirInst *instruction = current_block->instruction_list.at(instr_i); | |
| 3355 | 3355 | ir_print_inst_src(irp, instruction, false); |
| 3356 | 3356 | } |
| 3357 | 3357 | } |
| 3358 | 3358 | |
| 3359 | static void irp_print_basic_block_gen(IrPrintGen *irp, IrBasicBlockGen *current_block) { | |
| 3359 | static void irp_print_basic_block_gen(IrPrintGen *irp, Stage1AirBasicBlock *current_block) { | |
| 3360 | 3360 | fprintf(irp->f, "%s_%" PRIu32 ":\n", current_block->name_hint, current_block->debug_id); |
| 3361 | 3361 | for (size_t instr_i = 0; instr_i < current_block->instruction_list.length; instr_i += 1) { |
| 3362 | IrInstGen *instruction = current_block->instruction_list.at(instr_i); | |
| 3362 | Stage1AirInst *instruction = current_block->instruction_list.at(instr_i); | |
| 3363 | 3363 | irp->printed.put(instruction, 0); |
| 3364 | 3364 | irp->pending.clear(); |
| 3365 | 3365 | ir_print_inst_gen(irp, instruction, false); |
| ... | ... | @@ -3378,7 +3378,7 @@ void ir_print_basic_block_src(CodeGen *codegen, FILE *f, Stage1ZirBasicBlock *bb |
| 3378 | 3378 | irp_print_basic_block_src(&ir_print, bb); |
| 3379 | 3379 | } |
| 3380 | 3380 | |
| 3381 | void ir_print_basic_block_gen(CodeGen *codegen, FILE *f, IrBasicBlockGen *bb, int indent_size) { | |
| 3381 | void ir_print_basic_block_gen(CodeGen *codegen, FILE *f, Stage1AirBasicBlock *bb, int indent_size) { | |
| 3382 | 3382 | IrPrintGen ir_print = {}; |
| 3383 | 3383 | ir_print.codegen = codegen; |
| 3384 | 3384 | ir_print.f = f; |
| ... | ... | @@ -3426,7 +3426,7 @@ void ir_print_gen(CodeGen *codegen, FILE *f, Stage1Air *executable, int indent_s |
| 3426 | 3426 | irp->printed.deinit(); |
| 3427 | 3427 | } |
| 3428 | 3428 | |
| 3429 | void ir_print_inst_src(CodeGen *codegen, FILE *f, IrInstSrc *instruction, int indent_size) { | |
| 3429 | void ir_print_inst_src(CodeGen *codegen, FILE *f, Stage1ZirInst *instruction, int indent_size) { | |
| 3430 | 3430 | IrPrintSrc ir_print = {}; |
| 3431 | 3431 | IrPrintSrc *irp = &ir_print; |
| 3432 | 3432 | irp->codegen = codegen; |
| ... | ... | @@ -3437,7 +3437,7 @@ void ir_print_inst_src(CodeGen *codegen, FILE *f, IrInstSrc *instruction, int in |
| 3437 | 3437 | ir_print_inst_src(irp, instruction, false); |
| 3438 | 3438 | } |
| 3439 | 3439 | |
| 3440 | void ir_print_inst_gen(CodeGen *codegen, FILE *f, IrInstGen *instruction, int indent_size) { | |
| 3440 | void ir_print_inst_gen(CodeGen *codegen, FILE *f, Stage1AirInst *instruction, int indent_size) { | |
| 3441 | 3441 | IrPrintGen ir_print = {}; |
| 3442 | 3442 | IrPrintGen *irp = &ir_print; |
| 3443 | 3443 | irp->codegen = codegen; |
| ... | ... | @@ -3451,8 +3451,8 @@ void ir_print_inst_gen(CodeGen *codegen, FILE *f, IrInstGen *instruction, int in |
| 3451 | 3451 | ir_print_inst_gen(irp, instruction, false); |
| 3452 | 3452 | } |
| 3453 | 3453 | |
| 3454 | void IrInstSrc::dump() { | |
| 3455 | IrInstSrc *inst = this; | |
| 3454 | void Stage1ZirInst::dump() { | |
| 3455 | Stage1ZirInst *inst = this; | |
| 3456 | 3456 | inst->src(); |
| 3457 | 3457 | if (inst->scope == nullptr) { |
| 3458 | 3458 | fprintf(stderr, "(null scope)\n"); |
src/stage1/ir_print.hpp+5-5| ... | ... | @@ -14,12 +14,12 @@ |
| 14 | 14 | |
| 15 | 15 | void ir_print_src(CodeGen *codegen, FILE *f, Stage1Zir *executable, int indent_size); |
| 16 | 16 | void ir_print_gen(CodeGen *codegen, FILE *f, Stage1Air *executable, int indent_size); |
| 17 | void ir_print_inst_src(CodeGen *codegen, FILE *f, IrInstSrc *inst, int indent_size); | |
| 18 | void ir_print_inst_gen(CodeGen *codegen, FILE *f, IrInstGen *inst, int indent_size); | |
| 17 | void ir_print_inst_src(CodeGen *codegen, FILE *f, Stage1ZirInst *inst, int indent_size); | |
| 18 | void ir_print_inst_gen(CodeGen *codegen, FILE *f, Stage1AirInst *inst, int indent_size); | |
| 19 | 19 | void ir_print_basic_block_src(CodeGen *codegen, FILE *f, Stage1ZirBasicBlock *bb, int indent_size); |
| 20 | void ir_print_basic_block_gen(CodeGen *codegen, FILE *f, IrBasicBlockGen *bb, int indent_size); | |
| 20 | void ir_print_basic_block_gen(CodeGen *codegen, FILE *f, Stage1AirBasicBlock *bb, int indent_size); | |
| 21 | 21 | |
| 22 | const char* ir_inst_src_type_str(IrInstSrcId id); | |
| 23 | const char* ir_inst_gen_type_str(IrInstGenId id); | |
| 22 | const char* ir_inst_src_type_str(Stage1ZirInstId id); | |
| 23 | const char* ir_inst_gen_type_str(Stage1AirInstId id); | |
| 24 | 24 | |
| 25 | 25 | #endif |