aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-01-04 18:24:01 +0100
committerJakub Konka <kubkon@jakubkonka.com>2022-01-06 09:54:33 +0100
commitf01e6eec562e31445e940c5664c793ff443c35aa (patch)
treed169988df21d1e22aa1e5f46a5f1ae141ea0a9bc /src
parent2b77775cbb6990e24578f5f9c6bf32ad1da12f76 (diff)
downloadzig-f01e6eec562e31445e940c5664c793ff443c35aa.tar.gz
zig-f01e6eec562e31445e940c5664c793ff443c35aa.zip
stage2: implement slice_ptr
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86_64/CodeGen.zig26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig
index 09233d3adc..58bcaeb388 100644
--- a/src/arch/x86_64/CodeGen.zig
+++ b/src/arch/x86_64/CodeGen.zig
@@ -1255,10 +1255,18 @@ fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
fn airSlicePtr(self: *Self, inst: Air.Inst.Index) !void {
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
- const result: MCValue = if (self.liveness.isUnused(inst))
- .dead
- else
- return self.fail("TODO implement slice_ptr for {}", .{self.target.cpu.arch});
+ const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
+ const operand = try self.resolveInst(ty_op.operand);
+ const dst_mcv: MCValue = blk: {
+ switch (operand) {
+ .stack_offset => |off| {
+ break :blk MCValue{ .stack_offset = off };
+ },
+ else => return self.fail("TODO implement slice_ptr for {}", .{operand}),
+ }
+ };
+ break :result dst_mcv;
+ };
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
}
@@ -1266,9 +1274,13 @@ fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void {
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
const operand = try self.resolveInst(ty_op.operand);
- const dst_mcv: MCValue = switch (operand) {
- .stack_offset => |off| MCValue{ .stack_offset = off + 8 },
- else => return self.fail("TODO implement slice_len for {}", .{operand}),
+ const dst_mcv: MCValue = blk: {
+ switch (operand) {
+ .stack_offset => |off| {
+ break :blk MCValue{ .stack_offset = off + 8 };
+ },
+ else => return self.fail("TODO implement slice_len for {}", .{operand}),
+ }
};
break :result dst_mcv;
};