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 {...@@ -1255,10 +1255,18 @@ fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) !void {
12551255
1256fn airSlicePtr(self: *Self, inst: Air.Inst.Index) !void {1256fn airSlicePtr(self: *Self, inst: Air.Inst.Index) !void {
1257 const ty_op = self.air.instructions.items(.data)[inst].ty_op;1257 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
1258 const result: MCValue = if (self.liveness.isUnused(inst))1258 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
1259 .dead1259 const operand = try self.resolveInst(ty_op.operand);
1260 else1260 const dst_mcv: MCValue = blk: {
1261 return self.fail("TODO implement slice_ptr for {}", .{self.target.cpu.arch});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 };
1262 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });1270 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
1263}1271}
12641272
...@@ -1266,9 +1274,13 @@ fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void {...@@ -1266,9 +1274,13 @@ fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void {
1266 const ty_op = self.air.instructions.items(.data)[inst].ty_op;1274 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
1267 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {1275 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {
1268 const operand = try self.resolveInst(ty_op.operand);1276 const operand = try self.resolveInst(ty_op.operand);
1269 const dst_mcv: MCValue = switch (operand) {1277 const dst_mcv: MCValue = blk: {
1270 .stack_offset => |off| MCValue{ .stack_offset = off + 8 },1278 switch (operand) {
1271 else => return self.fail("TODO implement slice_len for {}", .{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 }
1272 };1284 };
1273 break :result dst_mcv;1285 break :result dst_mcv;
1274 };1286 };