authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-13 13:05:57-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:19-07:00
logf5ddef1e45fb5e6defcad21e50736c6e0f63c089
tree0fccbee2a74cc3dc4ce0e44dda245f4c22af16e9
parent41a8f5aec34ad4d6e4f5c4a2a2dc47f10bb1311d

update references to module (to be renamed to zcu)


9 files changed, 365 insertions(+), 365 deletions(-)

src/Compilation.zig+32-32
...@@ -1915,7 +1915,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1915,7 +1915,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1915}1915}
19161916
1917pub fn destroy(self: *Compilation) void {1917pub fn destroy(self: *Compilation) void {
1918 const optional_module = self.bin_file.options.module;1918 const optional_module = self.module;
1919 self.bin_file.destroy();1919 self.bin_file.destroy();
1920 if (optional_module) |module| module.deinit();1920 if (optional_module) |module| module.deinit();
19211921
...@@ -2017,7 +2017,7 @@ fn restorePrevZigCacheArtifactDirectory(comp: *Compilation, directory: *Director...@@ -2017,7 +2017,7 @@ fn restorePrevZigCacheArtifactDirectory(comp: *Compilation, directory: *Director
2017 // Restore the Module's previous zig_cache_artifact_directory2017 // Restore the Module's previous zig_cache_artifact_directory
2018 // This is only for cleanup purposes; Module.deinit calls close2018 // This is only for cleanup purposes; Module.deinit calls close
2019 // on the handle of zig_cache_artifact_directory.2019 // on the handle of zig_cache_artifact_directory.
2020 if (comp.bin_file.options.module) |module| {2020 if (comp.module) |module| {
2021 const builtin_mod = module.main_mod.deps.get("builtin").?;2021 const builtin_mod = module.main_mod.deps.get("builtin").?;
2022 module.zig_cache_artifact_directory = builtin_mod.root.root_dir;2022 module.zig_cache_artifact_directory = builtin_mod.root.root_dir;
2023 }2023 }
...@@ -2109,7 +2109,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2109,7 +2109,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2109 };2109 };
21102110
2111 // This updates the output directory for linker outputs.2111 // This updates the output directory for linker outputs.
2112 if (comp.bin_file.options.module) |module| {2112 if (comp.module) |module| {
2113 module.zig_cache_artifact_directory = tmp_artifact_directory.?;2113 module.zig_cache_artifact_directory = tmp_artifact_directory.?;
2114 }2114 }
21152115
...@@ -2155,7 +2155,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2155,7 +2155,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2155 }2155 }
2156 }2156 }
21572157
2158 if (comp.bin_file.options.module) |module| {2158 if (comp.module) |module| {
2159 module.compile_log_text.shrinkAndFree(module.gpa, 0);2159 module.compile_log_text.shrinkAndFree(module.gpa, 0);
2160 module.generation += 1;2160 module.generation += 1;
21612161
...@@ -2206,7 +2206,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2206,7 +2206,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
22062206
2207 try comp.performAllTheWork(main_progress_node);2207 try comp.performAllTheWork(main_progress_node);
22082208
2209 if (comp.bin_file.options.module) |module| {2209 if (comp.module) |module| {
2210 if (builtin.mode == .Debug and comp.verbose_intern_pool) {2210 if (builtin.mode == .Debug and comp.verbose_intern_pool) {
2211 std.debug.print("intern pool stats for '{s}':\n", .{2211 std.debug.print("intern pool stats for '{s}':\n", .{
2212 comp.bin_file.options.root_name,2212 comp.bin_file.options.root_name,
...@@ -2277,7 +2277,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2277,7 +2277,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2277 }2277 }
22782278
2279 // This is intentionally sandwiched between renameTmpIntoCache() and writeManifest().2279 // This is intentionally sandwiched between renameTmpIntoCache() and writeManifest().
2280 if (comp.bin_file.options.module) |module| {2280 if (comp.module) |module| {
2281 // We need to set the zig_cache_artifact_directory for -femit-asm, -femit-llvm-ir,2281 // We need to set the zig_cache_artifact_directory for -femit-asm, -femit-llvm-ir,
2282 // etc to know where to output to.2282 // etc to know where to output to.
2283 var artifact_dir = try comp.local_cache_directory.handle.openDir(o_sub_path, .{});2283 var artifact_dir = try comp.local_cache_directory.handle.openDir(o_sub_path, .{});
...@@ -2322,7 +2322,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2322,7 +2322,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2322 // to it, and (2) generic instantiations, comptime calls, inline calls will need2322 // to it, and (2) generic instantiations, comptime calls, inline calls will need
2323 // to reference the ZIR.2323 // to reference the ZIR.
2324 if (!comp.keep_source_files_loaded) {2324 if (!comp.keep_source_files_loaded) {
2325 if (comp.bin_file.options.module) |module| {2325 if (comp.module) |module| {
2326 for (module.import_table.values()) |file| {2326 for (module.import_table.values()) |file| {
2327 file.unloadTree(comp.gpa);2327 file.unloadTree(comp.gpa);
2328 file.unloadSource(comp.gpa);2328 file.unloadSource(comp.gpa);
...@@ -2332,7 +2332,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2332,7 +2332,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2332}2332}
23332333
2334fn maybeGenerateAutodocs(comp: *Compilation, prog_node: *std.Progress.Node) !void {2334fn maybeGenerateAutodocs(comp: *Compilation, prog_node: *std.Progress.Node) !void {
2335 const mod = comp.bin_file.options.module orelse return;2335 const mod = comp.module orelse return;
2336 // TODO: do this in a separate job during performAllTheWork(). The2336 // TODO: do this in a separate job during performAllTheWork(). The
2337 // file copies at the end of generate() can also be extracted to2337 // file copies at the end of generate() can also be extracted to
2338 // separate jobs2338 // separate jobs
...@@ -2360,7 +2360,7 @@ fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -2360,7 +2360,7 @@ fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {
2360 };2360 };
2361 comp.link_error_flags = comp.bin_file.errorFlags();2361 comp.link_error_flags = comp.bin_file.errorFlags();
23622362
2363 if (comp.bin_file.options.module) |module| {2363 if (comp.module) |module| {
2364 try link.File.C.flushEmitH(module);2364 try link.File.C.flushEmitH(module);
2365 }2365 }
2366}2366}
...@@ -2421,7 +2421,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes...@@ -2421,7 +2421,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
24212421
2422 comptime assert(link_hash_implementation_version == 10);2422 comptime assert(link_hash_implementation_version == 10);
24232423
2424 if (comp.bin_file.options.module) |mod| {2424 if (comp.module) |mod| {
2425 const main_zig_file = try mod.main_mod.root.joinString(arena, mod.main_mod.root_src_path);2425 const main_zig_file = try mod.main_mod.root.joinString(arena, mod.main_mod.root_src_path);
2426 _ = try man.addFile(main_zig_file, null);2426 _ = try man.addFile(main_zig_file, null);
2427 try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.main_mod, .{ .files = man });2427 try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.main_mod, .{ .files = man });
...@@ -2559,7 +2559,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes...@@ -2559,7 +2559,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
2559}2559}
25602560
2561fn emitOthers(comp: *Compilation) void {2561fn emitOthers(comp: *Compilation) void {
2562 if (comp.bin_file.options.output_mode != .Obj or comp.bin_file.options.module != null or2562 if (comp.bin_file.options.output_mode != .Obj or comp.module != null or
2563 comp.c_object_table.count() == 0)2563 comp.c_object_table.count() == 0)
2564 {2564 {
2565 return;2565 return;
...@@ -2727,7 +2727,7 @@ pub fn saveState(comp: *Compilation) !void {...@@ -2727,7 +2727,7 @@ pub fn saveState(comp: *Compilation) !void {
27272727
2728 const emit = comp.bin_file.options.emit orelse return;2728 const emit = comp.bin_file.options.emit orelse return;
27292729
2730 if (comp.bin_file.options.module) |mod| {2730 if (comp.module) |mod| {
2731 const ip = &mod.intern_pool;2731 const ip = &mod.intern_pool;
2732 const header: Header = .{2732 const header: Header = .{
2733 .intern_pool = .{2733 .intern_pool = .{
...@@ -2792,7 +2792,7 @@ pub fn totalErrorCount(self: *Compilation) u32 {...@@ -2792,7 +2792,7 @@ pub fn totalErrorCount(self: *Compilation) u32 {
2792 }2792 }
2793 }2793 }
27942794
2795 if (self.bin_file.options.module) |module| {2795 if (self.module) |module| {
2796 total += module.failed_exports.count();2796 total += module.failed_exports.count();
2797 total += module.failed_embed_files.count();2797 total += module.failed_embed_files.count();
27982798
...@@ -2844,7 +2844,7 @@ pub fn totalErrorCount(self: *Compilation) u32 {...@@ -2844,7 +2844,7 @@ pub fn totalErrorCount(self: *Compilation) u32 {
28442844
2845 // Compile log errors only count if there are no other errors.2845 // Compile log errors only count if there are no other errors.
2846 if (total == 0) {2846 if (total == 0) {
2847 if (self.bin_file.options.module) |module| {2847 if (self.module) |module| {
2848 total += @intFromBool(module.compile_log_decls.count() != 0);2848 total += @intFromBool(module.compile_log_decls.count() != 0);
2849 }2849 }
2850 }2850 }
...@@ -2896,7 +2896,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {...@@ -2896,7 +2896,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
2896 .msg = try bundle.addString("memory allocation failure"),2896 .msg = try bundle.addString("memory allocation failure"),
2897 });2897 });
2898 }2898 }
2899 if (self.bin_file.options.module) |module| {2899 if (self.module) |module| {
2900 for (module.failed_files.keys(), module.failed_files.values()) |file, error_msg| {2900 for (module.failed_files.keys(), module.failed_files.values()) |file, error_msg| {
2901 if (error_msg) |msg| {2901 if (error_msg) |msg| {
2902 try addModuleErrorMsg(module, &bundle, msg.*);2902 try addModuleErrorMsg(module, &bundle, msg.*);
...@@ -3002,7 +3002,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {...@@ -3002,7 +3002,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
3002 }3002 }
3003 }3003 }
30043004
3005 if (self.bin_file.options.module) |module| {3005 if (self.module) |module| {
3006 if (bundle.root_list.items.len == 0 and module.compile_log_decls.count() != 0) {3006 if (bundle.root_list.items.len == 0 and module.compile_log_decls.count() != 0) {
3007 const keys = module.compile_log_decls.keys();3007 const keys = module.compile_log_decls.keys();
3008 const values = module.compile_log_decls.values();3008 const values = module.compile_log_decls.values();
...@@ -3030,7 +3030,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {...@@ -3030,7 +3030,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
30303030
3031 assert(self.totalErrorCount() == bundle.root_list.items.len);3031 assert(self.totalErrorCount() == bundle.root_list.items.len);
30323032
3033 const compile_log_text = if (self.bin_file.options.module) |m| m.compile_log_text.items else "";3033 const compile_log_text = if (self.module) |m| m.compile_log_text.items else "";
3034 return bundle.toOwnedBundle(compile_log_text);3034 return bundle.toOwnedBundle(compile_log_text);
3035}3035}
30363036
...@@ -3314,7 +3314,7 @@ pub fn performAllTheWork(...@@ -3314,7 +3314,7 @@ pub fn performAllTheWork(
3314 // 1. to avoid race condition of zig processes truncating each other's builtin.zig files3314 // 1. to avoid race condition of zig processes truncating each other's builtin.zig files
3315 // 2. optimization; in the hot path it only incurs a stat() syscall, which happens3315 // 2. optimization; in the hot path it only incurs a stat() syscall, which happens
3316 // in the `astgen_wait_group`.3316 // in the `astgen_wait_group`.
3317 if (comp.bin_file.options.module) |mod| {3317 if (comp.module) |mod| {
3318 if (mod.job_queued_update_builtin_zig) {3318 if (mod.job_queued_update_builtin_zig) {
3319 mod.job_queued_update_builtin_zig = false;3319 mod.job_queued_update_builtin_zig = false;
33203320
...@@ -3356,15 +3356,15 @@ pub fn performAllTheWork(...@@ -3356,15 +3356,15 @@ pub fn performAllTheWork(
3356 }3356 }
3357 }3357 }
33583358
3359 if (comp.bin_file.options.module) |mod| {3359 if (comp.module) |mod| {
3360 try reportMultiModuleErrors(mod);3360 try reportMultiModuleErrors(mod);
3361 }3361 }
33623362
3363 if (comp.bin_file.options.module) |mod| {3363 if (comp.module) |mod| {
3364 mod.sema_prog_node = main_progress_node.start("Semantic Analysis", 0);3364 mod.sema_prog_node = main_progress_node.start("Semantic Analysis", 0);
3365 mod.sema_prog_node.activate();3365 mod.sema_prog_node.activate();
3366 }3366 }
3367 defer if (comp.bin_file.options.module) |mod| {3367 defer if (comp.module) |mod| {
3368 mod.sema_prog_node.end();3368 mod.sema_prog_node.end();
3369 mod.sema_prog_node = undefined;3369 mod.sema_prog_node = undefined;
3370 };3370 };
...@@ -3398,7 +3398,7 @@ pub fn performAllTheWork(...@@ -3398,7 +3398,7 @@ pub fn performAllTheWork(
3398fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !void {3398fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !void {
3399 switch (job) {3399 switch (job) {
3400 .codegen_decl => |decl_index| {3400 .codegen_decl => |decl_index| {
3401 const module = comp.bin_file.options.module.?;3401 const module = comp.module.?;
3402 const decl = module.declPtr(decl_index);3402 const decl = module.declPtr(decl_index);
34033403
3404 switch (decl.analysis) {3404 switch (decl.analysis) {
...@@ -3436,14 +3436,14 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v...@@ -3436,14 +3436,14 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
3436 const named_frame = tracy.namedFrame("codegen_func");3436 const named_frame = tracy.namedFrame("codegen_func");
3437 defer named_frame.end();3437 defer named_frame.end();
34383438
3439 const module = comp.bin_file.options.module.?;3439 const module = comp.module.?;
3440 module.ensureFuncBodyAnalyzed(func) catch |err| switch (err) {3440 module.ensureFuncBodyAnalyzed(func) catch |err| switch (err) {
3441 error.OutOfMemory => return error.OutOfMemory,3441 error.OutOfMemory => return error.OutOfMemory,
3442 error.AnalysisFail => return,3442 error.AnalysisFail => return,
3443 };3443 };
3444 },3444 },
3445 .emit_h_decl => |decl_index| {3445 .emit_h_decl => |decl_index| {
3446 const module = comp.bin_file.options.module.?;3446 const module = comp.module.?;
3447 const decl = module.declPtr(decl_index);3447 const decl = module.declPtr(decl_index);
34483448
3449 switch (decl.analysis) {3449 switch (decl.analysis) {
...@@ -3502,7 +3502,7 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v...@@ -3502,7 +3502,7 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
3502 }3502 }
3503 },3503 },
3504 .analyze_decl => |decl_index| {3504 .analyze_decl => |decl_index| {
3505 const module = comp.bin_file.options.module.?;3505 const module = comp.module.?;
3506 module.ensureDeclAnalyzed(decl_index) catch |err| switch (err) {3506 module.ensureDeclAnalyzed(decl_index) catch |err| switch (err) {
3507 error.OutOfMemory => return error.OutOfMemory,3507 error.OutOfMemory => return error.OutOfMemory,
3508 error.AnalysisFail => return,3508 error.AnalysisFail => return,
...@@ -3520,7 +3520,7 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v...@@ -3520,7 +3520,7 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
3520 defer named_frame.end();3520 defer named_frame.end();
35213521
3522 const gpa = comp.gpa;3522 const gpa = comp.gpa;
3523 const module = comp.bin_file.options.module.?;3523 const module = comp.module.?;
3524 const decl = module.declPtr(decl_index);3524 const decl = module.declPtr(decl_index);
3525 comp.bin_file.updateDeclLineNumber(module, decl_index) catch |err| {3525 comp.bin_file.updateDeclLineNumber(module, decl_index) catch |err| {
3526 try module.failed_decls.ensureUnusedCapacity(gpa, 1);3526 try module.failed_decls.ensureUnusedCapacity(gpa, 1);
...@@ -3537,7 +3537,7 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v...@@ -3537,7 +3537,7 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
3537 const named_frame = tracy.namedFrame("analyze_mod");3537 const named_frame = tracy.namedFrame("analyze_mod");
3538 defer named_frame.end();3538 defer named_frame.end();
35393539
3540 const module = comp.bin_file.options.module.?;3540 const module = comp.module.?;
3541 module.semaPkg(pkg) catch |err| switch (err) {3541 module.semaPkg(pkg) catch |err| switch (err) {
3542 error.OutOfMemory => return error.OutOfMemory,3542 error.OutOfMemory => return error.OutOfMemory,
3543 error.AnalysisFail => return,3543 error.AnalysisFail => return,
...@@ -3716,7 +3716,7 @@ fn workerAstGenFile(...@@ -3716,7 +3716,7 @@ fn workerAstGenFile(
3716 child_prog_node.activate();3716 child_prog_node.activate();
3717 defer child_prog_node.end();3717 defer child_prog_node.end();
37183718
3719 const mod = comp.bin_file.options.module.?;3719 const mod = comp.module.?;
3720 mod.astGenFile(file) catch |err| switch (err) {3720 mod.astGenFile(file) catch |err| switch (err) {
3721 error.AnalysisFail => return,3721 error.AnalysisFail => return,
3722 else => {3722 else => {
...@@ -3819,7 +3819,7 @@ fn workerCheckEmbedFile(...@@ -3819,7 +3819,7 @@ fn workerCheckEmbedFile(
3819}3819}
38203820
3821fn detectEmbedFileUpdate(comp: *Compilation, embed_file: *Module.EmbedFile) !void {3821fn detectEmbedFileUpdate(comp: *Compilation, embed_file: *Module.EmbedFile) !void {
3822 const mod = comp.bin_file.options.module.?;3822 const mod = comp.module.?;
3823 const ip = &mod.intern_pool;3823 const ip = &mod.intern_pool;
3824 const sub_file_path = ip.stringToSlice(embed_file.sub_file_path);3824 const sub_file_path = ip.stringToSlice(embed_file.sub_file_path);
3825 var file = try embed_file.owner.root.openFile(sub_file_path, .{});3825 var file = try embed_file.owner.root.openFile(sub_file_path, .{});
...@@ -4142,7 +4142,7 @@ fn reportRetryableAstGenError(...@@ -4142,7 +4142,7 @@ fn reportRetryableAstGenError(
4142 file: *Module.File,4142 file: *Module.File,
4143 err: anyerror,4143 err: anyerror,
4144) error{OutOfMemory}!void {4144) error{OutOfMemory}!void {
4145 const mod = comp.bin_file.options.module.?;4145 const mod = comp.module.?;
4146 const gpa = mod.gpa;4146 const gpa = mod.gpa;
41474147
4148 file.status = .retryable_failure;4148 file.status = .retryable_failure;
...@@ -4181,7 +4181,7 @@ fn reportRetryableEmbedFileError(...@@ -4181,7 +4181,7 @@ fn reportRetryableEmbedFileError(
4181 embed_file: *Module.EmbedFile,4181 embed_file: *Module.EmbedFile,
4182 err: anyerror,4182 err: anyerror,
4183) error{OutOfMemory}!void {4183) error{OutOfMemory}!void {
4184 const mod = comp.bin_file.options.module.?;4184 const mod = comp.module.?;
4185 const gpa = mod.gpa;4185 const gpa = mod.gpa;
4186 const src_loc = embed_file.src_loc;4186 const src_loc = embed_file.src_loc;
4187 const ip = &mod.intern_pool;4187 const ip = &mod.intern_pool;
...@@ -4248,7 +4248,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P...@@ -4248,7 +4248,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
4248 // Special case when doing build-obj for just one C file. When there are more than one object4248 // Special case when doing build-obj for just one C file. When there are more than one object
4249 // file and building an object we need to link them together, but with just one it should go4249 // file and building an object we need to link them together, but with just one it should go
4250 // directly to the output file.4250 // directly to the output file.
4251 const direct_o = comp.c_source_files.len == 1 and comp.bin_file.options.module == null and4251 const direct_o = comp.c_source_files.len == 1 and comp.module == null and
4252 comp.bin_file.options.output_mode == .Obj and comp.bin_file.options.objects.len == 0;4252 comp.bin_file.options.output_mode == .Obj and comp.bin_file.options.objects.len == 0;
4253 const o_basename_noext = if (direct_o)4253 const o_basename_noext = if (direct_o)
4254 comp.bin_file.options.root_name4254 comp.bin_file.options.root_name
src/arch/aarch64/CodeGen.zig+68-68
...@@ -341,7 +341,7 @@ pub fn generate(...@@ -341,7 +341,7 @@ pub fn generate(
341 @panic("Attempted to compile for architecture that was disabled by build configuration");341 @panic("Attempted to compile for architecture that was disabled by build configuration");
342 }342 }
343343
344 const mod = bin_file.options.module.?;344 const mod = bin_file.comp.module.?;
345 const func = mod.funcInfo(func_index);345 const func = mod.funcInfo(func_index);
346 const fn_owner_decl = mod.declPtr(func.owner_decl);346 const fn_owner_decl = mod.declPtr(func.owner_decl);
347 assert(fn_owner_decl.has_tv);347 assert(fn_owner_decl.has_tv);
...@@ -476,7 +476,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {...@@ -476,7 +476,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {
476}476}
477477
478fn gen(self: *Self) !void {478fn gen(self: *Self) !void {
479 const mod = self.bin_file.options.module.?;479 const mod = self.bin_file.comp.module.?;
480 const cc = self.fn_type.fnCallingConvention(mod);480 const cc = self.fn_type.fnCallingConvention(mod);
481 if (cc != .Naked) {481 if (cc != .Naked) {
482 // stp fp, lr, [sp, #-16]!482 // stp fp, lr, [sp, #-16]!
...@@ -656,7 +656,7 @@ fn gen(self: *Self) !void {...@@ -656,7 +656,7 @@ fn gen(self: *Self) !void {
656}656}
657657
658fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {658fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
659 const mod = self.bin_file.options.module.?;659 const mod = self.bin_file.comp.module.?;
660 const ip = &mod.intern_pool;660 const ip = &mod.intern_pool;
661 const air_tags = self.air.instructions.items(.tag);661 const air_tags = self.air.instructions.items(.tag);
662662
...@@ -1028,7 +1028,7 @@ fn allocMem(...@@ -1028,7 +1028,7 @@ fn allocMem(
10281028
1029/// Use a pointer instruction as the basis for allocating stack memory.1029/// Use a pointer instruction as the basis for allocating stack memory.
1030fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {1030fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
1031 const mod = self.bin_file.options.module.?;1031 const mod = self.bin_file.comp.module.?;
1032 const elem_ty = self.typeOfIndex(inst).childType(mod);1032 const elem_ty = self.typeOfIndex(inst).childType(mod);
10331033
1034 if (!elem_ty.hasRuntimeBits(mod)) {1034 if (!elem_ty.hasRuntimeBits(mod)) {
...@@ -1048,7 +1048,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {...@@ -1048,7 +1048,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
1048}1048}
10491049
1050fn allocRegOrMem(self: *Self, elem_ty: Type, reg_ok: bool, maybe_inst: ?Air.Inst.Index) !MCValue {1050fn allocRegOrMem(self: *Self, elem_ty: Type, reg_ok: bool, maybe_inst: ?Air.Inst.Index) !MCValue {
1051 const mod = self.bin_file.options.module.?;1051 const mod = self.bin_file.comp.module.?;
1052 const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {1052 const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {
1053 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});1053 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});
1054 };1054 };
...@@ -1139,7 +1139,7 @@ fn airAlloc(self: *Self, inst: Air.Inst.Index) !void {...@@ -1139,7 +1139,7 @@ fn airAlloc(self: *Self, inst: Air.Inst.Index) !void {
1139}1139}
11401140
1141fn airRetPtr(self: *Self, inst: Air.Inst.Index) !void {1141fn airRetPtr(self: *Self, inst: Air.Inst.Index) !void {
1142 const mod = self.bin_file.options.module.?;1142 const mod = self.bin_file.comp.module.?;
1143 const result: MCValue = switch (self.ret_mcv) {1143 const result: MCValue = switch (self.ret_mcv) {
1144 .none, .register => .{ .ptr_stack_offset = try self.allocMemPtr(inst) },1144 .none, .register => .{ .ptr_stack_offset = try self.allocMemPtr(inst) },
1145 .stack_offset => blk: {1145 .stack_offset => blk: {
...@@ -1176,7 +1176,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {...@@ -1176,7 +1176,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
1176 if (self.liveness.isUnused(inst))1176 if (self.liveness.isUnused(inst))
1177 return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });1177 return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });
11781178
1179 const mod = self.bin_file.options.module.?;1179 const mod = self.bin_file.comp.module.?;
1180 const operand = ty_op.operand;1180 const operand = ty_op.operand;
1181 const operand_mcv = try self.resolveInst(operand);1181 const operand_mcv = try self.resolveInst(operand);
1182 const operand_ty = self.typeOf(operand);1182 const operand_ty = self.typeOf(operand);
...@@ -1257,7 +1257,7 @@ fn trunc(...@@ -1257,7 +1257,7 @@ fn trunc(
1257 operand_ty: Type,1257 operand_ty: Type,
1258 dest_ty: Type,1258 dest_ty: Type,
1259) !MCValue {1259) !MCValue {
1260 const mod = self.bin_file.options.module.?;1260 const mod = self.bin_file.comp.module.?;
1261 const info_a = operand_ty.intInfo(mod);1261 const info_a = operand_ty.intInfo(mod);
1262 const info_b = dest_ty.intInfo(mod);1262 const info_b = dest_ty.intInfo(mod);
12631263
...@@ -1320,7 +1320,7 @@ fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {...@@ -1320,7 +1320,7 @@ fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
13201320
1321fn airNot(self: *Self, inst: Air.Inst.Index) !void {1321fn airNot(self: *Self, inst: Air.Inst.Index) !void {
1322 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;1322 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
1323 const mod = self.bin_file.options.module.?;1323 const mod = self.bin_file.comp.module.?;
1324 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {1324 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
1325 const operand = try self.resolveInst(ty_op.operand);1325 const operand = try self.resolveInst(ty_op.operand);
1326 const operand_ty = self.typeOf(ty_op.operand);1326 const operand_ty = self.typeOf(ty_op.operand);
...@@ -1415,7 +1415,7 @@ fn minMax(...@@ -1415,7 +1415,7 @@ fn minMax(
1415 rhs_ty: Type,1415 rhs_ty: Type,
1416 maybe_inst: ?Air.Inst.Index,1416 maybe_inst: ?Air.Inst.Index,
1417) !MCValue {1417) !MCValue {
1418 const mod = self.bin_file.options.module.?;1418 const mod = self.bin_file.comp.module.?;
1419 switch (lhs_ty.zigTypeTag(mod)) {1419 switch (lhs_ty.zigTypeTag(mod)) {
1420 .Float => return self.fail("TODO ARM min/max on floats", .{}),1420 .Float => return self.fail("TODO ARM min/max on floats", .{}),
1421 .Vector => return self.fail("TODO ARM min/max on vectors", .{}),1421 .Vector => return self.fail("TODO ARM min/max on vectors", .{}),
...@@ -1905,7 +1905,7 @@ fn addSub(...@@ -1905,7 +1905,7 @@ fn addSub(
1905 rhs_ty: Type,1905 rhs_ty: Type,
1906 maybe_inst: ?Air.Inst.Index,1906 maybe_inst: ?Air.Inst.Index,
1907) InnerError!MCValue {1907) InnerError!MCValue {
1908 const mod = self.bin_file.options.module.?;1908 const mod = self.bin_file.comp.module.?;
1909 switch (lhs_ty.zigTypeTag(mod)) {1909 switch (lhs_ty.zigTypeTag(mod)) {
1910 .Float => return self.fail("TODO binary operations on floats", .{}),1910 .Float => return self.fail("TODO binary operations on floats", .{}),
1911 .Vector => return self.fail("TODO binary operations on vectors", .{}),1911 .Vector => return self.fail("TODO binary operations on vectors", .{}),
...@@ -1966,7 +1966,7 @@ fn mul(...@@ -1966,7 +1966,7 @@ fn mul(
1966 rhs_ty: Type,1966 rhs_ty: Type,
1967 maybe_inst: ?Air.Inst.Index,1967 maybe_inst: ?Air.Inst.Index,
1968) InnerError!MCValue {1968) InnerError!MCValue {
1969 const mod = self.bin_file.options.module.?;1969 const mod = self.bin_file.comp.module.?;
1970 switch (lhs_ty.zigTypeTag(mod)) {1970 switch (lhs_ty.zigTypeTag(mod)) {
1971 .Vector => return self.fail("TODO binary operations on vectors", .{}),1971 .Vector => return self.fail("TODO binary operations on vectors", .{}),
1972 .Int => {1972 .Int => {
...@@ -1998,7 +1998,7 @@ fn divFloat(...@@ -1998,7 +1998,7 @@ fn divFloat(
1998 _ = rhs_ty;1998 _ = rhs_ty;
1999 _ = maybe_inst;1999 _ = maybe_inst;
20002000
2001 const mod = self.bin_file.options.module.?;2001 const mod = self.bin_file.comp.module.?;
2002 switch (lhs_ty.zigTypeTag(mod)) {2002 switch (lhs_ty.zigTypeTag(mod)) {
2003 .Float => return self.fail("TODO div_float", .{}),2003 .Float => return self.fail("TODO div_float", .{}),
2004 .Vector => return self.fail("TODO div_float on vectors", .{}),2004 .Vector => return self.fail("TODO div_float on vectors", .{}),
...@@ -2014,7 +2014,7 @@ fn divTrunc(...@@ -2014,7 +2014,7 @@ fn divTrunc(
2014 rhs_ty: Type,2014 rhs_ty: Type,
2015 maybe_inst: ?Air.Inst.Index,2015 maybe_inst: ?Air.Inst.Index,
2016) InnerError!MCValue {2016) InnerError!MCValue {
2017 const mod = self.bin_file.options.module.?;2017 const mod = self.bin_file.comp.module.?;
2018 switch (lhs_ty.zigTypeTag(mod)) {2018 switch (lhs_ty.zigTypeTag(mod)) {
2019 .Float => return self.fail("TODO div on floats", .{}),2019 .Float => return self.fail("TODO div on floats", .{}),
2020 .Vector => return self.fail("TODO div on vectors", .{}),2020 .Vector => return self.fail("TODO div on vectors", .{}),
...@@ -2048,7 +2048,7 @@ fn divFloor(...@@ -2048,7 +2048,7 @@ fn divFloor(
2048 rhs_ty: Type,2048 rhs_ty: Type,
2049 maybe_inst: ?Air.Inst.Index,2049 maybe_inst: ?Air.Inst.Index,
2050) InnerError!MCValue {2050) InnerError!MCValue {
2051 const mod = self.bin_file.options.module.?;2051 const mod = self.bin_file.comp.module.?;
2052 switch (lhs_ty.zigTypeTag(mod)) {2052 switch (lhs_ty.zigTypeTag(mod)) {
2053 .Float => return self.fail("TODO div on floats", .{}),2053 .Float => return self.fail("TODO div on floats", .{}),
2054 .Vector => return self.fail("TODO div on vectors", .{}),2054 .Vector => return self.fail("TODO div on vectors", .{}),
...@@ -2081,7 +2081,7 @@ fn divExact(...@@ -2081,7 +2081,7 @@ fn divExact(
2081 rhs_ty: Type,2081 rhs_ty: Type,
2082 maybe_inst: ?Air.Inst.Index,2082 maybe_inst: ?Air.Inst.Index,
2083) InnerError!MCValue {2083) InnerError!MCValue {
2084 const mod = self.bin_file.options.module.?;2084 const mod = self.bin_file.comp.module.?;
2085 switch (lhs_ty.zigTypeTag(mod)) {2085 switch (lhs_ty.zigTypeTag(mod)) {
2086 .Float => return self.fail("TODO div on floats", .{}),2086 .Float => return self.fail("TODO div on floats", .{}),
2087 .Vector => return self.fail("TODO div on vectors", .{}),2087 .Vector => return self.fail("TODO div on vectors", .{}),
...@@ -2117,7 +2117,7 @@ fn rem(...@@ -2117,7 +2117,7 @@ fn rem(
2117) InnerError!MCValue {2117) InnerError!MCValue {
2118 _ = maybe_inst;2118 _ = maybe_inst;
21192119
2120 const mod = self.bin_file.options.module.?;2120 const mod = self.bin_file.comp.module.?;
2121 switch (lhs_ty.zigTypeTag(mod)) {2121 switch (lhs_ty.zigTypeTag(mod)) {
2122 .Float => return self.fail("TODO rem/mod on floats", .{}),2122 .Float => return self.fail("TODO rem/mod on floats", .{}),
2123 .Vector => return self.fail("TODO rem/mod on vectors", .{}),2123 .Vector => return self.fail("TODO rem/mod on vectors", .{}),
...@@ -2188,7 +2188,7 @@ fn modulo(...@@ -2188,7 +2188,7 @@ fn modulo(
2188 _ = rhs_ty;2188 _ = rhs_ty;
2189 _ = maybe_inst;2189 _ = maybe_inst;
21902190
2191 const mod = self.bin_file.options.module.?;2191 const mod = self.bin_file.comp.module.?;
2192 switch (lhs_ty.zigTypeTag(mod)) {2192 switch (lhs_ty.zigTypeTag(mod)) {
2193 .Float => return self.fail("TODO mod on floats", .{}),2193 .Float => return self.fail("TODO mod on floats", .{}),
2194 .Vector => return self.fail("TODO mod on vectors", .{}),2194 .Vector => return self.fail("TODO mod on vectors", .{}),
...@@ -2206,7 +2206,7 @@ fn wrappingArithmetic(...@@ -2206,7 +2206,7 @@ fn wrappingArithmetic(
2206 rhs_ty: Type,2206 rhs_ty: Type,
2207 maybe_inst: ?Air.Inst.Index,2207 maybe_inst: ?Air.Inst.Index,
2208) InnerError!MCValue {2208) InnerError!MCValue {
2209 const mod = self.bin_file.options.module.?;2209 const mod = self.bin_file.comp.module.?;
2210 switch (lhs_ty.zigTypeTag(mod)) {2210 switch (lhs_ty.zigTypeTag(mod)) {
2211 .Vector => return self.fail("TODO binary operations on vectors", .{}),2211 .Vector => return self.fail("TODO binary operations on vectors", .{}),
2212 .Int => {2212 .Int => {
...@@ -2241,7 +2241,7 @@ fn bitwise(...@@ -2241,7 +2241,7 @@ fn bitwise(
2241 rhs_ty: Type,2241 rhs_ty: Type,
2242 maybe_inst: ?Air.Inst.Index,2242 maybe_inst: ?Air.Inst.Index,
2243) InnerError!MCValue {2243) InnerError!MCValue {
2244 const mod = self.bin_file.options.module.?;2244 const mod = self.bin_file.comp.module.?;
2245 switch (lhs_ty.zigTypeTag(mod)) {2245 switch (lhs_ty.zigTypeTag(mod)) {
2246 .Vector => return self.fail("TODO binary operations on vectors", .{}),2246 .Vector => return self.fail("TODO binary operations on vectors", .{}),
2247 .Int => {2247 .Int => {
...@@ -2276,7 +2276,7 @@ fn shiftExact(...@@ -2276,7 +2276,7 @@ fn shiftExact(
2276) InnerError!MCValue {2276) InnerError!MCValue {
2277 _ = rhs_ty;2277 _ = rhs_ty;
22782278
2279 const mod = self.bin_file.options.module.?;2279 const mod = self.bin_file.comp.module.?;
2280 switch (lhs_ty.zigTypeTag(mod)) {2280 switch (lhs_ty.zigTypeTag(mod)) {
2281 .Vector => return self.fail("TODO binary operations on vectors", .{}),2281 .Vector => return self.fail("TODO binary operations on vectors", .{}),
2282 .Int => {2282 .Int => {
...@@ -2326,7 +2326,7 @@ fn shiftNormal(...@@ -2326,7 +2326,7 @@ fn shiftNormal(
2326 rhs_ty: Type,2326 rhs_ty: Type,
2327 maybe_inst: ?Air.Inst.Index,2327 maybe_inst: ?Air.Inst.Index,
2328) InnerError!MCValue {2328) InnerError!MCValue {
2329 const mod = self.bin_file.options.module.?;2329 const mod = self.bin_file.comp.module.?;
2330 switch (lhs_ty.zigTypeTag(mod)) {2330 switch (lhs_ty.zigTypeTag(mod)) {
2331 .Vector => return self.fail("TODO binary operations on vectors", .{}),2331 .Vector => return self.fail("TODO binary operations on vectors", .{}),
2332 .Int => {2332 .Int => {
...@@ -2366,7 +2366,7 @@ fn booleanOp(...@@ -2366,7 +2366,7 @@ fn booleanOp(
2366 rhs_ty: Type,2366 rhs_ty: Type,
2367 maybe_inst: ?Air.Inst.Index,2367 maybe_inst: ?Air.Inst.Index,
2368) InnerError!MCValue {2368) InnerError!MCValue {
2369 const mod = self.bin_file.options.module.?;2369 const mod = self.bin_file.comp.module.?;
2370 switch (lhs_ty.zigTypeTag(mod)) {2370 switch (lhs_ty.zigTypeTag(mod)) {
2371 .Bool => {2371 .Bool => {
2372 assert((try lhs_bind.resolveToImmediate(self)) == null); // should have been handled by Sema2372 assert((try lhs_bind.resolveToImmediate(self)) == null); // should have been handled by Sema
...@@ -2393,7 +2393,7 @@ fn ptrArithmetic(...@@ -2393,7 +2393,7 @@ fn ptrArithmetic(
2393 rhs_ty: Type,2393 rhs_ty: Type,
2394 maybe_inst: ?Air.Inst.Index,2394 maybe_inst: ?Air.Inst.Index,
2395) InnerError!MCValue {2395) InnerError!MCValue {
2396 const mod = self.bin_file.options.module.?;2396 const mod = self.bin_file.comp.module.?;
2397 switch (lhs_ty.zigTypeTag(mod)) {2397 switch (lhs_ty.zigTypeTag(mod)) {
2398 .Pointer => {2398 .Pointer => {
2399 assert(rhs_ty.eql(Type.usize, mod));2399 assert(rhs_ty.eql(Type.usize, mod));
...@@ -2516,7 +2516,7 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -2516,7 +2516,7 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void {
2516 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];2516 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
2517 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;2517 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
2518 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;2518 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
2519 const mod = self.bin_file.options.module.?;2519 const mod = self.bin_file.comp.module.?;
2520 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2520 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2521 const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };2521 const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };
2522 const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };2522 const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };
...@@ -2644,7 +2644,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -2644,7 +2644,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
2644 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;2644 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
2645 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;2645 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
2646 if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });2646 if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });
2647 const mod = self.bin_file.options.module.?;2647 const mod = self.bin_file.comp.module.?;
2648 const result: MCValue = result: {2648 const result: MCValue = result: {
2649 const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };2649 const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };
2650 const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };2650 const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };
...@@ -2868,7 +2868,7 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -2868,7 +2868,7 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
2868 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;2868 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
2869 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;2869 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
2870 if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });2870 if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });
2871 const mod = self.bin_file.options.module.?;2871 const mod = self.bin_file.comp.module.?;
2872 const result: MCValue = result: {2872 const result: MCValue = result: {
2873 const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };2873 const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };
2874 const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };2874 const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };
...@@ -3016,7 +3016,7 @@ fn airOptionalPayload(self: *Self, inst: Air.Inst.Index) !void {...@@ -3016,7 +3016,7 @@ fn airOptionalPayload(self: *Self, inst: Air.Inst.Index) !void {
3016}3016}
30173017
3018fn optionalPayload(self: *Self, inst: Air.Inst.Index, mcv: MCValue, optional_ty: Type) !MCValue {3018fn optionalPayload(self: *Self, inst: Air.Inst.Index, mcv: MCValue, optional_ty: Type) !MCValue {
3019 const mod = self.bin_file.options.module.?;3019 const mod = self.bin_file.comp.module.?;
3020 const payload_ty = optional_ty.optionalChild(mod);3020 const payload_ty = optional_ty.optionalChild(mod);
3021 if (!payload_ty.hasRuntimeBits(mod)) return MCValue.none;3021 if (!payload_ty.hasRuntimeBits(mod)) return MCValue.none;
3022 if (optional_ty.isPtrLikeOptional(mod)) {3022 if (optional_ty.isPtrLikeOptional(mod)) {
...@@ -3060,7 +3060,7 @@ fn errUnionErr(...@@ -3060,7 +3060,7 @@ fn errUnionErr(
3060 error_union_ty: Type,3060 error_union_ty: Type,
3061 maybe_inst: ?Air.Inst.Index,3061 maybe_inst: ?Air.Inst.Index,
3062) !MCValue {3062) !MCValue {
3063 const mod = self.bin_file.options.module.?;3063 const mod = self.bin_file.comp.module.?;
3064 const err_ty = error_union_ty.errorUnionSet(mod);3064 const err_ty = error_union_ty.errorUnionSet(mod);
3065 const payload_ty = error_union_ty.errorUnionPayload(mod);3065 const payload_ty = error_union_ty.errorUnionPayload(mod);
3066 if (err_ty.errorSetIsEmpty(mod)) {3066 if (err_ty.errorSetIsEmpty(mod)) {
...@@ -3140,7 +3140,7 @@ fn errUnionPayload(...@@ -3140,7 +3140,7 @@ fn errUnionPayload(
3140 error_union_ty: Type,3140 error_union_ty: Type,
3141 maybe_inst: ?Air.Inst.Index,3141 maybe_inst: ?Air.Inst.Index,
3142) !MCValue {3142) !MCValue {
3143 const mod = self.bin_file.options.module.?;3143 const mod = self.bin_file.comp.module.?;
3144 const err_ty = error_union_ty.errorUnionSet(mod);3144 const err_ty = error_union_ty.errorUnionSet(mod);
3145 const payload_ty = error_union_ty.errorUnionPayload(mod);3145 const payload_ty = error_union_ty.errorUnionPayload(mod);
3146 if (err_ty.errorSetIsEmpty(mod)) {3146 if (err_ty.errorSetIsEmpty(mod)) {
...@@ -3252,7 +3252,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {...@@ -3252,7 +3252,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {
3252}3252}
32533253
3254fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {3254fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
3255 const mod = self.bin_file.options.module.?;3255 const mod = self.bin_file.comp.module.?;
3256 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;3256 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
32573257
3258 if (self.liveness.isUnused(inst)) {3258 if (self.liveness.isUnused(inst)) {
...@@ -3297,7 +3297,7 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {...@@ -3297,7 +3297,7 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
32973297
3298/// T to E!T3298/// T to E!T
3299fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {3299fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
3300 const mod = self.bin_file.options.module.?;3300 const mod = self.bin_file.comp.module.?;
3301 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;3301 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
3302 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {3302 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
3303 const error_union_ty = ty_op.ty.toType();3303 const error_union_ty = ty_op.ty.toType();
...@@ -3323,7 +3323,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {...@@ -3323,7 +3323,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
3323fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {3323fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
3324 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;3324 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
3325 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {3325 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
3326 const mod = self.bin_file.options.module.?;3326 const mod = self.bin_file.comp.module.?;
3327 const error_union_ty = ty_op.ty.toType();3327 const error_union_ty = ty_op.ty.toType();
3328 const error_ty = error_union_ty.errorUnionSet(mod);3328 const error_ty = error_union_ty.errorUnionSet(mod);
3329 const payload_ty = error_union_ty.errorUnionPayload(mod);3329 const payload_ty = error_union_ty.errorUnionPayload(mod);
...@@ -3426,7 +3426,7 @@ fn airPtrSlicePtrPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -3426,7 +3426,7 @@ fn airPtrSlicePtrPtr(self: *Self, inst: Air.Inst.Index) !void {
3426}3426}
34273427
3428fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {3428fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {
3429 const mod = self.bin_file.options.module.?;3429 const mod = self.bin_file.comp.module.?;
3430 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;3430 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
3431 const slice_ty = self.typeOf(bin_op.lhs);3431 const slice_ty = self.typeOf(bin_op.lhs);
3432 const result: MCValue = if (!slice_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {3432 const result: MCValue = if (!slice_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {
...@@ -3450,7 +3450,7 @@ fn ptrElemVal(...@@ -3450,7 +3450,7 @@ fn ptrElemVal(
3450 ptr_ty: Type,3450 ptr_ty: Type,
3451 maybe_inst: ?Air.Inst.Index,3451 maybe_inst: ?Air.Inst.Index,
3452) !MCValue {3452) !MCValue {
3453 const mod = self.bin_file.options.module.?;3453 const mod = self.bin_file.comp.module.?;
3454 const elem_ty = ptr_ty.childType(mod);3454 const elem_ty = ptr_ty.childType(mod);
3455 const elem_size = @as(u32, @intCast(elem_ty.abiSize(mod)));3455 const elem_size = @as(u32, @intCast(elem_ty.abiSize(mod)));
34563456
...@@ -3492,7 +3492,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -3492,7 +3492,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
3492}3492}
34933493
3494fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {3494fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
3495 const mod = self.bin_file.options.module.?;3495 const mod = self.bin_file.comp.module.?;
3496 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;3496 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
3497 const ptr_ty = self.typeOf(bin_op.lhs);3497 const ptr_ty = self.typeOf(bin_op.lhs);
3498 const result: MCValue = if (!ptr_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {3498 const result: MCValue = if (!ptr_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {
...@@ -3615,7 +3615,7 @@ fn reuseOperand(...@@ -3615,7 +3615,7 @@ fn reuseOperand(
3615}3615}
36163616
3617fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {3617fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {
3618 const mod = self.bin_file.options.module.?;3618 const mod = self.bin_file.comp.module.?;
3619 const elem_ty = ptr_ty.childType(mod);3619 const elem_ty = ptr_ty.childType(mod);
3620 const elem_size = elem_ty.abiSize(mod);3620 const elem_size = elem_ty.abiSize(mod);
36213621
...@@ -3863,7 +3863,7 @@ fn genInlineMemsetCode(...@@ -3863,7 +3863,7 @@ fn genInlineMemsetCode(
3863}3863}
38643864
3865fn airLoad(self: *Self, inst: Air.Inst.Index) !void {3865fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
3866 const mod = self.bin_file.options.module.?;3866 const mod = self.bin_file.comp.module.?;
3867 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;3867 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
3868 const elem_ty = self.typeOfIndex(inst);3868 const elem_ty = self.typeOfIndex(inst);
3869 const elem_size = elem_ty.abiSize(mod);3869 const elem_size = elem_ty.abiSize(mod);
...@@ -3894,7 +3894,7 @@ fn airLoad(self: *Self, inst: Air.Inst.Index) !void {...@@ -3894,7 +3894,7 @@ fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
3894}3894}
38953895
3896fn genLdrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type) !void {3896fn genLdrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type) !void {
3897 const mod = self.bin_file.options.module.?;3897 const mod = self.bin_file.comp.module.?;
3898 const abi_size = ty.abiSize(mod);3898 const abi_size = ty.abiSize(mod);
38993899
3900 const tag: Mir.Inst.Tag = switch (abi_size) {3900 const tag: Mir.Inst.Tag = switch (abi_size) {
...@@ -3917,7 +3917,7 @@ fn genLdrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type...@@ -3917,7 +3917,7 @@ fn genLdrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type
3917}3917}
39183918
3919fn genStrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type) !void {3919fn genStrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type) !void {
3920 const mod = self.bin_file.options.module.?;3920 const mod = self.bin_file.comp.module.?;
3921 const abi_size = ty.abiSize(mod);3921 const abi_size = ty.abiSize(mod);
39223922
3923 const tag: Mir.Inst.Tag = switch (abi_size) {3923 const tag: Mir.Inst.Tag = switch (abi_size) {
...@@ -3939,7 +3939,7 @@ fn genStrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type...@@ -3939,7 +3939,7 @@ fn genStrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type
3939}3939}
39403940
3941fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void {3941fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void {
3942 const mod = self.bin_file.options.module.?;3942 const mod = self.bin_file.comp.module.?;
3943 log.debug("store: storing {} to {}", .{ value, ptr });3943 log.debug("store: storing {} to {}", .{ value, ptr });
3944 const abi_size = value_ty.abiSize(mod);3944 const abi_size = value_ty.abiSize(mod);
39453945
...@@ -4092,7 +4092,7 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void {...@@ -4092,7 +4092,7 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void {
40924092
4093fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {4093fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {
4094 return if (self.liveness.isUnused(inst)) .dead else result: {4094 return if (self.liveness.isUnused(inst)) .dead else result: {
4095 const mod = self.bin_file.options.module.?;4095 const mod = self.bin_file.comp.module.?;
4096 const mcv = try self.resolveInst(operand);4096 const mcv = try self.resolveInst(operand);
4097 const ptr_ty = self.typeOf(operand);4097 const ptr_ty = self.typeOf(operand);
4098 const struct_ty = ptr_ty.childType(mod);4098 const struct_ty = ptr_ty.childType(mod);
...@@ -4117,7 +4117,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -4117,7 +4117,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
4117 const operand = extra.struct_operand;4117 const operand = extra.struct_operand;
4118 const index = extra.field_index;4118 const index = extra.field_index;
4119 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {4119 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
4120 const mod = self.bin_file.options.module.?;4120 const mod = self.bin_file.comp.module.?;
4121 const mcv = try self.resolveInst(operand);4121 const mcv = try self.resolveInst(operand);
4122 const struct_ty = self.typeOf(operand);4122 const struct_ty = self.typeOf(operand);
4123 const struct_field_ty = struct_ty.structFieldType(index, mod);4123 const struct_field_ty = struct_ty.structFieldType(index, mod);
...@@ -4167,7 +4167,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -4167,7 +4167,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
4167}4167}
41684168
4169fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {4169fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {
4170 const mod = self.bin_file.options.module.?;4170 const mod = self.bin_file.comp.module.?;
4171 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;4171 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
4172 const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;4172 const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;
4173 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {4173 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
...@@ -4195,7 +4195,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {...@@ -4195,7 +4195,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {
4195 while (self.args[arg_index] == .none) arg_index += 1;4195 while (self.args[arg_index] == .none) arg_index += 1;
4196 self.arg_index = arg_index + 1;4196 self.arg_index = arg_index + 1;
41974197
4198 const mod = self.bin_file.options.module.?;4198 const mod = self.bin_file.comp.module.?;
4199 const ty = self.typeOfIndex(inst);4199 const ty = self.typeOfIndex(inst);
4200 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];4200 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
4201 const src_index = self.air.instructions.items(.data)[@intFromEnum(inst)].arg.src_index;4201 const src_index = self.air.instructions.items(.data)[@intFromEnum(inst)].arg.src_index;
...@@ -4250,7 +4250,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -4250,7 +4250,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
4250 const extra = self.air.extraData(Air.Call, pl_op.payload);4250 const extra = self.air.extraData(Air.Call, pl_op.payload);
4251 const args = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[extra.end..][0..extra.data.args_len]));4251 const args = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[extra.end..][0..extra.data.args_len]));
4252 const ty = self.typeOf(callee);4252 const ty = self.typeOf(callee);
4253 const mod = self.bin_file.options.module.?;4253 const mod = self.bin_file.comp.module.?;
42544254
4255 const fn_ty = switch (ty.zigTypeTag(mod)) {4255 const fn_ty = switch (ty.zigTypeTag(mod)) {
4256 .Fn => ty,4256 .Fn => ty,
...@@ -4422,7 +4422,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -4422,7 +4422,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
4422}4422}
44234423
4424fn airRet(self: *Self, inst: Air.Inst.Index) !void {4424fn airRet(self: *Self, inst: Air.Inst.Index) !void {
4425 const mod = self.bin_file.options.module.?;4425 const mod = self.bin_file.comp.module.?;
4426 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4426 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4427 const operand = try self.resolveInst(un_op);4427 const operand = try self.resolveInst(un_op);
4428 const ret_ty = self.fn_type.fnReturnType(mod);4428 const ret_ty = self.fn_type.fnReturnType(mod);
...@@ -4454,7 +4454,7 @@ fn airRet(self: *Self, inst: Air.Inst.Index) !void {...@@ -4454,7 +4454,7 @@ fn airRet(self: *Self, inst: Air.Inst.Index) !void {
4454}4454}
44554455
4456fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void {4456fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void {
4457 const mod = self.bin_file.options.module.?;4457 const mod = self.bin_file.comp.module.?;
4458 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4458 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4459 const ptr = try self.resolveInst(un_op);4459 const ptr = try self.resolveInst(un_op);
4460 const ptr_ty = self.typeOf(un_op);4460 const ptr_ty = self.typeOf(un_op);
...@@ -4514,7 +4514,7 @@ fn cmp(...@@ -4514,7 +4514,7 @@ fn cmp(
4514 lhs_ty: Type,4514 lhs_ty: Type,
4515 op: math.CompareOperator,4515 op: math.CompareOperator,
4516) !MCValue {4516) !MCValue {
4517 const mod = self.bin_file.options.module.?;4517 const mod = self.bin_file.comp.module.?;
4518 const int_ty = switch (lhs_ty.zigTypeTag(mod)) {4518 const int_ty = switch (lhs_ty.zigTypeTag(mod)) {
4519 .Optional => blk: {4519 .Optional => blk: {
4520 const payload_ty = lhs_ty.optionalChild(mod);4520 const payload_ty = lhs_ty.optionalChild(mod);
...@@ -4622,7 +4622,7 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void {...@@ -4622,7 +4622,7 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void {
46224622
4623fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {4623fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {
4624 const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;4624 const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;
4625 const mod = self.bin_file.options.module.?;4625 const mod = self.bin_file.comp.module.?;
4626 const func = mod.funcInfo(ty_fn.func);4626 const func = mod.funcInfo(ty_fn.func);
4627 // TODO emit debug info for function change4627 // TODO emit debug info for function change
4628 _ = func;4628 _ = func;
...@@ -4830,7 +4830,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {...@@ -4830,7 +4830,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
4830}4830}
48314831
4832fn isNull(self: *Self, operand_bind: ReadArg.Bind, operand_ty: Type) !MCValue {4832fn isNull(self: *Self, operand_bind: ReadArg.Bind, operand_ty: Type) !MCValue {
4833 const mod = self.bin_file.options.module.?;4833 const mod = self.bin_file.comp.module.?;
4834 const sentinel: struct { ty: Type, bind: ReadArg.Bind } = if (!operand_ty.isPtrLikeOptional(mod)) blk: {4834 const sentinel: struct { ty: Type, bind: ReadArg.Bind } = if (!operand_ty.isPtrLikeOptional(mod)) blk: {
4835 const payload_ty = operand_ty.optionalChild(mod);4835 const payload_ty = operand_ty.optionalChild(mod);
4836 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod))4836 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod))
...@@ -4886,7 +4886,7 @@ fn isErr(...@@ -4886,7 +4886,7 @@ fn isErr(
4886 error_union_bind: ReadArg.Bind,4886 error_union_bind: ReadArg.Bind,
4887 error_union_ty: Type,4887 error_union_ty: Type,
4888) !MCValue {4888) !MCValue {
4889 const mod = self.bin_file.options.module.?;4889 const mod = self.bin_file.comp.module.?;
4890 const error_type = error_union_ty.errorUnionSet(mod);4890 const error_type = error_union_ty.errorUnionSet(mod);
48914891
4892 if (error_type.errorSetIsEmpty(mod)) {4892 if (error_type.errorSetIsEmpty(mod)) {
...@@ -4928,7 +4928,7 @@ fn airIsNull(self: *Self, inst: Air.Inst.Index) !void {...@@ -4928,7 +4928,7 @@ fn airIsNull(self: *Self, inst: Air.Inst.Index) !void {
4928}4928}
49294929
4930fn airIsNullPtr(self: *Self, inst: Air.Inst.Index) !void {4930fn airIsNullPtr(self: *Self, inst: Air.Inst.Index) !void {
4931 const mod = self.bin_file.options.module.?;4931 const mod = self.bin_file.comp.module.?;
4932 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4932 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4933 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {4933 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
4934 const operand_ptr = try self.resolveInst(un_op);4934 const operand_ptr = try self.resolveInst(un_op);
...@@ -4955,7 +4955,7 @@ fn airIsNonNull(self: *Self, inst: Air.Inst.Index) !void {...@@ -4955,7 +4955,7 @@ fn airIsNonNull(self: *Self, inst: Air.Inst.Index) !void {
4955}4955}
49564956
4957fn airIsNonNullPtr(self: *Self, inst: Air.Inst.Index) !void {4957fn airIsNonNullPtr(self: *Self, inst: Air.Inst.Index) !void {
4958 const mod = self.bin_file.options.module.?;4958 const mod = self.bin_file.comp.module.?;
4959 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4959 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4960 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {4960 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
4961 const operand_ptr = try self.resolveInst(un_op);4961 const operand_ptr = try self.resolveInst(un_op);
...@@ -4982,7 +4982,7 @@ fn airIsErr(self: *Self, inst: Air.Inst.Index) !void {...@@ -4982,7 +4982,7 @@ fn airIsErr(self: *Self, inst: Air.Inst.Index) !void {
4982}4982}
49834983
4984fn airIsErrPtr(self: *Self, inst: Air.Inst.Index) !void {4984fn airIsErrPtr(self: *Self, inst: Air.Inst.Index) !void {
4985 const mod = self.bin_file.options.module.?;4985 const mod = self.bin_file.comp.module.?;
4986 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4986 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4987 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {4987 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
4988 const operand_ptr = try self.resolveInst(un_op);4988 const operand_ptr = try self.resolveInst(un_op);
...@@ -5009,7 +5009,7 @@ fn airIsNonErr(self: *Self, inst: Air.Inst.Index) !void {...@@ -5009,7 +5009,7 @@ fn airIsNonErr(self: *Self, inst: Air.Inst.Index) !void {
5009}5009}
50105010
5011fn airIsNonErrPtr(self: *Self, inst: Air.Inst.Index) !void {5011fn airIsNonErrPtr(self: *Self, inst: Air.Inst.Index) !void {
5012 const mod = self.bin_file.options.module.?;5012 const mod = self.bin_file.comp.module.?;
5013 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;5013 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
5014 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {5014 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
5015 const operand_ptr = try self.resolveInst(un_op);5015 const operand_ptr = try self.resolveInst(un_op);
...@@ -5226,7 +5226,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void {...@@ -5226,7 +5226,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void {
5226}5226}
52275227
5228fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {5228fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {
5229 const mod = self.bin_file.options.module.?;5229 const mod = self.bin_file.comp.module.?;
5230 const block_data = self.blocks.getPtr(block).?;5230 const block_data = self.blocks.getPtr(block).?;
52315231
5232 if (self.typeOf(operand).hasRuntimeBits(mod)) {5232 if (self.typeOf(operand).hasRuntimeBits(mod)) {
...@@ -5403,7 +5403,7 @@ fn setRegOrMem(self: *Self, ty: Type, loc: MCValue, val: MCValue) !void {...@@ -5403,7 +5403,7 @@ fn setRegOrMem(self: *Self, ty: Type, loc: MCValue, val: MCValue) !void {
5403}5403}
54045404
5405fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {5405fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {
5406 const mod = self.bin_file.options.module.?;5406 const mod = self.bin_file.comp.module.?;
5407 const abi_size = @as(u32, @intCast(ty.abiSize(mod)));5407 const abi_size = @as(u32, @intCast(ty.abiSize(mod)));
5408 switch (mcv) {5408 switch (mcv) {
5409 .dead => unreachable,5409 .dead => unreachable,
...@@ -5573,7 +5573,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro...@@ -5573,7 +5573,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
5573}5573}
55745574
5575fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void {5575fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void {
5576 const mod = self.bin_file.options.module.?;5576 const mod = self.bin_file.comp.module.?;
5577 switch (mcv) {5577 switch (mcv) {
5578 .dead => unreachable,5578 .dead => unreachable,
5579 .unreach, .none => return, // Nothing to do.5579 .unreach, .none => return, // Nothing to do.
...@@ -5735,7 +5735,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void...@@ -5735,7 +5735,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
5735}5735}
57365736
5737fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {5737fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {
5738 const mod = self.bin_file.options.module.?;5738 const mod = self.bin_file.comp.module.?;
5739 const abi_size = @as(u32, @intCast(ty.abiSize(mod)));5739 const abi_size = @as(u32, @intCast(ty.abiSize(mod)));
5740 switch (mcv) {5740 switch (mcv) {
5741 .dead => unreachable,5741 .dead => unreachable,
...@@ -5934,7 +5934,7 @@ fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {...@@ -5934,7 +5934,7 @@ fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {
5934}5934}
59355935
5936fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {5936fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
5937 const mod = self.bin_file.options.module.?;5937 const mod = self.bin_file.comp.module.?;
5938 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5938 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
5939 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {5939 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
5940 const ptr_ty = self.typeOf(ty_op.operand);5940 const ptr_ty = self.typeOf(ty_op.operand);
...@@ -6054,7 +6054,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {...@@ -6054,7 +6054,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {
6054}6054}
60556055
6056fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {6056fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
6057 const mod = self.bin_file.options.module.?;6057 const mod = self.bin_file.comp.module.?;
6058 const vector_ty = self.typeOfIndex(inst);6058 const vector_ty = self.typeOfIndex(inst);
6059 const len = vector_ty.vectorLen(mod);6059 const len = vector_ty.vectorLen(mod);
6060 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;6060 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
...@@ -6098,7 +6098,7 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {...@@ -6098,7 +6098,7 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {
6098}6098}
60996099
6100fn airTry(self: *Self, inst: Air.Inst.Index) !void {6100fn airTry(self: *Self, inst: Air.Inst.Index) !void {
6101 const mod = self.bin_file.options.module.?;6101 const mod = self.bin_file.comp.module.?;
6102 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;6102 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
6103 const extra = self.air.extraData(Air.Try, pl_op.payload);6103 const extra = self.air.extraData(Air.Try, pl_op.payload);
6104 const body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]);6104 const body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]);
...@@ -6135,7 +6135,7 @@ fn airTryPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -6135,7 +6135,7 @@ fn airTryPtr(self: *Self, inst: Air.Inst.Index) !void {
6135}6135}
61366136
6137fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {6137fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
6138 const mod = self.bin_file.options.module.?;6138 const mod = self.bin_file.comp.module.?;
61396139
6140 // If the type has no codegen bits, no need to store it.6140 // If the type has no codegen bits, no need to store it.
6141 const inst_ty = self.typeOf(inst);6141 const inst_ty = self.typeOf(inst);
...@@ -6200,7 +6200,7 @@ const CallMCValues = struct {...@@ -6200,7 +6200,7 @@ const CallMCValues = struct {
62006200
6201/// Caller must call `CallMCValues.deinit`.6201/// Caller must call `CallMCValues.deinit`.
6202fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {6202fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
6203 const mod = self.bin_file.options.module.?;6203 const mod = self.bin_file.comp.module.?;
6204 const ip = &mod.intern_pool;6204 const ip = &mod.intern_pool;
6205 const fn_info = mod.typeToFunc(fn_ty).?;6205 const fn_info = mod.typeToFunc(fn_ty).?;
6206 const cc = fn_info.cc;6206 const cc = fn_info.cc;
...@@ -6363,7 +6363,7 @@ fn parseRegName(name: []const u8) ?Register {...@@ -6363,7 +6363,7 @@ fn parseRegName(name: []const u8) ?Register {
6363}6363}
63646364
6365fn registerAlias(self: *Self, reg: Register, ty: Type) Register {6365fn registerAlias(self: *Self, reg: Register, ty: Type) Register {
6366 const mod = self.bin_file.options.module.?;6366 const mod = self.bin_file.comp.module.?;
6367 const abi_size = ty.abiSize(mod);6367 const abi_size = ty.abiSize(mod);
63686368
6369 switch (reg.class()) {6369 switch (reg.class()) {
...@@ -6392,11 +6392,11 @@ fn registerAlias(self: *Self, reg: Register, ty: Type) Register {...@@ -6392,11 +6392,11 @@ fn registerAlias(self: *Self, reg: Register, ty: Type) Register {
6392}6392}
63936393
6394fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {6394fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
6395 const mod = self.bin_file.options.module.?;6395 const mod = self.bin_file.comp.module.?;
6396 return self.air.typeOf(inst, &mod.intern_pool);6396 return self.air.typeOf(inst, &mod.intern_pool);
6397}6397}
63986398
6399fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {6399fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
6400 const mod = self.bin_file.options.module.?;6400 const mod = self.bin_file.comp.module.?;
6401 return self.air.typeOfIndex(inst, &mod.intern_pool);6401 return self.air.typeOfIndex(inst, &mod.intern_pool);
6402}6402}
src/arch/arm/CodeGen.zig+70-70
...@@ -260,7 +260,7 @@ const DbgInfoReloc = struct {...@@ -260,7 +260,7 @@ const DbgInfoReloc = struct {
260 }260 }
261261
262 fn genArgDbgInfo(reloc: DbgInfoReloc, function: Self) error{OutOfMemory}!void {262 fn genArgDbgInfo(reloc: DbgInfoReloc, function: Self) error{OutOfMemory}!void {
263 const mod = function.bin_file.options.module.?;263 const mod = function.bin_file.comp.module.?;
264 switch (function.debug_output) {264 switch (function.debug_output) {
265 .dwarf => |dw| {265 .dwarf => |dw| {
266 const loc: link.File.Dwarf.DeclState.DbgInfoLoc = switch (reloc.mcv) {266 const loc: link.File.Dwarf.DeclState.DbgInfoLoc = switch (reloc.mcv) {
...@@ -289,7 +289,7 @@ const DbgInfoReloc = struct {...@@ -289,7 +289,7 @@ const DbgInfoReloc = struct {
289 }289 }
290290
291 fn genVarDbgInfo(reloc: DbgInfoReloc, function: Self) !void {291 fn genVarDbgInfo(reloc: DbgInfoReloc, function: Self) !void {
292 const mod = function.bin_file.options.module.?;292 const mod = function.bin_file.comp.module.?;
293 const is_ptr = switch (reloc.tag) {293 const is_ptr = switch (reloc.tag) {
294 .dbg_var_ptr => true,294 .dbg_var_ptr => true,
295 .dbg_var_val => false,295 .dbg_var_val => false,
...@@ -348,7 +348,7 @@ pub fn generate(...@@ -348,7 +348,7 @@ pub fn generate(
348 @panic("Attempted to compile for architecture that was disabled by build configuration");348 @panic("Attempted to compile for architecture that was disabled by build configuration");
349 }349 }
350350
351 const mod = bin_file.options.module.?;351 const mod = bin_file.comp.module.?;
352 const func = mod.funcInfo(func_index);352 const func = mod.funcInfo(func_index);
353 const fn_owner_decl = mod.declPtr(func.owner_decl);353 const fn_owner_decl = mod.declPtr(func.owner_decl);
354 assert(fn_owner_decl.has_tv);354 assert(fn_owner_decl.has_tv);
...@@ -482,7 +482,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {...@@ -482,7 +482,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {
482}482}
483483
484fn gen(self: *Self) !void {484fn gen(self: *Self) !void {
485 const mod = self.bin_file.options.module.?;485 const mod = self.bin_file.comp.module.?;
486 const cc = self.fn_type.fnCallingConvention(mod);486 const cc = self.fn_type.fnCallingConvention(mod);
487 if (cc != .Naked) {487 if (cc != .Naked) {
488 // push {fp, lr}488 // push {fp, lr}
...@@ -642,7 +642,7 @@ fn gen(self: *Self) !void {...@@ -642,7 +642,7 @@ fn gen(self: *Self) !void {
642}642}
643643
644fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {644fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
645 const mod = self.bin_file.options.module.?;645 const mod = self.bin_file.comp.module.?;
646 const ip = &mod.intern_pool;646 const ip = &mod.intern_pool;
647 const air_tags = self.air.instructions.items(.tag);647 const air_tags = self.air.instructions.items(.tag);
648648
...@@ -1010,7 +1010,7 @@ fn allocMem(...@@ -1010,7 +1010,7 @@ fn allocMem(
10101010
1011/// Use a pointer instruction as the basis for allocating stack memory.1011/// Use a pointer instruction as the basis for allocating stack memory.
1012fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {1012fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
1013 const mod = self.bin_file.options.module.?;1013 const mod = self.bin_file.comp.module.?;
1014 const elem_ty = self.typeOfIndex(inst).childType(mod);1014 const elem_ty = self.typeOfIndex(inst).childType(mod);
10151015
1016 if (!elem_ty.hasRuntimeBits(mod)) {1016 if (!elem_ty.hasRuntimeBits(mod)) {
...@@ -1031,7 +1031,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {...@@ -1031,7 +1031,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
1031}1031}
10321032
1033fn allocRegOrMem(self: *Self, elem_ty: Type, reg_ok: bool, maybe_inst: ?Air.Inst.Index) !MCValue {1033fn allocRegOrMem(self: *Self, elem_ty: Type, reg_ok: bool, maybe_inst: ?Air.Inst.Index) !MCValue {
1034 const mod = self.bin_file.options.module.?;1034 const mod = self.bin_file.comp.module.?;
1035 const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {1035 const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {
1036 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});1036 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});
1037 };1037 };
...@@ -1118,7 +1118,7 @@ fn airAlloc(self: *Self, inst: Air.Inst.Index) !void {...@@ -1118,7 +1118,7 @@ fn airAlloc(self: *Self, inst: Air.Inst.Index) !void {
1118}1118}
11191119
1120fn airRetPtr(self: *Self, inst: Air.Inst.Index) !void {1120fn airRetPtr(self: *Self, inst: Air.Inst.Index) !void {
1121 const mod = self.bin_file.options.module.?;1121 const mod = self.bin_file.comp.module.?;
1122 const result: MCValue = switch (self.ret_mcv) {1122 const result: MCValue = switch (self.ret_mcv) {
1123 .none, .register => .{ .ptr_stack_offset = try self.allocMemPtr(inst) },1123 .none, .register => .{ .ptr_stack_offset = try self.allocMemPtr(inst) },
1124 .stack_offset => blk: {1124 .stack_offset => blk: {
...@@ -1151,7 +1151,7 @@ fn airFpext(self: *Self, inst: Air.Inst.Index) !void {...@@ -1151,7 +1151,7 @@ fn airFpext(self: *Self, inst: Air.Inst.Index) !void {
1151}1151}
11521152
1153fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {1153fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
1154 const mod = self.bin_file.options.module.?;1154 const mod = self.bin_file.comp.module.?;
1155 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;1155 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
1156 if (self.liveness.isUnused(inst))1156 if (self.liveness.isUnused(inst))
1157 return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });1157 return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });
...@@ -1217,7 +1217,7 @@ fn trunc(...@@ -1217,7 +1217,7 @@ fn trunc(
1217 operand_ty: Type,1217 operand_ty: Type,
1218 dest_ty: Type,1218 dest_ty: Type,
1219) !MCValue {1219) !MCValue {
1220 const mod = self.bin_file.options.module.?;1220 const mod = self.bin_file.comp.module.?;
1221 const info_a = operand_ty.intInfo(mod);1221 const info_a = operand_ty.intInfo(mod);
1222 const info_b = dest_ty.intInfo(mod);1222 const info_b = dest_ty.intInfo(mod);
12231223
...@@ -1281,7 +1281,7 @@ fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {...@@ -1281,7 +1281,7 @@ fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
12811281
1282fn airNot(self: *Self, inst: Air.Inst.Index) !void {1282fn airNot(self: *Self, inst: Air.Inst.Index) !void {
1283 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;1283 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
1284 const mod = self.bin_file.options.module.?;1284 const mod = self.bin_file.comp.module.?;
1285 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {1285 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
1286 const operand_bind: ReadArg.Bind = .{ .inst = ty_op.operand };1286 const operand_bind: ReadArg.Bind = .{ .inst = ty_op.operand };
1287 const operand_ty = self.typeOf(ty_op.operand);1287 const operand_ty = self.typeOf(ty_op.operand);
...@@ -1377,7 +1377,7 @@ fn minMax(...@@ -1377,7 +1377,7 @@ fn minMax(
1377 rhs_ty: Type,1377 rhs_ty: Type,
1378 maybe_inst: ?Air.Inst.Index,1378 maybe_inst: ?Air.Inst.Index,
1379) !MCValue {1379) !MCValue {
1380 const mod = self.bin_file.options.module.?;1380 const mod = self.bin_file.comp.module.?;
1381 switch (lhs_ty.zigTypeTag(mod)) {1381 switch (lhs_ty.zigTypeTag(mod)) {
1382 .Float => return self.fail("TODO ARM min/max on floats", .{}),1382 .Float => return self.fail("TODO ARM min/max on floats", .{}),
1383 .Vector => return self.fail("TODO ARM min/max on vectors", .{}),1383 .Vector => return self.fail("TODO ARM min/max on vectors", .{}),
...@@ -1586,7 +1586,7 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -1586,7 +1586,7 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void {
1586 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];1586 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
1587 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;1587 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
1588 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;1588 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
1589 const mod = self.bin_file.options.module.?;1589 const mod = self.bin_file.comp.module.?;
1590 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {1590 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
1591 const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };1591 const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };
1592 const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };1592 const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };
...@@ -1699,7 +1699,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -1699,7 +1699,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
1699 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;1699 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
1700 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;1700 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
1701 if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });1701 if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });
1702 const mod = self.bin_file.options.module.?;1702 const mod = self.bin_file.comp.module.?;
1703 const result: MCValue = result: {1703 const result: MCValue = result: {
1704 const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };1704 const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };
1705 const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };1705 const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };
...@@ -1863,7 +1863,7 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -1863,7 +1863,7 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
1863 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;1863 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
1864 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;1864 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
1865 if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });1865 if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });
1866 const mod = self.bin_file.options.module.?;1866 const mod = self.bin_file.comp.module.?;
1867 const result: MCValue = result: {1867 const result: MCValue = result: {
1868 const lhs_ty = self.typeOf(extra.lhs);1868 const lhs_ty = self.typeOf(extra.lhs);
1869 const rhs_ty = self.typeOf(extra.rhs);1869 const rhs_ty = self.typeOf(extra.rhs);
...@@ -2019,7 +2019,7 @@ fn airOptionalPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {...@@ -2019,7 +2019,7 @@ fn airOptionalPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
2019}2019}
20202020
2021fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {2021fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
2022 const mod = self.bin_file.options.module.?;2022 const mod = self.bin_file.comp.module.?;
2023 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2023 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2024 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2024 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2025 const optional_ty = self.typeOfIndex(inst);2025 const optional_ty = self.typeOfIndex(inst);
...@@ -2042,7 +2042,7 @@ fn errUnionErr(...@@ -2042,7 +2042,7 @@ fn errUnionErr(
2042 error_union_ty: Type,2042 error_union_ty: Type,
2043 maybe_inst: ?Air.Inst.Index,2043 maybe_inst: ?Air.Inst.Index,
2044) !MCValue {2044) !MCValue {
2045 const mod = self.bin_file.options.module.?;2045 const mod = self.bin_file.comp.module.?;
2046 const err_ty = error_union_ty.errorUnionSet(mod);2046 const err_ty = error_union_ty.errorUnionSet(mod);
2047 const payload_ty = error_union_ty.errorUnionPayload(mod);2047 const payload_ty = error_union_ty.errorUnionPayload(mod);
2048 if (err_ty.errorSetIsEmpty(mod)) {2048 if (err_ty.errorSetIsEmpty(mod)) {
...@@ -2119,7 +2119,7 @@ fn errUnionPayload(...@@ -2119,7 +2119,7 @@ fn errUnionPayload(
2119 error_union_ty: Type,2119 error_union_ty: Type,
2120 maybe_inst: ?Air.Inst.Index,2120 maybe_inst: ?Air.Inst.Index,
2121) !MCValue {2121) !MCValue {
2122 const mod = self.bin_file.options.module.?;2122 const mod = self.bin_file.comp.module.?;
2123 const err_ty = error_union_ty.errorUnionSet(mod);2123 const err_ty = error_union_ty.errorUnionSet(mod);
2124 const payload_ty = error_union_ty.errorUnionPayload(mod);2124 const payload_ty = error_union_ty.errorUnionPayload(mod);
2125 if (err_ty.errorSetIsEmpty(mod)) {2125 if (err_ty.errorSetIsEmpty(mod)) {
...@@ -2229,7 +2229,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {...@@ -2229,7 +2229,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {
22292229
2230/// T to E!T2230/// T to E!T
2231fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {2231fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
2232 const mod = self.bin_file.options.module.?;2232 const mod = self.bin_file.comp.module.?;
2233 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2233 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2234 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2234 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2235 const error_union_ty = ty_op.ty.toType();2235 const error_union_ty = ty_op.ty.toType();
...@@ -2253,7 +2253,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {...@@ -2253,7 +2253,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
22532253
2254/// E to E!T2254/// E to E!T
2255fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {2255fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
2256 const mod = self.bin_file.options.module.?;2256 const mod = self.bin_file.comp.module.?;
2257 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2257 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2258 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2258 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2259 const error_union_ty = ty_op.ty.toType();2259 const error_union_ty = ty_op.ty.toType();
...@@ -2370,7 +2370,7 @@ fn ptrElemVal(...@@ -2370,7 +2370,7 @@ fn ptrElemVal(
2370 ptr_ty: Type,2370 ptr_ty: Type,
2371 maybe_inst: ?Air.Inst.Index,2371 maybe_inst: ?Air.Inst.Index,
2372) !MCValue {2372) !MCValue {
2373 const mod = self.bin_file.options.module.?;2373 const mod = self.bin_file.comp.module.?;
2374 const elem_ty = ptr_ty.childType(mod);2374 const elem_ty = ptr_ty.childType(mod);
2375 const elem_size: u32 = @intCast(elem_ty.abiSize(mod));2375 const elem_size: u32 = @intCast(elem_ty.abiSize(mod));
23762376
...@@ -2429,7 +2429,7 @@ fn ptrElemVal(...@@ -2429,7 +2429,7 @@ fn ptrElemVal(
2429}2429}
24302430
2431fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {2431fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {
2432 const mod = self.bin_file.options.module.?;2432 const mod = self.bin_file.comp.module.?;
2433 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;2433 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
2434 const slice_ty = self.typeOf(bin_op.lhs);2434 const slice_ty = self.typeOf(bin_op.lhs);
2435 const result: MCValue = if (!slice_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {2435 const result: MCValue = if (!slice_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {
...@@ -2472,7 +2472,7 @@ fn arrayElemVal(...@@ -2472,7 +2472,7 @@ fn arrayElemVal(
2472 array_ty: Type,2472 array_ty: Type,
2473 maybe_inst: ?Air.Inst.Index,2473 maybe_inst: ?Air.Inst.Index,
2474) InnerError!MCValue {2474) InnerError!MCValue {
2475 const mod = self.bin_file.options.module.?;2475 const mod = self.bin_file.comp.module.?;
2476 const elem_ty = array_ty.childType(mod);2476 const elem_ty = array_ty.childType(mod);
24772477
2478 const mcv = try array_bind.resolveToMcv(self);2478 const mcv = try array_bind.resolveToMcv(self);
...@@ -2528,7 +2528,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -2528,7 +2528,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
2528}2528}
25292529
2530fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {2530fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
2531 const mod = self.bin_file.options.module.?;2531 const mod = self.bin_file.comp.module.?;
2532 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;2532 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
2533 const ptr_ty = self.typeOf(bin_op.lhs);2533 const ptr_ty = self.typeOf(bin_op.lhs);
2534 const result: MCValue = if (!ptr_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {2534 const result: MCValue = if (!ptr_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {
...@@ -2662,7 +2662,7 @@ fn reuseOperand(...@@ -2662,7 +2662,7 @@ fn reuseOperand(
2662}2662}
26632663
2664fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {2664fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {
2665 const mod = self.bin_file.options.module.?;2665 const mod = self.bin_file.comp.module.?;
2666 const elem_ty = ptr_ty.childType(mod);2666 const elem_ty = ptr_ty.childType(mod);
2667 const elem_size: u32 = @intCast(elem_ty.abiSize(mod));2667 const elem_size: u32 = @intCast(elem_ty.abiSize(mod));
26682668
...@@ -2739,7 +2739,7 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo...@@ -2739,7 +2739,7 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo
2739}2739}
27402740
2741fn airLoad(self: *Self, inst: Air.Inst.Index) !void {2741fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
2742 const mod = self.bin_file.options.module.?;2742 const mod = self.bin_file.comp.module.?;
2743 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2743 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2744 const elem_ty = self.typeOfIndex(inst);2744 const elem_ty = self.typeOfIndex(inst);
2745 const result: MCValue = result: {2745 const result: MCValue = result: {
...@@ -2768,7 +2768,7 @@ fn airLoad(self: *Self, inst: Air.Inst.Index) !void {...@@ -2768,7 +2768,7 @@ fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
2768}2768}
27692769
2770fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void {2770fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void {
2771 const mod = self.bin_file.options.module.?;2771 const mod = self.bin_file.comp.module.?;
2772 const elem_size: u32 = @intCast(value_ty.abiSize(mod));2772 const elem_size: u32 = @intCast(value_ty.abiSize(mod));
27732773
2774 switch (ptr) {2774 switch (ptr) {
...@@ -2888,7 +2888,7 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void {...@@ -2888,7 +2888,7 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void {
28882888
2889fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {2889fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {
2890 return if (self.liveness.isUnused(inst)) .dead else result: {2890 return if (self.liveness.isUnused(inst)) .dead else result: {
2891 const mod = self.bin_file.options.module.?;2891 const mod = self.bin_file.comp.module.?;
2892 const mcv = try self.resolveInst(operand);2892 const mcv = try self.resolveInst(operand);
2893 const ptr_ty = self.typeOf(operand);2893 const ptr_ty = self.typeOf(operand);
2894 const struct_ty = ptr_ty.childType(mod);2894 const struct_ty = ptr_ty.childType(mod);
...@@ -2912,7 +2912,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -2912,7 +2912,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
2912 const extra = self.air.extraData(Air.StructField, ty_pl.payload).data;2912 const extra = self.air.extraData(Air.StructField, ty_pl.payload).data;
2913 const operand = extra.struct_operand;2913 const operand = extra.struct_operand;
2914 const index = extra.field_index;2914 const index = extra.field_index;
2915 const mod = self.bin_file.options.module.?;2915 const mod = self.bin_file.comp.module.?;
2916 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2916 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2917 const mcv = try self.resolveInst(operand);2917 const mcv = try self.resolveInst(operand);
2918 const struct_ty = self.typeOf(operand);2918 const struct_ty = self.typeOf(operand);
...@@ -3002,7 +3002,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -3002,7 +3002,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
3002}3002}
30033003
3004fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {3004fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {
3005 const mod = self.bin_file.options.module.?;3005 const mod = self.bin_file.comp.module.?;
3006 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;3006 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
3007 const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;3007 const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;
3008 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {3008 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
...@@ -3396,7 +3396,7 @@ fn addSub(...@@ -3396,7 +3396,7 @@ fn addSub(
3396 rhs_ty: Type,3396 rhs_ty: Type,
3397 maybe_inst: ?Air.Inst.Index,3397 maybe_inst: ?Air.Inst.Index,
3398) InnerError!MCValue {3398) InnerError!MCValue {
3399 const mod = self.bin_file.options.module.?;3399 const mod = self.bin_file.comp.module.?;
3400 switch (lhs_ty.zigTypeTag(mod)) {3400 switch (lhs_ty.zigTypeTag(mod)) {
3401 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3401 .Float => return self.fail("TODO ARM binary operations on floats", .{}),
3402 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3402 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
...@@ -3452,7 +3452,7 @@ fn mul(...@@ -3452,7 +3452,7 @@ fn mul(
3452 rhs_ty: Type,3452 rhs_ty: Type,
3453 maybe_inst: ?Air.Inst.Index,3453 maybe_inst: ?Air.Inst.Index,
3454) InnerError!MCValue {3454) InnerError!MCValue {
3455 const mod = self.bin_file.options.module.?;3455 const mod = self.bin_file.comp.module.?;
3456 switch (lhs_ty.zigTypeTag(mod)) {3456 switch (lhs_ty.zigTypeTag(mod)) {
3457 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3457 .Float => return self.fail("TODO ARM binary operations on floats", .{}),
3458 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3458 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
...@@ -3485,7 +3485,7 @@ fn divFloat(...@@ -3485,7 +3485,7 @@ fn divFloat(
3485 _ = rhs_ty;3485 _ = rhs_ty;
3486 _ = maybe_inst;3486 _ = maybe_inst;
34873487
3488 const mod = self.bin_file.options.module.?;3488 const mod = self.bin_file.comp.module.?;
3489 switch (lhs_ty.zigTypeTag(mod)) {3489 switch (lhs_ty.zigTypeTag(mod)) {
3490 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3490 .Float => return self.fail("TODO ARM binary operations on floats", .{}),
3491 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3491 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
...@@ -3501,7 +3501,7 @@ fn divTrunc(...@@ -3501,7 +3501,7 @@ fn divTrunc(
3501 rhs_ty: Type,3501 rhs_ty: Type,
3502 maybe_inst: ?Air.Inst.Index,3502 maybe_inst: ?Air.Inst.Index,
3503) InnerError!MCValue {3503) InnerError!MCValue {
3504 const mod = self.bin_file.options.module.?;3504 const mod = self.bin_file.comp.module.?;
3505 switch (lhs_ty.zigTypeTag(mod)) {3505 switch (lhs_ty.zigTypeTag(mod)) {
3506 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3506 .Float => return self.fail("TODO ARM binary operations on floats", .{}),
3507 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3507 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
...@@ -3544,7 +3544,7 @@ fn divFloor(...@@ -3544,7 +3544,7 @@ fn divFloor(
3544 rhs_ty: Type,3544 rhs_ty: Type,
3545 maybe_inst: ?Air.Inst.Index,3545 maybe_inst: ?Air.Inst.Index,
3546) InnerError!MCValue {3546) InnerError!MCValue {
3547 const mod = self.bin_file.options.module.?;3547 const mod = self.bin_file.comp.module.?;
3548 switch (lhs_ty.zigTypeTag(mod)) {3548 switch (lhs_ty.zigTypeTag(mod)) {
3549 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3549 .Float => return self.fail("TODO ARM binary operations on floats", .{}),
3550 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3550 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
...@@ -3592,7 +3592,7 @@ fn divExact(...@@ -3592,7 +3592,7 @@ fn divExact(
3592 _ = rhs_ty;3592 _ = rhs_ty;
3593 _ = maybe_inst;3593 _ = maybe_inst;
35943594
3595 const mod = self.bin_file.options.module.?;3595 const mod = self.bin_file.comp.module.?;
3596 switch (lhs_ty.zigTypeTag(mod)) {3596 switch (lhs_ty.zigTypeTag(mod)) {
3597 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3597 .Float => return self.fail("TODO ARM binary operations on floats", .{}),
3598 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3598 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
...@@ -3609,7 +3609,7 @@ fn rem(...@@ -3609,7 +3609,7 @@ fn rem(
3609 rhs_ty: Type,3609 rhs_ty: Type,
3610 maybe_inst: ?Air.Inst.Index,3610 maybe_inst: ?Air.Inst.Index,
3611) InnerError!MCValue {3611) InnerError!MCValue {
3612 const mod = self.bin_file.options.module.?;3612 const mod = self.bin_file.comp.module.?;
3613 switch (lhs_ty.zigTypeTag(mod)) {3613 switch (lhs_ty.zigTypeTag(mod)) {
3614 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3614 .Float => return self.fail("TODO ARM binary operations on floats", .{}),
3615 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3615 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
...@@ -3678,7 +3678,7 @@ fn modulo(...@@ -3678,7 +3678,7 @@ fn modulo(
3678 _ = rhs_ty;3678 _ = rhs_ty;
3679 _ = maybe_inst;3679 _ = maybe_inst;
36803680
3681 const mod = self.bin_file.options.module.?;3681 const mod = self.bin_file.comp.module.?;
3682 switch (lhs_ty.zigTypeTag(mod)) {3682 switch (lhs_ty.zigTypeTag(mod)) {
3683 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3683 .Float => return self.fail("TODO ARM binary operations on floats", .{}),
3684 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3684 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
...@@ -3696,7 +3696,7 @@ fn wrappingArithmetic(...@@ -3696,7 +3696,7 @@ fn wrappingArithmetic(
3696 rhs_ty: Type,3696 rhs_ty: Type,
3697 maybe_inst: ?Air.Inst.Index,3697 maybe_inst: ?Air.Inst.Index,
3698) InnerError!MCValue {3698) InnerError!MCValue {
3699 const mod = self.bin_file.options.module.?;3699 const mod = self.bin_file.comp.module.?;
3700 switch (lhs_ty.zigTypeTag(mod)) {3700 switch (lhs_ty.zigTypeTag(mod)) {
3701 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3701 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3702 .Int => {3702 .Int => {
...@@ -3734,7 +3734,7 @@ fn bitwise(...@@ -3734,7 +3734,7 @@ fn bitwise(
3734 rhs_ty: Type,3734 rhs_ty: Type,
3735 maybe_inst: ?Air.Inst.Index,3735 maybe_inst: ?Air.Inst.Index,
3736) InnerError!MCValue {3736) InnerError!MCValue {
3737 const mod = self.bin_file.options.module.?;3737 const mod = self.bin_file.comp.module.?;
3738 switch (lhs_ty.zigTypeTag(mod)) {3738 switch (lhs_ty.zigTypeTag(mod)) {
3739 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3739 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3740 .Int => {3740 .Int => {
...@@ -3779,7 +3779,7 @@ fn shiftExact(...@@ -3779,7 +3779,7 @@ fn shiftExact(
3779 rhs_ty: Type,3779 rhs_ty: Type,
3780 maybe_inst: ?Air.Inst.Index,3780 maybe_inst: ?Air.Inst.Index,
3781) InnerError!MCValue {3781) InnerError!MCValue {
3782 const mod = self.bin_file.options.module.?;3782 const mod = self.bin_file.comp.module.?;
3783 switch (lhs_ty.zigTypeTag(mod)) {3783 switch (lhs_ty.zigTypeTag(mod)) {
3784 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3784 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3785 .Int => {3785 .Int => {
...@@ -3818,7 +3818,7 @@ fn shiftNormal(...@@ -3818,7 +3818,7 @@ fn shiftNormal(
3818 rhs_ty: Type,3818 rhs_ty: Type,
3819 maybe_inst: ?Air.Inst.Index,3819 maybe_inst: ?Air.Inst.Index,
3820) InnerError!MCValue {3820) InnerError!MCValue {
3821 const mod = self.bin_file.options.module.?;3821 const mod = self.bin_file.comp.module.?;
3822 switch (lhs_ty.zigTypeTag(mod)) {3822 switch (lhs_ty.zigTypeTag(mod)) {
3823 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3823 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3824 .Int => {3824 .Int => {
...@@ -3861,7 +3861,7 @@ fn booleanOp(...@@ -3861,7 +3861,7 @@ fn booleanOp(
3861 rhs_ty: Type,3861 rhs_ty: Type,
3862 maybe_inst: ?Air.Inst.Index,3862 maybe_inst: ?Air.Inst.Index,
3863) InnerError!MCValue {3863) InnerError!MCValue {
3864 const mod = self.bin_file.options.module.?;3864 const mod = self.bin_file.comp.module.?;
3865 switch (lhs_ty.zigTypeTag(mod)) {3865 switch (lhs_ty.zigTypeTag(mod)) {
3866 .Bool => {3866 .Bool => {
3867 const lhs_immediate = try lhs_bind.resolveToImmediate(self);3867 const lhs_immediate = try lhs_bind.resolveToImmediate(self);
...@@ -3895,7 +3895,7 @@ fn ptrArithmetic(...@@ -3895,7 +3895,7 @@ fn ptrArithmetic(
3895 rhs_ty: Type,3895 rhs_ty: Type,
3896 maybe_inst: ?Air.Inst.Index,3896 maybe_inst: ?Air.Inst.Index,
3897) InnerError!MCValue {3897) InnerError!MCValue {
3898 const mod = self.bin_file.options.module.?;3898 const mod = self.bin_file.comp.module.?;
3899 switch (lhs_ty.zigTypeTag(mod)) {3899 switch (lhs_ty.zigTypeTag(mod)) {
3900 .Pointer => {3900 .Pointer => {
3901 assert(rhs_ty.eql(Type.usize, mod));3901 assert(rhs_ty.eql(Type.usize, mod));
...@@ -3932,7 +3932,7 @@ fn ptrArithmetic(...@@ -3932,7 +3932,7 @@ fn ptrArithmetic(
3932}3932}
39333933
3934fn genLdrRegister(self: *Self, dest_reg: Register, addr_reg: Register, ty: Type) !void {3934fn genLdrRegister(self: *Self, dest_reg: Register, addr_reg: Register, ty: Type) !void {
3935 const mod = self.bin_file.options.module.?;3935 const mod = self.bin_file.comp.module.?;
3936 const abi_size = ty.abiSize(mod);3936 const abi_size = ty.abiSize(mod);
39373937
3938 const tag: Mir.Inst.Tag = switch (abi_size) {3938 const tag: Mir.Inst.Tag = switch (abi_size) {
...@@ -3967,7 +3967,7 @@ fn genLdrRegister(self: *Self, dest_reg: Register, addr_reg: Register, ty: Type)...@@ -3967,7 +3967,7 @@ fn genLdrRegister(self: *Self, dest_reg: Register, addr_reg: Register, ty: Type)
3967}3967}
39683968
3969fn genStrRegister(self: *Self, source_reg: Register, addr_reg: Register, ty: Type) !void {3969fn genStrRegister(self: *Self, source_reg: Register, addr_reg: Register, ty: Type) !void {
3970 const mod = self.bin_file.options.module.?;3970 const mod = self.bin_file.comp.module.?;
3971 const abi_size = ty.abiSize(mod);3971 const abi_size = ty.abiSize(mod);
39723972
3973 const tag: Mir.Inst.Tag = switch (abi_size) {3973 const tag: Mir.Inst.Tag = switch (abi_size) {
...@@ -4174,7 +4174,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {...@@ -4174,7 +4174,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {
4174 while (self.args[arg_index] == .none) arg_index += 1;4174 while (self.args[arg_index] == .none) arg_index += 1;
4175 self.arg_index = arg_index + 1;4175 self.arg_index = arg_index + 1;
41764176
4177 const mod = self.bin_file.options.module.?;4177 const mod = self.bin_file.comp.module.?;
4178 const ty = self.typeOfIndex(inst);4178 const ty = self.typeOfIndex(inst);
4179 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];4179 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
4180 const src_index = self.air.instructions.items(.data)[@intFromEnum(inst)].arg.src_index;4180 const src_index = self.air.instructions.items(.data)[@intFromEnum(inst)].arg.src_index;
...@@ -4229,7 +4229,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -4229,7 +4229,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
4229 const extra = self.air.extraData(Air.Call, pl_op.payload);4229 const extra = self.air.extraData(Air.Call, pl_op.payload);
4230 const args: []const Air.Inst.Ref = @ptrCast(self.air.extra[extra.end..][0..extra.data.args_len]);4230 const args: []const Air.Inst.Ref = @ptrCast(self.air.extra[extra.end..][0..extra.data.args_len]);
4231 const ty = self.typeOf(callee);4231 const ty = self.typeOf(callee);
4232 const mod = self.bin_file.options.module.?;4232 const mod = self.bin_file.comp.module.?;
42334233
4234 const fn_ty = switch (ty.zigTypeTag(mod)) {4234 const fn_ty = switch (ty.zigTypeTag(mod)) {
4235 .Fn => ty,4235 .Fn => ty,
...@@ -4380,7 +4380,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -4380,7 +4380,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
4380}4380}
43814381
4382fn airRet(self: *Self, inst: Air.Inst.Index) !void {4382fn airRet(self: *Self, inst: Air.Inst.Index) !void {
4383 const mod = self.bin_file.options.module.?;4383 const mod = self.bin_file.comp.module.?;
4384 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4384 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4385 const operand = try self.resolveInst(un_op);4385 const operand = try self.resolveInst(un_op);
4386 const ret_ty = self.fn_type.fnReturnType(mod);4386 const ret_ty = self.fn_type.fnReturnType(mod);
...@@ -4412,7 +4412,7 @@ fn airRet(self: *Self, inst: Air.Inst.Index) !void {...@@ -4412,7 +4412,7 @@ fn airRet(self: *Self, inst: Air.Inst.Index) !void {
4412}4412}
44134413
4414fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void {4414fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void {
4415 const mod = self.bin_file.options.module.?;4415 const mod = self.bin_file.comp.module.?;
4416 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4416 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4417 const ptr = try self.resolveInst(un_op);4417 const ptr = try self.resolveInst(un_op);
4418 const ptr_ty = self.typeOf(un_op);4418 const ptr_ty = self.typeOf(un_op);
...@@ -4473,7 +4473,7 @@ fn cmp(...@@ -4473,7 +4473,7 @@ fn cmp(
4473 lhs_ty: Type,4473 lhs_ty: Type,
4474 op: math.CompareOperator,4474 op: math.CompareOperator,
4475) !MCValue {4475) !MCValue {
4476 const mod = self.bin_file.options.module.?;4476 const mod = self.bin_file.comp.module.?;
4477 const int_ty = switch (lhs_ty.zigTypeTag(mod)) {4477 const int_ty = switch (lhs_ty.zigTypeTag(mod)) {
4478 .Optional => blk: {4478 .Optional => blk: {
4479 const payload_ty = lhs_ty.optionalChild(mod);4479 const payload_ty = lhs_ty.optionalChild(mod);
...@@ -4580,7 +4580,7 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void {...@@ -4580,7 +4580,7 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void {
45804580
4581fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {4581fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {
4582 const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;4582 const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;
4583 const mod = self.bin_file.options.module.?;4583 const mod = self.bin_file.comp.module.?;
4584 const func = mod.funcInfo(ty_fn.func);4584 const func = mod.funcInfo(ty_fn.func);
4585 // TODO emit debug info for function change4585 // TODO emit debug info for function change
4586 _ = func;4586 _ = func;
...@@ -4795,7 +4795,7 @@ fn isNull(...@@ -4795,7 +4795,7 @@ fn isNull(
4795 operand_bind: ReadArg.Bind,4795 operand_bind: ReadArg.Bind,
4796 operand_ty: Type,4796 operand_ty: Type,
4797) !MCValue {4797) !MCValue {
4798 const mod = self.bin_file.options.module.?;4798 const mod = self.bin_file.comp.module.?;
4799 if (operand_ty.isPtrLikeOptional(mod)) {4799 if (operand_ty.isPtrLikeOptional(mod)) {
4800 assert(operand_ty.abiSize(mod) == 4);4800 assert(operand_ty.abiSize(mod) == 4);
48014801
...@@ -4829,7 +4829,7 @@ fn airIsNull(self: *Self, inst: Air.Inst.Index) !void {...@@ -4829,7 +4829,7 @@ fn airIsNull(self: *Self, inst: Air.Inst.Index) !void {
4829}4829}
48304830
4831fn airIsNullPtr(self: *Self, inst: Air.Inst.Index) !void {4831fn airIsNullPtr(self: *Self, inst: Air.Inst.Index) !void {
4832 const mod = self.bin_file.options.module.?;4832 const mod = self.bin_file.comp.module.?;
4833 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4833 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4834 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {4834 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
4835 const operand_ptr = try self.resolveInst(un_op);4835 const operand_ptr = try self.resolveInst(un_op);
...@@ -4856,7 +4856,7 @@ fn airIsNonNull(self: *Self, inst: Air.Inst.Index) !void {...@@ -4856,7 +4856,7 @@ fn airIsNonNull(self: *Self, inst: Air.Inst.Index) !void {
4856}4856}
48574857
4858fn airIsNonNullPtr(self: *Self, inst: Air.Inst.Index) !void {4858fn airIsNonNullPtr(self: *Self, inst: Air.Inst.Index) !void {
4859 const mod = self.bin_file.options.module.?;4859 const mod = self.bin_file.comp.module.?;
4860 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4860 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4861 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {4861 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
4862 const operand_ptr = try self.resolveInst(un_op);4862 const operand_ptr = try self.resolveInst(un_op);
...@@ -4876,7 +4876,7 @@ fn isErr(...@@ -4876,7 +4876,7 @@ fn isErr(
4876 error_union_bind: ReadArg.Bind,4876 error_union_bind: ReadArg.Bind,
4877 error_union_ty: Type,4877 error_union_ty: Type,
4878) !MCValue {4878) !MCValue {
4879 const mod = self.bin_file.options.module.?;4879 const mod = self.bin_file.comp.module.?;
4880 const error_type = error_union_ty.errorUnionSet(mod);4880 const error_type = error_union_ty.errorUnionSet(mod);
48814881
4882 if (error_type.errorSetIsEmpty(mod)) {4882 if (error_type.errorSetIsEmpty(mod)) {
...@@ -4918,7 +4918,7 @@ fn airIsErr(self: *Self, inst: Air.Inst.Index) !void {...@@ -4918,7 +4918,7 @@ fn airIsErr(self: *Self, inst: Air.Inst.Index) !void {
4918}4918}
49194919
4920fn airIsErrPtr(self: *Self, inst: Air.Inst.Index) !void {4920fn airIsErrPtr(self: *Self, inst: Air.Inst.Index) !void {
4921 const mod = self.bin_file.options.module.?;4921 const mod = self.bin_file.comp.module.?;
4922 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4922 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4923 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {4923 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
4924 const operand_ptr = try self.resolveInst(un_op);4924 const operand_ptr = try self.resolveInst(un_op);
...@@ -4945,7 +4945,7 @@ fn airIsNonErr(self: *Self, inst: Air.Inst.Index) !void {...@@ -4945,7 +4945,7 @@ fn airIsNonErr(self: *Self, inst: Air.Inst.Index) !void {
4945}4945}
49464946
4947fn airIsNonErrPtr(self: *Self, inst: Air.Inst.Index) !void {4947fn airIsNonErrPtr(self: *Self, inst: Air.Inst.Index) !void {
4948 const mod = self.bin_file.options.module.?;4948 const mod = self.bin_file.comp.module.?;
4949 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4949 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4950 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {4950 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
4951 const operand_ptr = try self.resolveInst(un_op);4951 const operand_ptr = try self.resolveInst(un_op);
...@@ -5160,7 +5160,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void {...@@ -5160,7 +5160,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void {
5160}5160}
51615161
5162fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {5162fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {
5163 const mod = self.bin_file.options.module.?;5163 const mod = self.bin_file.comp.module.?;
5164 const block_data = self.blocks.getPtr(block).?;5164 const block_data = self.blocks.getPtr(block).?;
51655165
5166 if (self.typeOf(operand).hasRuntimeBits(mod)) {5166 if (self.typeOf(operand).hasRuntimeBits(mod)) {
...@@ -5331,7 +5331,7 @@ fn setRegOrMem(self: *Self, ty: Type, loc: MCValue, val: MCValue) !void {...@@ -5331,7 +5331,7 @@ fn setRegOrMem(self: *Self, ty: Type, loc: MCValue, val: MCValue) !void {
5331}5331}
53325332
5333fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {5333fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {
5334 const mod = self.bin_file.options.module.?;5334 const mod = self.bin_file.comp.module.?;
5335 const abi_size: u32 = @intCast(ty.abiSize(mod));5335 const abi_size: u32 = @intCast(ty.abiSize(mod));
5336 switch (mcv) {5336 switch (mcv) {
5337 .dead => unreachable,5337 .dead => unreachable,
...@@ -5493,7 +5493,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro...@@ -5493,7 +5493,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
5493}5493}
54945494
5495fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void {5495fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void {
5496 const mod = self.bin_file.options.module.?;5496 const mod = self.bin_file.comp.module.?;
5497 switch (mcv) {5497 switch (mcv) {
5498 .dead => unreachable,5498 .dead => unreachable,
5499 .unreach, .none => return, // Nothing to do.5499 .unreach, .none => return, // Nothing to do.
...@@ -5740,7 +5740,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void...@@ -5740,7 +5740,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
5740}5740}
57415741
5742fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {5742fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {
5743 const mod = self.bin_file.options.module.?;5743 const mod = self.bin_file.comp.module.?;
5744 const abi_size: u32 = @intCast(ty.abiSize(mod));5744 const abi_size: u32 = @intCast(ty.abiSize(mod));
5745 switch (mcv) {5745 switch (mcv) {
5746 .dead => unreachable,5746 .dead => unreachable,
...@@ -5896,7 +5896,7 @@ fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {...@@ -5896,7 +5896,7 @@ fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {
5896}5896}
58975897
5898fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {5898fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
5899 const mod = self.bin_file.options.module.?;5899 const mod = self.bin_file.comp.module.?;
5900 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5900 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
5901 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {5901 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
5902 const ptr_ty = self.typeOf(ty_op.operand);5902 const ptr_ty = self.typeOf(ty_op.operand);
...@@ -6015,7 +6015,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {...@@ -6015,7 +6015,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {
6015}6015}
60166016
6017fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {6017fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
6018 const mod = self.bin_file.options.module.?;6018 const mod = self.bin_file.comp.module.?;
6019 const vector_ty = self.typeOfIndex(inst);6019 const vector_ty = self.typeOfIndex(inst);
6020 const len = vector_ty.vectorLen(mod);6020 const len = vector_ty.vectorLen(mod);
6021 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;6021 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
...@@ -6066,7 +6066,7 @@ fn airTry(self: *Self, inst: Air.Inst.Index) !void {...@@ -6066,7 +6066,7 @@ fn airTry(self: *Self, inst: Air.Inst.Index) !void {
6066 const result: MCValue = result: {6066 const result: MCValue = result: {
6067 const error_union_bind: ReadArg.Bind = .{ .inst = pl_op.operand };6067 const error_union_bind: ReadArg.Bind = .{ .inst = pl_op.operand };
6068 const error_union_ty = self.typeOf(pl_op.operand);6068 const error_union_ty = self.typeOf(pl_op.operand);
6069 const mod = self.bin_file.options.module.?;6069 const mod = self.bin_file.comp.module.?;
6070 const error_union_size: u32 = @intCast(error_union_ty.abiSize(mod));6070 const error_union_size: u32 = @intCast(error_union_ty.abiSize(mod));
6071 const error_union_align = error_union_ty.abiAlignment(mod);6071 const error_union_align = error_union_ty.abiAlignment(mod);
60726072
...@@ -6097,7 +6097,7 @@ fn airTryPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -6097,7 +6097,7 @@ fn airTryPtr(self: *Self, inst: Air.Inst.Index) !void {
6097}6097}
60986098
6099fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {6099fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
6100 const mod = self.bin_file.options.module.?;6100 const mod = self.bin_file.comp.module.?;
61016101
6102 // If the type has no codegen bits, no need to store it.6102 // If the type has no codegen bits, no need to store it.
6103 const inst_ty = self.typeOf(inst);6103 const inst_ty = self.typeOf(inst);
...@@ -6125,7 +6125,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) MCValue {...@@ -6125,7 +6125,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) MCValue {
6125}6125}
61266126
6127fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {6127fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
6128 const mod = self.bin_file.options.module.?;6128 const mod = self.bin_file.comp.module.?;
6129 const mcv: MCValue = switch (try codegen.genTypedValue(6129 const mcv: MCValue = switch (try codegen.genTypedValue(
6130 self.bin_file,6130 self.bin_file,
6131 self.src_loc,6131 self.src_loc,
...@@ -6161,7 +6161,7 @@ const CallMCValues = struct {...@@ -6161,7 +6161,7 @@ const CallMCValues = struct {
61616161
6162/// Caller must call `CallMCValues.deinit`.6162/// Caller must call `CallMCValues.deinit`.
6163fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {6163fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
6164 const mod = self.bin_file.options.module.?;6164 const mod = self.bin_file.comp.module.?;
6165 const ip = &mod.intern_pool;6165 const ip = &mod.intern_pool;
6166 const fn_info = mod.typeToFunc(fn_ty).?;6166 const fn_info = mod.typeToFunc(fn_ty).?;
6167 const cc = fn_info.cc;6167 const cc = fn_info.cc;
...@@ -6312,11 +6312,11 @@ fn parseRegName(name: []const u8) ?Register {...@@ -6312,11 +6312,11 @@ fn parseRegName(name: []const u8) ?Register {
6312}6312}
63136313
6314fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {6314fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
6315 const mod = self.bin_file.options.module.?;6315 const mod = self.bin_file.comp.module.?;
6316 return self.air.typeOf(inst, &mod.intern_pool);6316 return self.air.typeOf(inst, &mod.intern_pool);
6317}6317}
63186318
6319fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {6319fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
6320 const mod = self.bin_file.options.module.?;6320 const mod = self.bin_file.comp.module.?;
6321 return self.air.typeOfIndex(inst, &mod.intern_pool);6321 return self.air.typeOfIndex(inst, &mod.intern_pool);
6322}6322}
src/arch/riscv64/CodeGen.zig+22-22
...@@ -229,7 +229,7 @@ pub fn generate(...@@ -229,7 +229,7 @@ pub fn generate(
229 @panic("Attempted to compile for architecture that was disabled by build configuration");229 @panic("Attempted to compile for architecture that was disabled by build configuration");
230 }230 }
231231
232 const mod = bin_file.options.module.?;232 const mod = bin_file.comp.module.?;
233 const func = mod.funcInfo(func_index);233 const func = mod.funcInfo(func_index);
234 const fn_owner_decl = mod.declPtr(func.owner_decl);234 const fn_owner_decl = mod.declPtr(func.owner_decl);
235 assert(fn_owner_decl.has_tv);235 assert(fn_owner_decl.has_tv);
...@@ -350,7 +350,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {...@@ -350,7 +350,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {
350}350}
351351
352fn gen(self: *Self) !void {352fn gen(self: *Self) !void {
353 const mod = self.bin_file.options.module.?;353 const mod = self.bin_file.comp.module.?;
354 const cc = self.fn_type.fnCallingConvention(mod);354 const cc = self.fn_type.fnCallingConvention(mod);
355 if (cc != .Naked) {355 if (cc != .Naked) {
356 // TODO Finish function prologue and epilogue for riscv64.356 // TODO Finish function prologue and epilogue for riscv64.
...@@ -474,7 +474,7 @@ fn gen(self: *Self) !void {...@@ -474,7 +474,7 @@ fn gen(self: *Self) !void {
474}474}
475475
476fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {476fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
477 const mod = self.bin_file.options.module.?;477 const mod = self.bin_file.comp.module.?;
478 const ip = &mod.intern_pool;478 const ip = &mod.intern_pool;
479 const air_tags = self.air.instructions.items(.tag);479 const air_tags = self.air.instructions.items(.tag);
480480
...@@ -805,7 +805,7 @@ fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: Alignme...@@ -805,7 +805,7 @@ fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: Alignme
805805
806/// Use a pointer instruction as the basis for allocating stack memory.806/// Use a pointer instruction as the basis for allocating stack memory.
807fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {807fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
808 const mod = self.bin_file.options.module.?;808 const mod = self.bin_file.comp.module.?;
809 const elem_ty = self.typeOfIndex(inst).childType(mod);809 const elem_ty = self.typeOfIndex(inst).childType(mod);
810 const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {810 const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {
811 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});811 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});
...@@ -816,7 +816,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {...@@ -816,7 +816,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
816}816}
817817
818fn allocRegOrMem(self: *Self, inst: Air.Inst.Index, reg_ok: bool) !MCValue {818fn allocRegOrMem(self: *Self, inst: Air.Inst.Index, reg_ok: bool) !MCValue {
819 const mod = self.bin_file.options.module.?;819 const mod = self.bin_file.comp.module.?;
820 const elem_ty = self.typeOfIndex(inst);820 const elem_ty = self.typeOfIndex(inst);
821 const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {821 const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {
822 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});822 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});
...@@ -893,7 +893,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {...@@ -893,7 +893,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
893 if (self.liveness.isUnused(inst))893 if (self.liveness.isUnused(inst))
894 return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });894 return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });
895895
896 const mod = self.bin_file.options.module.?;896 const mod = self.bin_file.comp.module.?;
897 const operand_ty = self.typeOf(ty_op.operand);897 const operand_ty = self.typeOf(ty_op.operand);
898 const operand = try self.resolveInst(ty_op.operand);898 const operand = try self.resolveInst(ty_op.operand);
899 const info_a = operand_ty.intInfo(mod);899 const info_a = operand_ty.intInfo(mod);
...@@ -1069,7 +1069,7 @@ fn binOp(...@@ -1069,7 +1069,7 @@ fn binOp(
1069 lhs_ty: Type,1069 lhs_ty: Type,
1070 rhs_ty: Type,1070 rhs_ty: Type,
1071) InnerError!MCValue {1071) InnerError!MCValue {
1072 const mod = self.bin_file.options.module.?;1072 const mod = self.bin_file.comp.module.?;
1073 switch (tag) {1073 switch (tag) {
1074 // Arithmetic operations on integers and floats1074 // Arithmetic operations on integers and floats
1075 .add,1075 .add,
...@@ -1332,7 +1332,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {...@@ -1332,7 +1332,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {
1332fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {1332fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
1333 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;1333 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
1334 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {1334 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
1335 const mod = self.bin_file.options.module.?;1335 const mod = self.bin_file.comp.module.?;
1336 const optional_ty = self.typeOfIndex(inst);1336 const optional_ty = self.typeOfIndex(inst);
13371337
1338 // Optional with a zero-bit payload type is just a boolean true1338 // Optional with a zero-bit payload type is just a boolean true
...@@ -1506,7 +1506,7 @@ fn reuseOperand(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, op_ind...@@ -1506,7 +1506,7 @@ fn reuseOperand(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, op_ind
1506}1506}
15071507
1508fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {1508fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {
1509 const mod = self.bin_file.options.module.?;1509 const mod = self.bin_file.comp.module.?;
1510 const elem_ty = ptr_ty.childType(mod);1510 const elem_ty = ptr_ty.childType(mod);
1511 switch (ptr) {1511 switch (ptr) {
1512 .none => unreachable,1512 .none => unreachable,
...@@ -1532,7 +1532,7 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo...@@ -1532,7 +1532,7 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo
1532}1532}
15331533
1534fn airLoad(self: *Self, inst: Air.Inst.Index) !void {1534fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
1535 const mod = self.bin_file.options.module.?;1535 const mod = self.bin_file.comp.module.?;
1536 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;1536 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
1537 const elem_ty = self.typeOfIndex(inst);1537 const elem_ty = self.typeOfIndex(inst);
1538 const result: MCValue = result: {1538 const result: MCValue = result: {
...@@ -1633,7 +1633,7 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -1633,7 +1633,7 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {
1633}1633}
16341634
1635fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue) !void {1635fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue) !void {
1636 const mod = self.bin_file.options.module.?;1636 const mod = self.bin_file.comp.module.?;
1637 const arg = self.air.instructions.items(.data)[@intFromEnum(inst)].arg;1637 const arg = self.air.instructions.items(.data)[@intFromEnum(inst)].arg;
1638 const ty = arg.ty.toType();1638 const ty = arg.ty.toType();
1639 const owner_decl = mod.funcOwnerDeclIndex(self.func_index);1639 const owner_decl = mod.funcOwnerDeclIndex(self.func_index);
...@@ -1710,7 +1710,7 @@ fn airFence(self: *Self) !void {...@@ -1710,7 +1710,7 @@ fn airFence(self: *Self) !void {
1710}1710}
17111711
1712fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier) !void {1712fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier) !void {
1713 const mod = self.bin_file.options.module.?;1713 const mod = self.bin_file.comp.module.?;
1714 if (modifier == .always_tail) return self.fail("TODO implement tail calls for riscv64", .{});1714 if (modifier == .always_tail) return self.fail("TODO implement tail calls for riscv64", .{});
1715 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;1715 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
1716 const fn_ty = self.typeOf(pl_op.operand);1716 const fn_ty = self.typeOf(pl_op.operand);
...@@ -1812,7 +1812,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -1812,7 +1812,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
1812}1812}
18131813
1814fn ret(self: *Self, mcv: MCValue) !void {1814fn ret(self: *Self, mcv: MCValue) !void {
1815 const mod = self.bin_file.options.module.?;1815 const mod = self.bin_file.comp.module.?;
1816 const ret_ty = self.fn_type.fnReturnType(mod);1816 const ret_ty = self.fn_type.fnReturnType(mod);
1817 try self.setRegOrMem(ret_ty, self.ret_mcv, mcv);1817 try self.setRegOrMem(ret_ty, self.ret_mcv, mcv);
1818 // Just add space for an instruction, patch this later1818 // Just add space for an instruction, patch this later
...@@ -1843,7 +1843,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {...@@ -1843,7 +1843,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
1843 if (self.liveness.isUnused(inst))1843 if (self.liveness.isUnused(inst))
1844 return self.finishAir(inst, .dead, .{ bin_op.lhs, bin_op.rhs, .none });1844 return self.finishAir(inst, .dead, .{ bin_op.lhs, bin_op.rhs, .none });
1845 const ty = self.typeOf(bin_op.lhs);1845 const ty = self.typeOf(bin_op.lhs);
1846 const mod = self.bin_file.options.module.?;1846 const mod = self.bin_file.comp.module.?;
1847 assert(ty.eql(self.typeOf(bin_op.rhs), mod));1847 assert(ty.eql(self.typeOf(bin_op.rhs), mod));
1848 if (ty.zigTypeTag(mod) == .ErrorSet)1848 if (ty.zigTypeTag(mod) == .ErrorSet)
1849 return self.fail("TODO implement cmp for errors", .{});1849 return self.fail("TODO implement cmp for errors", .{});
...@@ -1887,7 +1887,7 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void {...@@ -1887,7 +1887,7 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void {
18871887
1888fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {1888fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {
1889 const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;1889 const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;
1890 const mod = self.bin_file.options.module.?;1890 const mod = self.bin_file.comp.module.?;
1891 const func = mod.funcInfo(ty_fn.func);1891 const func = mod.funcInfo(ty_fn.func);
1892 // TODO emit debug info for function change1892 // TODO emit debug info for function change
1893 _ = func;1893 _ = func;
...@@ -2125,7 +2125,7 @@ fn airBoolOp(self: *Self, inst: Air.Inst.Index) !void {...@@ -2125,7 +2125,7 @@ fn airBoolOp(self: *Self, inst: Air.Inst.Index) !void {
2125fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {2125fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {
2126 const block_data = self.blocks.getPtr(block).?;2126 const block_data = self.blocks.getPtr(block).?;
21272127
2128 const mod = self.bin_file.options.module.?;2128 const mod = self.bin_file.comp.module.?;
2129 if (self.typeOf(operand).hasRuntimeBits(mod)) {2129 if (self.typeOf(operand).hasRuntimeBits(mod)) {
2130 const operand_mcv = try self.resolveInst(operand);2130 const operand_mcv = try self.resolveInst(operand);
2131 const block_mcv = block_data.mcv;2131 const block_mcv = block_data.mcv;
...@@ -2508,7 +2508,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {...@@ -2508,7 +2508,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {
2508}2508}
25092509
2510fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {2510fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
2511 const mod = self.bin_file.options.module.?;2511 const mod = self.bin_file.comp.module.?;
2512 const vector_ty = self.typeOfIndex(inst);2512 const vector_ty = self.typeOfIndex(inst);
2513 const len = vector_ty.vectorLen(mod);2513 const len = vector_ty.vectorLen(mod);
2514 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;2514 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
...@@ -2553,7 +2553,7 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {...@@ -2553,7 +2553,7 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {
2553}2553}
25542554
2555fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {2555fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
2556 const mod = self.bin_file.options.module.?;2556 const mod = self.bin_file.comp.module.?;
25572557
2558 // If the type has no codegen bits, no need to store it.2558 // If the type has no codegen bits, no need to store it.
2559 const inst_ty = self.typeOf(inst);2559 const inst_ty = self.typeOf(inst);
...@@ -2581,7 +2581,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) MCValue {...@@ -2581,7 +2581,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) MCValue {
2581}2581}
25822582
2583fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue {2583fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue {
2584 const mod = self.bin_file.options.module.?;2584 const mod = self.bin_file.comp.module.?;
2585 const mcv: MCValue = switch (try codegen.genTypedValue(2585 const mcv: MCValue = switch (try codegen.genTypedValue(
2586 self.bin_file,2586 self.bin_file,
2587 self.src_loc,2587 self.src_loc,
...@@ -2617,7 +2617,7 @@ const CallMCValues = struct {...@@ -2617,7 +2617,7 @@ const CallMCValues = struct {
26172617
2618/// Caller must call `CallMCValues.deinit`.2618/// Caller must call `CallMCValues.deinit`.
2619fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {2619fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
2620 const mod = self.bin_file.options.module.?;2620 const mod = self.bin_file.comp.module.?;
2621 const ip = &mod.intern_pool;2621 const ip = &mod.intern_pool;
2622 const fn_info = mod.typeToFunc(fn_ty).?;2622 const fn_info = mod.typeToFunc(fn_ty).?;
2623 const cc = fn_info.cc;2623 const cc = fn_info.cc;
...@@ -2739,11 +2739,11 @@ fn parseRegName(name: []const u8) ?Register {...@@ -2739,11 +2739,11 @@ fn parseRegName(name: []const u8) ?Register {
2739}2739}
27402740
2741fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {2741fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
2742 const mod = self.bin_file.options.module.?;2742 const mod = self.bin_file.comp.module.?;
2743 return self.air.typeOf(inst, &mod.intern_pool);2743 return self.air.typeOf(inst, &mod.intern_pool);
2744}2744}
27452745
2746fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {2746fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
2747 const mod = self.bin_file.options.module.?;2747 const mod = self.bin_file.comp.module.?;
2748 return self.air.typeOfIndex(inst, &mod.intern_pool);2748 return self.air.typeOfIndex(inst, &mod.intern_pool);
2749}2749}
src/arch/sparc64/CodeGen.zig+43-43
...@@ -272,7 +272,7 @@ pub fn generate(...@@ -272,7 +272,7 @@ pub fn generate(
272 @panic("Attempted to compile for architecture that was disabled by build configuration");272 @panic("Attempted to compile for architecture that was disabled by build configuration");
273 }273 }
274274
275 const mod = bin_file.options.module.?;275 const mod = bin_file.comp.module.?;
276 const func = mod.funcInfo(func_index);276 const func = mod.funcInfo(func_index);
277 const fn_owner_decl = mod.declPtr(func.owner_decl);277 const fn_owner_decl = mod.declPtr(func.owner_decl);
278 assert(fn_owner_decl.has_tv);278 assert(fn_owner_decl.has_tv);
...@@ -364,7 +364,7 @@ pub fn generate(...@@ -364,7 +364,7 @@ pub fn generate(
364}364}
365365
366fn gen(self: *Self) !void {366fn gen(self: *Self) !void {
367 const mod = self.bin_file.options.module.?;367 const mod = self.bin_file.comp.module.?;
368 const cc = self.fn_type.fnCallingConvention(mod);368 const cc = self.fn_type.fnCallingConvention(mod);
369 if (cc != .Naked) {369 if (cc != .Naked) {
370 // TODO Finish function prologue and epilogue for sparc64.370 // TODO Finish function prologue and epilogue for sparc64.
...@@ -492,7 +492,7 @@ fn gen(self: *Self) !void {...@@ -492,7 +492,7 @@ fn gen(self: *Self) !void {
492}492}
493493
494fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {494fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
495 const mod = self.bin_file.options.module.?;495 const mod = self.bin_file.comp.module.?;
496 const ip = &mod.intern_pool;496 const ip = &mod.intern_pool;
497 const air_tags = self.air.instructions.items(.tag);497 const air_tags = self.air.instructions.items(.tag);
498498
...@@ -762,7 +762,7 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -762,7 +762,7 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
762 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];762 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
763 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;763 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
764 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;764 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
765 const mod = self.bin_file.options.module.?;765 const mod = self.bin_file.comp.module.?;
766 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {766 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
767 const lhs = try self.resolveInst(extra.lhs);767 const lhs = try self.resolveInst(extra.lhs);
768 const rhs = try self.resolveInst(extra.rhs);768 const rhs = try self.resolveInst(extra.rhs);
...@@ -840,7 +840,7 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -840,7 +840,7 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
840}840}
841841
842fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {842fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
843 const mod = self.bin_file.options.module.?;843 const mod = self.bin_file.comp.module.?;
844 const vector_ty = self.typeOfIndex(inst);844 const vector_ty = self.typeOfIndex(inst);
845 const len = vector_ty.vectorLen(mod);845 const len = vector_ty.vectorLen(mod);
846 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;846 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
...@@ -874,7 +874,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -874,7 +874,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
874}874}
875875
876fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {876fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
877 const mod = self.bin_file.options.module.?;877 const mod = self.bin_file.comp.module.?;
878 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;878 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
879 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {879 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
880 const ptr_ty = self.typeOf(ty_op.operand);880 const ptr_ty = self.typeOf(ty_op.operand);
...@@ -1011,7 +1011,7 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {...@@ -1011,7 +1011,7 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
1011}1011}
10121012
1013fn airArg(self: *Self, inst: Air.Inst.Index) !void {1013fn airArg(self: *Self, inst: Air.Inst.Index) !void {
1014 const mod = self.bin_file.options.module.?;1014 const mod = self.bin_file.comp.module.?;
1015 const arg_index = self.arg_index;1015 const arg_index = self.arg_index;
1016 self.arg_index += 1;1016 self.arg_index += 1;
10171017
...@@ -1206,7 +1206,7 @@ fn airBreakpoint(self: *Self) !void {...@@ -1206,7 +1206,7 @@ fn airBreakpoint(self: *Self) !void {
1206}1206}
12071207
1208fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void {1208fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void {
1209 const mod = self.bin_file.options.module.?;1209 const mod = self.bin_file.comp.module.?;
1210 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;1210 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
12111211
1212 // We have hardware byteswapper in SPARCv9, don't let mainstream compilers mislead you.1212 // We have hardware byteswapper in SPARCv9, don't let mainstream compilers mislead you.
...@@ -1298,7 +1298,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -1298,7 +1298,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
1298 const extra = self.air.extraData(Air.Call, pl_op.payload);1298 const extra = self.air.extraData(Air.Call, pl_op.payload);
1299 const args = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[extra.end .. extra.end + extra.data.args_len]));1299 const args = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[extra.end .. extra.end + extra.data.args_len]));
1300 const ty = self.typeOf(callee);1300 const ty = self.typeOf(callee);
1301 const mod = self.bin_file.options.module.?;1301 const mod = self.bin_file.comp.module.?;
1302 const fn_ty = switch (ty.zigTypeTag(mod)) {1302 const fn_ty = switch (ty.zigTypeTag(mod)) {
1303 .Fn => ty,1303 .Fn => ty,
1304 .Pointer => ty.childType(mod),1304 .Pointer => ty.childType(mod),
...@@ -1430,7 +1430,7 @@ fn airClz(self: *Self, inst: Air.Inst.Index) !void {...@@ -1430,7 +1430,7 @@ fn airClz(self: *Self, inst: Air.Inst.Index) !void {
14301430
1431fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {1431fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
1432 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;1432 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
1433 const mod = self.bin_file.options.module.?;1433 const mod = self.bin_file.comp.module.?;
1434 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {1434 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
1435 const lhs = try self.resolveInst(bin_op.lhs);1435 const lhs = try self.resolveInst(bin_op.lhs);
1436 const rhs = try self.resolveInst(bin_op.rhs);1436 const rhs = try self.resolveInst(bin_op.rhs);
...@@ -1662,7 +1662,7 @@ fn airDbgBlock(self: *Self, inst: Air.Inst.Index) !void {...@@ -1662,7 +1662,7 @@ fn airDbgBlock(self: *Self, inst: Air.Inst.Index) !void {
16621662
1663fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {1663fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {
1664 const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;1664 const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;
1665 const mod = self.bin_file.options.module.?;1665 const mod = self.bin_file.comp.module.?;
1666 const func = mod.funcInfo(ty_fn.func);1666 const func = mod.funcInfo(ty_fn.func);
1667 // TODO emit debug info for function change1667 // TODO emit debug info for function change
1668 _ = func;1668 _ = func;
...@@ -1758,7 +1758,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {...@@ -1758,7 +1758,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
1758 if (self.liveness.isUnused(inst))1758 if (self.liveness.isUnused(inst))
1759 return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });1759 return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });
17601760
1761 const mod = self.bin_file.options.module.?;1761 const mod = self.bin_file.comp.module.?;
1762 const operand_ty = self.typeOf(ty_op.operand);1762 const operand_ty = self.typeOf(ty_op.operand);
1763 const operand = try self.resolveInst(ty_op.operand);1763 const operand = try self.resolveInst(ty_op.operand);
1764 const info_a = operand_ty.intInfo(mod);1764 const info_a = operand_ty.intInfo(mod);
...@@ -1819,7 +1819,7 @@ fn airIsNonNull(self: *Self, inst: Air.Inst.Index) !void {...@@ -1819,7 +1819,7 @@ fn airIsNonNull(self: *Self, inst: Air.Inst.Index) !void {
1819}1819}
18201820
1821fn airLoad(self: *Self, inst: Air.Inst.Index) !void {1821fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
1822 const mod = self.bin_file.options.module.?;1822 const mod = self.bin_file.comp.module.?;
1823 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;1823 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
1824 const elem_ty = self.typeOfIndex(inst);1824 const elem_ty = self.typeOfIndex(inst);
1825 const elem_size = elem_ty.abiSize(mod);1825 const elem_size = elem_ty.abiSize(mod);
...@@ -1903,7 +1903,7 @@ fn airMod(self: *Self, inst: Air.Inst.Index) !void {...@@ -1903,7 +1903,7 @@ fn airMod(self: *Self, inst: Air.Inst.Index) !void {
1903 const rhs = try self.resolveInst(bin_op.rhs);1903 const rhs = try self.resolveInst(bin_op.rhs);
1904 const lhs_ty = self.typeOf(bin_op.lhs);1904 const lhs_ty = self.typeOf(bin_op.lhs);
1905 const rhs_ty = self.typeOf(bin_op.rhs);1905 const rhs_ty = self.typeOf(bin_op.rhs);
1906 assert(lhs_ty.eql(rhs_ty, self.bin_file.options.module.?));1906 assert(lhs_ty.eql(rhs_ty, self.bin_file.comp.module.?));
19071907
1908 if (self.liveness.isUnused(inst))1908 if (self.liveness.isUnused(inst))
1909 return self.finishAir(inst, .dead, .{ bin_op.lhs, bin_op.rhs, .none });1909 return self.finishAir(inst, .dead, .{ bin_op.lhs, bin_op.rhs, .none });
...@@ -2045,7 +2045,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -2045,7 +2045,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
2045 //const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];2045 //const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
2046 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;2046 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
2047 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;2047 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
2048 const mod = self.bin_file.options.module.?;2048 const mod = self.bin_file.comp.module.?;
2049 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2049 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2050 const lhs = try self.resolveInst(extra.lhs);2050 const lhs = try self.resolveInst(extra.lhs);
2051 const rhs = try self.resolveInst(extra.rhs);2051 const rhs = try self.resolveInst(extra.rhs);
...@@ -2109,7 +2109,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -2109,7 +2109,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
21092109
2110fn airNot(self: *Self, inst: Air.Inst.Index) !void {2110fn airNot(self: *Self, inst: Air.Inst.Index) !void {
2111 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2111 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2112 const mod = self.bin_file.options.module.?;2112 const mod = self.bin_file.comp.module.?;
2113 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2113 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2114 const operand = try self.resolveInst(ty_op.operand);2114 const operand = try self.resolveInst(ty_op.operand);
2115 const operand_ty = self.typeOf(ty_op.operand);2115 const operand_ty = self.typeOf(ty_op.operand);
...@@ -2341,7 +2341,7 @@ fn airShlSat(self: *Self, inst: Air.Inst.Index) !void {...@@ -2341,7 +2341,7 @@ fn airShlSat(self: *Self, inst: Air.Inst.Index) !void {
2341fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {2341fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
2342 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;2342 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
2343 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;2343 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
2344 const mod = self.bin_file.options.module.?;2344 const mod = self.bin_file.comp.module.?;
2345 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2345 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2346 const lhs = try self.resolveInst(extra.lhs);2346 const lhs = try self.resolveInst(extra.lhs);
2347 const rhs = try self.resolveInst(extra.rhs);2347 const rhs = try self.resolveInst(extra.rhs);
...@@ -2446,7 +2446,7 @@ fn airSlice(self: *Self, inst: Air.Inst.Index) !void {...@@ -2446,7 +2446,7 @@ fn airSlice(self: *Self, inst: Air.Inst.Index) !void {
2446}2446}
24472447
2448fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {2448fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {
2449 const mod = self.bin_file.options.module.?;2449 const mod = self.bin_file.comp.module.?;
2450 const is_volatile = false; // TODO2450 const is_volatile = false; // TODO
2451 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;2451 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
24522452
...@@ -2571,7 +2571,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -2571,7 +2571,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
2571 const operand = extra.struct_operand;2571 const operand = extra.struct_operand;
2572 const index = extra.field_index;2572 const index = extra.field_index;
2573 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2573 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2574 const mod = self.bin_file.options.module.?;2574 const mod = self.bin_file.comp.module.?;
2575 const mcv = try self.resolveInst(operand);2575 const mcv = try self.resolveInst(operand);
2576 const struct_ty = self.typeOf(operand);2576 const struct_ty = self.typeOf(operand);
2577 const struct_field_offset = @as(u32, @intCast(struct_ty.structFieldOffset(index, mod)));2577 const struct_field_offset = @as(u32, @intCast(struct_ty.structFieldOffset(index, mod)));
...@@ -2704,7 +2704,7 @@ fn airUnionInit(self: *Self, inst: Air.Inst.Index) !void {...@@ -2704,7 +2704,7 @@ fn airUnionInit(self: *Self, inst: Air.Inst.Index) !void {
2704}2704}
27052705
2706fn airUnwrapErrErr(self: *Self, inst: Air.Inst.Index) !void {2706fn airUnwrapErrErr(self: *Self, inst: Air.Inst.Index) !void {
2707 const mod = self.bin_file.options.module.?;2707 const mod = self.bin_file.comp.module.?;
2708 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2708 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2709 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2709 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2710 const error_union_ty = self.typeOf(ty_op.operand);2710 const error_union_ty = self.typeOf(ty_op.operand);
...@@ -2718,7 +2718,7 @@ fn airUnwrapErrErr(self: *Self, inst: Air.Inst.Index) !void {...@@ -2718,7 +2718,7 @@ fn airUnwrapErrErr(self: *Self, inst: Air.Inst.Index) !void {
2718}2718}
27192719
2720fn airUnwrapErrPayload(self: *Self, inst: Air.Inst.Index) !void {2720fn airUnwrapErrPayload(self: *Self, inst: Air.Inst.Index) !void {
2721 const mod = self.bin_file.options.module.?;2721 const mod = self.bin_file.comp.module.?;
2722 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2722 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2723 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2723 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2724 const error_union_ty = self.typeOf(ty_op.operand);2724 const error_union_ty = self.typeOf(ty_op.operand);
...@@ -2732,7 +2732,7 @@ fn airUnwrapErrPayload(self: *Self, inst: Air.Inst.Index) !void {...@@ -2732,7 +2732,7 @@ fn airUnwrapErrPayload(self: *Self, inst: Air.Inst.Index) !void {
27322732
2733/// E to E!T2733/// E to E!T
2734fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {2734fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
2735 const mod = self.bin_file.options.module.?;2735 const mod = self.bin_file.comp.module.?;
2736 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2736 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2737 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2737 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2738 const error_union_ty = ty_op.ty.toType();2738 const error_union_ty = ty_op.ty.toType();
...@@ -2753,7 +2753,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {...@@ -2753,7 +2753,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
2753}2753}
27542754
2755fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {2755fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
2756 const mod = self.bin_file.options.module.?;2756 const mod = self.bin_file.comp.module.?;
2757 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2757 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2758 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {2758 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
2759 const optional_ty = self.typeOfIndex(inst);2759 const optional_ty = self.typeOfIndex(inst);
...@@ -2793,7 +2793,7 @@ fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: Alignme...@@ -2793,7 +2793,7 @@ fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: Alignme
27932793
2794/// Use a pointer instruction as the basis for allocating stack memory.2794/// Use a pointer instruction as the basis for allocating stack memory.
2795fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {2795fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
2796 const mod = self.bin_file.options.module.?;2796 const mod = self.bin_file.comp.module.?;
2797 const elem_ty = self.typeOfIndex(inst).childType(mod);2797 const elem_ty = self.typeOfIndex(inst).childType(mod);
27982798
2799 if (!elem_ty.hasRuntimeBits(mod)) {2799 if (!elem_ty.hasRuntimeBits(mod)) {
...@@ -2813,7 +2813,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {...@@ -2813,7 +2813,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
2813}2813}
28142814
2815fn allocRegOrMem(self: *Self, inst: Air.Inst.Index, reg_ok: bool) !MCValue {2815fn allocRegOrMem(self: *Self, inst: Air.Inst.Index, reg_ok: bool) !MCValue {
2816 const mod = self.bin_file.options.module.?;2816 const mod = self.bin_file.comp.module.?;
2817 const elem_ty = self.typeOfIndex(inst);2817 const elem_ty = self.typeOfIndex(inst);
2818 const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {2818 const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {
2819 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});2819 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});
...@@ -2860,7 +2860,7 @@ fn binOp(...@@ -2860,7 +2860,7 @@ fn binOp(
2860 rhs_ty: Type,2860 rhs_ty: Type,
2861 metadata: ?BinOpMetadata,2861 metadata: ?BinOpMetadata,
2862) InnerError!MCValue {2862) InnerError!MCValue {
2863 const mod = self.bin_file.options.module.?;2863 const mod = self.bin_file.comp.module.?;
2864 switch (tag) {2864 switch (tag) {
2865 .add,2865 .add,
2866 .sub,2866 .sub,
...@@ -3401,7 +3401,7 @@ fn binOpRegister(...@@ -3401,7 +3401,7 @@ fn binOpRegister(
3401fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {3401fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {
3402 const block_data = self.blocks.getPtr(block).?;3402 const block_data = self.blocks.getPtr(block).?;
34033403
3404 const mod = self.bin_file.options.module.?;3404 const mod = self.bin_file.comp.module.?;
3405 if (self.typeOf(operand).hasRuntimeBits(mod)) {3405 if (self.typeOf(operand).hasRuntimeBits(mod)) {
3406 const operand_mcv = try self.resolveInst(operand);3406 const operand_mcv = try self.resolveInst(operand);
3407 const block_mcv = block_data.mcv;3407 const block_mcv = block_data.mcv;
...@@ -3521,7 +3521,7 @@ fn ensureProcessDeathCapacity(self: *Self, additional_count: usize) !void {...@@ -3521,7 +3521,7 @@ fn ensureProcessDeathCapacity(self: *Self, additional_count: usize) !void {
35213521
3522/// Given an error union, returns the payload3522/// Given an error union, returns the payload
3523fn errUnionPayload(self: *Self, error_union_mcv: MCValue, error_union_ty: Type) !MCValue {3523fn errUnionPayload(self: *Self, error_union_mcv: MCValue, error_union_ty: Type) !MCValue {
3524 const mod = self.bin_file.options.module.?;3524 const mod = self.bin_file.comp.module.?;
3525 const err_ty = error_union_ty.errorUnionSet(mod);3525 const err_ty = error_union_ty.errorUnionSet(mod);
3526 const payload_ty = error_union_ty.errorUnionPayload(mod);3526 const payload_ty = error_union_ty.errorUnionPayload(mod);
3527 if (err_ty.errorSetIsEmpty(mod)) {3527 if (err_ty.errorSetIsEmpty(mod)) {
...@@ -3591,7 +3591,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live...@@ -3591,7 +3591,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live
3591}3591}
35923592
3593fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue) !void {3593fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue) !void {
3594 const mod = self.bin_file.options.module.?;3594 const mod = self.bin_file.comp.module.?;
3595 const arg = self.air.instructions.items(.data)[@intFromEnum(inst)].arg;3595 const arg = self.air.instructions.items(.data)[@intFromEnum(inst)].arg;
3596 const ty = arg.ty.toType();3596 const ty = arg.ty.toType();
3597 const owner_decl = mod.funcOwnerDeclIndex(self.func_index);3597 const owner_decl = mod.funcOwnerDeclIndex(self.func_index);
...@@ -3740,7 +3740,7 @@ fn genLoadASI(self: *Self, value_reg: Register, addr_reg: Register, off_reg: Reg...@@ -3740,7 +3740,7 @@ fn genLoadASI(self: *Self, value_reg: Register, addr_reg: Register, off_reg: Reg
3740}3740}
37413741
3742fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void {3742fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void {
3743 const mod = self.bin_file.options.module.?;3743 const mod = self.bin_file.comp.module.?;
3744 switch (mcv) {3744 switch (mcv) {
3745 .dead => unreachable,3745 .dead => unreachable,
3746 .unreach, .none => return, // Nothing to do.3746 .unreach, .none => return, // Nothing to do.
...@@ -3951,7 +3951,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void...@@ -3951,7 +3951,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
3951}3951}
39523952
3953fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {3953fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {
3954 const mod = self.bin_file.options.module.?;3954 const mod = self.bin_file.comp.module.?;
3955 const abi_size = ty.abiSize(mod);3955 const abi_size = ty.abiSize(mod);
3956 switch (mcv) {3956 switch (mcv) {
3957 .dead => unreachable,3957 .dead => unreachable,
...@@ -4125,7 +4125,7 @@ fn genStoreASI(self: *Self, value_reg: Register, addr_reg: Register, off_reg: Re...@@ -4125,7 +4125,7 @@ fn genStoreASI(self: *Self, value_reg: Register, addr_reg: Register, off_reg: Re
4125}4125}
41264126
4127fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue {4127fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue {
4128 const mod = self.bin_file.options.module.?;4128 const mod = self.bin_file.comp.module.?;
4129 const mcv: MCValue = switch (try codegen.genTypedValue(4129 const mcv: MCValue = switch (try codegen.genTypedValue(
4130 self.bin_file,4130 self.bin_file,
4131 self.src_loc,4131 self.src_loc,
...@@ -4161,7 +4161,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) MCValue {...@@ -4161,7 +4161,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) MCValue {
4161}4161}
41624162
4163fn isErr(self: *Self, ty: Type, operand: MCValue) !MCValue {4163fn isErr(self: *Self, ty: Type, operand: MCValue) !MCValue {
4164 const mod = self.bin_file.options.module.?;4164 const mod = self.bin_file.comp.module.?;
4165 const error_type = ty.errorUnionSet(mod);4165 const error_type = ty.errorUnionSet(mod);
4166 const payload_type = ty.errorUnionPayload(mod);4166 const payload_type = ty.errorUnionPayload(mod);
41674167
...@@ -4259,7 +4259,7 @@ fn jump(self: *Self, inst: Mir.Inst.Index) !void {...@@ -4259,7 +4259,7 @@ fn jump(self: *Self, inst: Mir.Inst.Index) !void {
4259}4259}
42604260
4261fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {4261fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {
4262 const mod = self.bin_file.options.module.?;4262 const mod = self.bin_file.comp.module.?;
4263 const elem_ty = ptr_ty.childType(mod);4263 const elem_ty = ptr_ty.childType(mod);
4264 const elem_size = elem_ty.abiSize(mod);4264 const elem_size = elem_ty.abiSize(mod);
42654265
...@@ -4330,7 +4330,7 @@ fn minMax(...@@ -4330,7 +4330,7 @@ fn minMax(
4330 lhs_ty: Type,4330 lhs_ty: Type,
4331 rhs_ty: Type,4331 rhs_ty: Type,
4332) InnerError!MCValue {4332) InnerError!MCValue {
4333 const mod = self.bin_file.options.module.?;4333 const mod = self.bin_file.comp.module.?;
4334 assert(lhs_ty.eql(rhs_ty, mod));4334 assert(lhs_ty.eql(rhs_ty, mod));
4335 switch (lhs_ty.zigTypeTag(mod)) {4335 switch (lhs_ty.zigTypeTag(mod)) {
4336 .Float => return self.fail("TODO min/max on floats", .{}),4336 .Float => return self.fail("TODO min/max on floats", .{}),
...@@ -4450,7 +4450,7 @@ fn realStackOffset(off: u32) u32 {...@@ -4450,7 +4450,7 @@ fn realStackOffset(off: u32) u32 {
44504450
4451/// Caller must call `CallMCValues.deinit`.4451/// Caller must call `CallMCValues.deinit`.
4452fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView) !CallMCValues {4452fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView) !CallMCValues {
4453 const mod = self.bin_file.options.module.?;4453 const mod = self.bin_file.comp.module.?;
4454 const ip = &mod.intern_pool;4454 const ip = &mod.intern_pool;
4455 const fn_info = mod.typeToFunc(fn_ty).?;4455 const fn_info = mod.typeToFunc(fn_ty).?;
4456 const cc = fn_info.cc;4456 const cc = fn_info.cc;
...@@ -4542,7 +4542,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView)...@@ -4542,7 +4542,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView)
4542}4542}
45434543
4544fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {4544fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {
4545 const mod = self.bin_file.options.module.?;4545 const mod = self.bin_file.comp.module.?;
4546 const ty = self.typeOf(ref);4546 const ty = self.typeOf(ref);
45474547
4548 // If the type has no codegen bits, no need to store it.4548 // If the type has no codegen bits, no need to store it.
...@@ -4559,7 +4559,7 @@ fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {...@@ -4559,7 +4559,7 @@ fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {
4559}4559}
45604560
4561fn ret(self: *Self, mcv: MCValue) !void {4561fn ret(self: *Self, mcv: MCValue) !void {
4562 const mod = self.bin_file.options.module.?;4562 const mod = self.bin_file.comp.module.?;
4563 const ret_ty = self.fn_type.fnReturnType(mod);4563 const ret_ty = self.fn_type.fnReturnType(mod);
4564 try self.setRegOrMem(ret_ty, self.ret_mcv, mcv);4564 try self.setRegOrMem(ret_ty, self.ret_mcv, mcv);
45654565
...@@ -4661,7 +4661,7 @@ pub fn spillInstruction(self: *Self, reg: Register, inst: Air.Inst.Index) !void...@@ -4661,7 +4661,7 @@ pub fn spillInstruction(self: *Self, reg: Register, inst: Air.Inst.Index) !void
4661}4661}
46624662
4663fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void {4663fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void {
4664 const mod = self.bin_file.options.module.?;4664 const mod = self.bin_file.comp.module.?;
4665 const abi_size = value_ty.abiSize(mod);4665 const abi_size = value_ty.abiSize(mod);
46664666
4667 switch (ptr) {4667 switch (ptr) {
...@@ -4703,7 +4703,7 @@ fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type...@@ -4703,7 +4703,7 @@ fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type
47034703
4704fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {4704fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {
4705 return if (self.liveness.isUnused(inst)) .dead else result: {4705 return if (self.liveness.isUnused(inst)) .dead else result: {
4706 const mod = self.bin_file.options.module.?;4706 const mod = self.bin_file.comp.module.?;
4707 const mcv = try self.resolveInst(operand);4707 const mcv = try self.resolveInst(operand);
4708 const ptr_ty = self.typeOf(operand);4708 const ptr_ty = self.typeOf(operand);
4709 const struct_ty = ptr_ty.childType(mod);4709 const struct_ty = ptr_ty.childType(mod);
...@@ -4745,7 +4745,7 @@ fn trunc(...@@ -4745,7 +4745,7 @@ fn trunc(
4745 operand_ty: Type,4745 operand_ty: Type,
4746 dest_ty: Type,4746 dest_ty: Type,
4747) !MCValue {4747) !MCValue {
4748 const mod = self.bin_file.options.module.?;4748 const mod = self.bin_file.comp.module.?;
4749 const info_a = operand_ty.intInfo(mod);4749 const info_a = operand_ty.intInfo(mod);
4750 const info_b = dest_ty.intInfo(mod);4750 const info_b = dest_ty.intInfo(mod);
47514751
...@@ -4866,11 +4866,11 @@ fn wantSafety(self: *Self) bool {...@@ -4866,11 +4866,11 @@ fn wantSafety(self: *Self) bool {
4866}4866}
48674867
4868fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {4868fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
4869 const mod = self.bin_file.options.module.?;4869 const mod = self.bin_file.comp.module.?;
4870 return self.air.typeOf(inst, &mod.intern_pool);4870 return self.air.typeOf(inst, &mod.intern_pool);
4871}4871}
48724872
4873fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {4873fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
4874 const mod = self.bin_file.options.module.?;4874 const mod = self.bin_file.comp.module.?;
4875 return self.air.typeOfIndex(inst, &mod.intern_pool);4875 return self.air.typeOfIndex(inst, &mod.intern_pool);
4876}4876}
src/arch/wasm/CodeGen.zig+1-1
...@@ -1210,7 +1210,7 @@ pub fn generate(...@@ -1210,7 +1210,7 @@ pub fn generate(
1210 debug_output: codegen.DebugInfoOutput,1210 debug_output: codegen.DebugInfoOutput,
1211) codegen.CodeGenError!codegen.Result {1211) codegen.CodeGenError!codegen.Result {
1212 _ = src_loc;1212 _ = src_loc;
1213 const mod = bin_file.options.module.?;1213 const mod = bin_file.comp.module.?;
1214 const func = mod.funcInfo(func_index);1214 const func = mod.funcInfo(func_index);
1215 var code_gen: CodeGen = .{1215 var code_gen: CodeGen = .{
1216 .gpa = bin_file.allocator,1216 .gpa = bin_file.allocator,
src/arch/x86_64/CodeGen.zig+120-120
...@@ -131,7 +131,7 @@ const Owner = union(enum) {...@@ -131,7 +131,7 @@ const Owner = union(enum) {
131 fn getSymbolIndex(owner: Owner, ctx: *Self) !u32 {131 fn getSymbolIndex(owner: Owner, ctx: *Self) !u32 {
132 switch (owner) {132 switch (owner) {
133 .func_index => |func_index| {133 .func_index => |func_index| {
134 const mod = ctx.bin_file.options.module.?;134 const mod = ctx.bin_file.comp.module.?;
135 const decl_index = mod.funcOwnerDeclIndex(func_index);135 const decl_index = mod.funcOwnerDeclIndex(func_index);
136 if (ctx.bin_file.cast(link.File.Elf)) |elf_file| {136 if (ctx.bin_file.cast(link.File.Elf)) |elf_file| {
137 return elf_file.zigObjectPtr().?.getOrCreateMetadataForDecl(elf_file, decl_index);137 return elf_file.zigObjectPtr().?.getOrCreateMetadataForDecl(elf_file, decl_index);
...@@ -799,7 +799,7 @@ pub fn generate(...@@ -799,7 +799,7 @@ pub fn generate(
799 @panic("Attempted to compile for architecture that was disabled by build configuration");799 @panic("Attempted to compile for architecture that was disabled by build configuration");
800 }800 }
801801
802 const mod = bin_file.options.module.?;802 const mod = bin_file.comp.module.?;
803 const func = mod.funcInfo(func_index);803 const func = mod.funcInfo(func_index);
804 const fn_owner_decl = mod.declPtr(func.owner_decl);804 const fn_owner_decl = mod.declPtr(func.owner_decl);
805 assert(fn_owner_decl.has_tv);805 assert(fn_owner_decl.has_tv);
...@@ -1060,7 +1060,7 @@ fn formatDecl(...@@ -1060,7 +1060,7 @@ fn formatDecl(
1060}1060}
1061fn fmtDecl(self: *Self, decl_index: InternPool.DeclIndex) std.fmt.Formatter(formatDecl) {1061fn fmtDecl(self: *Self, decl_index: InternPool.DeclIndex) std.fmt.Formatter(formatDecl) {
1062 return .{ .data = .{1062 return .{ .data = .{
1063 .mod = self.bin_file.options.module.?,1063 .mod = self.bin_file.comp.module.?,
1064 .decl_index = decl_index,1064 .decl_index = decl_index,
1065 } };1065 } };
1066}1066}
...@@ -1077,7 +1077,7 @@ fn formatAir(...@@ -1077,7 +1077,7 @@ fn formatAir(
1077) @TypeOf(writer).Error!void {1077) @TypeOf(writer).Error!void {
1078 @import("../../print_air.zig").dumpInst(1078 @import("../../print_air.zig").dumpInst(
1079 data.inst,1079 data.inst,
1080 data.self.bin_file.options.module.?,1080 data.self.bin_file.comp.module.?,
1081 data.self.air,1081 data.self.air,
1082 data.self.liveness,1082 data.self.liveness,
1083 );1083 );
...@@ -1683,7 +1683,7 @@ fn asmMemoryRegisterImmediate(...@@ -1683,7 +1683,7 @@ fn asmMemoryRegisterImmediate(
1683}1683}
16841684
1685fn gen(self: *Self) InnerError!void {1685fn gen(self: *Self) InnerError!void {
1686 const mod = self.bin_file.options.module.?;1686 const mod = self.bin_file.comp.module.?;
1687 const fn_info = mod.typeToFunc(self.fn_type).?;1687 const fn_info = mod.typeToFunc(self.fn_type).?;
1688 const cc = abi.resolveCallingConvention(fn_info.cc, self.target.*);1688 const cc = abi.resolveCallingConvention(fn_info.cc, self.target.*);
1689 if (cc != .Naked) {1689 if (cc != .Naked) {
...@@ -1885,7 +1885,7 @@ fn gen(self: *Self) InnerError!void {...@@ -1885,7 +1885,7 @@ fn gen(self: *Self) InnerError!void {
1885}1885}
18861886
1887fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {1887fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
1888 const mod = self.bin_file.options.module.?;1888 const mod = self.bin_file.comp.module.?;
1889 const ip = &mod.intern_pool;1889 const ip = &mod.intern_pool;
1890 const air_tags = self.air.instructions.items(.tag);1890 const air_tags = self.air.instructions.items(.tag);
18911891
...@@ -2167,7 +2167,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -2167,7 +2167,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
2167}2167}
21682168
2169fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void {2169fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void {
2170 const mod = self.bin_file.options.module.?;2170 const mod = self.bin_file.comp.module.?;
2171 switch (lazy_sym.ty.zigTypeTag(mod)) {2171 switch (lazy_sym.ty.zigTypeTag(mod)) {
2172 .Enum => {2172 .Enum => {
2173 const enum_ty = lazy_sym.ty;2173 const enum_ty = lazy_sym.ty;
...@@ -2418,7 +2418,7 @@ fn allocFrameIndex(self: *Self, alloc: FrameAlloc) !FrameIndex {...@@ -2418,7 +2418,7 @@ fn allocFrameIndex(self: *Self, alloc: FrameAlloc) !FrameIndex {
24182418
2419/// Use a pointer instruction as the basis for allocating stack memory.2419/// Use a pointer instruction as the basis for allocating stack memory.
2420fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !FrameIndex {2420fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !FrameIndex {
2421 const mod = self.bin_file.options.module.?;2421 const mod = self.bin_file.comp.module.?;
2422 const ptr_ty = self.typeOfIndex(inst);2422 const ptr_ty = self.typeOfIndex(inst);
2423 const val_ty = ptr_ty.childType(mod);2423 const val_ty = ptr_ty.childType(mod);
2424 return self.allocFrameIndex(FrameAlloc.init(.{2424 return self.allocFrameIndex(FrameAlloc.init(.{
...@@ -2438,7 +2438,7 @@ fn allocTempRegOrMem(self: *Self, elem_ty: Type, reg_ok: bool) !MCValue {...@@ -2438,7 +2438,7 @@ fn allocTempRegOrMem(self: *Self, elem_ty: Type, reg_ok: bool) !MCValue {
2438}2438}
24392439
2440fn allocRegOrMemAdvanced(self: *Self, ty: Type, inst: ?Air.Inst.Index, reg_ok: bool) !MCValue {2440fn allocRegOrMemAdvanced(self: *Self, ty: Type, inst: ?Air.Inst.Index, reg_ok: bool) !MCValue {
2441 const mod = self.bin_file.options.module.?;2441 const mod = self.bin_file.comp.module.?;
2442 const abi_size = math.cast(u32, ty.abiSize(mod)) orelse {2442 const abi_size = math.cast(u32, ty.abiSize(mod)) orelse {
2443 return self.fail("type '{}' too big to fit into stack frame", .{ty.fmt(mod)});2443 return self.fail("type '{}' too big to fit into stack frame", .{ty.fmt(mod)});
2444 };2444 };
...@@ -2471,7 +2471,7 @@ fn allocRegOrMemAdvanced(self: *Self, ty: Type, inst: ?Air.Inst.Index, reg_ok: b...@@ -2471,7 +2471,7 @@ fn allocRegOrMemAdvanced(self: *Self, ty: Type, inst: ?Air.Inst.Index, reg_ok: b
2471}2471}
24722472
2473fn regClassForType(self: *Self, ty: Type) RegisterManager.RegisterBitSet {2473fn regClassForType(self: *Self, ty: Type) RegisterManager.RegisterBitSet {
2474 const mod = self.bin_file.options.module.?;2474 const mod = self.bin_file.comp.module.?;
2475 return switch (ty.zigTypeTag(mod)) {2475 return switch (ty.zigTypeTag(mod)) {
2476 .Float => switch (ty.floatBits(self.target.*)) {2476 .Float => switch (ty.floatBits(self.target.*)) {
2477 80 => abi.RegisterClass.x87,2477 80 => abi.RegisterClass.x87,
...@@ -2884,7 +2884,7 @@ fn airFpext(self: *Self, inst: Air.Inst.Index) !void {...@@ -2884,7 +2884,7 @@ fn airFpext(self: *Self, inst: Air.Inst.Index) !void {
2884}2884}
28852885
2886fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {2886fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
2887 const mod = self.bin_file.options.module.?;2887 const mod = self.bin_file.comp.module.?;
2888 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2888 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2889 const result: MCValue = result: {2889 const result: MCValue = result: {
2890 const src_ty = self.typeOf(ty_op.operand);2890 const src_ty = self.typeOf(ty_op.operand);
...@@ -2975,7 +2975,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {...@@ -2975,7 +2975,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
2975}2975}
29762976
2977fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {2977fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {
2978 const mod = self.bin_file.options.module.?;2978 const mod = self.bin_file.comp.module.?;
2979 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2979 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
29802980
2981 const dst_ty = self.typeOfIndex(inst);2981 const dst_ty = self.typeOfIndex(inst);
...@@ -3102,7 +3102,7 @@ fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {...@@ -3102,7 +3102,7 @@ fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
3102}3102}
31033103
3104fn airSlice(self: *Self, inst: Air.Inst.Index) !void {3104fn airSlice(self: *Self, inst: Air.Inst.Index) !void {
3105 const mod = self.bin_file.options.module.?;3105 const mod = self.bin_file.comp.module.?;
3106 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;3106 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
3107 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;3107 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
31083108
...@@ -3131,7 +3131,7 @@ fn airUnOp(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {...@@ -3131,7 +3131,7 @@ fn airUnOp(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
3131}3131}
31323132
3133fn airBinOp(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {3133fn airBinOp(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
3134 const mod = self.bin_file.options.module.?;3134 const mod = self.bin_file.comp.module.?;
3135 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;3135 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
3136 const dst_mcv = try self.genBinOp(inst, tag, bin_op.lhs, bin_op.rhs);3136 const dst_mcv = try self.genBinOp(inst, tag, bin_op.lhs, bin_op.rhs);
31373137
...@@ -3172,7 +3172,7 @@ fn airPtrArithmetic(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void...@@ -3172,7 +3172,7 @@ fn airPtrArithmetic(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void
3172}3172}
31733173
3174fn activeIntBits(self: *Self, dst_air: Air.Inst.Ref) u16 {3174fn activeIntBits(self: *Self, dst_air: Air.Inst.Ref) u16 {
3175 const mod = self.bin_file.options.module.?;3175 const mod = self.bin_file.comp.module.?;
3176 const air_tag = self.air.instructions.items(.tag);3176 const air_tag = self.air.instructions.items(.tag);
3177 const air_data = self.air.instructions.items(.data);3177 const air_data = self.air.instructions.items(.data);
31783178
...@@ -3206,7 +3206,7 @@ fn activeIntBits(self: *Self, dst_air: Air.Inst.Ref) u16 {...@@ -3206,7 +3206,7 @@ fn activeIntBits(self: *Self, dst_air: Air.Inst.Ref) u16 {
3206}3206}
32073207
3208fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {3208fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
3209 const mod = self.bin_file.options.module.?;3209 const mod = self.bin_file.comp.module.?;
3210 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;3210 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
3211 const result = result: {3211 const result = result: {
3212 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];3212 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
...@@ -3432,7 +3432,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {...@@ -3432,7 +3432,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
3432}3432}
34333433
3434fn airAddSat(self: *Self, inst: Air.Inst.Index) !void {3434fn airAddSat(self: *Self, inst: Air.Inst.Index) !void {
3435 const mod = self.bin_file.options.module.?;3435 const mod = self.bin_file.comp.module.?;
3436 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;3436 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
3437 const ty = self.typeOf(bin_op.lhs);3437 const ty = self.typeOf(bin_op.lhs);
3438 if (ty.zigTypeTag(mod) == .Vector or ty.abiSize(mod) > 8) return self.fail(3438 if (ty.zigTypeTag(mod) == .Vector or ty.abiSize(mod) > 8) return self.fail(
...@@ -3515,7 +3515,7 @@ fn airAddSat(self: *Self, inst: Air.Inst.Index) !void {...@@ -3515,7 +3515,7 @@ fn airAddSat(self: *Self, inst: Air.Inst.Index) !void {
3515}3515}
35163516
3517fn airSubSat(self: *Self, inst: Air.Inst.Index) !void {3517fn airSubSat(self: *Self, inst: Air.Inst.Index) !void {
3518 const mod = self.bin_file.options.module.?;3518 const mod = self.bin_file.comp.module.?;
3519 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;3519 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
3520 const ty = self.typeOf(bin_op.lhs);3520 const ty = self.typeOf(bin_op.lhs);
3521 if (ty.zigTypeTag(mod) == .Vector or ty.abiSize(mod) > 8) return self.fail(3521 if (ty.zigTypeTag(mod) == .Vector or ty.abiSize(mod) > 8) return self.fail(
...@@ -3591,7 +3591,7 @@ fn airSubSat(self: *Self, inst: Air.Inst.Index) !void {...@@ -3591,7 +3591,7 @@ fn airSubSat(self: *Self, inst: Air.Inst.Index) !void {
3591}3591}
35923592
3593fn airMulSat(self: *Self, inst: Air.Inst.Index) !void {3593fn airMulSat(self: *Self, inst: Air.Inst.Index) !void {
3594 const mod = self.bin_file.options.module.?;3594 const mod = self.bin_file.comp.module.?;
3595 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;3595 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
3596 const ty = self.typeOf(bin_op.lhs);3596 const ty = self.typeOf(bin_op.lhs);
35973597
...@@ -3731,7 +3731,7 @@ fn airMulSat(self: *Self, inst: Air.Inst.Index) !void {...@@ -3731,7 +3731,7 @@ fn airMulSat(self: *Self, inst: Air.Inst.Index) !void {
3731}3731}
37323732
3733fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {3733fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
3734 const mod = self.bin_file.options.module.?;3734 const mod = self.bin_file.comp.module.?;
3735 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;3735 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
3736 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;3736 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
3737 const result: MCValue = result: {3737 const result: MCValue = result: {
...@@ -3792,7 +3792,7 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -3792,7 +3792,7 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
3792}3792}
37933793
3794fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {3794fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
3795 const mod = self.bin_file.options.module.?;3795 const mod = self.bin_file.comp.module.?;
3796 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;3796 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
3797 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;3797 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
3798 const result: MCValue = result: {3798 const result: MCValue = result: {
...@@ -3871,7 +3871,7 @@ fn genSetFrameTruncatedOverflowCompare(...@@ -3871,7 +3871,7 @@ fn genSetFrameTruncatedOverflowCompare(
3871 src_mcv: MCValue,3871 src_mcv: MCValue,
3872 overflow_cc: ?Condition,3872 overflow_cc: ?Condition,
3873) !void {3873) !void {
3874 const mod = self.bin_file.options.module.?;3874 const mod = self.bin_file.comp.module.?;
3875 const src_lock = switch (src_mcv) {3875 const src_lock = switch (src_mcv) {
3876 .register => |reg| self.register_manager.lockReg(reg),3876 .register => |reg| self.register_manager.lockReg(reg),
3877 else => null,3877 else => null,
...@@ -3935,7 +3935,7 @@ fn genSetFrameTruncatedOverflowCompare(...@@ -3935,7 +3935,7 @@ fn genSetFrameTruncatedOverflowCompare(
3935}3935}
39363936
3937fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {3937fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
3938 const mod = self.bin_file.options.module.?;3938 const mod = self.bin_file.comp.module.?;
3939 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;3939 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
3940 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;3940 const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
3941 const tuple_ty = self.typeOfIndex(inst);3941 const tuple_ty = self.typeOfIndex(inst);
...@@ -4169,7 +4169,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -4169,7 +4169,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
4169/// Clobbers .rax and .rdx registers.4169/// Clobbers .rax and .rdx registers.
4170/// Quotient is saved in .rax and remainder in .rdx.4170/// Quotient is saved in .rax and remainder in .rdx.
4171fn genIntMulDivOpMir(self: *Self, tag: Mir.Inst.FixedTag, ty: Type, lhs: MCValue, rhs: MCValue) !void {4171fn genIntMulDivOpMir(self: *Self, tag: Mir.Inst.FixedTag, ty: Type, lhs: MCValue, rhs: MCValue) !void {
4172 const mod = self.bin_file.options.module.?;4172 const mod = self.bin_file.comp.module.?;
4173 const abi_size: u32 = @intCast(ty.abiSize(mod));4173 const abi_size: u32 = @intCast(ty.abiSize(mod));
4174 const bit_size: u32 = @intCast(self.regBitSize(ty));4174 const bit_size: u32 = @intCast(self.regBitSize(ty));
4175 if (abi_size > 8) {4175 if (abi_size > 8) {
...@@ -4219,7 +4219,7 @@ fn genIntMulDivOpMir(self: *Self, tag: Mir.Inst.FixedTag, ty: Type, lhs: MCValue...@@ -4219,7 +4219,7 @@ fn genIntMulDivOpMir(self: *Self, tag: Mir.Inst.FixedTag, ty: Type, lhs: MCValue
4219/// Always returns a register.4219/// Always returns a register.
4220/// Clobbers .rax and .rdx registers.4220/// Clobbers .rax and .rdx registers.
4221fn genInlineIntDivFloor(self: *Self, ty: Type, lhs: MCValue, rhs: MCValue) !MCValue {4221fn genInlineIntDivFloor(self: *Self, ty: Type, lhs: MCValue, rhs: MCValue) !MCValue {
4222 const mod = self.bin_file.options.module.?;4222 const mod = self.bin_file.comp.module.?;
4223 const abi_size: u32 = @intCast(ty.abiSize(mod));4223 const abi_size: u32 = @intCast(ty.abiSize(mod));
4224 const int_info = ty.intInfo(mod);4224 const int_info = ty.intInfo(mod);
4225 const dividend = switch (lhs) {4225 const dividend = switch (lhs) {
...@@ -4271,7 +4271,7 @@ fn genInlineIntDivFloor(self: *Self, ty: Type, lhs: MCValue, rhs: MCValue) !MCVa...@@ -4271,7 +4271,7 @@ fn genInlineIntDivFloor(self: *Self, ty: Type, lhs: MCValue, rhs: MCValue) !MCVa
4271}4271}
42724272
4273fn airShlShrBinOp(self: *Self, inst: Air.Inst.Index) !void {4273fn airShlShrBinOp(self: *Self, inst: Air.Inst.Index) !void {
4274 const mod = self.bin_file.options.module.?;4274 const mod = self.bin_file.comp.module.?;
4275 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;4275 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
42764276
4277 const air_tags = self.air.instructions.items(.tag);4277 const air_tags = self.air.instructions.items(.tag);
...@@ -4546,7 +4546,7 @@ fn airShlSat(self: *Self, inst: Air.Inst.Index) !void {...@@ -4546,7 +4546,7 @@ fn airShlSat(self: *Self, inst: Air.Inst.Index) !void {
4546}4546}
45474547
4548fn airOptionalPayload(self: *Self, inst: Air.Inst.Index) !void {4548fn airOptionalPayload(self: *Self, inst: Air.Inst.Index) !void {
4549 const mod = self.bin_file.options.module.?;4549 const mod = self.bin_file.comp.module.?;
4550 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4550 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4551 const result: MCValue = result: {4551 const result: MCValue = result: {
4552 const pl_ty = self.typeOfIndex(inst);4552 const pl_ty = self.typeOfIndex(inst);
...@@ -4592,7 +4592,7 @@ fn airOptionalPayloadPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -4592,7 +4592,7 @@ fn airOptionalPayloadPtr(self: *Self, inst: Air.Inst.Index) !void {
4592}4592}
45934593
4594fn airOptionalPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {4594fn airOptionalPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
4595 const mod = self.bin_file.options.module.?;4595 const mod = self.bin_file.comp.module.?;
4596 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4596 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4597 const result = result: {4597 const result = result: {
4598 const dst_ty = self.typeOfIndex(inst);4598 const dst_ty = self.typeOfIndex(inst);
...@@ -4626,7 +4626,7 @@ fn airOptionalPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {...@@ -4626,7 +4626,7 @@ fn airOptionalPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
4626}4626}
46274627
4628fn airUnwrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {4628fn airUnwrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
4629 const mod = self.bin_file.options.module.?;4629 const mod = self.bin_file.comp.module.?;
4630 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4630 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4631 const err_union_ty = self.typeOf(ty_op.operand);4631 const err_union_ty = self.typeOf(ty_op.operand);
4632 const err_ty = err_union_ty.errorUnionSet(mod);4632 const err_ty = err_union_ty.errorUnionSet(mod);
...@@ -4678,7 +4678,7 @@ fn airUnwrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {...@@ -4678,7 +4678,7 @@ fn airUnwrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
46784678
4679// *(E!T) -> E4679// *(E!T) -> E
4680fn airUnwrapErrUnionErrPtr(self: *Self, inst: Air.Inst.Index) !void {4680fn airUnwrapErrUnionErrPtr(self: *Self, inst: Air.Inst.Index) !void {
4681 const mod = self.bin_file.options.module.?;4681 const mod = self.bin_file.comp.module.?;
4682 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4682 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
46834683
4684 const src_ty = self.typeOf(ty_op.operand);4684 const src_ty = self.typeOf(ty_op.operand);
...@@ -4725,7 +4725,7 @@ fn airUnwrapErrUnionPayloadPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -4725,7 +4725,7 @@ fn airUnwrapErrUnionPayloadPtr(self: *Self, inst: Air.Inst.Index) !void {
4725}4725}
47264726
4727fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {4727fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
4728 const mod = self.bin_file.options.module.?;4728 const mod = self.bin_file.comp.module.?;
4729 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4729 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4730 const result: MCValue = result: {4730 const result: MCValue = result: {
4731 const src_ty = self.typeOf(ty_op.operand);4731 const src_ty = self.typeOf(ty_op.operand);
...@@ -4785,7 +4785,7 @@ fn genUnwrapErrUnionPayloadMir(...@@ -4785,7 +4785,7 @@ fn genUnwrapErrUnionPayloadMir(
4785 err_union_ty: Type,4785 err_union_ty: Type,
4786 err_union: MCValue,4786 err_union: MCValue,
4787) !MCValue {4787) !MCValue {
4788 const mod = self.bin_file.options.module.?;4788 const mod = self.bin_file.comp.module.?;
4789 const payload_ty = err_union_ty.errorUnionPayload(mod);4789 const payload_ty = err_union_ty.errorUnionPayload(mod);
47904790
4791 const result: MCValue = result: {4791 const result: MCValue = result: {
...@@ -4833,7 +4833,7 @@ fn genUnwrapErrUnionPayloadPtrMir(...@@ -4833,7 +4833,7 @@ fn genUnwrapErrUnionPayloadPtrMir(
4833 ptr_ty: Type,4833 ptr_ty: Type,
4834 ptr_mcv: MCValue,4834 ptr_mcv: MCValue,
4835) !MCValue {4835) !MCValue {
4836 const mod = self.bin_file.options.module.?;4836 const mod = self.bin_file.comp.module.?;
4837 const err_union_ty = ptr_ty.childType(mod);4837 const err_union_ty = ptr_ty.childType(mod);
4838 const payload_ty = err_union_ty.errorUnionPayload(mod);4838 const payload_ty = err_union_ty.errorUnionPayload(mod);
48394839
...@@ -4867,7 +4867,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {...@@ -4867,7 +4867,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {
4867}4867}
48684868
4869fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {4869fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
4870 const mod = self.bin_file.options.module.?;4870 const mod = self.bin_file.comp.module.?;
4871 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4871 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4872 const result: MCValue = result: {4872 const result: MCValue = result: {
4873 const pl_ty = self.typeOf(ty_op.operand);4873 const pl_ty = self.typeOf(ty_op.operand);
...@@ -4921,7 +4921,7 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {...@@ -4921,7 +4921,7 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
49214921
4922/// T to E!T4922/// T to E!T
4923fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {4923fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
4924 const mod = self.bin_file.options.module.?;4924 const mod = self.bin_file.comp.module.?;
4925 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4925 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
49264926
4927 const eu_ty = ty_op.ty.toType();4927 const eu_ty = ty_op.ty.toType();
...@@ -4944,7 +4944,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {...@@ -4944,7 +4944,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
49444944
4945/// E to E!T4945/// E to E!T
4946fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {4946fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
4947 const mod = self.bin_file.options.module.?;4947 const mod = self.bin_file.comp.module.?;
4948 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4948 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
49494949
4950 const eu_ty = ty_op.ty.toType();4950 const eu_ty = ty_op.ty.toType();
...@@ -5003,7 +5003,7 @@ fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void {...@@ -5003,7 +5003,7 @@ fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void {
5003}5003}
50045004
5005fn airPtrSliceLenPtr(self: *Self, inst: Air.Inst.Index) !void {5005fn airPtrSliceLenPtr(self: *Self, inst: Air.Inst.Index) !void {
5006 const mod = self.bin_file.options.module.?;5006 const mod = self.bin_file.comp.module.?;
5007 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5007 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
50085008
5009 const src_ty = self.typeOf(ty_op.operand);5009 const src_ty = self.typeOf(ty_op.operand);
...@@ -5071,7 +5071,7 @@ fn elemOffset(self: *Self, index_ty: Type, index: MCValue, elem_size: u64) !Regi...@@ -5071,7 +5071,7 @@ fn elemOffset(self: *Self, index_ty: Type, index: MCValue, elem_size: u64) !Regi
5071}5071}
50725072
5073fn genSliceElemPtr(self: *Self, lhs: Air.Inst.Ref, rhs: Air.Inst.Ref) !MCValue {5073fn genSliceElemPtr(self: *Self, lhs: Air.Inst.Ref, rhs: Air.Inst.Ref) !MCValue {
5074 const mod = self.bin_file.options.module.?;5074 const mod = self.bin_file.comp.module.?;
5075 const slice_ty = self.typeOf(lhs);5075 const slice_ty = self.typeOf(lhs);
5076 const slice_mcv = try self.resolveInst(lhs);5076 const slice_mcv = try self.resolveInst(lhs);
5077 const slice_mcv_lock: ?RegisterLock = switch (slice_mcv) {5077 const slice_mcv_lock: ?RegisterLock = switch (slice_mcv) {
...@@ -5107,7 +5107,7 @@ fn genSliceElemPtr(self: *Self, lhs: Air.Inst.Ref, rhs: Air.Inst.Ref) !MCValue {...@@ -5107,7 +5107,7 @@ fn genSliceElemPtr(self: *Self, lhs: Air.Inst.Ref, rhs: Air.Inst.Ref) !MCValue {
5107}5107}
51085108
5109fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {5109fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {
5110 const mod = self.bin_file.options.module.?;5110 const mod = self.bin_file.comp.module.?;
5111 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;5111 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
51125112
5113 const result: MCValue = result: {5113 const result: MCValue = result: {
...@@ -5132,7 +5132,7 @@ fn airSliceElemPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -5132,7 +5132,7 @@ fn airSliceElemPtr(self: *Self, inst: Air.Inst.Index) !void {
5132}5132}
51335133
5134fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {5134fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
5135 const mod = self.bin_file.options.module.?;5135 const mod = self.bin_file.comp.module.?;
5136 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;5136 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
51375137
5138 const result: MCValue = result: {5138 const result: MCValue = result: {
...@@ -5246,7 +5246,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -5246,7 +5246,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
5246}5246}
52475247
5248fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {5248fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
5249 const mod = self.bin_file.options.module.?;5249 const mod = self.bin_file.comp.module.?;
5250 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;5250 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
5251 const ptr_ty = self.typeOf(bin_op.lhs);5251 const ptr_ty = self.typeOf(bin_op.lhs);
52525252
...@@ -5296,7 +5296,7 @@ fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -5296,7 +5296,7 @@ fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
5296}5296}
52975297
5298fn airPtrElemPtr(self: *Self, inst: Air.Inst.Index) !void {5298fn airPtrElemPtr(self: *Self, inst: Air.Inst.Index) !void {
5299 const mod = self.bin_file.options.module.?;5299 const mod = self.bin_file.comp.module.?;
5300 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;5300 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
5301 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;5301 const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
53025302
...@@ -5341,7 +5341,7 @@ fn airPtrElemPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -5341,7 +5341,7 @@ fn airPtrElemPtr(self: *Self, inst: Air.Inst.Index) !void {
5341}5341}
53425342
5343fn airSetUnionTag(self: *Self, inst: Air.Inst.Index) !void {5343fn airSetUnionTag(self: *Self, inst: Air.Inst.Index) !void {
5344 const mod = self.bin_file.options.module.?;5344 const mod = self.bin_file.comp.module.?;
5345 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;5345 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
5346 const ptr_union_ty = self.typeOf(bin_op.lhs);5346 const ptr_union_ty = self.typeOf(bin_op.lhs);
5347 const union_ty = ptr_union_ty.childType(mod);5347 const union_ty = ptr_union_ty.childType(mod);
...@@ -5385,7 +5385,7 @@ fn airSetUnionTag(self: *Self, inst: Air.Inst.Index) !void {...@@ -5385,7 +5385,7 @@ fn airSetUnionTag(self: *Self, inst: Air.Inst.Index) !void {
5385}5385}
53865386
5387fn airGetUnionTag(self: *Self, inst: Air.Inst.Index) !void {5387fn airGetUnionTag(self: *Self, inst: Air.Inst.Index) !void {
5388 const mod = self.bin_file.options.module.?;5388 const mod = self.bin_file.comp.module.?;
5389 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5389 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
53905390
5391 const tag_ty = self.typeOfIndex(inst);5391 const tag_ty = self.typeOfIndex(inst);
...@@ -5439,7 +5439,7 @@ fn airGetUnionTag(self: *Self, inst: Air.Inst.Index) !void {...@@ -5439,7 +5439,7 @@ fn airGetUnionTag(self: *Self, inst: Air.Inst.Index) !void {
5439}5439}
54405440
5441fn airClz(self: *Self, inst: Air.Inst.Index) !void {5441fn airClz(self: *Self, inst: Air.Inst.Index) !void {
5442 const mod = self.bin_file.options.module.?;5442 const mod = self.bin_file.comp.module.?;
5443 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5443 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
5444 const result = result: {5444 const result = result: {
5445 const dst_ty = self.typeOfIndex(inst);5445 const dst_ty = self.typeOfIndex(inst);
...@@ -5598,7 +5598,7 @@ fn airClz(self: *Self, inst: Air.Inst.Index) !void {...@@ -5598,7 +5598,7 @@ fn airClz(self: *Self, inst: Air.Inst.Index) !void {
5598}5598}
55995599
5600fn airCtz(self: *Self, inst: Air.Inst.Index) !void {5600fn airCtz(self: *Self, inst: Air.Inst.Index) !void {
5601 const mod = self.bin_file.options.module.?;5601 const mod = self.bin_file.comp.module.?;
5602 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5602 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
5603 const result = result: {5603 const result = result: {
5604 const dst_ty = self.typeOfIndex(inst);5604 const dst_ty = self.typeOfIndex(inst);
...@@ -5716,7 +5716,7 @@ fn airCtz(self: *Self, inst: Air.Inst.Index) !void {...@@ -5716,7 +5716,7 @@ fn airCtz(self: *Self, inst: Air.Inst.Index) !void {
5716}5716}
57175717
5718fn airPopCount(self: *Self, inst: Air.Inst.Index) !void {5718fn airPopCount(self: *Self, inst: Air.Inst.Index) !void {
5719 const mod = self.bin_file.options.module.?;5719 const mod = self.bin_file.comp.module.?;
5720 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5720 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
5721 const result: MCValue = result: {5721 const result: MCValue = result: {
5722 try self.spillEflagsIfOccupied();5722 try self.spillEflagsIfOccupied();
...@@ -5779,7 +5779,7 @@ fn genPopCount(...@@ -5779,7 +5779,7 @@ fn genPopCount(
5779 src_mcv: MCValue,5779 src_mcv: MCValue,
5780 dst_contains_src: bool,5780 dst_contains_src: bool,
5781) !void {5781) !void {
5782 const mod = self.bin_file.options.module.?;5782 const mod = self.bin_file.comp.module.?;
57835783
5784 const src_abi_size: u32 = @intCast(src_ty.abiSize(mod));5784 const src_abi_size: u32 = @intCast(src_ty.abiSize(mod));
5785 if (self.hasFeature(.popcnt)) return self.genBinOpMir(5785 if (self.hasFeature(.popcnt)) return self.genBinOpMir(
...@@ -5871,7 +5871,7 @@ fn genByteSwap(...@@ -5871,7 +5871,7 @@ fn genByteSwap(
5871 src_mcv: MCValue,5871 src_mcv: MCValue,
5872 mem_ok: bool,5872 mem_ok: bool,
5873) !MCValue {5873) !MCValue {
5874 const mod = self.bin_file.options.module.?;5874 const mod = self.bin_file.comp.module.?;
5875 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5875 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
58765876
5877 if (src_ty.zigTypeTag(mod) == .Vector) return self.fail(5877 if (src_ty.zigTypeTag(mod) == .Vector) return self.fail(
...@@ -5962,7 +5962,7 @@ fn genByteSwap(...@@ -5962,7 +5962,7 @@ fn genByteSwap(
5962}5962}
59635963
5964fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void {5964fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void {
5965 const mod = self.bin_file.options.module.?;5965 const mod = self.bin_file.comp.module.?;
5966 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5966 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
59675967
5968 const src_ty = self.typeOf(ty_op.operand);5968 const src_ty = self.typeOf(ty_op.operand);
...@@ -5984,7 +5984,7 @@ fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void {...@@ -5984,7 +5984,7 @@ fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void {
5984}5984}
59855985
5986fn airBitReverse(self: *Self, inst: Air.Inst.Index) !void {5986fn airBitReverse(self: *Self, inst: Air.Inst.Index) !void {
5987 const mod = self.bin_file.options.module.?;5987 const mod = self.bin_file.comp.module.?;
5988 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5988 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
59895989
5990 const src_ty = self.typeOf(ty_op.operand);5990 const src_ty = self.typeOf(ty_op.operand);
...@@ -6106,7 +6106,7 @@ fn airBitReverse(self: *Self, inst: Air.Inst.Index) !void {...@@ -6106,7 +6106,7 @@ fn airBitReverse(self: *Self, inst: Air.Inst.Index) !void {
6106}6106}
61076107
6108fn floatSign(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, ty: Type) !void {6108fn floatSign(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, ty: Type) !void {
6109 const mod = self.bin_file.options.module.?;6109 const mod = self.bin_file.comp.module.?;
6110 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];6110 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
61116111
6112 const result = result: {6112 const result = result: {
...@@ -6282,7 +6282,7 @@ fn airRound(self: *Self, inst: Air.Inst.Index, mode: RoundMode) !void {...@@ -6282,7 +6282,7 @@ fn airRound(self: *Self, inst: Air.Inst.Index, mode: RoundMode) !void {
6282}6282}
62836283
6284fn getRoundTag(self: *Self, ty: Type) ?Mir.Inst.FixedTag {6284fn getRoundTag(self: *Self, ty: Type) ?Mir.Inst.FixedTag {
6285 const mod = self.bin_file.options.module.?;6285 const mod = self.bin_file.comp.module.?;
6286 return if (self.hasFeature(.sse4_1)) switch (ty.zigTypeTag(mod)) {6286 return if (self.hasFeature(.sse4_1)) switch (ty.zigTypeTag(mod)) {
6287 .Float => switch (ty.floatBits(self.target.*)) {6287 .Float => switch (ty.floatBits(self.target.*)) {
6288 32 => if (self.hasFeature(.avx)) .{ .v_ss, .round } else .{ ._ss, .round },6288 32 => if (self.hasFeature(.avx)) .{ .v_ss, .round } else .{ ._ss, .round },
...@@ -6314,7 +6314,7 @@ fn getRoundTag(self: *Self, ty: Type) ?Mir.Inst.FixedTag {...@@ -6314,7 +6314,7 @@ fn getRoundTag(self: *Self, ty: Type) ?Mir.Inst.FixedTag {
6314}6314}
63156315
6316fn genRoundLibcall(self: *Self, ty: Type, src_mcv: MCValue, mode: RoundMode) !MCValue {6316fn genRoundLibcall(self: *Self, ty: Type, src_mcv: MCValue, mode: RoundMode) !MCValue {
6317 const mod = self.bin_file.options.module.?;6317 const mod = self.bin_file.comp.module.?;
6318 if (self.getRoundTag(ty)) |_| return .none;6318 if (self.getRoundTag(ty)) |_| return .none;
63196319
6320 if (ty.zigTypeTag(mod) != .Float)6320 if (ty.zigTypeTag(mod) != .Float)
...@@ -6338,7 +6338,7 @@ fn genRoundLibcall(self: *Self, ty: Type, src_mcv: MCValue, mode: RoundMode) !MC...@@ -6338,7 +6338,7 @@ fn genRoundLibcall(self: *Self, ty: Type, src_mcv: MCValue, mode: RoundMode) !MC
6338}6338}
63396339
6340fn genRound(self: *Self, ty: Type, dst_reg: Register, src_mcv: MCValue, mode: RoundMode) !void {6340fn genRound(self: *Self, ty: Type, dst_reg: Register, src_mcv: MCValue, mode: RoundMode) !void {
6341 const mod = self.bin_file.options.module.?;6341 const mod = self.bin_file.comp.module.?;
6342 const mir_tag = self.getRoundTag(ty) orelse {6342 const mir_tag = self.getRoundTag(ty) orelse {
6343 const result = try self.genRoundLibcall(ty, src_mcv, mode);6343 const result = try self.genRoundLibcall(ty, src_mcv, mode);
6344 return self.genSetReg(dst_reg, ty, result);6344 return self.genSetReg(dst_reg, ty, result);
...@@ -6380,7 +6380,7 @@ fn genRound(self: *Self, ty: Type, dst_reg: Register, src_mcv: MCValue, mode: Ro...@@ -6380,7 +6380,7 @@ fn genRound(self: *Self, ty: Type, dst_reg: Register, src_mcv: MCValue, mode: Ro
6380}6380}
63816381
6382fn airAbs(self: *Self, inst: Air.Inst.Index) !void {6382fn airAbs(self: *Self, inst: Air.Inst.Index) !void {
6383 const mod = self.bin_file.options.module.?;6383 const mod = self.bin_file.comp.module.?;
6384 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;6384 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
6385 const ty = self.typeOf(ty_op.operand);6385 const ty = self.typeOf(ty_op.operand);
63866386
...@@ -6520,7 +6520,7 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void {...@@ -6520,7 +6520,7 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void {
6520}6520}
65216521
6522fn airSqrt(self: *Self, inst: Air.Inst.Index) !void {6522fn airSqrt(self: *Self, inst: Air.Inst.Index) !void {
6523 const mod = self.bin_file.options.module.?;6523 const mod = self.bin_file.comp.module.?;
6524 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;6524 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
6525 const ty = self.typeOf(un_op);6525 const ty = self.typeOf(un_op);
6526 const abi_size: u32 = @intCast(ty.abiSize(mod));6526 const abi_size: u32 = @intCast(ty.abiSize(mod));
...@@ -6765,7 +6765,7 @@ fn reuseOperandAdvanced(...@@ -6765,7 +6765,7 @@ fn reuseOperandAdvanced(
6765}6765}
67666766
6767fn packedLoad(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerError!void {6767fn packedLoad(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerError!void {
6768 const mod = self.bin_file.options.module.?;6768 const mod = self.bin_file.comp.module.?;
67696769
6770 const ptr_info = ptr_ty.ptrInfo(mod);6770 const ptr_info = ptr_ty.ptrInfo(mod);
6771 const val_ty = Type.fromInterned(ptr_info.child);6771 const val_ty = Type.fromInterned(ptr_info.child);
...@@ -6864,7 +6864,7 @@ fn packedLoad(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) Inn...@@ -6864,7 +6864,7 @@ fn packedLoad(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) Inn
6864}6864}
68656865
6866fn load(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerError!void {6866fn load(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerError!void {
6867 const mod = self.bin_file.options.module.?;6867 const mod = self.bin_file.comp.module.?;
6868 const dst_ty = ptr_ty.childType(mod);6868 const dst_ty = ptr_ty.childType(mod);
6869 if (!dst_ty.hasRuntimeBitsIgnoreComptime(mod)) return;6869 if (!dst_ty.hasRuntimeBitsIgnoreComptime(mod)) return;
6870 switch (ptr_mcv) {6870 switch (ptr_mcv) {
...@@ -6905,7 +6905,7 @@ fn load(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerErro...@@ -6905,7 +6905,7 @@ fn load(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerErro
6905}6905}
69066906
6907fn airLoad(self: *Self, inst: Air.Inst.Index) !void {6907fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
6908 const mod = self.bin_file.options.module.?;6908 const mod = self.bin_file.comp.module.?;
6909 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;6909 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
6910 const elem_ty = self.typeOfIndex(inst);6910 const elem_ty = self.typeOfIndex(inst);
6911 const result: MCValue = result: {6911 const result: MCValue = result: {
...@@ -6962,7 +6962,7 @@ fn airLoad(self: *Self, inst: Air.Inst.Index) !void {...@@ -6962,7 +6962,7 @@ fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
6962}6962}
69636963
6964fn packedStore(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) InnerError!void {6964fn packedStore(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) InnerError!void {
6965 const mod = self.bin_file.options.module.?;6965 const mod = self.bin_file.comp.module.?;
6966 const ptr_info = ptr_ty.ptrInfo(mod);6966 const ptr_info = ptr_ty.ptrInfo(mod);
6967 const src_ty = Type.fromInterned(ptr_info.child);6967 const src_ty = Type.fromInterned(ptr_info.child);
6968 if (!src_ty.hasRuntimeBitsIgnoreComptime(mod)) return;6968 if (!src_ty.hasRuntimeBitsIgnoreComptime(mod)) return;
...@@ -7059,7 +7059,7 @@ fn packedStore(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) In...@@ -7059,7 +7059,7 @@ fn packedStore(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) In
7059}7059}
70607060
7061fn store(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) InnerError!void {7061fn store(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) InnerError!void {
7062 const mod = self.bin_file.options.module.?;7062 const mod = self.bin_file.comp.module.?;
7063 const src_ty = ptr_ty.childType(mod);7063 const src_ty = ptr_ty.childType(mod);
7064 if (!src_ty.hasRuntimeBitsIgnoreComptime(mod)) return;7064 if (!src_ty.hasRuntimeBitsIgnoreComptime(mod)) return;
7065 switch (ptr_mcv) {7065 switch (ptr_mcv) {
...@@ -7100,7 +7100,7 @@ fn store(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) InnerErr...@@ -7100,7 +7100,7 @@ fn store(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) InnerErr
7100}7100}
71017101
7102fn airStore(self: *Self, inst: Air.Inst.Index, safety: bool) !void {7102fn airStore(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
7103 const mod = self.bin_file.options.module.?;7103 const mod = self.bin_file.comp.module.?;
7104 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;7104 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
71057105
7106 result: {7106 result: {
...@@ -7138,7 +7138,7 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void {...@@ -7138,7 +7138,7 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void {
7138}7138}
71397139
7140fn fieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {7140fn fieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {
7141 const mod = self.bin_file.options.module.?;7141 const mod = self.bin_file.comp.module.?;
7142 const ptr_field_ty = self.typeOfIndex(inst);7142 const ptr_field_ty = self.typeOfIndex(inst);
7143 const ptr_container_ty = self.typeOf(operand);7143 const ptr_container_ty = self.typeOf(operand);
7144 const ptr_container_ty_info = ptr_container_ty.ptrInfo(mod);7144 const ptr_container_ty_info = ptr_container_ty.ptrInfo(mod);
...@@ -7163,7 +7163,7 @@ fn fieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32...@@ -7163,7 +7163,7 @@ fn fieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32
7163}7163}
71647164
7165fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {7165fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
7166 const mod = self.bin_file.options.module.?;7166 const mod = self.bin_file.comp.module.?;
7167 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;7167 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
7168 const extra = self.air.extraData(Air.StructField, ty_pl.payload).data;7168 const extra = self.air.extraData(Air.StructField, ty_pl.payload).data;
7169 const result: MCValue = result: {7169 const result: MCValue = result: {
...@@ -7451,7 +7451,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -7451,7 +7451,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
7451}7451}
74527452
7453fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {7453fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {
7454 const mod = self.bin_file.options.module.?;7454 const mod = self.bin_file.comp.module.?;
7455 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;7455 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
7456 const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;7456 const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;
74577457
...@@ -7470,7 +7470,7 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -7470,7 +7470,7 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {
7470}7470}
74717471
7472fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air: Air.Inst.Ref) !MCValue {7472fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air: Air.Inst.Ref) !MCValue {
7473 const mod = self.bin_file.options.module.?;7473 const mod = self.bin_file.comp.module.?;
7474 const src_ty = self.typeOf(src_air);7474 const src_ty = self.typeOf(src_air);
7475 if (src_ty.zigTypeTag(mod) == .Vector)7475 if (src_ty.zigTypeTag(mod) == .Vector)
7476 return self.fail("TODO implement genUnOp for {}", .{src_ty.fmt(mod)});7476 return self.fail("TODO implement genUnOp for {}", .{src_ty.fmt(mod)});
...@@ -7558,7 +7558,7 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air:...@@ -7558,7 +7558,7 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air:
7558}7558}
75597559
7560fn genUnOpMir(self: *Self, mir_tag: Mir.Inst.FixedTag, dst_ty: Type, dst_mcv: MCValue) !void {7560fn genUnOpMir(self: *Self, mir_tag: Mir.Inst.FixedTag, dst_ty: Type, dst_mcv: MCValue) !void {
7561 const mod = self.bin_file.options.module.?;7561 const mod = self.bin_file.comp.module.?;
7562 const abi_size: u32 = @intCast(dst_ty.abiSize(mod));7562 const abi_size: u32 = @intCast(dst_ty.abiSize(mod));
7563 if (abi_size > 8) return self.fail("TODO implement {} for {}", .{ mir_tag, dst_ty.fmt(mod) });7563 if (abi_size > 8) return self.fail("TODO implement {} for {}", .{ mir_tag, dst_ty.fmt(mod) });
7564 switch (dst_mcv) {7564 switch (dst_mcv) {
...@@ -7605,7 +7605,7 @@ fn genShiftBinOpMir(...@@ -7605,7 +7605,7 @@ fn genShiftBinOpMir(
7605 lhs_mcv: MCValue,7605 lhs_mcv: MCValue,
7606 shift_mcv: MCValue,7606 shift_mcv: MCValue,
7607) !void {7607) !void {
7608 const mod = self.bin_file.options.module.?;7608 const mod = self.bin_file.comp.module.?;
7609 const rhs_mcv: MCValue = rhs: {7609 const rhs_mcv: MCValue = rhs: {
7610 switch (shift_mcv) {7610 switch (shift_mcv) {
7611 .immediate => |imm| switch (imm) {7611 .immediate => |imm| switch (imm) {
...@@ -7975,7 +7975,7 @@ fn genShiftBinOp(...@@ -7975,7 +7975,7 @@ fn genShiftBinOp(
7975 lhs_ty: Type,7975 lhs_ty: Type,
7976 rhs_ty: Type,7976 rhs_ty: Type,
7977) !MCValue {7977) !MCValue {
7978 const mod = self.bin_file.options.module.?;7978 const mod = self.bin_file.comp.module.?;
7979 if (lhs_ty.zigTypeTag(mod) == .Vector) return self.fail("TODO implement genShiftBinOp for {}", .{7979 if (lhs_ty.zigTypeTag(mod) == .Vector) return self.fail("TODO implement genShiftBinOp for {}", .{
7980 lhs_ty.fmt(mod),7980 lhs_ty.fmt(mod),
7981 });7981 });
...@@ -8041,7 +8041,7 @@ fn genMulDivBinOp(...@@ -8041,7 +8041,7 @@ fn genMulDivBinOp(
8041 lhs_mcv: MCValue,8041 lhs_mcv: MCValue,
8042 rhs_mcv: MCValue,8042 rhs_mcv: MCValue,
8043) !MCValue {8043) !MCValue {
8044 const mod = self.bin_file.options.module.?;8044 const mod = self.bin_file.comp.module.?;
8045 if (dst_ty.zigTypeTag(mod) == .Vector or dst_ty.zigTypeTag(mod) == .Float) return self.fail(8045 if (dst_ty.zigTypeTag(mod) == .Vector or dst_ty.zigTypeTag(mod) == .Float) return self.fail(
8046 "TODO implement genMulDivBinOp for {s} from {} to {}",8046 "TODO implement genMulDivBinOp for {s} from {} to {}",
8047 .{ @tagName(tag), src_ty.fmt(mod), dst_ty.fmt(mod) },8047 .{ @tagName(tag), src_ty.fmt(mod), dst_ty.fmt(mod) },
...@@ -8283,7 +8283,7 @@ fn genBinOp(...@@ -8283,7 +8283,7 @@ fn genBinOp(
8283 lhs_air: Air.Inst.Ref,8283 lhs_air: Air.Inst.Ref,
8284 rhs_air: Air.Inst.Ref,8284 rhs_air: Air.Inst.Ref,
8285) !MCValue {8285) !MCValue {
8286 const mod = self.bin_file.options.module.?;8286 const mod = self.bin_file.comp.module.?;
8287 const lhs_ty = self.typeOf(lhs_air);8287 const lhs_ty = self.typeOf(lhs_air);
8288 const rhs_ty = self.typeOf(rhs_air);8288 const rhs_ty = self.typeOf(rhs_air);
8289 const abi_size: u32 = @intCast(lhs_ty.abiSize(mod));8289 const abi_size: u32 = @intCast(lhs_ty.abiSize(mod));
...@@ -10015,7 +10015,7 @@ fn genBinOpMir(...@@ -10015,7 +10015,7 @@ fn genBinOpMir(
10015 dst_mcv: MCValue,10015 dst_mcv: MCValue,
10016 src_mcv: MCValue,10016 src_mcv: MCValue,
10017) !void {10017) !void {
10018 const mod = self.bin_file.options.module.?;10018 const mod = self.bin_file.comp.module.?;
10019 const abi_size: u32 = @intCast(ty.abiSize(mod));10019 const abi_size: u32 = @intCast(ty.abiSize(mod));
10020 try self.spillEflagsIfOccupied();10020 try self.spillEflagsIfOccupied();
10021 switch (dst_mcv) {10021 switch (dst_mcv) {
...@@ -10435,7 +10435,7 @@ fn genBinOpMir(...@@ -10435,7 +10435,7 @@ fn genBinOpMir(
10435/// Performs multi-operand integer multiplication between dst_mcv and src_mcv, storing the result in dst_mcv.10435/// Performs multi-operand integer multiplication between dst_mcv and src_mcv, storing the result in dst_mcv.
10436/// Does not support byte-size operands.10436/// Does not support byte-size operands.
10437fn genIntMulComplexOpMir(self: *Self, dst_ty: Type, dst_mcv: MCValue, src_mcv: MCValue) InnerError!void {10437fn genIntMulComplexOpMir(self: *Self, dst_ty: Type, dst_mcv: MCValue, src_mcv: MCValue) InnerError!void {
10438 const mod = self.bin_file.options.module.?;10438 const mod = self.bin_file.comp.module.?;
10439 const abi_size: u32 = @intCast(dst_ty.abiSize(mod));10439 const abi_size: u32 = @intCast(dst_ty.abiSize(mod));
10440 try self.spillEflagsIfOccupied();10440 try self.spillEflagsIfOccupied();
10441 switch (dst_mcv) {10441 switch (dst_mcv) {
...@@ -10560,7 +10560,7 @@ fn genIntMulComplexOpMir(self: *Self, dst_ty: Type, dst_mcv: MCValue, src_mcv: M...@@ -10560,7 +10560,7 @@ fn genIntMulComplexOpMir(self: *Self, dst_ty: Type, dst_mcv: MCValue, src_mcv: M
10560}10560}
1056110561
10562fn airArg(self: *Self, inst: Air.Inst.Index) !void {10562fn airArg(self: *Self, inst: Air.Inst.Index) !void {
10563 const mod = self.bin_file.options.module.?;10563 const mod = self.bin_file.comp.module.?;
10564 // skip zero-bit arguments as they don't have a corresponding arg instruction10564 // skip zero-bit arguments as they don't have a corresponding arg instruction
10565 var arg_index = self.arg_index;10565 var arg_index = self.arg_index;
10566 while (self.args[arg_index] == .none) arg_index += 1;10566 while (self.args[arg_index] == .none) arg_index += 1;
...@@ -10593,7 +10593,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {...@@ -10593,7 +10593,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {
10593}10593}
1059410594
10595fn genArgDbgInfo(self: Self, ty: Type, name: [:0]const u8, mcv: MCValue) !void {10595fn genArgDbgInfo(self: Self, ty: Type, name: [:0]const u8, mcv: MCValue) !void {
10596 const mod = self.bin_file.options.module.?;10596 const mod = self.bin_file.comp.module.?;
10597 switch (self.debug_output) {10597 switch (self.debug_output) {
10598 .dwarf => |dw| {10598 .dwarf => |dw| {
10599 const loc: link.File.Dwarf.DeclState.DbgInfoLoc = switch (mcv) {10599 const loc: link.File.Dwarf.DeclState.DbgInfoLoc = switch (mcv) {
...@@ -10629,7 +10629,7 @@ fn genVarDbgInfo(...@@ -10629,7 +10629,7 @@ fn genVarDbgInfo(
10629 mcv: MCValue,10629 mcv: MCValue,
10630 name: [:0]const u8,10630 name: [:0]const u8,
10631) !void {10631) !void {
10632 const mod = self.bin_file.options.module.?;10632 const mod = self.bin_file.comp.module.?;
10633 const is_ptr = switch (tag) {10633 const is_ptr = switch (tag) {
10634 .dbg_var_ptr => true,10634 .dbg_var_ptr => true,
10635 .dbg_var_val => false,10635 .dbg_var_val => false,
...@@ -10748,7 +10748,7 @@ fn genCall(self: *Self, info: union(enum) {...@@ -10748,7 +10748,7 @@ fn genCall(self: *Self, info: union(enum) {
10748 callee: []const u8,10748 callee: []const u8,
10749 },10749 },
10750}, arg_types: []const Type, args: []const MCValue) !MCValue {10750}, arg_types: []const Type, args: []const MCValue) !MCValue {
10751 const mod = self.bin_file.options.module.?;10751 const mod = self.bin_file.comp.module.?;
1075210752
10753 const fn_ty = switch (info) {10753 const fn_ty = switch (info) {
10754 .air => |callee| fn_info: {10754 .air => |callee| fn_info: {
...@@ -10969,7 +10969,7 @@ fn genCall(self: *Self, info: union(enum) {...@@ -10969,7 +10969,7 @@ fn genCall(self: *Self, info: union(enum) {
10969}10969}
1097010970
10971fn airRet(self: *Self, inst: Air.Inst.Index) !void {10971fn airRet(self: *Self, inst: Air.Inst.Index) !void {
10972 const mod = self.bin_file.options.module.?;10972 const mod = self.bin_file.comp.module.?;
10973 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;10973 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
1097410974
10975 const ret_ty = self.fn_type.fnReturnType(mod);10975 const ret_ty = self.fn_type.fnReturnType(mod);
...@@ -11018,7 +11018,7 @@ fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void {...@@ -11018,7 +11018,7 @@ fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void {
11018}11018}
1101911019
11020fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {11020fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
11021 const mod = self.bin_file.options.module.?;11021 const mod = self.bin_file.comp.module.?;
11022 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;11022 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
11023 const ty = self.typeOf(bin_op.lhs);11023 const ty = self.typeOf(bin_op.lhs);
1102411024
...@@ -11412,7 +11412,7 @@ fn airCmpVector(self: *Self, inst: Air.Inst.Index) !void {...@@ -11412,7 +11412,7 @@ fn airCmpVector(self: *Self, inst: Air.Inst.Index) !void {
11412}11412}
1141311413
11414fn airCmpLtErrorsLen(self: *Self, inst: Air.Inst.Index) !void {11414fn airCmpLtErrorsLen(self: *Self, inst: Air.Inst.Index) !void {
11415 const mod = self.bin_file.options.module.?;11415 const mod = self.bin_file.comp.module.?;
11416 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;11416 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
1141711417
11418 const addr_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);11418 const addr_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);
...@@ -11551,7 +11551,7 @@ fn airDbgVar(self: *Self, inst: Air.Inst.Index) !void {...@@ -11551,7 +11551,7 @@ fn airDbgVar(self: *Self, inst: Air.Inst.Index) !void {
11551}11551}
1155211552
11553fn genCondBrMir(self: *Self, ty: Type, mcv: MCValue) !Mir.Inst.Index {11553fn genCondBrMir(self: *Self, ty: Type, mcv: MCValue) !Mir.Inst.Index {
11554 const mod = self.bin_file.options.module.?;11554 const mod = self.bin_file.comp.module.?;
11555 const abi_size = ty.abiSize(mod);11555 const abi_size = ty.abiSize(mod);
11556 switch (mcv) {11556 switch (mcv) {
11557 .eflags => |cc| {11557 .eflags => |cc| {
...@@ -11624,7 +11624,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {...@@ -11624,7 +11624,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
11624}11624}
1162511625
11626fn isNull(self: *Self, inst: Air.Inst.Index, opt_ty: Type, opt_mcv: MCValue) !MCValue {11626fn isNull(self: *Self, inst: Air.Inst.Index, opt_ty: Type, opt_mcv: MCValue) !MCValue {
11627 const mod = self.bin_file.options.module.?;11627 const mod = self.bin_file.comp.module.?;
11628 switch (opt_mcv) {11628 switch (opt_mcv) {
11629 .register_overflow => |ro| return .{ .eflags = ro.eflags.negate() },11629 .register_overflow => |ro| return .{ .eflags = ro.eflags.negate() },
11630 else => {},11630 else => {},
...@@ -11732,7 +11732,7 @@ fn isNull(self: *Self, inst: Air.Inst.Index, opt_ty: Type, opt_mcv: MCValue) !MC...@@ -11732,7 +11732,7 @@ fn isNull(self: *Self, inst: Air.Inst.Index, opt_ty: Type, opt_mcv: MCValue) !MC
11732}11732}
1173311733
11734fn isNullPtr(self: *Self, inst: Air.Inst.Index, ptr_ty: Type, ptr_mcv: MCValue) !MCValue {11734fn isNullPtr(self: *Self, inst: Air.Inst.Index, ptr_ty: Type, ptr_mcv: MCValue) !MCValue {
11735 const mod = self.bin_file.options.module.?;11735 const mod = self.bin_file.comp.module.?;
11736 const opt_ty = ptr_ty.childType(mod);11736 const opt_ty = ptr_ty.childType(mod);
11737 const pl_ty = opt_ty.optionalChild(mod);11737 const pl_ty = opt_ty.optionalChild(mod);
1173811738
...@@ -11768,7 +11768,7 @@ fn isNullPtr(self: *Self, inst: Air.Inst.Index, ptr_ty: Type, ptr_mcv: MCValue)...@@ -11768,7 +11768,7 @@ fn isNullPtr(self: *Self, inst: Air.Inst.Index, ptr_ty: Type, ptr_mcv: MCValue)
11768}11768}
1176911769
11770fn isErr(self: *Self, maybe_inst: ?Air.Inst.Index, eu_ty: Type, eu_mcv: MCValue) !MCValue {11770fn isErr(self: *Self, maybe_inst: ?Air.Inst.Index, eu_ty: Type, eu_mcv: MCValue) !MCValue {
11771 const mod = self.bin_file.options.module.?;11771 const mod = self.bin_file.comp.module.?;
11772 const err_ty = eu_ty.errorUnionSet(mod);11772 const err_ty = eu_ty.errorUnionSet(mod);
11773 if (err_ty.errorSetIsEmpty(mod)) return MCValue{ .immediate = 0 }; // always false11773 if (err_ty.errorSetIsEmpty(mod)) return MCValue{ .immediate = 0 }; // always false
1177411774
...@@ -11815,7 +11815,7 @@ fn isErr(self: *Self, maybe_inst: ?Air.Inst.Index, eu_ty: Type, eu_mcv: MCValue)...@@ -11815,7 +11815,7 @@ fn isErr(self: *Self, maybe_inst: ?Air.Inst.Index, eu_ty: Type, eu_mcv: MCValue)
11815}11815}
1181611816
11817fn isErrPtr(self: *Self, maybe_inst: ?Air.Inst.Index, ptr_ty: Type, ptr_mcv: MCValue) !MCValue {11817fn isErrPtr(self: *Self, maybe_inst: ?Air.Inst.Index, ptr_ty: Type, ptr_mcv: MCValue) !MCValue {
11818 const mod = self.bin_file.options.module.?;11818 const mod = self.bin_file.comp.module.?;
11819 const eu_ty = ptr_ty.childType(mod);11819 const eu_ty = ptr_ty.childType(mod);
11820 const err_ty = eu_ty.errorUnionSet(mod);11820 const err_ty = eu_ty.errorUnionSet(mod);
11821 if (err_ty.errorSetIsEmpty(mod)) return MCValue{ .immediate = 0 }; // always false11821 if (err_ty.errorSetIsEmpty(mod)) return MCValue{ .immediate = 0 }; // always false
...@@ -12097,7 +12097,7 @@ fn performReloc(self: *Self, reloc: Mir.Inst.Index) !void {...@@ -12097,7 +12097,7 @@ fn performReloc(self: *Self, reloc: Mir.Inst.Index) !void {
12097}12097}
1209812098
12099fn airBr(self: *Self, inst: Air.Inst.Index) !void {12099fn airBr(self: *Self, inst: Air.Inst.Index) !void {
12100 const mod = self.bin_file.options.module.?;12100 const mod = self.bin_file.comp.module.?;
12101 const br = self.air.instructions.items(.data)[@intFromEnum(inst)].br;12101 const br = self.air.instructions.items(.data)[@intFromEnum(inst)].br;
1210212102
12103 const block_ty = self.typeOfIndex(br.block_inst);12103 const block_ty = self.typeOfIndex(br.block_inst);
...@@ -12158,7 +12158,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void {...@@ -12158,7 +12158,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void {
12158}12158}
1215912159
12160fn airAsm(self: *Self, inst: Air.Inst.Index) !void {12160fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
12161 const mod = self.bin_file.options.module.?;12161 const mod = self.bin_file.comp.module.?;
12162 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;12162 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
12163 const extra = self.air.extraData(Air.Asm, ty_pl.payload);12163 const extra = self.air.extraData(Air.Asm, ty_pl.payload);
12164 const clobbers_len: u31 = @truncate(extra.data.flags);12164 const clobbers_len: u31 = @truncate(extra.data.flags);
...@@ -12865,7 +12865,7 @@ const MoveStrategy = union(enum) {...@@ -12865,7 +12865,7 @@ const MoveStrategy = union(enum) {
12865 }12865 }
12866};12866};
12867fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !MoveStrategy {12867fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !MoveStrategy {
12868 const mod = self.bin_file.options.module.?;12868 const mod = self.bin_file.comp.module.?;
12869 switch (class) {12869 switch (class) {
12870 .general_purpose, .segment => return .{ .move = .{ ._, .mov } },12870 .general_purpose, .segment => return .{ .move = .{ ._, .mov } },
12871 .x87 => return .x87_load_store,12871 .x87 => return .x87_load_store,
...@@ -13164,7 +13164,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo...@@ -13164,7 +13164,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo
13164}13164}
1316513165
13166fn genCopy(self: *Self, ty: Type, dst_mcv: MCValue, src_mcv: MCValue) InnerError!void {13166fn genCopy(self: *Self, ty: Type, dst_mcv: MCValue, src_mcv: MCValue) InnerError!void {
13167 const mod = self.bin_file.options.module.?;13167 const mod = self.bin_file.comp.module.?;
1316813168
13169 const src_lock = if (src_mcv.getReg()) |reg| self.register_manager.lockReg(reg) else null;13169 const src_lock = if (src_mcv.getReg()) |reg| self.register_manager.lockReg(reg) else null;
13170 defer if (src_lock) |lock| self.register_manager.unlockReg(lock);13170 defer if (src_lock) |lock| self.register_manager.unlockReg(lock);
...@@ -13262,7 +13262,7 @@ fn genCopy(self: *Self, ty: Type, dst_mcv: MCValue, src_mcv: MCValue) InnerError...@@ -13262,7 +13262,7 @@ fn genCopy(self: *Self, ty: Type, dst_mcv: MCValue, src_mcv: MCValue) InnerError
13262}13262}
1326313263
13264fn genSetReg(self: *Self, dst_reg: Register, ty: Type, src_mcv: MCValue) InnerError!void {13264fn genSetReg(self: *Self, dst_reg: Register, ty: Type, src_mcv: MCValue) InnerError!void {
13265 const mod = self.bin_file.options.module.?;13265 const mod = self.bin_file.comp.module.?;
13266 const abi_size: u32 = @intCast(ty.abiSize(mod));13266 const abi_size: u32 = @intCast(ty.abiSize(mod));
13267 if (ty.bitSize(mod) > dst_reg.bitSize())13267 if (ty.bitSize(mod) > dst_reg.bitSize())
13268 return self.fail("genSetReg called with a value larger than dst_reg", .{});13268 return self.fail("genSetReg called with a value larger than dst_reg", .{});
...@@ -13561,7 +13561,7 @@ fn genSetReg(self: *Self, dst_reg: Register, ty: Type, src_mcv: MCValue) InnerEr...@@ -13561,7 +13561,7 @@ fn genSetReg(self: *Self, dst_reg: Register, ty: Type, src_mcv: MCValue) InnerEr
13561}13561}
1356213562
13563fn genSetMem(self: *Self, base: Memory.Base, disp: i32, ty: Type, src_mcv: MCValue) InnerError!void {13563fn genSetMem(self: *Self, base: Memory.Base, disp: i32, ty: Type, src_mcv: MCValue) InnerError!void {
13564 const mod = self.bin_file.options.module.?;13564 const mod = self.bin_file.comp.module.?;
13565 const abi_size: u32 = @intCast(ty.abiSize(mod));13565 const abi_size: u32 = @intCast(ty.abiSize(mod));
13566 const dst_ptr_mcv: MCValue = switch (base) {13566 const dst_ptr_mcv: MCValue = switch (base) {
13567 .none => .{ .immediate = @bitCast(@as(i64, disp)) },13567 .none => .{ .immediate = @bitCast(@as(i64, disp)) },
...@@ -13922,7 +13922,7 @@ fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -13922,7 +13922,7 @@ fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
13922}13922}
1392313923
13924fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {13924fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {
13925 const mod = self.bin_file.options.module.?;13925 const mod = self.bin_file.comp.module.?;
13926 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;13926 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
13927 const dst_ty = self.typeOfIndex(inst);13927 const dst_ty = self.typeOfIndex(inst);
13928 const src_ty = self.typeOf(ty_op.operand);13928 const src_ty = self.typeOf(ty_op.operand);
...@@ -13980,7 +13980,7 @@ fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {...@@ -13980,7 +13980,7 @@ fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {
13980}13980}
1398113981
13982fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {13982fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
13983 const mod = self.bin_file.options.module.?;13983 const mod = self.bin_file.comp.module.?;
13984 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;13984 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
1398513985
13986 const slice_ty = self.typeOfIndex(inst);13986 const slice_ty = self.typeOfIndex(inst);
...@@ -14003,7 +14003,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {...@@ -14003,7 +14003,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
14003}14003}
1400414004
14005fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {14005fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
14006 const mod = self.bin_file.options.module.?;14006 const mod = self.bin_file.comp.module.?;
14007 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;14007 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
1400814008
14009 const dst_ty = self.typeOfIndex(inst);14009 const dst_ty = self.typeOfIndex(inst);
...@@ -14082,7 +14082,7 @@ fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {...@@ -14082,7 +14082,7 @@ fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
14082}14082}
1408314083
14084fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {14084fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
14085 const mod = self.bin_file.options.module.?;14085 const mod = self.bin_file.comp.module.?;
14086 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;14086 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
1408714087
14088 const dst_ty = self.typeOfIndex(inst);14088 const dst_ty = self.typeOfIndex(inst);
...@@ -14153,7 +14153,7 @@ fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {...@@ -14153,7 +14153,7 @@ fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
14153}14153}
1415414154
14155fn airCmpxchg(self: *Self, inst: Air.Inst.Index) !void {14155fn airCmpxchg(self: *Self, inst: Air.Inst.Index) !void {
14156 const mod = self.bin_file.options.module.?;14156 const mod = self.bin_file.comp.module.?;
14157 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;14157 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
14158 const extra = self.air.extraData(Air.Cmpxchg, ty_pl.payload).data;14158 const extra = self.air.extraData(Air.Cmpxchg, ty_pl.payload).data;
1415914159
...@@ -14249,7 +14249,7 @@ fn atomicOp(...@@ -14249,7 +14249,7 @@ fn atomicOp(
14249 rmw_op: ?std.builtin.AtomicRmwOp,14249 rmw_op: ?std.builtin.AtomicRmwOp,
14250 order: std.builtin.AtomicOrder,14250 order: std.builtin.AtomicOrder,
14251) InnerError!MCValue {14251) InnerError!MCValue {
14252 const mod = self.bin_file.options.module.?;14252 const mod = self.bin_file.comp.module.?;
14253 const ptr_lock = switch (ptr_mcv) {14253 const ptr_lock = switch (ptr_mcv) {
14254 .register => |reg| self.register_manager.lockReg(reg),14254 .register => |reg| self.register_manager.lockReg(reg),
14255 else => null,14255 else => null,
...@@ -14653,7 +14653,7 @@ fn airAtomicStore(self: *Self, inst: Air.Inst.Index, order: std.builtin.AtomicOr...@@ -14653,7 +14653,7 @@ fn airAtomicStore(self: *Self, inst: Air.Inst.Index, order: std.builtin.AtomicOr
14653}14653}
1465414654
14655fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {14655fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
14656 const mod = self.bin_file.options.module.?;14656 const mod = self.bin_file.comp.module.?;
14657 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;14657 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
1465814658
14659 result: {14659 result: {
...@@ -14781,7 +14781,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {...@@ -14781,7 +14781,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
14781}14781}
1478214782
14783fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {14783fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {
14784 const mod = self.bin_file.options.module.?;14784 const mod = self.bin_file.comp.module.?;
14785 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;14785 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
1478614786
14787 try self.spillRegisters(&.{ .rdi, .rsi, .rcx });14787 try self.spillRegisters(&.{ .rdi, .rsi, .rcx });
...@@ -14836,7 +14836,7 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {...@@ -14836,7 +14836,7 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {
14836}14836}
1483714837
14838fn airTagName(self: *Self, inst: Air.Inst.Index) !void {14838fn airTagName(self: *Self, inst: Air.Inst.Index) !void {
14839 const mod = self.bin_file.options.module.?;14839 const mod = self.bin_file.comp.module.?;
14840 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;14840 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
14841 const inst_ty = self.typeOfIndex(inst);14841 const inst_ty = self.typeOfIndex(inst);
14842 const enum_ty = self.typeOf(un_op);14842 const enum_ty = self.typeOf(un_op);
...@@ -14878,7 +14878,7 @@ fn airTagName(self: *Self, inst: Air.Inst.Index) !void {...@@ -14878,7 +14878,7 @@ fn airTagName(self: *Self, inst: Air.Inst.Index) !void {
14878}14878}
1487914879
14880fn airErrorName(self: *Self, inst: Air.Inst.Index) !void {14880fn airErrorName(self: *Self, inst: Air.Inst.Index) !void {
14881 const mod = self.bin_file.options.module.?;14881 const mod = self.bin_file.comp.module.?;
14882 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;14882 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
1488314883
14884 const err_ty = self.typeOf(un_op);14884 const err_ty = self.typeOf(un_op);
...@@ -14980,7 +14980,7 @@ fn airErrorName(self: *Self, inst: Air.Inst.Index) !void {...@@ -14980,7 +14980,7 @@ fn airErrorName(self: *Self, inst: Air.Inst.Index) !void {
14980}14980}
1498114981
14982fn airSplat(self: *Self, inst: Air.Inst.Index) !void {14982fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
14983 const mod = self.bin_file.options.module.?;14983 const mod = self.bin_file.comp.module.?;
14984 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;14984 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
14985 const vector_ty = self.typeOfIndex(inst);14985 const vector_ty = self.typeOfIndex(inst);
14986 const vector_len = vector_ty.vectorLen(mod);14986 const vector_len = vector_ty.vectorLen(mod);
...@@ -15332,7 +15332,7 @@ fn airShuffle(self: *Self, inst: Air.Inst.Index) !void {...@@ -15332,7 +15332,7 @@ fn airShuffle(self: *Self, inst: Air.Inst.Index) !void {
15332}15332}
1533315333
15334fn airReduce(self: *Self, inst: Air.Inst.Index) !void {15334fn airReduce(self: *Self, inst: Air.Inst.Index) !void {
15335 const mod = self.bin_file.options.module.?;15335 const mod = self.bin_file.comp.module.?;
15336 const reduce = self.air.instructions.items(.data)[@intFromEnum(inst)].reduce;15336 const reduce = self.air.instructions.items(.data)[@intFromEnum(inst)].reduce;
1533715337
15338 const result: MCValue = result: {15338 const result: MCValue = result: {
...@@ -15389,7 +15389,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {...@@ -15389,7 +15389,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {
15389}15389}
1539015390
15391fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {15391fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
15392 const mod = self.bin_file.options.module.?;15392 const mod = self.bin_file.comp.module.?;
15393 const result_ty = self.typeOfIndex(inst);15393 const result_ty = self.typeOfIndex(inst);
15394 const len: usize = @intCast(result_ty.arrayLen(mod));15394 const len: usize = @intCast(result_ty.arrayLen(mod));
15395 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;15395 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
...@@ -15562,7 +15562,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {...@@ -15562,7 +15562,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
15562}15562}
1556315563
15564fn airUnionInit(self: *Self, inst: Air.Inst.Index) !void {15564fn airUnionInit(self: *Self, inst: Air.Inst.Index) !void {
15565 const mod = self.bin_file.options.module.?;15565 const mod = self.bin_file.comp.module.?;
15566 const ip = &mod.intern_pool;15566 const ip = &mod.intern_pool;
15567 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;15567 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
15568 const extra = self.air.extraData(Air.UnionInit, ty_pl.payload).data;15568 const extra = self.air.extraData(Air.UnionInit, ty_pl.payload).data;
...@@ -15613,7 +15613,7 @@ fn airPrefetch(self: *Self, inst: Air.Inst.Index) !void {...@@ -15613,7 +15613,7 @@ fn airPrefetch(self: *Self, inst: Air.Inst.Index) !void {
15613}15613}
1561415614
15615fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {15615fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {
15616 const mod = self.bin_file.options.module.?;15616 const mod = self.bin_file.comp.module.?;
15617 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;15617 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
15618 const extra = self.air.extraData(Air.Bin, pl_op.payload).data;15618 const extra = self.air.extraData(Air.Bin, pl_op.payload).data;
15619 const ty = self.typeOfIndex(inst);15619 const ty = self.typeOfIndex(inst);
...@@ -15780,7 +15780,7 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {...@@ -15780,7 +15780,7 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {
15780}15780}
1578115781
15782fn airVaStart(self: *Self, inst: Air.Inst.Index) !void {15782fn airVaStart(self: *Self, inst: Air.Inst.Index) !void {
15783 const mod = self.bin_file.options.module.?;15783 const mod = self.bin_file.comp.module.?;
15784 const va_list_ty = self.air.instructions.items(.data)[@intFromEnum(inst)].ty;15784 const va_list_ty = self.air.instructions.items(.data)[@intFromEnum(inst)].ty;
15785 const ptr_anyopaque_ty = try mod.singleMutPtrType(Type.anyopaque);15785 const ptr_anyopaque_ty = try mod.singleMutPtrType(Type.anyopaque);
1578615786
...@@ -15833,7 +15833,7 @@ fn airVaStart(self: *Self, inst: Air.Inst.Index) !void {...@@ -15833,7 +15833,7 @@ fn airVaStart(self: *Self, inst: Air.Inst.Index) !void {
15833}15833}
1583415834
15835fn airVaArg(self: *Self, inst: Air.Inst.Index) !void {15835fn airVaArg(self: *Self, inst: Air.Inst.Index) !void {
15836 const mod = self.bin_file.options.module.?;15836 const mod = self.bin_file.comp.module.?;
15837 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;15837 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
15838 const ty = self.typeOfIndex(inst);15838 const ty = self.typeOfIndex(inst);
15839 const promote_ty = self.promoteVarArg(ty);15839 const promote_ty = self.promoteVarArg(ty);
...@@ -16042,7 +16042,7 @@ fn airVaEnd(self: *Self, inst: Air.Inst.Index) !void {...@@ -16042,7 +16042,7 @@ fn airVaEnd(self: *Self, inst: Air.Inst.Index) !void {
16042}16042}
1604316043
16044fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {16044fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {
16045 const mod = self.bin_file.options.module.?;16045 const mod = self.bin_file.comp.module.?;
16046 const ty = self.typeOf(ref);16046 const ty = self.typeOf(ref);
1604716047
16048 // If the type has no codegen bits, no need to store it.16048 // If the type has no codegen bits, no need to store it.
...@@ -16116,7 +16116,7 @@ fn limitImmediateType(self: *Self, operand: Air.Inst.Ref, comptime T: type) !MCV...@@ -16116,7 +16116,7 @@ fn limitImmediateType(self: *Self, operand: Air.Inst.Ref, comptime T: type) !MCV
16116}16116}
1611716117
16118fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {16118fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
16119 const mod = self.bin_file.options.module.?;16119 const mod = self.bin_file.comp.module.?;
16120 return switch (try codegen.genTypedValue(self.bin_file, self.src_loc, arg_tv, self.owner.getDecl(mod))) {16120 return switch (try codegen.genTypedValue(self.bin_file, self.src_loc, arg_tv, self.owner.getDecl(mod))) {
16121 .mcv => |mcv| switch (mcv) {16121 .mcv => |mcv| switch (mcv) {
16122 .none => .none,16122 .none => .none,
...@@ -16156,7 +16156,7 @@ fn resolveCallingConventionValues(...@@ -16156,7 +16156,7 @@ fn resolveCallingConventionValues(
16156 var_args: []const Type,16156 var_args: []const Type,
16157 stack_frame_base: FrameIndex,16157 stack_frame_base: FrameIndex,
16158) !CallMCValues {16158) !CallMCValues {
16159 const mod = self.bin_file.options.module.?;16159 const mod = self.bin_file.comp.module.?;
16160 const ip = &mod.intern_pool;16160 const ip = &mod.intern_pool;
16161 const cc = fn_info.cc;16161 const cc = fn_info.cc;
16162 const param_types = try self.gpa.alloc(Type, fn_info.param_types.len + var_args.len);16162 const param_types = try self.gpa.alloc(Type, fn_info.param_types.len + var_args.len);
...@@ -16468,7 +16468,7 @@ fn registerAlias(reg: Register, size_bytes: u32) Register {...@@ -16468,7 +16468,7 @@ fn registerAlias(reg: Register, size_bytes: u32) Register {
16468}16468}
1646916469
16470fn memSize(self: *Self, ty: Type) Memory.Size {16470fn memSize(self: *Self, ty: Type) Memory.Size {
16471 const mod = self.bin_file.options.module.?;16471 const mod = self.bin_file.comp.module.?;
16472 return switch (ty.zigTypeTag(mod)) {16472 return switch (ty.zigTypeTag(mod)) {
16473 .Float => Memory.Size.fromBitSize(ty.floatBits(self.target.*)),16473 .Float => Memory.Size.fromBitSize(ty.floatBits(self.target.*)),
16474 else => Memory.Size.fromSize(@intCast(ty.abiSize(mod))),16474 else => Memory.Size.fromSize(@intCast(ty.abiSize(mod))),
...@@ -16476,7 +16476,7 @@ fn memSize(self: *Self, ty: Type) Memory.Size {...@@ -16476,7 +16476,7 @@ fn memSize(self: *Self, ty: Type) Memory.Size {
16476}16476}
1647716477
16478fn splitType(self: *Self, ty: Type) ![2]Type {16478fn splitType(self: *Self, ty: Type) ![2]Type {
16479 const mod = self.bin_file.options.module.?;16479 const mod = self.bin_file.comp.module.?;
16480 const classes = mem.sliceTo(&abi.classifySystemV(ty, mod, .other), .none);16480 const classes = mem.sliceTo(&abi.classifySystemV(ty, mod, .other), .none);
16481 var parts: [2]Type = undefined;16481 var parts: [2]Type = undefined;
16482 if (classes.len == 2) for (&parts, classes, 0..) |*part, class, part_i| {16482 if (classes.len == 2) for (&parts, classes, 0..) |*part, class, part_i| {
...@@ -16505,7 +16505,7 @@ fn splitType(self: *Self, ty: Type) ![2]Type {...@@ -16505,7 +16505,7 @@ fn splitType(self: *Self, ty: Type) ![2]Type {
16505/// Truncates the value in the register in place.16505/// Truncates the value in the register in place.
16506/// Clobbers any remaining bits.16506/// Clobbers any remaining bits.
16507fn truncateRegister(self: *Self, ty: Type, reg: Register) !void {16507fn truncateRegister(self: *Self, ty: Type, reg: Register) !void {
16508 const mod = self.bin_file.options.module.?;16508 const mod = self.bin_file.comp.module.?;
16509 const int_info = if (ty.isAbiInt(mod)) ty.intInfo(mod) else std.builtin.Type.Int{16509 const int_info = if (ty.isAbiInt(mod)) ty.intInfo(mod) else std.builtin.Type.Int{
16510 .signedness = .unsigned,16510 .signedness = .unsigned,
16511 .bits = @intCast(ty.bitSize(mod)),16511 .bits = @intCast(ty.bitSize(mod)),
...@@ -16550,7 +16550,7 @@ fn truncateRegister(self: *Self, ty: Type, reg: Register) !void {...@@ -16550,7 +16550,7 @@ fn truncateRegister(self: *Self, ty: Type, reg: Register) !void {
16550}16550}
1655116551
16552fn regBitSize(self: *Self, ty: Type) u64 {16552fn regBitSize(self: *Self, ty: Type) u64 {
16553 const mod = self.bin_file.options.module.?;16553 const mod = self.bin_file.comp.module.?;
16554 const abi_size = ty.abiSize(mod);16554 const abi_size = ty.abiSize(mod);
16555 return switch (ty.zigTypeTag(mod)) {16555 return switch (ty.zigTypeTag(mod)) {
16556 else => switch (abi_size) {16556 else => switch (abi_size) {
...@@ -16569,7 +16569,7 @@ fn regBitSize(self: *Self, ty: Type) u64 {...@@ -16569,7 +16569,7 @@ fn regBitSize(self: *Self, ty: Type) u64 {
16569}16569}
1657016570
16571fn regExtraBits(self: *Self, ty: Type) u64 {16571fn regExtraBits(self: *Self, ty: Type) u64 {
16572 const mod = self.bin_file.options.module.?;16572 const mod = self.bin_file.comp.module.?;
16573 return self.regBitSize(ty) - ty.bitSize(mod);16573 return self.regBitSize(ty) - ty.bitSize(mod);
16574}16574}
1657516575
...@@ -16584,12 +16584,12 @@ fn hasAllFeatures(self: *Self, features: anytype) bool {...@@ -16584,12 +16584,12 @@ fn hasAllFeatures(self: *Self, features: anytype) bool {
16584}16584}
1658516585
16586fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {16586fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
16587 const mod = self.bin_file.options.module.?;16587 const mod = self.bin_file.comp.module.?;
16588 return self.air.typeOf(inst, &mod.intern_pool);16588 return self.air.typeOf(inst, &mod.intern_pool);
16589}16589}
1659016590
16591fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {16591fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
16592 const mod = self.bin_file.options.module.?;16592 const mod = self.bin_file.comp.module.?;
16593 return self.air.typeOfIndex(inst, &mod.intern_pool);16593 return self.air.typeOfIndex(inst, &mod.intern_pool);
16594}16594}
1659516595
...@@ -16641,7 +16641,7 @@ fn floatLibcAbiSuffix(ty: Type) []const u8 {...@@ -16641,7 +16641,7 @@ fn floatLibcAbiSuffix(ty: Type) []const u8 {
16641}16641}
1664216642
16643fn promoteInt(self: *Self, ty: Type) Type {16643fn promoteInt(self: *Self, ty: Type) Type {
16644 const mod = self.bin_file.options.module.?;16644 const mod = self.bin_file.comp.module.?;
16645 const int_info: InternPool.Key.IntType = switch (ty.toIntern()) {16645 const int_info: InternPool.Key.IntType = switch (ty.toIntern()) {
16646 .bool_type => .{ .signedness = .unsigned, .bits = 1 },16646 .bool_type => .{ .signedness = .unsigned, .bits = 1 },
16647 else => if (ty.isAbiInt(mod)) ty.intInfo(mod) else return ty,16647 else => if (ty.isAbiInt(mod)) ty.intInfo(mod) else return ty,
src/codegen.zig+8-8
...@@ -110,7 +110,7 @@ pub fn generateLazySymbol(...@@ -110,7 +110,7 @@ pub fn generateLazySymbol(
110 const target = bin_file.options.target;110 const target = bin_file.options.target;
111 const endian = target.cpu.arch.endian();111 const endian = target.cpu.arch.endian();
112112
113 const mod = bin_file.options.module.?;113 const mod = bin_file.comp.module.?;
114 log.debug("generateLazySymbol: kind = {s}, ty = {}", .{114 log.debug("generateLazySymbol: kind = {s}, ty = {}", .{
115 @tagName(lazy_sym.kind),115 @tagName(lazy_sym.kind),
116 lazy_sym.ty.fmt(mod),116 lazy_sym.ty.fmt(mod),
...@@ -165,7 +165,7 @@ pub fn generateSymbol(...@@ -165,7 +165,7 @@ pub fn generateSymbol(
165 const tracy = trace(@src());165 const tracy = trace(@src());
166 defer tracy.end();166 defer tracy.end();
167167
168 const mod = bin_file.options.module.?;168 const mod = bin_file.comp.module.?;
169 const ip = &mod.intern_pool;169 const ip = &mod.intern_pool;
170 const typed_value = arg_tv;170 const typed_value = arg_tv;
171171
...@@ -662,7 +662,7 @@ fn lowerParentPtr(...@@ -662,7 +662,7 @@ fn lowerParentPtr(
662 debug_output: DebugInfoOutput,662 debug_output: DebugInfoOutput,
663 reloc_info: RelocInfo,663 reloc_info: RelocInfo,
664) CodeGenError!Result {664) CodeGenError!Result {
665 const mod = bin_file.options.module.?;665 const mod = bin_file.comp.module.?;
666 const ptr = mod.intern_pool.indexToKey(parent_ptr).ptr;666 const ptr = mod.intern_pool.indexToKey(parent_ptr).ptr;
667 assert(ptr.len == .none);667 assert(ptr.len == .none);
668 return switch (ptr.addr) {668 return switch (ptr.addr) {
...@@ -766,7 +766,7 @@ fn lowerAnonDeclRef(...@@ -766,7 +766,7 @@ fn lowerAnonDeclRef(
766) CodeGenError!Result {766) CodeGenError!Result {
767 _ = debug_output;767 _ = debug_output;
768 const target = bin_file.options.target;768 const target = bin_file.options.target;
769 const mod = bin_file.options.module.?;769 const mod = bin_file.comp.module.?;
770770
771 const ptr_width_bytes = @divExact(target.ptrBitWidth(), 8);771 const ptr_width_bytes = @divExact(target.ptrBitWidth(), 8);
772 const decl_val = anon_decl.val;772 const decl_val = anon_decl.val;
...@@ -812,7 +812,7 @@ fn lowerDeclRef(...@@ -812,7 +812,7 @@ fn lowerDeclRef(
812 _ = src_loc;812 _ = src_loc;
813 _ = debug_output;813 _ = debug_output;
814 const target = bin_file.options.target;814 const target = bin_file.options.target;
815 const mod = bin_file.options.module.?;815 const mod = bin_file.comp.module.?;
816816
817 const ptr_width = target.ptrBitWidth();817 const ptr_width = target.ptrBitWidth();
818 const decl = mod.declPtr(decl_index);818 const decl = mod.declPtr(decl_index);
...@@ -902,7 +902,7 @@ fn genDeclRef(...@@ -902,7 +902,7 @@ fn genDeclRef(
902 tv: TypedValue,902 tv: TypedValue,
903 ptr_decl_index: InternPool.DeclIndex,903 ptr_decl_index: InternPool.DeclIndex,
904) CodeGenError!GenResult {904) CodeGenError!GenResult {
905 const mod = bin_file.options.module.?;905 const mod = bin_file.comp.module.?;
906 log.debug("genDeclRef: ty = {}, val = {}", .{ tv.ty.fmt(mod), tv.val.fmtValue(tv.ty, mod) });906 log.debug("genDeclRef: ty = {}, val = {}", .{ tv.ty.fmt(mod), tv.val.fmtValue(tv.ty, mod) });
907907
908 const target = bin_file.options.target;908 const target = bin_file.options.target;
...@@ -1010,7 +1010,7 @@ fn genUnnamedConst(...@@ -1010,7 +1010,7 @@ fn genUnnamedConst(
1010 tv: TypedValue,1010 tv: TypedValue,
1011 owner_decl_index: InternPool.DeclIndex,1011 owner_decl_index: InternPool.DeclIndex,
1012) CodeGenError!GenResult {1012) CodeGenError!GenResult {
1013 const mod = bin_file.options.module.?;1013 const mod = bin_file.comp.module.?;
1014 log.debug("genUnnamedConst: ty = {}, val = {}", .{ tv.ty.fmt(mod), tv.val.fmtValue(tv.ty, mod) });1014 log.debug("genUnnamedConst: ty = {}, val = {}", .{ tv.ty.fmt(mod), tv.val.fmtValue(tv.ty, mod) });
10151015
1016 const target = bin_file.options.target;1016 const target = bin_file.options.target;
...@@ -1038,7 +1038,7 @@ pub fn genTypedValue(...@@ -1038,7 +1038,7 @@ pub fn genTypedValue(
1038 arg_tv: TypedValue,1038 arg_tv: TypedValue,
1039 owner_decl_index: InternPool.DeclIndex,1039 owner_decl_index: InternPool.DeclIndex,
1040) CodeGenError!GenResult {1040) CodeGenError!GenResult {
1041 const mod = bin_file.options.module.?;1041 const mod = bin_file.comp.module.?;
1042 const typed_value = arg_tv;1042 const typed_value = arg_tv;
10431043
1044 log.debug("genTypedValue: ty = {}, val = {}", .{1044 log.debug("genTypedValue: ty = {}, val = {}", .{
src/codegen/llvm.zig+1-1
...@@ -1227,7 +1227,7 @@ pub const Object = struct {...@@ -1227,7 +1227,7 @@ pub const Object = struct {
1227 defer arena_allocator.deinit();1227 defer arena_allocator.deinit();
1228 const arena = arena_allocator.allocator();1228 const arena = arena_allocator.allocator();
12291229
1230 const mod = comp.bin_file.options.module.?;1230 const mod = comp.module.?;
1231 const cache_dir = mod.zig_cache_artifact_directory;1231 const cache_dir = mod.zig_cache_artifact_directory;
12321232
1233 if (std.debug.runtime_safety and !try self.builder.verify()) {1233 if (std.debug.runtime_safety and !try self.builder.verify()) {