aboutsummaryrefslogtreecommitdiff
path: root/src/arch/arm/CodeGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-08-11 15:07:06 -0700
committerGitHub <noreply@github.com>2024-08-11 15:07:06 -0700
commitfc2924080694d68945308d394751a2ec4841b3c0 (patch)
treec4b372662b0253de33483225d17a8a79c735ada5 /src/arch/arm/CodeGen.zig
parent531cd177e89c1edfcd2e52f74f220eb186a25f78 (diff)
parent153e7d6235a7d74d0c02d51f84edc5c06ab7469d (diff)
downloadzig-fc2924080694d68945308d394751a2ec4841b3c0.tar.gz
zig-fc2924080694d68945308d394751a2ec4841b3c0.zip
Merge pull request #20964 from mlugg/the-great-decl-split-mk2
compiler: split `Decl` into `Nav` and `Cau`
Diffstat (limited to 'src/arch/arm/CodeGen.zig')
-rw-r--r--src/arch/arm/CodeGen.zig41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/arch/arm/CodeGen.zig b/src/arch/arm/CodeGen.zig
index 19bef2f991..e4d106921e 100644
--- a/src/arch/arm/CodeGen.zig
+++ b/src/arch/arm/CodeGen.zig
@@ -262,7 +262,7 @@ const DbgInfoReloc = struct {
fn genArgDbgInfo(reloc: DbgInfoReloc, function: Self) error{OutOfMemory}!void {
switch (function.debug_output) {
.dwarf => |dw| {
- const loc: link.File.Dwarf.DeclState.DbgInfoLoc = switch (reloc.mcv) {
+ const loc: link.File.Dwarf.NavState.DbgInfoLoc = switch (reloc.mcv) {
.register => |reg| .{ .register = reg.dwarfLocOp() },
.stack_offset,
.stack_argument_offset,
@@ -280,7 +280,7 @@ const DbgInfoReloc = struct {
else => unreachable, // not a possible argument
};
- try dw.genArgDbgInfo(reloc.name, reloc.ty, function.pt.zcu.funcOwnerDeclIndex(function.func_index), loc);
+ try dw.genArgDbgInfo(reloc.name, reloc.ty, function.pt.zcu.funcInfo(function.func_index).owner_nav, loc);
},
.plan9 => {},
.none => {},
@@ -296,7 +296,7 @@ const DbgInfoReloc = struct {
switch (function.debug_output) {
.dwarf => |dw| {
- const loc: link.File.Dwarf.DeclState.DbgInfoLoc = switch (reloc.mcv) {
+ const loc: link.File.Dwarf.NavState.DbgInfoLoc = switch (reloc.mcv) {
.register => |reg| .{ .register = reg.dwarfLocOp() },
.ptr_stack_offset,
.stack_offset,
@@ -323,7 +323,7 @@ const DbgInfoReloc = struct {
break :blk .nop;
},
};
- try dw.genVarDbgInfo(reloc.name, reloc.ty, function.pt.zcu.funcOwnerDeclIndex(function.func_index), is_ptr, loc);
+ try dw.genVarDbgInfo(reloc.name, reloc.ty, function.pt.zcu.funcInfo(function.func_index).owner_nav, is_ptr, loc);
},
.plan9 => {},
.none => {},
@@ -346,11 +346,9 @@ pub fn generate(
const zcu = pt.zcu;
const gpa = zcu.gpa;
const func = zcu.funcInfo(func_index);
- const fn_owner_decl = zcu.declPtr(func.owner_decl);
- assert(fn_owner_decl.has_tv);
- const fn_type = fn_owner_decl.typeOf(zcu);
- const namespace = zcu.namespacePtr(fn_owner_decl.src_namespace);
- const target = &namespace.fileScope(zcu).mod.resolved_target.result;
+ const func_ty = Type.fromInterned(func.ty);
+ const file_scope = zcu.navFileScope(func.owner_nav);
+ const target = &file_scope.mod.resolved_target.result;
var branch_stack = std.ArrayList(Branch).init(gpa);
defer {
@@ -372,7 +370,7 @@ pub fn generate(
.err_msg = null,
.args = undefined, // populated after `resolveCallingConventionValues`
.ret_mcv = undefined, // populated after `resolveCallingConventionValues`
- .fn_type = fn_type,
+ .fn_type = func_ty,
.arg_index = 0,
.branch_stack = &branch_stack,
.src_loc = src_loc,
@@ -385,7 +383,7 @@ pub fn generate(
defer function.exitlude_jump_relocs.deinit(gpa);
defer function.dbg_info_relocs.deinit(gpa);
- var call_info = function.resolveCallingConventionValues(fn_type) catch |err| switch (err) {
+ var call_info = function.resolveCallingConventionValues(func_ty) catch |err| switch (err) {
error.CodegenFail => return Result{ .fail = function.err_msg.? },
error.OutOfRegisters => return Result{
.fail = try ErrorMsg.create(gpa, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}),
@@ -4264,6 +4262,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
const ty = self.typeOf(callee);
const pt = self.pt;
const mod = pt.zcu;
+ const ip = &mod.intern_pool;
const fn_ty = switch (ty.zigTypeTag(mod)) {
.Fn => ty,
@@ -4333,16 +4332,16 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
// Due to incremental compilation, how function calls are generated depends
// on linking.
- if (try self.air.value(callee, pt)) |func_value| {
- if (func_value.getFunction(mod)) |func| {
- if (self.bin_file.cast(link.File.Elf)) |elf_file| {
+ if (try self.air.value(callee, pt)) |func_value| switch (ip.indexToKey(func_value.toIntern())) {
+ .func => |func| {
+ if (self.bin_file.cast(.elf)) |elf_file| {
const zo = elf_file.zigObjectPtr().?;
- const sym_index = try zo.getOrCreateMetadataForDecl(elf_file, func.owner_decl);
+ const sym_index = try zo.getOrCreateMetadataForNav(elf_file, func.owner_nav);
const sym = zo.symbol(sym_index);
_ = try sym.getOrCreateZigGotEntry(sym_index, elf_file);
const got_addr: u32 = @intCast(sym.zigGotAddress(elf_file));
try self.genSetReg(Type.usize, .lr, .{ .memory = got_addr });
- } else if (self.bin_file.cast(link.File.MachO)) |_| {
+ } else if (self.bin_file.cast(.macho)) |_| {
unreachable; // unsupported architecture for MachO
} else {
return self.fail("TODO implement call on {s} for {s}", .{
@@ -4350,11 +4349,13 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
@tagName(self.target.cpu.arch),
});
}
- } else if (func_value.getExternFunc(mod)) |_| {
+ },
+ .@"extern" => {
return self.fail("TODO implement calling extern functions", .{});
- } else {
+ },
+ else => {
return self.fail("TODO implement calling bitcasted functions", .{});
- }
+ },
} else {
assert(ty.zigTypeTag(mod) == .Pointer);
const mcv = try self.resolveInst(callee);
@@ -6178,7 +6179,7 @@ fn genTypedValue(self: *Self, val: Value) InnerError!MCValue {
pt,
self.src_loc,
val,
- pt.zcu.funcOwnerDeclIndex(self.func_index),
+ self.target.*,
)) {
.mcv => |mcv| switch (mcv) {
.none => .none,