aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-04-27 18:36:12 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-04-28 16:57:01 -0700
commitf86469bc5eea2b7bd95222d00a11bd287bfdfedf (patch)
treec34ef71820e4c7b962a631f2b9cdecdff3f5aa79 /src/codegen.zig
parentfa6bb4b662155e4d6a61cc551b5d02a2a7d5d144 (diff)
downloadzig-f86469bc5eea2b7bd95222d00a11bd287bfdfedf.tar.gz
zig-f86469bc5eea2b7bd95222d00a11bd287bfdfedf.zip
stage2: semaDecl properly analyzes the decl block
Also flattened out Decl TypedValue fields into ty, val, has_tv and add relevant fields to Decl for alignment and link section.
Diffstat (limited to 'src/codegen.zig')
-rw-r--r--src/codegen.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/codegen.zig b/src/codegen.zig
index 290daee457..ad401066ef 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -400,7 +400,8 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
const module_fn = typed_value.val.castTag(.function).?.data;
- const fn_type = module_fn.owner_decl.typed_value.most_recent.typed_value.ty;
+ assert(module_fn.owner_decl.has_tv);
+ const fn_type = module_fn.owner_decl.ty;
var branch_stack = std.ArrayList(Branch).init(bin_file.allocator);
defer {
@@ -1925,7 +1926,8 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
else
unreachable;
- const return_type = func.owner_decl.typed_value.most_recent.typed_value.ty.fnReturnType();
+ assert(func.owner_decl.has_tv);
+ const return_type = func.owner_decl.ty.fnReturnType();
// First, push the return address, then jump; if noreturn, don't bother with the first step
// TODO: implement packed struct -> u16 at comptime and move the bitcast here
var instr = Instruction{ .condition = .always, .input0 = .immediate, .input1 = .zero, .modify_flags = false, .output = .jump, .command = .load16 };