authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-03-05 00:30:55-05:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-03-05 02:59:02-05:00
log8f6da78fb1bfc9d5e8b3d5affd33cf6a62f5e8c7
tree2ded76abd083b0e8b09cec69409f8f3b247984c1
parentc478c7609e4529267d1ce030577777e836ffc10b

CBE: implement vector element pointers


3 files changed, 3 insertions(+), 12 deletions(-)

src/codegen/c.zig+2-8
......@@ -17,12 +17,6 @@ const LazySrcLoc = Module.LazySrcLoc;
1717const Air = @import("../Air.zig");
1818const Liveness = @import("../Liveness.zig");
1919
20const target_util = @import("../target.zig");
21const libcFloatPrefix = target_util.libcFloatPrefix;
22const libcFloatSuffix = target_util.libcFloatSuffix;
23const compilerRtFloatAbbrev = target_util.compilerRtFloatAbbrev;
24const compilerRtIntAbbrev = target_util.compilerRtIntAbbrev;
25
2620const BigIntLimb = std.math.big.Limb;
2721const BigInt = std.math.big.int;
2822
......@@ -3317,7 +3311,7 @@ fn airLoad(f: *Function, inst: Air.Inst.Index) !CValue {
33173311 try writer.writeAll(", sizeof(");
33183312 try f.renderType(writer, src_ty);
33193313 try writer.writeAll("))");
3320 } else if (ptr_info.host_size != 0) {
3314 } else if (ptr_info.host_size > 0 and ptr_info.vector_index == .none) {
33213315 var host_pl = Type.Payload.Bits{
33223316 .base = .{ .tag = .int_unsigned },
33233317 .data = ptr_info.host_size * 8,
......@@ -3647,7 +3641,7 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue {
36473641 if (src_val == .constant) {
36483642 try freeLocal(f, inst, array_src.new_local, 0);
36493643 }
3650 } else if (ptr_info.host_size != 0) {
3644 } else if (ptr_info.host_size > 0 and ptr_info.vector_index == .none) {
36513645 const host_bits = ptr_info.host_size * 8;
36523646 var host_pl = Type.Payload.Bits{ .base = .{ .tag = .int_unsigned }, .data = host_bits };
36533647 const host_ty = Type.initPayload(&host_pl.base);
src/codegen/c/type.zig+1-1
......@@ -1465,7 +1465,7 @@ pub const CType = extern union {
14651465 .base = .{ .tag = .int_unsigned },
14661466 .data = info.host_size * 8,
14671467 };
1468 const pointee_ty = if (info.host_size > 0)
1468 const pointee_ty = if (info.host_size > 0 and info.vector_index == .none)
14691469 Type.initPayload(&host_int_pl.base)
14701470 else
14711471 info.pointee_type;
test/behavior/vector.zig-3
......@@ -1118,7 +1118,6 @@ test "byte vector initialized in inline function" {
11181118}
11191119
11201120test "byte vector initialized in inline function" {
1121 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
11221121 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
11231122 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
11241123 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
......@@ -1233,7 +1232,6 @@ test "load packed vector element" {
12331232 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
12341233 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
12351234 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
1236 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
12371235
12381236 var x: @Vector(2, u15) = .{ 1, 4 };
12391237 try expect((&x[0]).* == 1);
......@@ -1246,7 +1244,6 @@ test "store packed vector element" {
12461244 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
12471245 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
12481246 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
1249 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
12501247
12511248 var v = @Vector(4, u1){ 1, 1, 1, 1 };
12521249 try expectEqual(@Vector(4, u1){ 1, 1, 1, 1 }, v);