authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-01-04 18:24:01+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-01-06 09:54:33+01:00
logf01e6eec562e31445e940c5664c793ff443c35aa
treed169988df21d1e22aa1e5f46a5f1ae141ea0a9bc
parent2b77775cbb6990e24578f5f9c6bf32ad1da12f76

stage2: implement slice_ptr


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

src/arch/x86_64/CodeGen.zig+19-7
......@@ -1255,10 +1255,18 @@ fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
12551255
12561256fn airSlicePtr(self: *Self, inst: Air.Inst.Index) !void {
12571257 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
1258 const result: MCValue = if (self.liveness.isUnused(inst))
1259 .dead
1260 else
1261 return self.fail("TODO implement slice_ptr for {}", .{self.target.cpu.arch});
1258 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
1259 const operand = try self.resolveInst(ty_op.operand);
1260 const dst_mcv: MCValue = blk: {
1261 switch (operand) {
1262 .stack_offset => |off| {
1263 break :blk MCValue{ .stack_offset = off };
1264 },
1265 else => return self.fail("TODO implement slice_ptr for {}", .{operand}),
1266 }
1267 };
1268 break :result dst_mcv;
1269 };
12621270 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
12631271}
12641272
......@@ -1266,9 +1274,13 @@ fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void {
12661274 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
12671275 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
12681276 const operand = try self.resolveInst(ty_op.operand);
1269 const dst_mcv: MCValue = switch (operand) {
1270 .stack_offset => |off| MCValue{ .stack_offset = off + 8 },
1271 else => return self.fail("TODO implement slice_len for {}", .{operand}),
1277 const dst_mcv: MCValue = blk: {
1278 switch (operand) {
1279 .stack_offset => |off| {
1280 break :blk MCValue{ .stack_offset = off + 8 };
1281 },
1282 else => return self.fail("TODO implement slice_len for {}", .{operand}),
1283 }
12721284 };
12731285 break :result dst_mcv;
12741286 };