authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-10-21 14:12:54+02:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-10-21 16:24:18+02:00
log84876fec582e13707a809c8136bb1eaf92b5da09
tree31a7024410c73a01ffbf59da136b6eb9ea01d837
parent1d3382202029cde2e00d7747ec0ea53a5df68047

stage2: remove ptr_ptr_elem_val and ptr_slice_elem_val


7 files changed, 0 insertions(+), 89 deletions(-)

src/Air.zig-14
......@@ -384,10 +384,6 @@ pub const Inst = struct {
384384 /// Result type is the element type of the slice operand.
385385 /// Uses the `bin_op` field.
386386 slice_elem_val,
387 /// Given a pointer to a slice, and element index, return the element value at that index.
388 /// Result type is the element type of the slice operand (2 element type operations).
389 /// Uses the `bin_op` field.
390 ptr_slice_elem_val,
391387 /// Given a pointer value, and element index, return the element value at that index.
392388 /// Result type is the element type of the pointer operand.
393389 /// Uses the `bin_op` field.
......@@ -396,11 +392,6 @@ pub const Inst = struct {
396392 /// Result type is pointer to the element type of the pointer operand.
397393 /// Uses the `ty_pl` field with payload `Bin`.
398394 ptr_elem_ptr,
399 /// Given a pointer to a pointer, and element index, return the element value of the inner
400 /// pointer at that index.
401 /// Result type is the element type of the inner pointer operand.
402 /// Uses the `bin_op` field.
403 ptr_ptr_elem_val,
404395 /// Given a pointer to an array, return a slice.
405396 /// Uses the `ty_op` field.
406397 array_to_slice,
......@@ -772,11 +763,6 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index) Type {
772763 const ptr_ty = air.typeOf(datas[inst].bin_op.lhs);
773764 return ptr_ty.elemType();
774765 },
775 .ptr_slice_elem_val, .ptr_ptr_elem_val => {
776 const outer_ptr_ty = air.typeOf(datas[inst].bin_op.lhs);
777 const inner_ptr_ty = outer_ptr_ty.elemType();
778 return inner_ptr_ty.elemType();
779 },
780766 .atomic_load => {
781767 const ptr_ty = air.typeOf(datas[inst].atomic_load.ptr);
782768 return ptr_ty.elemType();
src/Liveness.zig-2
......@@ -252,9 +252,7 @@ fn analyzeInst(
252252 .store,
253253 .array_elem_val,
254254 .slice_elem_val,
255 .ptr_slice_elem_val,
256255 .ptr_elem_val,
257 .ptr_ptr_elem_val,
258256 .shl,
259257 .shl_exact,
260258 .shl_sat,
src/arch/aarch64/CodeGen.zig-16
......@@ -500,10 +500,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
500500
501501 .array_elem_val => try self.airArrayElemVal(inst),
502502 .slice_elem_val => try self.airSliceElemVal(inst),
503 .ptr_slice_elem_val => try self.airPtrSliceElemVal(inst),
504503 .ptr_elem_val => try self.airPtrElemVal(inst),
505504 .ptr_elem_ptr => try self.airPtrElemPtr(inst),
506 .ptr_ptr_elem_val => try self.airPtrPtrElemVal(inst),
507505
508506 .constant => unreachable, // excluded from function bodies
509507 .const_ty => unreachable, // excluded from function bodies
......@@ -1092,13 +1090,6 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
10921090 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
10931091}
10941092
1095fn airPtrSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {
1096 const is_volatile = false; // TODO
1097 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
1098 const result: MCValue = if (!is_volatile and self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement ptr_slice_elem_val for {}", .{self.target.cpu.arch});
1099 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
1100}
1101
11021093fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
11031094 const is_volatile = false; // TODO
11041095 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -1113,13 +1104,6 @@ fn airPtrElemPtr(self: *Self, inst: Air.Inst.Index) !void {
11131104 return self.finishAir(inst, result, .{ extra.lhs, extra.rhs, .none });
11141105}
11151106
1116fn airPtrPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
1117 const is_volatile = false; // TODO
1118 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
1119 const result: MCValue = if (!is_volatile and self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement ptr_ptr_elem_val for {}", .{self.target.cpu.arch});
1120 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
1121}
1122
11231107fn airSetUnionTag(self: *Self, inst: Air.Inst.Index) !void {
11241108 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
11251109 _ = bin_op;
src/codegen.zig-20
......@@ -848,10 +848,8 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
848848
849849 .array_elem_val => try self.airArrayElemVal(inst),
850850 .slice_elem_val => try self.airSliceElemVal(inst),
851 .ptr_slice_elem_val => try self.airPtrSliceElemVal(inst),
852851 .ptr_elem_val => try self.airPtrElemVal(inst),
853852 .ptr_elem_ptr => try self.airPtrElemPtr(inst),
854 .ptr_ptr_elem_val => try self.airPtrPtrElemVal(inst),
855853
856854 .constant => unreachable, // excluded from function bodies
857855 .const_ty => unreachable, // excluded from function bodies
......@@ -1543,15 +1541,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
15431541 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
15441542 }
15451543
1546 fn airPtrSliceElemVal(self: *Self, inst: Air.Inst.Index) !void {
1547 const is_volatile = false; // TODO
1548 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
1549 const result: MCValue = if (!is_volatile and self.liveness.isUnused(inst)) .dead else switch (arch) {
1550 else => return self.fail("TODO implement ptr_slice_elem_val for {}", .{self.target.cpu.arch}),
1551 };
1552 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
1553 }
1554
15551544 fn airPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
15561545 const is_volatile = false; // TODO
15571546 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
......@@ -1570,15 +1559,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
15701559 return self.finishAir(inst, result, .{ extra.lhs, extra.rhs, .none });
15711560 }
15721561
1573 fn airPtrPtrElemVal(self: *Self, inst: Air.Inst.Index) !void {
1574 const is_volatile = false; // TODO
1575 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
1576 const result: MCValue = if (!is_volatile and self.liveness.isUnused(inst)) .dead else switch (arch) {
1577 else => return self.fail("TODO implement ptr_ptr_elem_val for {}", .{self.target.cpu.arch}),
1578 };
1579 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
1580 }
1581
15821562 fn airSetUnionTag(self: *Self, inst: Air.Inst.Index) !void {
15831563 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
15841564 const result: MCValue = switch (arch) {
src/codegen/c.zig-2
......@@ -1081,10 +1081,8 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO
10811081 .ptr_slice_ptr_ptr => try airPtrSliceFieldPtr(f, inst, ".ptr;\n"),
10821082
10831083 .ptr_elem_val => try airPtrElemVal(f, inst, "["),
1084 .ptr_ptr_elem_val => try airPtrElemVal(f, inst, "[0]["),
10851084 .ptr_elem_ptr => try airPtrElemPtr(f, inst),
10861085 .slice_elem_val => try airSliceElemVal(f, inst, "["),
1087 .ptr_slice_elem_val => try airSliceElemVal(f, inst, "[0]["),
10881086 .array_elem_val => try airArrayElemVal(f, inst),
10891087
10901088 .unwrap_errunion_payload => try airUnwrapErrUnionPay(f, inst),
src/codegen/llvm.zig-33
......@@ -1760,10 +1760,8 @@ pub const FuncGen = struct {
17601760
17611761 .array_elem_val => try self.airArrayElemVal(inst),
17621762 .slice_elem_val => try self.airSliceElemVal(inst),
1763 .ptr_slice_elem_val => try self.airPtrSliceElemVal(inst),
17641763 .ptr_elem_val => try self.airPtrElemVal(inst),
17651764 .ptr_elem_ptr => try self.airPtrElemPtr(inst),
1766 .ptr_ptr_elem_val => try self.airPtrPtrElemVal(inst),
17671765
17681766 .optional_payload => try self.airOptionalPayload(inst, false),
17691767 .optional_payload_ptr => try self.airOptionalPayload(inst, true),
......@@ -2165,24 +2163,6 @@ pub const FuncGen = struct {
21652163 return self.load(ptr, slice_ty);
21662164 }
21672165
2168 fn airPtrSliceElemVal(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
2169 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
2170 const slice_ty = self.air.typeOf(bin_op.lhs).childType();
2171 if (!slice_ty.isVolatilePtr() and self.liveness.isUnused(inst)) return null;
2172
2173 const lhs = try self.resolveInst(bin_op.lhs);
2174 const rhs = try self.resolveInst(bin_op.rhs);
2175
2176 const base_ptr = ptr: {
2177 const ptr_field_ptr = self.builder.buildStructGEP(lhs, 0, "");
2178 break :ptr self.builder.buildLoad(ptr_field_ptr, "");
2179 };
2180
2181 const indices: [1]*const llvm.Value = .{rhs};
2182 const ptr = self.builder.buildInBoundsGEP(base_ptr, &indices, indices.len, "");
2183 return self.load(ptr, slice_ty);
2184 }
2185
21862166 fn airArrayElemVal(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
21872167 if (self.liveness.isUnused(inst)) return null;
21882168
......@@ -2240,19 +2220,6 @@ pub const FuncGen = struct {
22402220 }
22412221 }
22422222
2243 fn airPtrPtrElemVal(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
2244 const bin_op = self.air.instructions.items(.data)[inst].bin_op;
2245 const ptr_ty = self.air.typeOf(bin_op.lhs).childType();
2246 if (!ptr_ty.isVolatilePtr() and self.liveness.isUnused(inst)) return null;
2247
2248 const lhs = try self.resolveInst(bin_op.lhs);
2249 const rhs = try self.resolveInst(bin_op.rhs);
2250 const base_ptr = self.builder.buildLoad(lhs, "");
2251 const indices: [1]*const llvm.Value = .{rhs};
2252 const ptr = self.builder.buildInBoundsGEP(base_ptr, &indices, indices.len, "");
2253 return self.load(ptr, ptr_ty);
2254 }
2255
22562223 fn airStructFieldPtr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
22572224 if (self.liveness.isUnused(inst))
22582225 return null;
src/print_air.zig-2
......@@ -130,9 +130,7 @@ const Writer = struct {
130130 .store,
131131 .array_elem_val,
132132 .slice_elem_val,
133 .ptr_slice_elem_val,
134133 .ptr_elem_val,
135 .ptr_ptr_elem_val,
136134 .shl,
137135 .shl_exact,
138136 .shl_sat,