update references to module (to be renamed to zcu)
This commit is contained in:
@@ -1915,7 +1915,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
|
||||
}
|
||||
|
||||
pub fn destroy(self: *Compilation) void {
|
||||
const optional_module = self.bin_file.options.module;
|
||||
const optional_module = self.module;
|
||||
self.bin_file.destroy();
|
||||
if (optional_module) |module| module.deinit();
|
||||
|
||||
@@ -2017,7 +2017,7 @@ fn restorePrevZigCacheArtifactDirectory(comp: *Compilation, directory: *Director
|
||||
// Restore the Module's previous zig_cache_artifact_directory
|
||||
// This is only for cleanup purposes; Module.deinit calls close
|
||||
// on the handle of zig_cache_artifact_directory.
|
||||
if (comp.bin_file.options.module) |module| {
|
||||
if (comp.module) |module| {
|
||||
const builtin_mod = module.main_mod.deps.get("builtin").?;
|
||||
module.zig_cache_artifact_directory = builtin_mod.root.root_dir;
|
||||
}
|
||||
@@ -2109,7 +2109,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
|
||||
};
|
||||
|
||||
// This updates the output directory for linker outputs.
|
||||
if (comp.bin_file.options.module) |module| {
|
||||
if (comp.module) |module| {
|
||||
module.zig_cache_artifact_directory = tmp_artifact_directory.?;
|
||||
}
|
||||
|
||||
@@ -2155,7 +2155,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
|
||||
}
|
||||
}
|
||||
|
||||
if (comp.bin_file.options.module) |module| {
|
||||
if (comp.module) |module| {
|
||||
module.compile_log_text.shrinkAndFree(module.gpa, 0);
|
||||
module.generation += 1;
|
||||
|
||||
@@ -2206,7 +2206,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
|
||||
|
||||
try comp.performAllTheWork(main_progress_node);
|
||||
|
||||
if (comp.bin_file.options.module) |module| {
|
||||
if (comp.module) |module| {
|
||||
if (builtin.mode == .Debug and comp.verbose_intern_pool) {
|
||||
std.debug.print("intern pool stats for '{s}':\n", .{
|
||||
comp.bin_file.options.root_name,
|
||||
@@ -2277,7 +2277,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
|
||||
}
|
||||
|
||||
// This is intentionally sandwiched between renameTmpIntoCache() and writeManifest().
|
||||
if (comp.bin_file.options.module) |module| {
|
||||
if (comp.module) |module| {
|
||||
// We need to set the zig_cache_artifact_directory for -femit-asm, -femit-llvm-ir,
|
||||
// etc to know where to output to.
|
||||
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
|
||||
// to it, and (2) generic instantiations, comptime calls, inline calls will need
|
||||
// to reference the ZIR.
|
||||
if (!comp.keep_source_files_loaded) {
|
||||
if (comp.bin_file.options.module) |module| {
|
||||
if (comp.module) |module| {
|
||||
for (module.import_table.values()) |file| {
|
||||
file.unloadTree(comp.gpa);
|
||||
file.unloadSource(comp.gpa);
|
||||
@@ -2332,7 +2332,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
|
||||
}
|
||||
|
||||
fn maybeGenerateAutodocs(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
||||
const mod = comp.bin_file.options.module orelse return;
|
||||
const mod = comp.module orelse return;
|
||||
// TODO: do this in a separate job during performAllTheWork(). The
|
||||
// file copies at the end of generate() can also be extracted to
|
||||
// separate jobs
|
||||
@@ -2360,7 +2360,7 @@ fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {
|
||||
};
|
||||
comp.link_error_flags = comp.bin_file.errorFlags();
|
||||
|
||||
if (comp.bin_file.options.module) |module| {
|
||||
if (comp.module) |module| {
|
||||
try link.File.C.flushEmitH(module);
|
||||
}
|
||||
}
|
||||
@@ -2421,7 +2421,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
|
||||
|
||||
comptime assert(link_hash_implementation_version == 10);
|
||||
|
||||
if (comp.bin_file.options.module) |mod| {
|
||||
if (comp.module) |mod| {
|
||||
const main_zig_file = try mod.main_mod.root.joinString(arena, mod.main_mod.root_src_path);
|
||||
_ = try man.addFile(main_zig_file, null);
|
||||
try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.main_mod, .{ .files = man });
|
||||
@@ -2559,7 +2559,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
|
||||
}
|
||||
|
||||
fn emitOthers(comp: *Compilation) void {
|
||||
if (comp.bin_file.options.output_mode != .Obj or comp.bin_file.options.module != null or
|
||||
if (comp.bin_file.options.output_mode != .Obj or comp.module != null or
|
||||
comp.c_object_table.count() == 0)
|
||||
{
|
||||
return;
|
||||
@@ -2727,7 +2727,7 @@ pub fn saveState(comp: *Compilation) !void {
|
||||
|
||||
const emit = comp.bin_file.options.emit orelse return;
|
||||
|
||||
if (comp.bin_file.options.module) |mod| {
|
||||
if (comp.module) |mod| {
|
||||
const ip = &mod.intern_pool;
|
||||
const header: Header = .{
|
||||
.intern_pool = .{
|
||||
@@ -2792,7 +2792,7 @@ pub fn totalErrorCount(self: *Compilation) u32 {
|
||||
}
|
||||
}
|
||||
|
||||
if (self.bin_file.options.module) |module| {
|
||||
if (self.module) |module| {
|
||||
total += module.failed_exports.count();
|
||||
total += module.failed_embed_files.count();
|
||||
|
||||
@@ -2844,7 +2844,7 @@ pub fn totalErrorCount(self: *Compilation) u32 {
|
||||
|
||||
// Compile log errors only count if there are no other errors.
|
||||
if (total == 0) {
|
||||
if (self.bin_file.options.module) |module| {
|
||||
if (self.module) |module| {
|
||||
total += @intFromBool(module.compile_log_decls.count() != 0);
|
||||
}
|
||||
}
|
||||
@@ -2896,7 +2896,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
|
||||
.msg = try bundle.addString("memory allocation failure"),
|
||||
});
|
||||
}
|
||||
if (self.bin_file.options.module) |module| {
|
||||
if (self.module) |module| {
|
||||
for (module.failed_files.keys(), module.failed_files.values()) |file, error_msg| {
|
||||
if (error_msg) |msg| {
|
||||
try addModuleErrorMsg(module, &bundle, msg.*);
|
||||
@@ -3002,7 +3002,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
|
||||
}
|
||||
}
|
||||
|
||||
if (self.bin_file.options.module) |module| {
|
||||
if (self.module) |module| {
|
||||
if (bundle.root_list.items.len == 0 and module.compile_log_decls.count() != 0) {
|
||||
const keys = module.compile_log_decls.keys();
|
||||
const values = module.compile_log_decls.values();
|
||||
@@ -3030,7 +3030,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
|
||||
|
||||
assert(self.totalErrorCount() == bundle.root_list.items.len);
|
||||
|
||||
const compile_log_text = if (self.bin_file.options.module) |m| m.compile_log_text.items else "";
|
||||
const compile_log_text = if (self.module) |m| m.compile_log_text.items else "";
|
||||
return bundle.toOwnedBundle(compile_log_text);
|
||||
}
|
||||
|
||||
@@ -3314,7 +3314,7 @@ pub fn performAllTheWork(
|
||||
// 1. to avoid race condition of zig processes truncating each other's builtin.zig files
|
||||
// 2. optimization; in the hot path it only incurs a stat() syscall, which happens
|
||||
// in the `astgen_wait_group`.
|
||||
if (comp.bin_file.options.module) |mod| {
|
||||
if (comp.module) |mod| {
|
||||
if (mod.job_queued_update_builtin_zig) {
|
||||
mod.job_queued_update_builtin_zig = false;
|
||||
|
||||
@@ -3356,15 +3356,15 @@ pub fn performAllTheWork(
|
||||
}
|
||||
}
|
||||
|
||||
if (comp.bin_file.options.module) |mod| {
|
||||
if (comp.module) |mod| {
|
||||
try reportMultiModuleErrors(mod);
|
||||
}
|
||||
|
||||
if (comp.bin_file.options.module) |mod| {
|
||||
if (comp.module) |mod| {
|
||||
mod.sema_prog_node = main_progress_node.start("Semantic Analysis", 0);
|
||||
mod.sema_prog_node.activate();
|
||||
}
|
||||
defer if (comp.bin_file.options.module) |mod| {
|
||||
defer if (comp.module) |mod| {
|
||||
mod.sema_prog_node.end();
|
||||
mod.sema_prog_node = undefined;
|
||||
};
|
||||
@@ -3398,7 +3398,7 @@ pub fn performAllTheWork(
|
||||
fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !void {
|
||||
switch (job) {
|
||||
.codegen_decl => |decl_index| {
|
||||
const module = comp.bin_file.options.module.?;
|
||||
const module = comp.module.?;
|
||||
const decl = module.declPtr(decl_index);
|
||||
|
||||
switch (decl.analysis) {
|
||||
@@ -3436,14 +3436,14 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
|
||||
const named_frame = tracy.namedFrame("codegen_func");
|
||||
defer named_frame.end();
|
||||
|
||||
const module = comp.bin_file.options.module.?;
|
||||
const module = comp.module.?;
|
||||
module.ensureFuncBodyAnalyzed(func) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.AnalysisFail => return,
|
||||
};
|
||||
},
|
||||
.emit_h_decl => |decl_index| {
|
||||
const module = comp.bin_file.options.module.?;
|
||||
const module = comp.module.?;
|
||||
const decl = module.declPtr(decl_index);
|
||||
|
||||
switch (decl.analysis) {
|
||||
@@ -3502,7 +3502,7 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
|
||||
}
|
||||
},
|
||||
.analyze_decl => |decl_index| {
|
||||
const module = comp.bin_file.options.module.?;
|
||||
const module = comp.module.?;
|
||||
module.ensureDeclAnalyzed(decl_index) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.AnalysisFail => return,
|
||||
@@ -3520,7 +3520,7 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
|
||||
defer named_frame.end();
|
||||
|
||||
const gpa = comp.gpa;
|
||||
const module = comp.bin_file.options.module.?;
|
||||
const module = comp.module.?;
|
||||
const decl = module.declPtr(decl_index);
|
||||
comp.bin_file.updateDeclLineNumber(module, decl_index) catch |err| {
|
||||
try module.failed_decls.ensureUnusedCapacity(gpa, 1);
|
||||
@@ -3537,7 +3537,7 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
|
||||
const named_frame = tracy.namedFrame("analyze_mod");
|
||||
defer named_frame.end();
|
||||
|
||||
const module = comp.bin_file.options.module.?;
|
||||
const module = comp.module.?;
|
||||
module.semaPkg(pkg) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.AnalysisFail => return,
|
||||
@@ -3716,7 +3716,7 @@ fn workerAstGenFile(
|
||||
child_prog_node.activate();
|
||||
defer child_prog_node.end();
|
||||
|
||||
const mod = comp.bin_file.options.module.?;
|
||||
const mod = comp.module.?;
|
||||
mod.astGenFile(file) catch |err| switch (err) {
|
||||
error.AnalysisFail => return,
|
||||
else => {
|
||||
@@ -3819,7 +3819,7 @@ fn workerCheckEmbedFile(
|
||||
}
|
||||
|
||||
fn detectEmbedFileUpdate(comp: *Compilation, embed_file: *Module.EmbedFile) !void {
|
||||
const mod = comp.bin_file.options.module.?;
|
||||
const mod = comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const sub_file_path = ip.stringToSlice(embed_file.sub_file_path);
|
||||
var file = try embed_file.owner.root.openFile(sub_file_path, .{});
|
||||
@@ -4142,7 +4142,7 @@ fn reportRetryableAstGenError(
|
||||
file: *Module.File,
|
||||
err: anyerror,
|
||||
) error{OutOfMemory}!void {
|
||||
const mod = comp.bin_file.options.module.?;
|
||||
const mod = comp.module.?;
|
||||
const gpa = mod.gpa;
|
||||
|
||||
file.status = .retryable_failure;
|
||||
@@ -4181,7 +4181,7 @@ fn reportRetryableEmbedFileError(
|
||||
embed_file: *Module.EmbedFile,
|
||||
err: anyerror,
|
||||
) error{OutOfMemory}!void {
|
||||
const mod = comp.bin_file.options.module.?;
|
||||
const mod = comp.module.?;
|
||||
const gpa = mod.gpa;
|
||||
const src_loc = embed_file.src_loc;
|
||||
const ip = &mod.intern_pool;
|
||||
@@ -4248,7 +4248,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
|
||||
// Special case when doing build-obj for just one C file. When there are more than one object
|
||||
// file and building an object we need to link them together, but with just one it should go
|
||||
// directly to the output file.
|
||||
const direct_o = comp.c_source_files.len == 1 and comp.bin_file.options.module == null and
|
||||
const direct_o = comp.c_source_files.len == 1 and comp.module == null and
|
||||
comp.bin_file.options.output_mode == .Obj and comp.bin_file.options.objects.len == 0;
|
||||
const o_basename_noext = if (direct_o)
|
||||
comp.bin_file.options.root_name
|
||||
|
||||
@@ -341,7 +341,7 @@ pub fn generate(
|
||||
@panic("Attempted to compile for architecture that was disabled by build configuration");
|
||||
}
|
||||
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
const func = mod.funcInfo(func_index);
|
||||
const fn_owner_decl = mod.declPtr(func.owner_decl);
|
||||
assert(fn_owner_decl.has_tv);
|
||||
@@ -476,7 +476,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {
|
||||
}
|
||||
|
||||
fn gen(self: *Self) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const cc = self.fn_type.fnCallingConvention(mod);
|
||||
if (cc != .Naked) {
|
||||
// stp fp, lr, [sp, #-16]!
|
||||
@@ -656,7 +656,7 @@ fn gen(self: *Self) !void {
|
||||
}
|
||||
|
||||
fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const air_tags = self.air.instructions.items(.tag);
|
||||
|
||||
@@ -1028,7 +1028,7 @@ fn allocMem(
|
||||
|
||||
/// Use a pointer instruction as the basis for allocating stack memory.
|
||||
fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = self.typeOfIndex(inst).childType(mod);
|
||||
|
||||
if (!elem_ty.hasRuntimeBits(mod)) {
|
||||
@@ -1048,7 +1048,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
|
||||
}
|
||||
|
||||
fn allocRegOrMem(self: *Self, elem_ty: Type, reg_ok: bool, maybe_inst: ?Air.Inst.Index) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {
|
||||
return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});
|
||||
};
|
||||
@@ -1139,7 +1139,7 @@ fn airAlloc(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airRetPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = switch (self.ret_mcv) {
|
||||
.none, .register => .{ .ptr_stack_offset = try self.allocMemPtr(inst) },
|
||||
.stack_offset => blk: {
|
||||
@@ -1176,7 +1176,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
|
||||
if (self.liveness.isUnused(inst))
|
||||
return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const operand = ty_op.operand;
|
||||
const operand_mcv = try self.resolveInst(operand);
|
||||
const operand_ty = self.typeOf(operand);
|
||||
@@ -1257,7 +1257,7 @@ fn trunc(
|
||||
operand_ty: Type,
|
||||
dest_ty: Type,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const info_a = operand_ty.intInfo(mod);
|
||||
const info_b = dest_ty.intInfo(mod);
|
||||
|
||||
@@ -1320,7 +1320,7 @@ fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airNot(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const operand = try self.resolveInst(ty_op.operand);
|
||||
const operand_ty = self.typeOf(ty_op.operand);
|
||||
@@ -1415,7 +1415,7 @@ fn minMax(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO ARM min/max on floats", .{}),
|
||||
.Vector => return self.fail("TODO ARM min/max on vectors", .{}),
|
||||
@@ -1905,7 +1905,7 @@ fn addSub(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO binary operations on floats", .{}),
|
||||
.Vector => return self.fail("TODO binary operations on vectors", .{}),
|
||||
@@ -1966,7 +1966,7 @@ fn mul(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Vector => return self.fail("TODO binary operations on vectors", .{}),
|
||||
.Int => {
|
||||
@@ -1998,7 +1998,7 @@ fn divFloat(
|
||||
_ = rhs_ty;
|
||||
_ = maybe_inst;
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO div_float", .{}),
|
||||
.Vector => return self.fail("TODO div_float on vectors", .{}),
|
||||
@@ -2014,7 +2014,7 @@ fn divTrunc(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO div on floats", .{}),
|
||||
.Vector => return self.fail("TODO div on vectors", .{}),
|
||||
@@ -2048,7 +2048,7 @@ fn divFloor(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO div on floats", .{}),
|
||||
.Vector => return self.fail("TODO div on vectors", .{}),
|
||||
@@ -2081,7 +2081,7 @@ fn divExact(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO div on floats", .{}),
|
||||
.Vector => return self.fail("TODO div on vectors", .{}),
|
||||
@@ -2117,7 +2117,7 @@ fn rem(
|
||||
) InnerError!MCValue {
|
||||
_ = maybe_inst;
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO rem/mod on floats", .{}),
|
||||
.Vector => return self.fail("TODO rem/mod on vectors", .{}),
|
||||
@@ -2188,7 +2188,7 @@ fn modulo(
|
||||
_ = rhs_ty;
|
||||
_ = maybe_inst;
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO mod on floats", .{}),
|
||||
.Vector => return self.fail("TODO mod on vectors", .{}),
|
||||
@@ -2206,7 +2206,7 @@ fn wrappingArithmetic(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Vector => return self.fail("TODO binary operations on vectors", .{}),
|
||||
.Int => {
|
||||
@@ -2241,7 +2241,7 @@ fn bitwise(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Vector => return self.fail("TODO binary operations on vectors", .{}),
|
||||
.Int => {
|
||||
@@ -2276,7 +2276,7 @@ fn shiftExact(
|
||||
) InnerError!MCValue {
|
||||
_ = rhs_ty;
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Vector => return self.fail("TODO binary operations on vectors", .{}),
|
||||
.Int => {
|
||||
@@ -2326,7 +2326,7 @@ fn shiftNormal(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Vector => return self.fail("TODO binary operations on vectors", .{}),
|
||||
.Int => {
|
||||
@@ -2366,7 +2366,7 @@ fn booleanOp(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Bool => {
|
||||
assert((try lhs_bind.resolveToImmediate(self)) == null); // should have been handled by Sema
|
||||
@@ -2393,7 +2393,7 @@ fn ptrArithmetic(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Pointer => {
|
||||
assert(rhs_ty.eql(Type.usize, mod));
|
||||
@@ -2516,7 +2516,7 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };
|
||||
const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };
|
||||
@@ -2644,7 +2644,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = result: {
|
||||
const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };
|
||||
const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };
|
||||
@@ -2868,7 +2868,7 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = result: {
|
||||
const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };
|
||||
const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };
|
||||
@@ -3016,7 +3016,7 @@ fn airOptionalPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn optionalPayload(self: *Self, inst: Air.Inst.Index, mcv: MCValue, optional_ty: Type) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const payload_ty = optional_ty.optionalChild(mod);
|
||||
if (!payload_ty.hasRuntimeBits(mod)) return MCValue.none;
|
||||
if (optional_ty.isPtrLikeOptional(mod)) {
|
||||
@@ -3060,7 +3060,7 @@ fn errUnionErr(
|
||||
error_union_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const err_ty = error_union_ty.errorUnionSet(mod);
|
||||
const payload_ty = error_union_ty.errorUnionPayload(mod);
|
||||
if (err_ty.errorSetIsEmpty(mod)) {
|
||||
@@ -3140,7 +3140,7 @@ fn errUnionPayload(
|
||||
error_union_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const err_ty = error_union_ty.errorUnionSet(mod);
|
||||
const payload_ty = error_union_ty.errorUnionPayload(mod);
|
||||
if (err_ty.errorSetIsEmpty(mod)) {
|
||||
@@ -3252,7 +3252,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
if (self.liveness.isUnused(inst)) {
|
||||
@@ -3297,7 +3297,7 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
/// T to E!T
|
||||
fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const error_union_ty = ty_op.ty.toType();
|
||||
@@ -3323,7 +3323,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const error_union_ty = ty_op.ty.toType();
|
||||
const error_ty = error_union_ty.errorUnionSet(mod);
|
||||
const payload_ty = error_union_ty.errorUnionPayload(mod);
|
||||
@@ -3426,7 +3426,7 @@ fn airPtrSlicePtrPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const slice_ty = self.typeOf(bin_op.lhs);
|
||||
const result: MCValue = if (!slice_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {
|
||||
@@ -3450,7 +3450,7 @@ fn ptrElemVal(
|
||||
ptr_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = ptr_ty.childType(mod);
|
||||
const elem_size = @as(u32, @intCast(elem_ty.abiSize(mod)));
|
||||
|
||||
@@ -3492,7 +3492,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const ptr_ty = self.typeOf(bin_op.lhs);
|
||||
const result: MCValue = if (!ptr_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {
|
||||
@@ -3615,7 +3615,7 @@ fn reuseOperand(
|
||||
}
|
||||
|
||||
fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = ptr_ty.childType(mod);
|
||||
const elem_size = elem_ty.abiSize(mod);
|
||||
|
||||
@@ -3863,7 +3863,7 @@ fn genInlineMemsetCode(
|
||||
}
|
||||
|
||||
fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const elem_ty = self.typeOfIndex(inst);
|
||||
const elem_size = elem_ty.abiSize(mod);
|
||||
@@ -3894,7 +3894,7 @@ fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn genLdrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = ty.abiSize(mod);
|
||||
|
||||
const tag: Mir.Inst.Tag = switch (abi_size) {
|
||||
@@ -3917,7 +3917,7 @@ fn genLdrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type
|
||||
}
|
||||
|
||||
fn genStrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = ty.abiSize(mod);
|
||||
|
||||
const tag: Mir.Inst.Tag = switch (abi_size) {
|
||||
@@ -3939,7 +3939,7 @@ fn genStrRegister(self: *Self, value_reg: Register, addr_reg: Register, ty: Type
|
||||
}
|
||||
|
||||
fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
log.debug("store: storing {} to {}", .{ value, ptr });
|
||||
const abi_size = value_ty.abiSize(mod);
|
||||
|
||||
@@ -4092,7 +4092,7 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void {
|
||||
|
||||
fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {
|
||||
return if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const mcv = try self.resolveInst(operand);
|
||||
const ptr_ty = self.typeOf(operand);
|
||||
const struct_ty = ptr_ty.childType(mod);
|
||||
@@ -4117,7 +4117,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const operand = extra.struct_operand;
|
||||
const index = extra.field_index;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const mcv = try self.resolveInst(operand);
|
||||
const struct_ty = self.typeOf(operand);
|
||||
const struct_field_ty = struct_ty.structFieldType(index, mod);
|
||||
@@ -4167,7 +4167,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
@@ -4195,7 +4195,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {
|
||||
while (self.args[arg_index] == .none) arg_index += 1;
|
||||
self.arg_index = arg_index + 1;
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty = self.typeOfIndex(inst);
|
||||
const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
|
||||
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
|
||||
const extra = self.air.extraData(Air.Call, pl_op.payload);
|
||||
const args = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[extra.end..][0..extra.data.args_len]));
|
||||
const ty = self.typeOf(callee);
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
|
||||
const fn_ty = switch (ty.zigTypeTag(mod)) {
|
||||
.Fn => ty,
|
||||
@@ -4422,7 +4422,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
|
||||
}
|
||||
|
||||
fn airRet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const operand = try self.resolveInst(un_op);
|
||||
const ret_ty = self.fn_type.fnReturnType(mod);
|
||||
@@ -4454,7 +4454,7 @@ fn airRet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const ptr = try self.resolveInst(un_op);
|
||||
const ptr_ty = self.typeOf(un_op);
|
||||
@@ -4514,7 +4514,7 @@ fn cmp(
|
||||
lhs_ty: Type,
|
||||
op: math.CompareOperator,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const int_ty = switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Optional => blk: {
|
||||
const payload_ty = lhs_ty.optionalChild(mod);
|
||||
@@ -4622,7 +4622,7 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const func = mod.funcInfo(ty_fn.func);
|
||||
// TODO emit debug info for function change
|
||||
_ = func;
|
||||
@@ -4830,7 +4830,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn isNull(self: *Self, operand_bind: ReadArg.Bind, operand_ty: Type) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const sentinel: struct { ty: Type, bind: ReadArg.Bind } = if (!operand_ty.isPtrLikeOptional(mod)) blk: {
|
||||
const payload_ty = operand_ty.optionalChild(mod);
|
||||
if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod))
|
||||
@@ -4886,7 +4886,7 @@ fn isErr(
|
||||
error_union_bind: ReadArg.Bind,
|
||||
error_union_ty: Type,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const error_type = error_union_ty.errorUnionSet(mod);
|
||||
|
||||
if (error_type.errorSetIsEmpty(mod)) {
|
||||
@@ -4928,7 +4928,7 @@ fn airIsNull(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airIsNullPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const operand_ptr = try self.resolveInst(un_op);
|
||||
@@ -4955,7 +4955,7 @@ fn airIsNonNull(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airIsNonNullPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const operand_ptr = try self.resolveInst(un_op);
|
||||
@@ -4982,7 +4982,7 @@ fn airIsErr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airIsErrPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const operand_ptr = try self.resolveInst(un_op);
|
||||
@@ -5009,7 +5009,7 @@ fn airIsNonErr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airIsNonErrPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const operand_ptr = try self.resolveInst(un_op);
|
||||
@@ -5226,7 +5226,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const block_data = self.blocks.getPtr(block).?;
|
||||
|
||||
if (self.typeOf(operand).hasRuntimeBits(mod)) {
|
||||
@@ -5403,7 +5403,7 @@ fn setRegOrMem(self: *Self, ty: Type, loc: MCValue, val: MCValue) !void {
|
||||
}
|
||||
|
||||
fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = @as(u32, @intCast(ty.abiSize(mod)));
|
||||
switch (mcv) {
|
||||
.dead => unreachable,
|
||||
@@ -5573,7 +5573,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
|
||||
}
|
||||
|
||||
fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (mcv) {
|
||||
.dead => unreachable,
|
||||
.unreach, .none => return, // Nothing to do.
|
||||
@@ -5735,7 +5735,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
|
||||
}
|
||||
|
||||
fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = @as(u32, @intCast(ty.abiSize(mod)));
|
||||
switch (mcv) {
|
||||
.dead => unreachable,
|
||||
@@ -5934,7 +5934,7 @@ fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const ptr_ty = self.typeOf(ty_op.operand);
|
||||
@@ -6054,7 +6054,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const vector_ty = self.typeOfIndex(inst);
|
||||
const len = vector_ty.vectorLen(mod);
|
||||
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 {
|
||||
}
|
||||
|
||||
fn airTry(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
|
||||
const extra = self.air.extraData(Air.Try, pl_op.payload);
|
||||
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 {
|
||||
}
|
||||
|
||||
fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
|
||||
// If the type has no codegen bits, no need to store it.
|
||||
const inst_ty = self.typeOf(inst);
|
||||
@@ -6200,7 +6200,7 @@ const CallMCValues = struct {
|
||||
|
||||
/// Caller must call `CallMCValues.deinit`.
|
||||
fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const fn_info = mod.typeToFunc(fn_ty).?;
|
||||
const cc = fn_info.cc;
|
||||
@@ -6363,7 +6363,7 @@ fn parseRegName(name: []const u8) ?Register {
|
||||
}
|
||||
|
||||
fn registerAlias(self: *Self, reg: Register, ty: Type) Register {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = ty.abiSize(mod);
|
||||
|
||||
switch (reg.class()) {
|
||||
@@ -6392,11 +6392,11 @@ fn registerAlias(self: *Self, reg: Register, ty: Type) Register {
|
||||
}
|
||||
|
||||
fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return self.air.typeOf(inst, &mod.intern_pool);
|
||||
}
|
||||
|
||||
fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return self.air.typeOfIndex(inst, &mod.intern_pool);
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ const DbgInfoReloc = struct {
|
||||
}
|
||||
|
||||
fn genArgDbgInfo(reloc: DbgInfoReloc, function: Self) error{OutOfMemory}!void {
|
||||
const mod = function.bin_file.options.module.?;
|
||||
const mod = function.bin_file.comp.module.?;
|
||||
switch (function.debug_output) {
|
||||
.dwarf => |dw| {
|
||||
const loc: link.File.Dwarf.DeclState.DbgInfoLoc = switch (reloc.mcv) {
|
||||
@@ -289,7 +289,7 @@ const DbgInfoReloc = struct {
|
||||
}
|
||||
|
||||
fn genVarDbgInfo(reloc: DbgInfoReloc, function: Self) !void {
|
||||
const mod = function.bin_file.options.module.?;
|
||||
const mod = function.bin_file.comp.module.?;
|
||||
const is_ptr = switch (reloc.tag) {
|
||||
.dbg_var_ptr => true,
|
||||
.dbg_var_val => false,
|
||||
@@ -348,7 +348,7 @@ pub fn generate(
|
||||
@panic("Attempted to compile for architecture that was disabled by build configuration");
|
||||
}
|
||||
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
const func = mod.funcInfo(func_index);
|
||||
const fn_owner_decl = mod.declPtr(func.owner_decl);
|
||||
assert(fn_owner_decl.has_tv);
|
||||
@@ -482,7 +482,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {
|
||||
}
|
||||
|
||||
fn gen(self: *Self) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const cc = self.fn_type.fnCallingConvention(mod);
|
||||
if (cc != .Naked) {
|
||||
// push {fp, lr}
|
||||
@@ -642,7 +642,7 @@ fn gen(self: *Self) !void {
|
||||
}
|
||||
|
||||
fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const air_tags = self.air.instructions.items(.tag);
|
||||
|
||||
@@ -1010,7 +1010,7 @@ fn allocMem(
|
||||
|
||||
/// Use a pointer instruction as the basis for allocating stack memory.
|
||||
fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = self.typeOfIndex(inst).childType(mod);
|
||||
|
||||
if (!elem_ty.hasRuntimeBits(mod)) {
|
||||
@@ -1031,7 +1031,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
|
||||
}
|
||||
|
||||
fn allocRegOrMem(self: *Self, elem_ty: Type, reg_ok: bool, maybe_inst: ?Air.Inst.Index) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {
|
||||
return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});
|
||||
};
|
||||
@@ -1118,7 +1118,7 @@ fn airAlloc(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airRetPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = switch (self.ret_mcv) {
|
||||
.none, .register => .{ .ptr_stack_offset = try self.allocMemPtr(inst) },
|
||||
.stack_offset => blk: {
|
||||
@@ -1151,7 +1151,7 @@ fn airFpext(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
if (self.liveness.isUnused(inst))
|
||||
return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });
|
||||
@@ -1217,7 +1217,7 @@ fn trunc(
|
||||
operand_ty: Type,
|
||||
dest_ty: Type,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const info_a = operand_ty.intInfo(mod);
|
||||
const info_b = dest_ty.intInfo(mod);
|
||||
|
||||
@@ -1281,7 +1281,7 @@ fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airNot(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const operand_bind: ReadArg.Bind = .{ .inst = ty_op.operand };
|
||||
const operand_ty = self.typeOf(ty_op.operand);
|
||||
@@ -1377,7 +1377,7 @@ fn minMax(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO ARM min/max on floats", .{}),
|
||||
.Vector => return self.fail("TODO ARM min/max on vectors", .{}),
|
||||
@@ -1586,7 +1586,7 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };
|
||||
const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };
|
||||
@@ -1699,7 +1699,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = result: {
|
||||
const lhs_bind: ReadArg.Bind = .{ .inst = extra.lhs };
|
||||
const rhs_bind: ReadArg.Bind = .{ .inst = extra.rhs };
|
||||
@@ -1863,7 +1863,7 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
if (self.liveness.isUnused(inst)) return self.finishAir(inst, .dead, .{ extra.lhs, extra.rhs, .none });
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = result: {
|
||||
const lhs_ty = self.typeOf(extra.lhs);
|
||||
const rhs_ty = self.typeOf(extra.rhs);
|
||||
@@ -2019,7 +2019,7 @@ fn airOptionalPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const optional_ty = self.typeOfIndex(inst);
|
||||
@@ -2042,7 +2042,7 @@ fn errUnionErr(
|
||||
error_union_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const err_ty = error_union_ty.errorUnionSet(mod);
|
||||
const payload_ty = error_union_ty.errorUnionPayload(mod);
|
||||
if (err_ty.errorSetIsEmpty(mod)) {
|
||||
@@ -2119,7 +2119,7 @@ fn errUnionPayload(
|
||||
error_union_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const err_ty = error_union_ty.errorUnionSet(mod);
|
||||
const payload_ty = error_union_ty.errorUnionPayload(mod);
|
||||
if (err_ty.errorSetIsEmpty(mod)) {
|
||||
@@ -2229,7 +2229,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
/// T to E!T
|
||||
fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const error_union_ty = ty_op.ty.toType();
|
||||
@@ -2253,7 +2253,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
/// E to E!T
|
||||
fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const error_union_ty = ty_op.ty.toType();
|
||||
@@ -2370,7 +2370,7 @@ fn ptrElemVal(
|
||||
ptr_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = ptr_ty.childType(mod);
|
||||
const elem_size: u32 = @intCast(elem_ty.abiSize(mod));
|
||||
|
||||
@@ -2429,7 +2429,7 @@ fn ptrElemVal(
|
||||
}
|
||||
|
||||
fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const slice_ty = self.typeOf(bin_op.lhs);
|
||||
const result: MCValue = if (!slice_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {
|
||||
@@ -2472,7 +2472,7 @@ fn arrayElemVal(
|
||||
array_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = array_ty.childType(mod);
|
||||
|
||||
const mcv = try array_bind.resolveToMcv(self);
|
||||
@@ -2528,7 +2528,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const ptr_ty = self.typeOf(bin_op.lhs);
|
||||
const result: MCValue = if (!ptr_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) .dead else result: {
|
||||
@@ -2662,7 +2662,7 @@ fn reuseOperand(
|
||||
}
|
||||
|
||||
fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = ptr_ty.childType(mod);
|
||||
const elem_size: u32 = @intCast(elem_ty.abiSize(mod));
|
||||
|
||||
@@ -2739,7 +2739,7 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo
|
||||
}
|
||||
|
||||
fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const elem_ty = self.typeOfIndex(inst);
|
||||
const result: MCValue = result: {
|
||||
@@ -2768,7 +2768,7 @@ fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_size: u32 = @intCast(value_ty.abiSize(mod));
|
||||
|
||||
switch (ptr) {
|
||||
@@ -2888,7 +2888,7 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void {
|
||||
|
||||
fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {
|
||||
return if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const mcv = try self.resolveInst(operand);
|
||||
const ptr_ty = self.typeOf(operand);
|
||||
const struct_ty = ptr_ty.childType(mod);
|
||||
@@ -2912,7 +2912,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const extra = self.air.extraData(Air.StructField, ty_pl.payload).data;
|
||||
const operand = extra.struct_operand;
|
||||
const index = extra.field_index;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const mcv = try self.resolveInst(operand);
|
||||
const struct_ty = self.typeOf(operand);
|
||||
@@ -3002,7 +3002,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
@@ -3396,7 +3396,7 @@ fn addSub(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO ARM binary operations on floats", .{}),
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
@@ -3452,7 +3452,7 @@ fn mul(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO ARM binary operations on floats", .{}),
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
@@ -3485,7 +3485,7 @@ fn divFloat(
|
||||
_ = rhs_ty;
|
||||
_ = maybe_inst;
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO ARM binary operations on floats", .{}),
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
@@ -3501,7 +3501,7 @@ fn divTrunc(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO ARM binary operations on floats", .{}),
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
@@ -3544,7 +3544,7 @@ fn divFloor(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO ARM binary operations on floats", .{}),
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
@@ -3592,7 +3592,7 @@ fn divExact(
|
||||
_ = rhs_ty;
|
||||
_ = maybe_inst;
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO ARM binary operations on floats", .{}),
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
@@ -3609,7 +3609,7 @@ fn rem(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO ARM binary operations on floats", .{}),
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
@@ -3678,7 +3678,7 @@ fn modulo(
|
||||
_ = rhs_ty;
|
||||
_ = maybe_inst;
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO ARM binary operations on floats", .{}),
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
@@ -3696,7 +3696,7 @@ fn wrappingArithmetic(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
.Int => {
|
||||
@@ -3734,7 +3734,7 @@ fn bitwise(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
.Int => {
|
||||
@@ -3779,7 +3779,7 @@ fn shiftExact(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
.Int => {
|
||||
@@ -3818,7 +3818,7 @@ fn shiftNormal(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Vector => return self.fail("TODO ARM binary operations on vectors", .{}),
|
||||
.Int => {
|
||||
@@ -3861,7 +3861,7 @@ fn booleanOp(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Bool => {
|
||||
const lhs_immediate = try lhs_bind.resolveToImmediate(self);
|
||||
@@ -3895,7 +3895,7 @@ fn ptrArithmetic(
|
||||
rhs_ty: Type,
|
||||
maybe_inst: ?Air.Inst.Index,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Pointer => {
|
||||
assert(rhs_ty.eql(Type.usize, mod));
|
||||
@@ -3932,7 +3932,7 @@ fn ptrArithmetic(
|
||||
}
|
||||
|
||||
fn genLdrRegister(self: *Self, dest_reg: Register, addr_reg: Register, ty: Type) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = ty.abiSize(mod);
|
||||
|
||||
const tag: Mir.Inst.Tag = switch (abi_size) {
|
||||
@@ -3967,7 +3967,7 @@ fn genLdrRegister(self: *Self, dest_reg: Register, addr_reg: Register, ty: Type)
|
||||
}
|
||||
|
||||
fn genStrRegister(self: *Self, source_reg: Register, addr_reg: Register, ty: Type) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = ty.abiSize(mod);
|
||||
|
||||
const tag: Mir.Inst.Tag = switch (abi_size) {
|
||||
@@ -4174,7 +4174,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {
|
||||
while (self.args[arg_index] == .none) arg_index += 1;
|
||||
self.arg_index = arg_index + 1;
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty = self.typeOfIndex(inst);
|
||||
const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
|
||||
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
|
||||
const extra = self.air.extraData(Air.Call, pl_op.payload);
|
||||
const args: []const Air.Inst.Ref = @ptrCast(self.air.extra[extra.end..][0..extra.data.args_len]);
|
||||
const ty = self.typeOf(callee);
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
|
||||
const fn_ty = switch (ty.zigTypeTag(mod)) {
|
||||
.Fn => ty,
|
||||
@@ -4380,7 +4380,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
|
||||
}
|
||||
|
||||
fn airRet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const operand = try self.resolveInst(un_op);
|
||||
const ret_ty = self.fn_type.fnReturnType(mod);
|
||||
@@ -4412,7 +4412,7 @@ fn airRet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const ptr = try self.resolveInst(un_op);
|
||||
const ptr_ty = self.typeOf(un_op);
|
||||
@@ -4473,7 +4473,7 @@ fn cmp(
|
||||
lhs_ty: Type,
|
||||
op: math.CompareOperator,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const int_ty = switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Optional => blk: {
|
||||
const payload_ty = lhs_ty.optionalChild(mod);
|
||||
@@ -4580,7 +4580,7 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const func = mod.funcInfo(ty_fn.func);
|
||||
// TODO emit debug info for function change
|
||||
_ = func;
|
||||
@@ -4795,7 +4795,7 @@ fn isNull(
|
||||
operand_bind: ReadArg.Bind,
|
||||
operand_ty: Type,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
if (operand_ty.isPtrLikeOptional(mod)) {
|
||||
assert(operand_ty.abiSize(mod) == 4);
|
||||
|
||||
@@ -4829,7 +4829,7 @@ fn airIsNull(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airIsNullPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const operand_ptr = try self.resolveInst(un_op);
|
||||
@@ -4856,7 +4856,7 @@ fn airIsNonNull(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airIsNonNullPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const operand_ptr = try self.resolveInst(un_op);
|
||||
@@ -4876,7 +4876,7 @@ fn isErr(
|
||||
error_union_bind: ReadArg.Bind,
|
||||
error_union_ty: Type,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const error_type = error_union_ty.errorUnionSet(mod);
|
||||
|
||||
if (error_type.errorSetIsEmpty(mod)) {
|
||||
@@ -4918,7 +4918,7 @@ fn airIsErr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airIsErrPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const operand_ptr = try self.resolveInst(un_op);
|
||||
@@ -4945,7 +4945,7 @@ fn airIsNonErr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airIsNonErrPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const operand_ptr = try self.resolveInst(un_op);
|
||||
@@ -5160,7 +5160,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const block_data = self.blocks.getPtr(block).?;
|
||||
|
||||
if (self.typeOf(operand).hasRuntimeBits(mod)) {
|
||||
@@ -5331,7 +5331,7 @@ fn setRegOrMem(self: *Self, ty: Type, loc: MCValue, val: MCValue) !void {
|
||||
}
|
||||
|
||||
fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size: u32 = @intCast(ty.abiSize(mod));
|
||||
switch (mcv) {
|
||||
.dead => unreachable,
|
||||
@@ -5493,7 +5493,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
|
||||
}
|
||||
|
||||
fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (mcv) {
|
||||
.dead => unreachable,
|
||||
.unreach, .none => return, // Nothing to do.
|
||||
@@ -5740,7 +5740,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
|
||||
}
|
||||
|
||||
fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size: u32 = @intCast(ty.abiSize(mod));
|
||||
switch (mcv) {
|
||||
.dead => unreachable,
|
||||
@@ -5896,7 +5896,7 @@ fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const ptr_ty = self.typeOf(ty_op.operand);
|
||||
@@ -6015,7 +6015,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const vector_ty = self.typeOfIndex(inst);
|
||||
const len = vector_ty.vectorLen(mod);
|
||||
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 {
|
||||
const result: MCValue = result: {
|
||||
const error_union_bind: ReadArg.Bind = .{ .inst = pl_op.operand };
|
||||
const error_union_ty = self.typeOf(pl_op.operand);
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const error_union_size: u32 = @intCast(error_union_ty.abiSize(mod));
|
||||
const error_union_align = error_union_ty.abiAlignment(mod);
|
||||
|
||||
@@ -6097,7 +6097,7 @@ fn airTryPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
|
||||
// If the type has no codegen bits, no need to store it.
|
||||
const inst_ty = self.typeOf(inst);
|
||||
@@ -6125,7 +6125,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) MCValue {
|
||||
}
|
||||
|
||||
fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const mcv: MCValue = switch (try codegen.genTypedValue(
|
||||
self.bin_file,
|
||||
self.src_loc,
|
||||
@@ -6161,7 +6161,7 @@ const CallMCValues = struct {
|
||||
|
||||
/// Caller must call `CallMCValues.deinit`.
|
||||
fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const fn_info = mod.typeToFunc(fn_ty).?;
|
||||
const cc = fn_info.cc;
|
||||
@@ -6312,11 +6312,11 @@ fn parseRegName(name: []const u8) ?Register {
|
||||
}
|
||||
|
||||
fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return self.air.typeOf(inst, &mod.intern_pool);
|
||||
}
|
||||
|
||||
fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return self.air.typeOfIndex(inst, &mod.intern_pool);
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ pub fn generate(
|
||||
@panic("Attempted to compile for architecture that was disabled by build configuration");
|
||||
}
|
||||
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
const func = mod.funcInfo(func_index);
|
||||
const fn_owner_decl = mod.declPtr(func.owner_decl);
|
||||
assert(fn_owner_decl.has_tv);
|
||||
@@ -350,7 +350,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {
|
||||
}
|
||||
|
||||
fn gen(self: *Self) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const cc = self.fn_type.fnCallingConvention(mod);
|
||||
if (cc != .Naked) {
|
||||
// TODO Finish function prologue and epilogue for riscv64.
|
||||
@@ -474,7 +474,7 @@ fn gen(self: *Self) !void {
|
||||
}
|
||||
|
||||
fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const air_tags = self.air.instructions.items(.tag);
|
||||
|
||||
@@ -805,7 +805,7 @@ fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: Alignme
|
||||
|
||||
/// Use a pointer instruction as the basis for allocating stack memory.
|
||||
fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = self.typeOfIndex(inst).childType(mod);
|
||||
const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {
|
||||
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 {
|
||||
}
|
||||
|
||||
fn allocRegOrMem(self: *Self, inst: Air.Inst.Index, reg_ok: bool) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = self.typeOfIndex(inst);
|
||||
const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {
|
||||
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 {
|
||||
if (self.liveness.isUnused(inst))
|
||||
return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const operand_ty = self.typeOf(ty_op.operand);
|
||||
const operand = try self.resolveInst(ty_op.operand);
|
||||
const info_a = operand_ty.intInfo(mod);
|
||||
@@ -1069,7 +1069,7 @@ fn binOp(
|
||||
lhs_ty: Type,
|
||||
rhs_ty: Type,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (tag) {
|
||||
// Arithmetic operations on integers and floats
|
||||
.add,
|
||||
@@ -1332,7 +1332,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {
|
||||
fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const optional_ty = self.typeOfIndex(inst);
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = ptr_ty.childType(mod);
|
||||
switch (ptr) {
|
||||
.none => unreachable,
|
||||
@@ -1532,7 +1532,7 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo
|
||||
}
|
||||
|
||||
fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const elem_ty = self.typeOfIndex(inst);
|
||||
const result: MCValue = result: {
|
||||
@@ -1633,7 +1633,7 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const arg = self.air.instructions.items(.data)[@intFromEnum(inst)].arg;
|
||||
const ty = arg.ty.toType();
|
||||
const owner_decl = mod.funcOwnerDeclIndex(self.func_index);
|
||||
@@ -1710,7 +1710,7 @@ fn airFence(self: *Self) !void {
|
||||
}
|
||||
|
||||
fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
if (modifier == .always_tail) return self.fail("TODO implement tail calls for riscv64", .{});
|
||||
const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
|
||||
const fn_ty = self.typeOf(pl_op.operand);
|
||||
@@ -1812,7 +1812,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
|
||||
}
|
||||
|
||||
fn ret(self: *Self, mcv: MCValue) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ret_ty = self.fn_type.fnReturnType(mod);
|
||||
try self.setRegOrMem(ret_ty, self.ret_mcv, mcv);
|
||||
// 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 {
|
||||
if (self.liveness.isUnused(inst))
|
||||
return self.finishAir(inst, .dead, .{ bin_op.lhs, bin_op.rhs, .none });
|
||||
const ty = self.typeOf(bin_op.lhs);
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
assert(ty.eql(self.typeOf(bin_op.rhs), mod));
|
||||
if (ty.zigTypeTag(mod) == .ErrorSet)
|
||||
return self.fail("TODO implement cmp for errors", .{});
|
||||
@@ -1887,7 +1887,7 @@ fn airDbgStmt(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const func = mod.funcInfo(ty_fn.func);
|
||||
// TODO emit debug info for function change
|
||||
_ = func;
|
||||
@@ -2125,7 +2125,7 @@ fn airBoolOp(self: *Self, inst: Air.Inst.Index) !void {
|
||||
fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {
|
||||
const block_data = self.blocks.getPtr(block).?;
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
if (self.typeOf(operand).hasRuntimeBits(mod)) {
|
||||
const operand_mcv = try self.resolveInst(operand);
|
||||
const block_mcv = block_data.mcv;
|
||||
@@ -2508,7 +2508,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const vector_ty = self.typeOfIndex(inst);
|
||||
const len = vector_ty.vectorLen(mod);
|
||||
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 {
|
||||
}
|
||||
|
||||
fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
|
||||
// If the type has no codegen bits, no need to store it.
|
||||
const inst_ty = self.typeOf(inst);
|
||||
@@ -2581,7 +2581,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) MCValue {
|
||||
}
|
||||
|
||||
fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const mcv: MCValue = switch (try codegen.genTypedValue(
|
||||
self.bin_file,
|
||||
self.src_loc,
|
||||
@@ -2617,7 +2617,7 @@ const CallMCValues = struct {
|
||||
|
||||
/// Caller must call `CallMCValues.deinit`.
|
||||
fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const fn_info = mod.typeToFunc(fn_ty).?;
|
||||
const cc = fn_info.cc;
|
||||
@@ -2739,11 +2739,11 @@ fn parseRegName(name: []const u8) ?Register {
|
||||
}
|
||||
|
||||
fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return self.air.typeOf(inst, &mod.intern_pool);
|
||||
}
|
||||
|
||||
fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return self.air.typeOfIndex(inst, &mod.intern_pool);
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ pub fn generate(
|
||||
@panic("Attempted to compile for architecture that was disabled by build configuration");
|
||||
}
|
||||
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
const func = mod.funcInfo(func_index);
|
||||
const fn_owner_decl = mod.declPtr(func.owner_decl);
|
||||
assert(fn_owner_decl.has_tv);
|
||||
@@ -364,7 +364,7 @@ pub fn generate(
|
||||
}
|
||||
|
||||
fn gen(self: *Self) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const cc = self.fn_type.fnCallingConvention(mod);
|
||||
if (cc != .Naked) {
|
||||
// TODO Finish function prologue and epilogue for sparc64.
|
||||
@@ -492,7 +492,7 @@ fn gen(self: *Self) !void {
|
||||
}
|
||||
|
||||
fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const air_tags = self.air.instructions.items(.tag);
|
||||
|
||||
@@ -762,7 +762,7 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const lhs = try self.resolveInst(extra.lhs);
|
||||
const rhs = try self.resolveInst(extra.rhs);
|
||||
@@ -840,7 +840,7 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const vector_ty = self.typeOfIndex(inst);
|
||||
const len = vector_ty.vectorLen(mod);
|
||||
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 {
|
||||
}
|
||||
|
||||
fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const ptr_ty = self.typeOf(ty_op.operand);
|
||||
@@ -1011,7 +1011,7 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airArg(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const arg_index = self.arg_index;
|
||||
self.arg_index += 1;
|
||||
|
||||
@@ -1206,7 +1206,7 @@ fn airBreakpoint(self: *Self) !void {
|
||||
}
|
||||
|
||||
fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
// 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
|
||||
const extra = self.air.extraData(Air.Call, pl_op.payload);
|
||||
const args = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[extra.end .. extra.end + extra.data.args_len]));
|
||||
const ty = self.typeOf(callee);
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const fn_ty = switch (ty.zigTypeTag(mod)) {
|
||||
.Fn => ty,
|
||||
.Pointer => ty.childType(mod),
|
||||
@@ -1430,7 +1430,7 @@ fn airClz(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const lhs = try self.resolveInst(bin_op.lhs);
|
||||
const rhs = try self.resolveInst(bin_op.rhs);
|
||||
@@ -1662,7 +1662,7 @@ fn airDbgBlock(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airDbgInline(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_fn = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_fn;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const func = mod.funcInfo(ty_fn.func);
|
||||
// TODO emit debug info for function change
|
||||
_ = func;
|
||||
@@ -1758,7 +1758,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
|
||||
if (self.liveness.isUnused(inst))
|
||||
return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none });
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const operand_ty = self.typeOf(ty_op.operand);
|
||||
const operand = try self.resolveInst(ty_op.operand);
|
||||
const info_a = operand_ty.intInfo(mod);
|
||||
@@ -1819,7 +1819,7 @@ fn airIsNonNull(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const elem_ty = self.typeOfIndex(inst);
|
||||
const elem_size = elem_ty.abiSize(mod);
|
||||
@@ -1903,7 +1903,7 @@ fn airMod(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const rhs = try self.resolveInst(bin_op.rhs);
|
||||
const lhs_ty = self.typeOf(bin_op.lhs);
|
||||
const rhs_ty = self.typeOf(bin_op.rhs);
|
||||
assert(lhs_ty.eql(rhs_ty, self.bin_file.options.module.?));
|
||||
assert(lhs_ty.eql(rhs_ty, self.bin_file.comp.module.?));
|
||||
|
||||
if (self.liveness.isUnused(inst))
|
||||
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 {
|
||||
//const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const lhs = try self.resolveInst(extra.lhs);
|
||||
const rhs = try self.resolveInst(extra.rhs);
|
||||
@@ -2109,7 +2109,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airNot(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const operand = try self.resolveInst(ty_op.operand);
|
||||
const operand_ty = self.typeOf(ty_op.operand);
|
||||
@@ -2341,7 +2341,7 @@ fn airShlSat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const lhs = try self.resolveInst(extra.lhs);
|
||||
const rhs = try self.resolveInst(extra.rhs);
|
||||
@@ -2446,7 +2446,7 @@ fn airSlice(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const is_volatile = false; // TODO
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
|
||||
@@ -2571,7 +2571,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const operand = extra.struct_operand;
|
||||
const index = extra.field_index;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const mcv = try self.resolveInst(operand);
|
||||
const struct_ty = self.typeOf(operand);
|
||||
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 {
|
||||
}
|
||||
|
||||
fn airUnwrapErrErr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const error_union_ty = self.typeOf(ty_op.operand);
|
||||
@@ -2718,7 +2718,7 @@ fn airUnwrapErrErr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airUnwrapErrPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const error_union_ty = self.typeOf(ty_op.operand);
|
||||
@@ -2732,7 +2732,7 @@ fn airUnwrapErrPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
/// E to E!T
|
||||
fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const error_union_ty = ty_op.ty.toType();
|
||||
@@ -2753,7 +2753,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const optional_ty = self.typeOfIndex(inst);
|
||||
@@ -2793,7 +2793,7 @@ fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: Alignme
|
||||
|
||||
/// Use a pointer instruction as the basis for allocating stack memory.
|
||||
fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = self.typeOfIndex(inst).childType(mod);
|
||||
|
||||
if (!elem_ty.hasRuntimeBits(mod)) {
|
||||
@@ -2813,7 +2813,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
|
||||
}
|
||||
|
||||
fn allocRegOrMem(self: *Self, inst: Air.Inst.Index, reg_ok: bool) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = self.typeOfIndex(inst);
|
||||
const abi_size = math.cast(u32, elem_ty.abiSize(mod)) orelse {
|
||||
return self.fail("type '{}' too big to fit into stack frame", .{elem_ty.fmt(mod)});
|
||||
@@ -2860,7 +2860,7 @@ fn binOp(
|
||||
rhs_ty: Type,
|
||||
metadata: ?BinOpMetadata,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (tag) {
|
||||
.add,
|
||||
.sub,
|
||||
@@ -3401,7 +3401,7 @@ fn binOpRegister(
|
||||
fn br(self: *Self, block: Air.Inst.Index, operand: Air.Inst.Ref) !void {
|
||||
const block_data = self.blocks.getPtr(block).?;
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
if (self.typeOf(operand).hasRuntimeBits(mod)) {
|
||||
const operand_mcv = try self.resolveInst(operand);
|
||||
const block_mcv = block_data.mcv;
|
||||
@@ -3521,7 +3521,7 @@ fn ensureProcessDeathCapacity(self: *Self, additional_count: usize) !void {
|
||||
|
||||
/// Given an error union, returns the payload
|
||||
fn errUnionPayload(self: *Self, error_union_mcv: MCValue, error_union_ty: Type) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const err_ty = error_union_ty.errorUnionSet(mod);
|
||||
const payload_ty = error_union_ty.errorUnionPayload(mod);
|
||||
if (err_ty.errorSetIsEmpty(mod)) {
|
||||
@@ -3591,7 +3591,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live
|
||||
}
|
||||
|
||||
fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const arg = self.air.instructions.items(.data)[@intFromEnum(inst)].arg;
|
||||
const ty = arg.ty.toType();
|
||||
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
|
||||
}
|
||||
|
||||
fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (mcv) {
|
||||
.dead => unreachable,
|
||||
.unreach, .none => return, // Nothing to do.
|
||||
@@ -3951,7 +3951,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
|
||||
}
|
||||
|
||||
fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = ty.abiSize(mod);
|
||||
switch (mcv) {
|
||||
.dead => unreachable,
|
||||
@@ -4125,7 +4125,7 @@ fn genStoreASI(self: *Self, value_reg: Register, addr_reg: Register, off_reg: Re
|
||||
}
|
||||
|
||||
fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const mcv: MCValue = switch (try codegen.genTypedValue(
|
||||
self.bin_file,
|
||||
self.src_loc,
|
||||
@@ -4161,7 +4161,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) MCValue {
|
||||
}
|
||||
|
||||
fn isErr(self: *Self, ty: Type, operand: MCValue) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const error_type = ty.errorUnionSet(mod);
|
||||
const payload_type = ty.errorUnionPayload(mod);
|
||||
|
||||
@@ -4259,7 +4259,7 @@ fn jump(self: *Self, inst: Mir.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const elem_ty = ptr_ty.childType(mod);
|
||||
const elem_size = elem_ty.abiSize(mod);
|
||||
|
||||
@@ -4330,7 +4330,7 @@ fn minMax(
|
||||
lhs_ty: Type,
|
||||
rhs_ty: Type,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
assert(lhs_ty.eql(rhs_ty, mod));
|
||||
switch (lhs_ty.zigTypeTag(mod)) {
|
||||
.Float => return self.fail("TODO min/max on floats", .{}),
|
||||
@@ -4450,7 +4450,7 @@ fn realStackOffset(off: u32) u32 {
|
||||
|
||||
/// Caller must call `CallMCValues.deinit`.
|
||||
fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView) !CallMCValues {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const fn_info = mod.typeToFunc(fn_ty).?;
|
||||
const cc = fn_info.cc;
|
||||
@@ -4542,7 +4542,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView)
|
||||
}
|
||||
|
||||
fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty = self.typeOf(ref);
|
||||
|
||||
// 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 {
|
||||
}
|
||||
|
||||
fn ret(self: *Self, mcv: MCValue) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ret_ty = self.fn_type.fnReturnType(mod);
|
||||
try self.setRegOrMem(ret_ty, self.ret_mcv, mcv);
|
||||
|
||||
@@ -4661,7 +4661,7 @@ pub fn spillInstruction(self: *Self, reg: Register, inst: Air.Inst.Index) !void
|
||||
}
|
||||
|
||||
fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = value_ty.abiSize(mod);
|
||||
|
||||
switch (ptr) {
|
||||
@@ -4703,7 +4703,7 @@ fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type
|
||||
|
||||
fn structFieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {
|
||||
return if (self.liveness.isUnused(inst)) .dead else result: {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const mcv = try self.resolveInst(operand);
|
||||
const ptr_ty = self.typeOf(operand);
|
||||
const struct_ty = ptr_ty.childType(mod);
|
||||
@@ -4745,7 +4745,7 @@ fn trunc(
|
||||
operand_ty: Type,
|
||||
dest_ty: Type,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const info_a = operand_ty.intInfo(mod);
|
||||
const info_b = dest_ty.intInfo(mod);
|
||||
|
||||
@@ -4866,11 +4866,11 @@ fn wantSafety(self: *Self) bool {
|
||||
}
|
||||
|
||||
fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return self.air.typeOf(inst, &mod.intern_pool);
|
||||
}
|
||||
|
||||
fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return self.air.typeOfIndex(inst, &mod.intern_pool);
|
||||
}
|
||||
|
||||
@@ -1210,7 +1210,7 @@ pub fn generate(
|
||||
debug_output: codegen.DebugInfoOutput,
|
||||
) codegen.CodeGenError!codegen.Result {
|
||||
_ = src_loc;
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
const func = mod.funcInfo(func_index);
|
||||
var code_gen: CodeGen = .{
|
||||
.gpa = bin_file.allocator,
|
||||
|
||||
@@ -131,7 +131,7 @@ const Owner = union(enum) {
|
||||
fn getSymbolIndex(owner: Owner, ctx: *Self) !u32 {
|
||||
switch (owner) {
|
||||
.func_index => |func_index| {
|
||||
const mod = ctx.bin_file.options.module.?;
|
||||
const mod = ctx.bin_file.comp.module.?;
|
||||
const decl_index = mod.funcOwnerDeclIndex(func_index);
|
||||
if (ctx.bin_file.cast(link.File.Elf)) |elf_file| {
|
||||
return elf_file.zigObjectPtr().?.getOrCreateMetadataForDecl(elf_file, decl_index);
|
||||
@@ -799,7 +799,7 @@ pub fn generate(
|
||||
@panic("Attempted to compile for architecture that was disabled by build configuration");
|
||||
}
|
||||
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
const func = mod.funcInfo(func_index);
|
||||
const fn_owner_decl = mod.declPtr(func.owner_decl);
|
||||
assert(fn_owner_decl.has_tv);
|
||||
@@ -1060,7 +1060,7 @@ fn formatDecl(
|
||||
}
|
||||
fn fmtDecl(self: *Self, decl_index: InternPool.DeclIndex) std.fmt.Formatter(formatDecl) {
|
||||
return .{ .data = .{
|
||||
.mod = self.bin_file.options.module.?,
|
||||
.mod = self.bin_file.comp.module.?,
|
||||
.decl_index = decl_index,
|
||||
} };
|
||||
}
|
||||
@@ -1077,7 +1077,7 @@ fn formatAir(
|
||||
) @TypeOf(writer).Error!void {
|
||||
@import("../../print_air.zig").dumpInst(
|
||||
data.inst,
|
||||
data.self.bin_file.options.module.?,
|
||||
data.self.bin_file.comp.module.?,
|
||||
data.self.air,
|
||||
data.self.liveness,
|
||||
);
|
||||
@@ -1683,7 +1683,7 @@ fn asmMemoryRegisterImmediate(
|
||||
}
|
||||
|
||||
fn gen(self: *Self) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const fn_info = mod.typeToFunc(self.fn_type).?;
|
||||
const cc = abi.resolveCallingConvention(fn_info.cc, self.target.*);
|
||||
if (cc != .Naked) {
|
||||
@@ -1885,7 +1885,7 @@ fn gen(self: *Self) InnerError!void {
|
||||
}
|
||||
|
||||
fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const air_tags = self.air.instructions.items(.tag);
|
||||
|
||||
@@ -2167,7 +2167,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
|
||||
}
|
||||
|
||||
fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (lazy_sym.ty.zigTypeTag(mod)) {
|
||||
.Enum => {
|
||||
const enum_ty = lazy_sym.ty;
|
||||
@@ -2418,7 +2418,7 @@ fn allocFrameIndex(self: *Self, alloc: FrameAlloc) !FrameIndex {
|
||||
|
||||
/// Use a pointer instruction as the basis for allocating stack memory.
|
||||
fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !FrameIndex {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ptr_ty = self.typeOfIndex(inst);
|
||||
const val_ty = ptr_ty.childType(mod);
|
||||
return self.allocFrameIndex(FrameAlloc.init(.{
|
||||
@@ -2438,7 +2438,7 @@ fn allocTempRegOrMem(self: *Self, elem_ty: Type, reg_ok: bool) !MCValue {
|
||||
}
|
||||
|
||||
fn allocRegOrMemAdvanced(self: *Self, ty: Type, inst: ?Air.Inst.Index, reg_ok: bool) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = math.cast(u32, ty.abiSize(mod)) orelse {
|
||||
return self.fail("type '{}' too big to fit into stack frame", .{ty.fmt(mod)});
|
||||
};
|
||||
@@ -2471,7 +2471,7 @@ fn allocRegOrMemAdvanced(self: *Self, ty: Type, inst: ?Air.Inst.Index, reg_ok: b
|
||||
}
|
||||
|
||||
fn regClassForType(self: *Self, ty: Type) RegisterManager.RegisterBitSet {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return switch (ty.zigTypeTag(mod)) {
|
||||
.Float => switch (ty.floatBits(self.target.*)) {
|
||||
80 => abi.RegisterClass.x87,
|
||||
@@ -2884,7 +2884,7 @@ fn airFpext(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = result: {
|
||||
const src_ty = self.typeOf(ty_op.operand);
|
||||
@@ -2975,7 +2975,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
const dst_ty = self.typeOfIndex(inst);
|
||||
@@ -3102,7 +3102,7 @@ fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airSlice(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
|
||||
@@ -3131,7 +3131,7 @@ fn airUnOp(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
|
||||
}
|
||||
|
||||
fn airBinOp(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const dst_mcv = try self.genBinOp(inst, tag, bin_op.lhs, bin_op.rhs);
|
||||
|
||||
@@ -3172,7 +3172,7 @@ fn airPtrArithmetic(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void
|
||||
}
|
||||
|
||||
fn activeIntBits(self: *Self, dst_air: Air.Inst.Ref) u16 {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const air_tag = self.air.instructions.items(.tag);
|
||||
const air_data = self.air.instructions.items(.data);
|
||||
|
||||
@@ -3206,7 +3206,7 @@ fn activeIntBits(self: *Self, dst_air: Air.Inst.Ref) u16 {
|
||||
}
|
||||
|
||||
fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const result = result: {
|
||||
const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
|
||||
@@ -3432,7 +3432,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airAddSat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const ty = self.typeOf(bin_op.lhs);
|
||||
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 {
|
||||
}
|
||||
|
||||
fn airSubSat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const ty = self.typeOf(bin_op.lhs);
|
||||
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 {
|
||||
}
|
||||
|
||||
fn airMulSat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const ty = self.typeOf(bin_op.lhs);
|
||||
|
||||
@@ -3731,7 +3731,7 @@ fn airMulSat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
const result: MCValue = result: {
|
||||
@@ -3792,7 +3792,7 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
const result: MCValue = result: {
|
||||
@@ -3871,7 +3871,7 @@ fn genSetFrameTruncatedOverflowCompare(
|
||||
src_mcv: MCValue,
|
||||
overflow_cc: ?Condition,
|
||||
) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const src_lock = switch (src_mcv) {
|
||||
.register => |reg| self.register_manager.lockReg(reg),
|
||||
else => null,
|
||||
@@ -3935,7 +3935,7 @@ fn genSetFrameTruncatedOverflowCompare(
|
||||
}
|
||||
|
||||
fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
const tuple_ty = self.typeOfIndex(inst);
|
||||
@@ -4169,7 +4169,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
|
||||
/// Clobbers .rax and .rdx registers.
|
||||
/// Quotient is saved in .rax and remainder in .rdx.
|
||||
fn genIntMulDivOpMir(self: *Self, tag: Mir.Inst.FixedTag, ty: Type, lhs: MCValue, rhs: MCValue) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size: u32 = @intCast(ty.abiSize(mod));
|
||||
const bit_size: u32 = @intCast(self.regBitSize(ty));
|
||||
if (abi_size > 8) {
|
||||
@@ -4219,7 +4219,7 @@ fn genIntMulDivOpMir(self: *Self, tag: Mir.Inst.FixedTag, ty: Type, lhs: MCValue
|
||||
/// Always returns a register.
|
||||
/// Clobbers .rax and .rdx registers.
|
||||
fn genInlineIntDivFloor(self: *Self, ty: Type, lhs: MCValue, rhs: MCValue) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size: u32 = @intCast(ty.abiSize(mod));
|
||||
const int_info = ty.intInfo(mod);
|
||||
const dividend = switch (lhs) {
|
||||
@@ -4271,7 +4271,7 @@ fn genInlineIntDivFloor(self: *Self, ty: Type, lhs: MCValue, rhs: MCValue) !MCVa
|
||||
}
|
||||
|
||||
fn airShlShrBinOp(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
|
||||
const air_tags = self.air.instructions.items(.tag);
|
||||
@@ -4546,7 +4546,7 @@ fn airShlSat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airOptionalPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = result: {
|
||||
const pl_ty = self.typeOfIndex(inst);
|
||||
@@ -4592,7 +4592,7 @@ fn airOptionalPayloadPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airOptionalPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result = result: {
|
||||
const dst_ty = self.typeOfIndex(inst);
|
||||
@@ -4626,7 +4626,7 @@ fn airOptionalPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airUnwrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const err_union_ty = self.typeOf(ty_op.operand);
|
||||
const err_ty = err_union_ty.errorUnionSet(mod);
|
||||
@@ -4678,7 +4678,7 @@ fn airUnwrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
// *(E!T) -> E
|
||||
fn airUnwrapErrUnionErrPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
const src_ty = self.typeOf(ty_op.operand);
|
||||
@@ -4725,7 +4725,7 @@ fn airUnwrapErrUnionPayloadPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = result: {
|
||||
const src_ty = self.typeOf(ty_op.operand);
|
||||
@@ -4785,7 +4785,7 @@ fn genUnwrapErrUnionPayloadMir(
|
||||
err_union_ty: Type,
|
||||
err_union: MCValue,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const payload_ty = err_union_ty.errorUnionPayload(mod);
|
||||
|
||||
const result: MCValue = result: {
|
||||
@@ -4833,7 +4833,7 @@ fn genUnwrapErrUnionPayloadPtrMir(
|
||||
ptr_ty: Type,
|
||||
ptr_mcv: MCValue,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const err_union_ty = ptr_ty.childType(mod);
|
||||
const payload_ty = err_union_ty.errorUnionPayload(mod);
|
||||
|
||||
@@ -4867,7 +4867,7 @@ fn airSaveErrReturnTraceIndex(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = result: {
|
||||
const pl_ty = self.typeOf(ty_op.operand);
|
||||
@@ -4921,7 +4921,7 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
/// T to E!T
|
||||
fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
const eu_ty = ty_op.ty.toType();
|
||||
@@ -4944,7 +4944,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
/// E to E!T
|
||||
fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
const eu_ty = ty_op.ty.toType();
|
||||
@@ -5003,7 +5003,7 @@ fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airPtrSliceLenPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
fn genSliceElemPtr(self: *Self, lhs: Air.Inst.Ref, rhs: Air.Inst.Ref) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const slice_ty = self.typeOf(lhs);
|
||||
const slice_mcv = try self.resolveInst(lhs);
|
||||
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 {
|
||||
}
|
||||
|
||||
fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
|
||||
const result: MCValue = result: {
|
||||
@@ -5132,7 +5132,7 @@ fn airSliceElemPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
|
||||
const result: MCValue = result: {
|
||||
@@ -5246,7 +5246,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const ptr_ty = self.typeOf(bin_op.lhs);
|
||||
|
||||
@@ -5296,7 +5296,7 @@ fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airPtrElemPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
|
||||
@@ -5341,7 +5341,7 @@ fn airPtrElemPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airSetUnionTag(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const ptr_union_ty = self.typeOf(bin_op.lhs);
|
||||
const union_ty = ptr_union_ty.childType(mod);
|
||||
@@ -5385,7 +5385,7 @@ fn airSetUnionTag(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airGetUnionTag(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
const tag_ty = self.typeOfIndex(inst);
|
||||
@@ -5439,7 +5439,7 @@ fn airGetUnionTag(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airClz(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result = result: {
|
||||
const dst_ty = self.typeOfIndex(inst);
|
||||
@@ -5598,7 +5598,7 @@ fn airClz(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airCtz(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result = result: {
|
||||
const dst_ty = self.typeOfIndex(inst);
|
||||
@@ -5716,7 +5716,7 @@ fn airCtz(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airPopCount(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const result: MCValue = result: {
|
||||
try self.spillEflagsIfOccupied();
|
||||
@@ -5779,7 +5779,7 @@ fn genPopCount(
|
||||
src_mcv: MCValue,
|
||||
dst_contains_src: bool,
|
||||
) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
|
||||
const src_abi_size: u32 = @intCast(src_ty.abiSize(mod));
|
||||
if (self.hasFeature(.popcnt)) return self.genBinOpMir(
|
||||
@@ -5871,7 +5871,7 @@ fn genByteSwap(
|
||||
src_mcv: MCValue,
|
||||
mem_ok: bool,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
if (src_ty.zigTypeTag(mod) == .Vector) return self.fail(
|
||||
@@ -5962,7 +5962,7 @@ fn genByteSwap(
|
||||
}
|
||||
|
||||
fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
const src_ty = self.typeOf(ty_op.operand);
|
||||
@@ -5984,7 +5984,7 @@ fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airBitReverse(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
const src_ty = self.typeOf(ty_op.operand);
|
||||
@@ -6106,7 +6106,7 @@ fn airBitReverse(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn floatSign(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, ty: Type) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
|
||||
|
||||
const result = result: {
|
||||
@@ -6282,7 +6282,7 @@ fn airRound(self: *Self, inst: Air.Inst.Index, mode: RoundMode) !void {
|
||||
}
|
||||
|
||||
fn getRoundTag(self: *Self, ty: Type) ?Mir.Inst.FixedTag {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return if (self.hasFeature(.sse4_1)) switch (ty.zigTypeTag(mod)) {
|
||||
.Float => switch (ty.floatBits(self.target.*)) {
|
||||
32 => if (self.hasFeature(.avx)) .{ .v_ss, .round } else .{ ._ss, .round },
|
||||
@@ -6314,7 +6314,7 @@ fn getRoundTag(self: *Self, ty: Type) ?Mir.Inst.FixedTag {
|
||||
}
|
||||
|
||||
fn genRoundLibcall(self: *Self, ty: Type, src_mcv: MCValue, mode: RoundMode) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
if (self.getRoundTag(ty)) |_| return .none;
|
||||
|
||||
if (ty.zigTypeTag(mod) != .Float)
|
||||
@@ -6338,7 +6338,7 @@ fn genRoundLibcall(self: *Self, ty: Type, src_mcv: MCValue, mode: RoundMode) !MC
|
||||
}
|
||||
|
||||
fn genRound(self: *Self, ty: Type, dst_reg: Register, src_mcv: MCValue, mode: RoundMode) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const mir_tag = self.getRoundTag(ty) orelse {
|
||||
const result = try self.genRoundLibcall(ty, src_mcv, mode);
|
||||
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
|
||||
}
|
||||
|
||||
fn airAbs(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const ty = self.typeOf(ty_op.operand);
|
||||
|
||||
@@ -6520,7 +6520,7 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airSqrt(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const ty = self.typeOf(un_op);
|
||||
const abi_size: u32 = @intCast(ty.abiSize(mod));
|
||||
@@ -6765,7 +6765,7 @@ fn reuseOperandAdvanced(
|
||||
}
|
||||
|
||||
fn packedLoad(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
|
||||
const ptr_info = ptr_ty.ptrInfo(mod);
|
||||
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
|
||||
}
|
||||
|
||||
fn load(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const dst_ty = ptr_ty.childType(mod);
|
||||
if (!dst_ty.hasRuntimeBitsIgnoreComptime(mod)) return;
|
||||
switch (ptr_mcv) {
|
||||
@@ -6905,7 +6905,7 @@ fn load(self: *Self, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerErro
|
||||
}
|
||||
|
||||
fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const elem_ty = self.typeOfIndex(inst);
|
||||
const result: MCValue = result: {
|
||||
@@ -6962,7 +6962,7 @@ fn airLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn packedStore(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ptr_info = ptr_ty.ptrInfo(mod);
|
||||
const src_ty = Type.fromInterned(ptr_info.child);
|
||||
if (!src_ty.hasRuntimeBitsIgnoreComptime(mod)) return;
|
||||
@@ -7059,7 +7059,7 @@ fn packedStore(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) In
|
||||
}
|
||||
|
||||
fn store(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const src_ty = ptr_ty.childType(mod);
|
||||
if (!src_ty.hasRuntimeBitsIgnoreComptime(mod)) return;
|
||||
switch (ptr_mcv) {
|
||||
@@ -7100,7 +7100,7 @@ fn store(self: *Self, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) InnerErr
|
||||
}
|
||||
|
||||
fn airStore(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
|
||||
result: {
|
||||
@@ -7138,7 +7138,7 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void {
|
||||
}
|
||||
|
||||
fn fieldPtr(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, index: u32) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ptr_field_ty = self.typeOfIndex(inst);
|
||||
const ptr_container_ty = self.typeOf(operand);
|
||||
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
|
||||
}
|
||||
|
||||
fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.StructField, ty_pl.payload).data;
|
||||
const result: MCValue = result: {
|
||||
@@ -7451,7 +7451,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;
|
||||
|
||||
@@ -7470,7 +7470,7 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air: Air.Inst.Ref) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const src_ty = self.typeOf(src_air);
|
||||
if (src_ty.zigTypeTag(mod) == .Vector)
|
||||
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:
|
||||
}
|
||||
|
||||
fn genUnOpMir(self: *Self, mir_tag: Mir.Inst.FixedTag, dst_ty: Type, dst_mcv: MCValue) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size: u32 = @intCast(dst_ty.abiSize(mod));
|
||||
if (abi_size > 8) return self.fail("TODO implement {} for {}", .{ mir_tag, dst_ty.fmt(mod) });
|
||||
switch (dst_mcv) {
|
||||
@@ -7605,7 +7605,7 @@ fn genShiftBinOpMir(
|
||||
lhs_mcv: MCValue,
|
||||
shift_mcv: MCValue,
|
||||
) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const rhs_mcv: MCValue = rhs: {
|
||||
switch (shift_mcv) {
|
||||
.immediate => |imm| switch (imm) {
|
||||
@@ -7975,7 +7975,7 @@ fn genShiftBinOp(
|
||||
lhs_ty: Type,
|
||||
rhs_ty: Type,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
if (lhs_ty.zigTypeTag(mod) == .Vector) return self.fail("TODO implement genShiftBinOp for {}", .{
|
||||
lhs_ty.fmt(mod),
|
||||
});
|
||||
@@ -8041,7 +8041,7 @@ fn genMulDivBinOp(
|
||||
lhs_mcv: MCValue,
|
||||
rhs_mcv: MCValue,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
if (dst_ty.zigTypeTag(mod) == .Vector or dst_ty.zigTypeTag(mod) == .Float) return self.fail(
|
||||
"TODO implement genMulDivBinOp for {s} from {} to {}",
|
||||
.{ @tagName(tag), src_ty.fmt(mod), dst_ty.fmt(mod) },
|
||||
@@ -8283,7 +8283,7 @@ fn genBinOp(
|
||||
lhs_air: Air.Inst.Ref,
|
||||
rhs_air: Air.Inst.Ref,
|
||||
) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const lhs_ty = self.typeOf(lhs_air);
|
||||
const rhs_ty = self.typeOf(rhs_air);
|
||||
const abi_size: u32 = @intCast(lhs_ty.abiSize(mod));
|
||||
@@ -10015,7 +10015,7 @@ fn genBinOpMir(
|
||||
dst_mcv: MCValue,
|
||||
src_mcv: MCValue,
|
||||
) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size: u32 = @intCast(ty.abiSize(mod));
|
||||
try self.spillEflagsIfOccupied();
|
||||
switch (dst_mcv) {
|
||||
@@ -10435,7 +10435,7 @@ fn genBinOpMir(
|
||||
/// Performs multi-operand integer multiplication between dst_mcv and src_mcv, storing the result in dst_mcv.
|
||||
/// Does not support byte-size operands.
|
||||
fn genIntMulComplexOpMir(self: *Self, dst_ty: Type, dst_mcv: MCValue, src_mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size: u32 = @intCast(dst_ty.abiSize(mod));
|
||||
try self.spillEflagsIfOccupied();
|
||||
switch (dst_mcv) {
|
||||
@@ -10560,7 +10560,7 @@ fn genIntMulComplexOpMir(self: *Self, dst_ty: Type, dst_mcv: MCValue, src_mcv: M
|
||||
}
|
||||
|
||||
fn airArg(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
// skip zero-bit arguments as they don't have a corresponding arg instruction
|
||||
var arg_index = self.arg_index;
|
||||
while (self.args[arg_index] == .none) arg_index += 1;
|
||||
@@ -10593,7 +10593,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn genArgDbgInfo(self: Self, ty: Type, name: [:0]const u8, mcv: MCValue) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (self.debug_output) {
|
||||
.dwarf => |dw| {
|
||||
const loc: link.File.Dwarf.DeclState.DbgInfoLoc = switch (mcv) {
|
||||
@@ -10629,7 +10629,7 @@ fn genVarDbgInfo(
|
||||
mcv: MCValue,
|
||||
name: [:0]const u8,
|
||||
) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const is_ptr = switch (tag) {
|
||||
.dbg_var_ptr => true,
|
||||
.dbg_var_val => false,
|
||||
@@ -10748,7 +10748,7 @@ fn genCall(self: *Self, info: union(enum) {
|
||||
callee: []const u8,
|
||||
},
|
||||
}, arg_types: []const Type, args: []const MCValue) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
|
||||
const fn_ty = switch (info) {
|
||||
.air => |callee| fn_info: {
|
||||
@@ -10969,7 +10969,7 @@ fn genCall(self: *Self, info: union(enum) {
|
||||
}
|
||||
|
||||
fn airRet(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
|
||||
const ret_ty = self.fn_type.fnReturnType(mod);
|
||||
@@ -11018,7 +11018,7 @@ fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const ty = self.typeOf(bin_op.lhs);
|
||||
|
||||
@@ -11412,7 +11412,7 @@ fn airCmpVector(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airCmpLtErrorsLen(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
|
||||
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 {
|
||||
}
|
||||
|
||||
fn genCondBrMir(self: *Self, ty: Type, mcv: MCValue) !Mir.Inst.Index {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = ty.abiSize(mod);
|
||||
switch (mcv) {
|
||||
.eflags => |cc| {
|
||||
@@ -11624,7 +11624,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn isNull(self: *Self, inst: Air.Inst.Index, opt_ty: Type, opt_mcv: MCValue) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (opt_mcv) {
|
||||
.register_overflow => |ro| return .{ .eflags = ro.eflags.negate() },
|
||||
else => {},
|
||||
@@ -11732,7 +11732,7 @@ fn isNull(self: *Self, inst: Air.Inst.Index, opt_ty: Type, opt_mcv: MCValue) !MC
|
||||
}
|
||||
|
||||
fn isNullPtr(self: *Self, inst: Air.Inst.Index, ptr_ty: Type, ptr_mcv: MCValue) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const opt_ty = ptr_ty.childType(mod);
|
||||
const pl_ty = opt_ty.optionalChild(mod);
|
||||
|
||||
@@ -11768,7 +11768,7 @@ fn isNullPtr(self: *Self, inst: Air.Inst.Index, ptr_ty: Type, ptr_mcv: MCValue)
|
||||
}
|
||||
|
||||
fn isErr(self: *Self, maybe_inst: ?Air.Inst.Index, eu_ty: Type, eu_mcv: MCValue) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const err_ty = eu_ty.errorUnionSet(mod);
|
||||
if (err_ty.errorSetIsEmpty(mod)) return MCValue{ .immediate = 0 }; // always false
|
||||
|
||||
@@ -11815,7 +11815,7 @@ fn isErr(self: *Self, maybe_inst: ?Air.Inst.Index, eu_ty: Type, eu_mcv: MCValue)
|
||||
}
|
||||
|
||||
fn isErrPtr(self: *Self, maybe_inst: ?Air.Inst.Index, ptr_ty: Type, ptr_mcv: MCValue) !MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const eu_ty = ptr_ty.childType(mod);
|
||||
const err_ty = eu_ty.errorUnionSet(mod);
|
||||
if (err_ty.errorSetIsEmpty(mod)) return MCValue{ .immediate = 0 }; // always false
|
||||
@@ -12097,7 +12097,7 @@ fn performReloc(self: *Self, reloc: Mir.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airBr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const br = self.air.instructions.items(.data)[@intFromEnum(inst)].br;
|
||||
|
||||
const block_ty = self.typeOfIndex(br.block_inst);
|
||||
@@ -12158,7 +12158,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Asm, ty_pl.payload);
|
||||
const clobbers_len: u31 = @truncate(extra.data.flags);
|
||||
@@ -12865,7 +12865,7 @@ const MoveStrategy = union(enum) {
|
||||
}
|
||||
};
|
||||
fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !MoveStrategy {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
switch (class) {
|
||||
.general_purpose, .segment => return .{ .move = .{ ._, .mov } },
|
||||
.x87 => return .x87_load_store,
|
||||
@@ -13164,7 +13164,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo
|
||||
}
|
||||
|
||||
fn genCopy(self: *Self, ty: Type, dst_mcv: MCValue, src_mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
|
||||
const src_lock = if (src_mcv.getReg()) |reg| self.register_manager.lockReg(reg) else null;
|
||||
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
|
||||
}
|
||||
|
||||
fn genSetReg(self: *Self, dst_reg: Register, ty: Type, src_mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size: u32 = @intCast(ty.abiSize(mod));
|
||||
if (ty.bitSize(mod) > dst_reg.bitSize())
|
||||
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
|
||||
}
|
||||
|
||||
fn genSetMem(self: *Self, base: Memory.Base, disp: i32, ty: Type, src_mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size: u32 = @intCast(ty.abiSize(mod));
|
||||
const dst_ptr_mcv: MCValue = switch (base) {
|
||||
.none => .{ .immediate = @bitCast(@as(i64, disp)) },
|
||||
@@ -13922,7 +13922,7 @@ fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const dst_ty = self.typeOfIndex(inst);
|
||||
const src_ty = self.typeOf(ty_op.operand);
|
||||
@@ -13980,7 +13980,7 @@ fn airBitCast(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
const slice_ty = self.typeOfIndex(inst);
|
||||
@@ -14003,7 +14003,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
const dst_ty = self.typeOfIndex(inst);
|
||||
@@ -14082,7 +14082,7 @@ fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
|
||||
const dst_ty = self.typeOfIndex(inst);
|
||||
@@ -14153,7 +14153,7 @@ fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airCmpxchg(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.Cmpxchg, ty_pl.payload).data;
|
||||
|
||||
@@ -14249,7 +14249,7 @@ fn atomicOp(
|
||||
rmw_op: ?std.builtin.AtomicRmwOp,
|
||||
order: std.builtin.AtomicOrder,
|
||||
) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ptr_lock = switch (ptr_mcv) {
|
||||
.register => |reg| self.register_manager.lockReg(reg),
|
||||
else => null,
|
||||
@@ -14653,7 +14653,7 @@ fn airAtomicStore(self: *Self, inst: Air.Inst.Index, order: std.builtin.AtomicOr
|
||||
}
|
||||
|
||||
fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
|
||||
result: {
|
||||
@@ -14781,7 +14781,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
|
||||
}
|
||||
|
||||
fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
|
||||
try self.spillRegisters(&.{ .rdi, .rsi, .rcx });
|
||||
@@ -14836,7 +14836,7 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airTagName(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
const inst_ty = self.typeOfIndex(inst);
|
||||
const enum_ty = self.typeOf(un_op);
|
||||
@@ -14878,7 +14878,7 @@ fn airTagName(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airErrorName(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
|
||||
|
||||
const err_ty = self.typeOf(un_op);
|
||||
@@ -14980,7 +14980,7 @@ fn airErrorName(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const vector_ty = self.typeOfIndex(inst);
|
||||
const vector_len = vector_ty.vectorLen(mod);
|
||||
@@ -15332,7 +15332,7 @@ fn airShuffle(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airReduce(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const reduce = self.air.instructions.items(.data)[@intFromEnum(inst)].reduce;
|
||||
|
||||
const result: MCValue = result: {
|
||||
@@ -15389,7 +15389,7 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const result_ty = self.typeOfIndex(inst);
|
||||
const len: usize = @intCast(result_ty.arrayLen(mod));
|
||||
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 {
|
||||
}
|
||||
|
||||
fn airUnionInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const extra = self.air.extraData(Air.UnionInit, ty_pl.payload).data;
|
||||
@@ -15613,7 +15613,7 @@ fn airPrefetch(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
|
||||
const extra = self.air.extraData(Air.Bin, pl_op.payload).data;
|
||||
const ty = self.typeOfIndex(inst);
|
||||
@@ -15780,7 +15780,7 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airVaStart(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const va_list_ty = self.air.instructions.items(.data)[@intFromEnum(inst)].ty;
|
||||
const ptr_anyopaque_ty = try mod.singleMutPtrType(Type.anyopaque);
|
||||
|
||||
@@ -15833,7 +15833,7 @@ fn airVaStart(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn airVaArg(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
|
||||
const ty = self.typeOfIndex(inst);
|
||||
const promote_ty = self.promoteVarArg(ty);
|
||||
@@ -16042,7 +16042,7 @@ fn airVaEnd(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ty = self.typeOf(ref);
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
fn genTypedValue(self: *Self, arg_tv: TypedValue) InnerError!MCValue {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return switch (try codegen.genTypedValue(self.bin_file, self.src_loc, arg_tv, self.owner.getDecl(mod))) {
|
||||
.mcv => |mcv| switch (mcv) {
|
||||
.none => .none,
|
||||
@@ -16156,7 +16156,7 @@ fn resolveCallingConventionValues(
|
||||
var_args: []const Type,
|
||||
stack_frame_base: FrameIndex,
|
||||
) !CallMCValues {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const cc = fn_info.cc;
|
||||
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 {
|
||||
}
|
||||
|
||||
fn memSize(self: *Self, ty: Type) Memory.Size {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return switch (ty.zigTypeTag(mod)) {
|
||||
.Float => Memory.Size.fromBitSize(ty.floatBits(self.target.*)),
|
||||
else => Memory.Size.fromSize(@intCast(ty.abiSize(mod))),
|
||||
@@ -16476,7 +16476,7 @@ fn memSize(self: *Self, ty: Type) Memory.Size {
|
||||
}
|
||||
|
||||
fn splitType(self: *Self, ty: Type) ![2]Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const classes = mem.sliceTo(&abi.classifySystemV(ty, mod, .other), .none);
|
||||
var parts: [2]Type = undefined;
|
||||
if (classes.len == 2) for (&parts, classes, 0..) |*part, class, part_i| {
|
||||
@@ -16505,7 +16505,7 @@ fn splitType(self: *Self, ty: Type) ![2]Type {
|
||||
/// Truncates the value in the register in place.
|
||||
/// Clobbers any remaining bits.
|
||||
fn truncateRegister(self: *Self, ty: Type, reg: Register) !void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const int_info = if (ty.isAbiInt(mod)) ty.intInfo(mod) else std.builtin.Type.Int{
|
||||
.signedness = .unsigned,
|
||||
.bits = @intCast(ty.bitSize(mod)),
|
||||
@@ -16550,7 +16550,7 @@ fn truncateRegister(self: *Self, ty: Type, reg: Register) !void {
|
||||
}
|
||||
|
||||
fn regBitSize(self: *Self, ty: Type) u64 {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const abi_size = ty.abiSize(mod);
|
||||
return switch (ty.zigTypeTag(mod)) {
|
||||
else => switch (abi_size) {
|
||||
@@ -16569,7 +16569,7 @@ fn regBitSize(self: *Self, ty: Type) u64 {
|
||||
}
|
||||
|
||||
fn regExtraBits(self: *Self, ty: Type) u64 {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return self.regBitSize(ty) - ty.bitSize(mod);
|
||||
}
|
||||
|
||||
@@ -16584,12 +16584,12 @@ fn hasAllFeatures(self: *Self, features: anytype) bool {
|
||||
}
|
||||
|
||||
fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return self.air.typeOf(inst, &mod.intern_pool);
|
||||
}
|
||||
|
||||
fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
return self.air.typeOfIndex(inst, &mod.intern_pool);
|
||||
}
|
||||
|
||||
@@ -16641,7 +16641,7 @@ fn floatLibcAbiSuffix(ty: Type) []const u8 {
|
||||
}
|
||||
|
||||
fn promoteInt(self: *Self, ty: Type) Type {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const mod = self.bin_file.comp.module.?;
|
||||
const int_info: InternPool.Key.IntType = switch (ty.toIntern()) {
|
||||
.bool_type => .{ .signedness = .unsigned, .bits = 1 },
|
||||
else => if (ty.isAbiInt(mod)) ty.intInfo(mod) else return ty,
|
||||
|
||||
@@ -110,7 +110,7 @@ pub fn generateLazySymbol(
|
||||
const target = bin_file.options.target;
|
||||
const endian = target.cpu.arch.endian();
|
||||
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
log.debug("generateLazySymbol: kind = {s}, ty = {}", .{
|
||||
@tagName(lazy_sym.kind),
|
||||
lazy_sym.ty.fmt(mod),
|
||||
@@ -165,7 +165,7 @@ pub fn generateSymbol(
|
||||
const tracy = trace(@src());
|
||||
defer tracy.end();
|
||||
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
const ip = &mod.intern_pool;
|
||||
const typed_value = arg_tv;
|
||||
|
||||
@@ -662,7 +662,7 @@ fn lowerParentPtr(
|
||||
debug_output: DebugInfoOutput,
|
||||
reloc_info: RelocInfo,
|
||||
) CodeGenError!Result {
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
const ptr = mod.intern_pool.indexToKey(parent_ptr).ptr;
|
||||
assert(ptr.len == .none);
|
||||
return switch (ptr.addr) {
|
||||
@@ -766,7 +766,7 @@ fn lowerAnonDeclRef(
|
||||
) CodeGenError!Result {
|
||||
_ = debug_output;
|
||||
const target = bin_file.options.target;
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
|
||||
const ptr_width_bytes = @divExact(target.ptrBitWidth(), 8);
|
||||
const decl_val = anon_decl.val;
|
||||
@@ -812,7 +812,7 @@ fn lowerDeclRef(
|
||||
_ = src_loc;
|
||||
_ = debug_output;
|
||||
const target = bin_file.options.target;
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
|
||||
const ptr_width = target.ptrBitWidth();
|
||||
const decl = mod.declPtr(decl_index);
|
||||
@@ -902,7 +902,7 @@ fn genDeclRef(
|
||||
tv: TypedValue,
|
||||
ptr_decl_index: InternPool.DeclIndex,
|
||||
) CodeGenError!GenResult {
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
log.debug("genDeclRef: ty = {}, val = {}", .{ tv.ty.fmt(mod), tv.val.fmtValue(tv.ty, mod) });
|
||||
|
||||
const target = bin_file.options.target;
|
||||
@@ -1010,7 +1010,7 @@ fn genUnnamedConst(
|
||||
tv: TypedValue,
|
||||
owner_decl_index: InternPool.DeclIndex,
|
||||
) CodeGenError!GenResult {
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
log.debug("genUnnamedConst: ty = {}, val = {}", .{ tv.ty.fmt(mod), tv.val.fmtValue(tv.ty, mod) });
|
||||
|
||||
const target = bin_file.options.target;
|
||||
@@ -1038,7 +1038,7 @@ pub fn genTypedValue(
|
||||
arg_tv: TypedValue,
|
||||
owner_decl_index: InternPool.DeclIndex,
|
||||
) CodeGenError!GenResult {
|
||||
const mod = bin_file.options.module.?;
|
||||
const mod = bin_file.comp.module.?;
|
||||
const typed_value = arg_tv;
|
||||
|
||||
log.debug("genTypedValue: ty = {}, val = {}", .{
|
||||
|
||||
@@ -1227,7 +1227,7 @@ pub const Object = struct {
|
||||
defer arena_allocator.deinit();
|
||||
const arena = arena_allocator.allocator();
|
||||
|
||||
const mod = comp.bin_file.options.module.?;
|
||||
const mod = comp.module.?;
|
||||
const cache_dir = mod.zig_cache_artifact_directory;
|
||||
|
||||
if (std.debug.runtime_safety and !try self.builder.verify()) {
|
||||
|
||||
Reference in New Issue
Block a user