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;...@@ -17,12 +17,6 @@ const LazySrcLoc = Module.LazySrcLoc;
17const Air = @import("../Air.zig");17const Air = @import("../Air.zig");
18const Liveness = @import("../Liveness.zig");18const 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
26const BigIntLimb = std.math.big.Limb;20const BigIntLimb = std.math.big.Limb;
27const BigInt = std.math.big.int;21const BigInt = std.math.big.int;
2822
...@@ -3317,7 +3311,7 @@ fn airLoad(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -3317,7 +3311,7 @@ fn airLoad(f: *Function, inst: Air.Inst.Index) !CValue {
3317 try writer.writeAll(", sizeof(");3311 try writer.writeAll(", sizeof(");
3318 try f.renderType(writer, src_ty);3312 try f.renderType(writer, src_ty);
3319 try writer.writeAll("))");3313 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) {
3321 var host_pl = Type.Payload.Bits{3315 var host_pl = Type.Payload.Bits{
3322 .base = .{ .tag = .int_unsigned },3316 .base = .{ .tag = .int_unsigned },
3323 .data = ptr_info.host_size * 8,3317 .data = ptr_info.host_size * 8,
...@@ -3647,7 +3641,7 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -3647,7 +3641,7 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue {
3647 if (src_val == .constant) {3641 if (src_val == .constant) {
3648 try freeLocal(f, inst, array_src.new_local, 0);3642 try freeLocal(f, inst, array_src.new_local, 0);
3649 }3643 }
3650 } else if (ptr_info.host_size != 0) {3644 } else if (ptr_info.host_size > 0 and ptr_info.vector_index == .none) {
3651 const host_bits = ptr_info.host_size * 8;3645 const host_bits = ptr_info.host_size * 8;
3652 var host_pl = Type.Payload.Bits{ .base = .{ .tag = .int_unsigned }, .data = host_bits };3646 var host_pl = Type.Payload.Bits{ .base = .{ .tag = .int_unsigned }, .data = host_bits };
3653 const host_ty = Type.initPayload(&host_pl.base);3647 const host_ty = Type.initPayload(&host_pl.base);
src/codegen/c/type.zig+1-1
...@@ -1465,7 +1465,7 @@ pub const CType = extern union {...@@ -1465,7 +1465,7 @@ pub const CType = extern union {
1465 .base = .{ .tag = .int_unsigned },1465 .base = .{ .tag = .int_unsigned },
1466 .data = info.host_size * 8,1466 .data = info.host_size * 8,
1467 };1467 };
1468 const pointee_ty = if (info.host_size > 0)1468 const pointee_ty = if (info.host_size > 0 and info.vector_index == .none)
1469 Type.initPayload(&host_int_pl.base)1469 Type.initPayload(&host_int_pl.base)
1470 else1470 else
1471 info.pointee_type;1471 info.pointee_type;
test/behavior/vector.zig-3
...@@ -1118,7 +1118,6 @@ test "byte vector initialized in inline function" {...@@ -1118,7 +1118,6 @@ test "byte vector initialized in inline function" {
1118}1118}
11191119
1120test "byte vector initialized in inline function" {1120test "byte vector initialized in inline function" {
1121 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
1122 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO1121 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
1123 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO1122 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
1124 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO1123 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
...@@ -1233,7 +1232,6 @@ test "load packed vector element" {...@@ -1233,7 +1232,6 @@ test "load packed vector element" {
1233 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO1232 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
1234 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO1233 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
1235 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO1234 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
1236 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
12371235
1238 var x: @Vector(2, u15) = .{ 1, 4 };1236 var x: @Vector(2, u15) = .{ 1, 4 };
1239 try expect((&x[0]).* == 1);1237 try expect((&x[0]).* == 1);
...@@ -1246,7 +1244,6 @@ test "store packed vector element" {...@@ -1246,7 +1244,6 @@ test "store packed vector element" {
1246 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO1244 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
1247 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO1245 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
1248 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO1246 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
1249 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
12501247
1251 var v = @Vector(4, u1){ 1, 1, 1, 1 };1248 var v = @Vector(4, u1){ 1, 1, 1, 1 };
1252 try expectEqual(@Vector(4, u1){ 1, 1, 1, 1 }, v);1249 try expectEqual(@Vector(4, u1){ 1, 1, 1, 1 }, v);