authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-12-10 20:55:57+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-12-10 21:11:14+07:00
log219b5f0ad6eada2174c20147a34b51986c8f44d5
tree8b6f1b597bca34093e690f75d8bb5b68f3300b44
parenta72362f3953d38a108ba1c4dc265e22fb11cf8f6

stage2: sparc64: Implement stack argument


1 files changed, 16 insertions(+), 7 deletions(-)

src/arch/sparc64/CodeGen.zig+16-7
...@@ -992,12 +992,21 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {...@@ -992,12 +992,21 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void {
992 self.arg_index += 1;992 self.arg_index += 1;
993993
994 const ty = self.air.typeOfIndex(inst);994 const ty = self.air.typeOfIndex(inst);
995 _ = ty;
996995
997 const result = self.args[arg_index];996 const arg = self.args[arg_index];
998 // TODO support stack-only arguments997 const mcv = blk: {
999 // TODO Copy registers to the stack998 switch (arg) {
1000 const mcv = result;999 .stack_offset => |off| {
1000 const mod = self.bin_file.options.module.?;
1001 const abi_size = math.cast(u32, ty.abiSize(self.target.*)) orelse {
1002 return self.fail("type '{}' too big to fit into stack frame", .{ty.fmt(mod)});
1003 };
1004 const offset = off + abi_size;
1005 break :blk MCValue{ .stack_offset = offset };
1006 },
1007 else => break :blk arg,
1008 }
1009 };
10011010
1002 try self.genArgDbgInfo(inst, mcv, @intCast(u32, arg_index));1011 try self.genArgDbgInfo(inst, mcv, @intCast(u32, arg_index));
10031012
...@@ -4182,7 +4191,7 @@ fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {...@@ -4182,7 +4191,7 @@ fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
4182 const ref_int = @enumToInt(inst);4191 const ref_int = @enumToInt(inst);
4183 if (ref_int < Air.Inst.Ref.typed_value_map.len) {4192 if (ref_int < Air.Inst.Ref.typed_value_map.len) {
4184 const tv = Air.Inst.Ref.typed_value_map[ref_int];4193 const tv = Air.Inst.Ref.typed_value_map[ref_int];
4185 if (!tv.ty.hasRuntimeBits() and !tv.ty.isError()) {4194 if (!tv.ty.hasRuntimeBitsIgnoreComptime() and !tv.ty.isError()) {
4186 return MCValue{ .none = {} };4195 return MCValue{ .none = {} };
4187 }4196 }
4188 return self.genTypedValue(tv);4197 return self.genTypedValue(tv);
...@@ -4190,7 +4199,7 @@ fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {...@@ -4190,7 +4199,7 @@ fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
41904199
4191 // If the type has no codegen bits, no need to store it.4200 // If the type has no codegen bits, no need to store it.
4192 const inst_ty = self.air.typeOf(inst);4201 const inst_ty = self.air.typeOf(inst);
4193 if (!inst_ty.hasRuntimeBits() and !inst_ty.isError())4202 if (!inst_ty.hasRuntimeBitsIgnoreComptime() and !inst_ty.isError())
4194 return MCValue{ .none = {} };4203 return MCValue{ .none = {} };
41954204
4196 const inst_index = @intCast(Air.Inst.Index, ref_int - Air.Inst.Ref.typed_value_map.len);4205 const inst_index = @intCast(Air.Inst.Index, ref_int - Air.Inst.Ref.typed_value_map.len);