| author | |
| committer | |
| log | 3794f2c493c9744e19cd7df23c3d4b32565aaa96 |
| tree | f7840fae06c5f0f909e5c58dc1160c211782ca7b |
| parent | 25729d6155682933d7ab3aa30c7e060519b2f4e1 |
| signature | Commit is signed but in an unrecognized format. |
13 files changed, 36 insertions(+), 24 deletions(-)
src/arch/arm/CodeGen.zig+36-1| ... | ... | @@ -2739,6 +2739,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { |
| 2739 | 2739 | const mcv = try self.resolveInst(operand); |
| 2740 | 2740 | const struct_ty = self.air.typeOf(operand); |
| 2741 | 2741 | const struct_field_offset = @intCast(u32, struct_ty.structFieldOffset(index, self.target.*)); |
| 2742 | const struct_field_ty = struct_ty.structFieldType(index); | |
| 2742 | 2743 | |
| 2743 | 2744 | switch (mcv) { |
| 2744 | 2745 | .dead, .unreach => unreachable, |
| ... | ... | @@ -2776,11 +2777,45 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { |
| 2776 | 2777 | } else { |
| 2777 | 2778 | // Copy to new register |
| 2778 | 2779 | const dest_reg = try self.register_manager.allocReg(null, gp); |
| 2779 | try self.genSetReg(struct_ty.structFieldType(index), dest_reg, field); | |
| 2780 | try self.genSetReg(struct_field_ty, dest_reg, field); | |
| 2780 | 2781 | |
| 2781 | 2782 | break :result MCValue{ .register = dest_reg }; |
| 2782 | 2783 | } |
| 2783 | 2784 | }, |
| 2785 | .register => { | |
| 2786 | var operand_reg: Register = undefined; | |
| 2787 | var dest_reg: Register = undefined; | |
| 2788 | ||
| 2789 | const read_args = [_]ReadArg{ | |
| 2790 | .{ .ty = struct_ty, .bind = .{ .mcv = mcv }, .class = gp, .reg = &operand_reg }, | |
| 2791 | }; | |
| 2792 | const write_args = [_]WriteArg{ | |
| 2793 | .{ .ty = struct_field_ty, .bind = .none, .class = gp, .reg = &dest_reg }, | |
| 2794 | }; | |
| 2795 | try self.allocRegs( | |
| 2796 | &read_args, | |
| 2797 | &write_args, | |
| 2798 | ReuseMetadata{ | |
| 2799 | .corresponding_inst = inst, | |
| 2800 | .operand_mapping = &.{0}, | |
| 2801 | }, | |
| 2802 | ); | |
| 2803 | ||
| 2804 | const field_bit_offset = struct_field_offset * 8; | |
| 2805 | const field_bit_size = @intCast(u32, struct_field_ty.abiSize(self.target.*)) * 8; | |
| 2806 | ||
| 2807 | _ = try self.addInst(.{ | |
| 2808 | .tag = if (struct_field_ty.isSignedInt()) Mir.Inst.Tag.sbfx else .ubfx, | |
| 2809 | .data = .{ .rr_lsb_width = .{ | |
| 2810 | .rd = dest_reg, | |
| 2811 | .rn = operand_reg, | |
| 2812 | .lsb = @intCast(u5, field_bit_offset), | |
| 2813 | .width = @intCast(u6, field_bit_size), | |
| 2814 | } }, | |
| 2815 | }); | |
| 2816 | ||
| 2817 | break :result MCValue{ .register = dest_reg }; | |
| 2818 | }, | |
| 2784 | 2819 | else => return self.fail("TODO implement codegen struct_field_val for {}", .{mcv}), |
| 2785 | 2820 | } |
| 2786 | 2821 | }; |
test/behavior/array.zig-2| ... | ... | @@ -175,7 +175,6 @@ test "nested arrays of integers" { |
| 175 | 175 | |
| 176 | 176 | test "implicit comptime in array type size" { |
| 177 | 177 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 178 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 179 | 178 | |
| 180 | 179 | var arr: [plusOne(10)]bool = undefined; |
| 181 | 180 | try expect(arr.len == 11); |
| ... | ... | @@ -484,7 +483,6 @@ test "sentinel element count towards the ABI size calculation" { |
| 484 | 483 | test "zero-sized array with recursive type definition" { |
| 485 | 484 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 486 | 485 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 487 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 488 | 486 | |
| 489 | 487 | const U = struct { |
| 490 | 488 | fn foo(comptime T: type, comptime n: usize) type { |
test/behavior/basic.zig-2| ... | ... | @@ -465,7 +465,6 @@ fn nine() u8 { |
| 465 | 465 | |
| 466 | 466 | test "struct inside function" { |
| 467 | 467 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 468 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 469 | 468 | |
| 470 | 469 | try testStructInFn(); |
| 471 | 470 | comptime try testStructInFn(); |
| ... | ... | @@ -514,7 +513,6 @@ var global_foo: *i32 = undefined; |
| 514 | 513 | |
| 515 | 514 | test "peer result location with typed parent, runtime condition, comptime prongs" { |
| 516 | 515 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 517 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 518 | 516 | |
| 519 | 517 | const S = struct { |
| 520 | 518 | fn doTheTest(arg: i32) i32 { |
test/behavior/bitcast.zig-1| ... | ... | @@ -138,7 +138,6 @@ test "@bitCast extern structs at runtime and comptime" { |
| 138 | 138 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 139 | 139 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 140 | 140 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 141 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 142 | 141 | |
| 143 | 142 | const Full = extern struct { |
| 144 | 143 | number: u16, |
test/behavior/enum.zig-1| ... | ... | @@ -1127,7 +1127,6 @@ test "tag name functions are unique" { |
| 1127 | 1127 | |
| 1128 | 1128 | test "size of enum with only one tag which has explicit integer tag type" { |
| 1129 | 1129 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 1130 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 1131 | 1130 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 1132 | 1131 | |
| 1133 | 1132 | const E = enum(u8) { nope = 10 }; |
test/behavior/eval.zig-1| ... | ... | @@ -954,7 +954,6 @@ test "const local with comptime init through array init" { |
| 954 | 954 | |
| 955 | 955 | test "closure capture type of runtime-known parameter" { |
| 956 | 956 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 957 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 958 | 957 | |
| 959 | 958 | const S = struct { |
| 960 | 959 | fn b(c: anytype) !void { |
test/behavior/for.zig-1| ... | ... | @@ -213,7 +213,6 @@ test "for on slice with allowzero ptr" { |
| 213 | 213 | |
| 214 | 214 | test "else continue outer for" { |
| 215 | 215 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 216 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 217 | 216 | |
| 218 | 217 | var i: usize = 6; |
| 219 | 218 | var buf: [5]u8 = undefined; |
test/behavior/pointers.zig-1| ... | ... | @@ -66,7 +66,6 @@ test "initialize const optional C pointer to null" { |
| 66 | 66 | |
| 67 | 67 | test "assigning integer to C pointer" { |
| 68 | 68 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 69 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 70 | 69 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 71 | 70 | |
| 72 | 71 | var x: i32 = 0; |
test/behavior/ptrcast.zig-3| ... | ... | @@ -4,7 +4,6 @@ const expect = std.testing.expect; |
| 4 | 4 | const native_endian = builtin.target.cpu.arch.endian(); |
| 5 | 5 | |
| 6 | 6 | test "reinterpret bytes as integer with nonzero offset" { |
| 7 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 8 | 7 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 9 | 8 | |
| 10 | 9 | try testReinterpretBytesAsInteger(); |
| ... | ... | @@ -39,7 +38,6 @@ fn testReinterpretWithOffsetAndNoWellDefinedLayout() !void { |
| 39 | 38 | } |
| 40 | 39 | |
| 41 | 40 | test "reinterpret bytes inside auto-layout struct as integer with nonzero offset" { |
| 42 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 43 | 41 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 44 | 42 | |
| 45 | 43 | try testReinterpretStructWrappedBytesAsInteger(); |
| ... | ... | @@ -179,7 +177,6 @@ test "lower reinterpreted comptime field ptr" { |
| 179 | 177 | } |
| 180 | 178 | |
| 181 | 179 | test "reinterpret struct field at comptime" { |
| 182 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 183 | 180 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 184 | 181 | |
| 185 | 182 | const numNative = comptime Bytes.init(0x12345678); |
test/behavior/sizeof_and_typeof.zig-2| ... | ... | @@ -18,7 +18,6 @@ test "@sizeOf on compile-time types" { |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | test "@TypeOf() with multiple arguments" { |
| 21 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 22 | 21 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 23 | 22 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 24 | 23 | { |
| ... | ... | @@ -77,7 +76,6 @@ const P = packed struct { |
| 77 | 76 | }; |
| 78 | 77 | |
| 79 | 78 | test "@offsetOf" { |
| 80 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 81 | 79 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 82 | 80 | |
| 83 | 81 | // Packed structs have fixed memory layout |
test/behavior/struct.zig-7| ... | ... | @@ -10,7 +10,6 @@ top_level_field: i32, |
| 10 | 10 | |
| 11 | 11 | test "top level fields" { |
| 12 | 12 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 13 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 14 | 13 | |
| 15 | 14 | var instance = @This(){ |
| 16 | 15 | .top_level_field = 1234, |
| ... | ... | @@ -239,7 +238,6 @@ test "usingnamespace within struct scope" { |
| 239 | 238 | |
| 240 | 239 | test "struct field init with catch" { |
| 241 | 240 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 242 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 243 | 241 | |
| 244 | 242 | const S = struct { |
| 245 | 243 | fn doTheTest() !void { |
| ... | ... | @@ -280,7 +278,6 @@ const Val = struct { |
| 280 | 278 | test "struct point to self" { |
| 281 | 279 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 282 | 280 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 283 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 284 | 281 | |
| 285 | 282 | var root: Node = undefined; |
| 286 | 283 | root.val.x = 1; |
| ... | ... | @@ -296,7 +293,6 @@ test "struct point to self" { |
| 296 | 293 | |
| 297 | 294 | test "void struct fields" { |
| 298 | 295 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 299 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 300 | 296 | |
| 301 | 297 | const foo = VoidStructFieldsFoo{ |
| 302 | 298 | .a = void{}, |
| ... | ... | @@ -760,7 +756,6 @@ test "packed struct with u0 field access" { |
| 760 | 756 | } |
| 761 | 757 | |
| 762 | 758 | test "access to global struct fields" { |
| 763 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 764 | 759 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 765 | 760 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 766 | 761 | |
| ... | ... | @@ -1259,7 +1254,6 @@ test "typed init through error unions and optionals" { |
| 1259 | 1254 | |
| 1260 | 1255 | test "initialize struct with empty literal" { |
| 1261 | 1256 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 1262 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 1263 | 1257 | |
| 1264 | 1258 | const S = struct { x: i32 = 1234 }; |
| 1265 | 1259 | var s: S = .{}; |
| ... | ... | @@ -1361,7 +1355,6 @@ test "store to comptime field" { |
| 1361 | 1355 | |
| 1362 | 1356 | test "struct field init value is size of the struct" { |
| 1363 | 1357 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 1364 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 1365 | 1358 | |
| 1366 | 1359 | const namespace = struct { |
| 1367 | 1360 | const S = extern struct { |
test/behavior/switch.zig-1| ... | ... | @@ -348,7 +348,6 @@ test "switch on const enum with var" { |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | test "anon enum literal used in switch on union enum" { |
| 351 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 352 | 351 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 353 | 352 | |
| 354 | 353 | const Foo = union(enum) { |
test/behavior/usingnamespace.zig-1| ... | ... | @@ -58,7 +58,6 @@ test "two files usingnamespace import each other" { |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | test { |
| 61 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 62 | 61 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 63 | 62 | |
| 64 | 63 | const AA = struct { |