aboutsummaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorKoakuma <koachan@protonmail.com>2022-12-10 20:55:57 +0700
committerKoakuma <koachan@protonmail.com>2022-12-10 21:11:14 +0700
commit219b5f0ad6eada2174c20147a34b51986c8f44d5 (patch)
tree8b6f1b597bca34093e690f75d8bb5b68f3300b44 /src/arch
parenta72362f3953d38a108ba1c4dc265e22fb11cf8f6 (diff)
downloadzig-219b5f0ad6eada2174c20147a34b51986c8f44d5.tar.gz
zig-219b5f0ad6eada2174c20147a34b51986c8f44d5.zip
stage2: sparc64: Implement stack argument
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/sparc64/CodeGen.zig23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/arch/sparc64/CodeGen.zig b/src/arch/sparc64/CodeGen.zig
index 470a5226bf..347c86dbb7 100644
--- a/src/arch/sparc64/CodeGen.zig
+++ b/src/arch/sparc64/CodeGen.zig
@@ -992,12 +992,21 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {
self.arg_index += 1;
const ty = self.air.typeOfIndex(inst);
- _ = ty;
- const result = self.args[arg_index];
- // TODO support stack-only arguments
- // TODO Copy registers to the stack
- const mcv = result;
+ const arg = self.args[arg_index];
+ const mcv = blk: {
+ switch (arg) {
+ .stack_offset => |off| {
+ const mod = self.bin_file.options.module.?;
+ const abi_size = math.cast(u32, ty.abiSize(self.target.*)) orelse {
+ return self.fail("type '{}' too big to fit into stack frame", .{ty.fmt(mod)});
+ };
+ const offset = off + abi_size;
+ break :blk MCValue{ .stack_offset = offset };
+ },
+ else => break :blk arg,
+ }
+ };
try self.genArgDbgInfo(inst, mcv, @intCast(u32, arg_index));
@@ -4182,7 +4191,7 @@ fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
const ref_int = @enumToInt(inst);
if (ref_int < Air.Inst.Ref.typed_value_map.len) {
const tv = Air.Inst.Ref.typed_value_map[ref_int];
- if (!tv.ty.hasRuntimeBits() and !tv.ty.isError()) {
+ if (!tv.ty.hasRuntimeBitsIgnoreComptime() and !tv.ty.isError()) {
return MCValue{ .none = {} };
}
return self.genTypedValue(tv);
@@ -4190,7 +4199,7 @@ fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
// If the type has no codegen bits, no need to store it.
const inst_ty = self.air.typeOf(inst);
- if (!inst_ty.hasRuntimeBits() and !inst_ty.isError())
+ if (!inst_ty.hasRuntimeBitsIgnoreComptime() and !inst_ty.isError())
return MCValue{ .none = {} };
const inst_index = @intCast(Air.Inst.Index, ref_int - Air.Inst.Ref.typed_value_map.len);