authorgravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2022-02-08 12:56:50+01:00
committergravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2022-02-08 21:02:50+01:00
log6b0c950cb873f5fe65c0029140b91dfd8a7b1adb
tree290acd017849ae6dd1944f07cac267e055c59c08
parent37fea3e3ddc1f7d266d95789c3b1005291bcb96b
signaturelock-open Commit is signed but in an unrecognized format.

stage2 ARM: support all integer types in genTypedValue


7 files changed, 17 insertions(+), 22 deletions(-)

src/arch/arm/CodeGen.zig+17-7
......@@ -3180,7 +3180,6 @@ fn setRegOrMem(self: *Self, ty: Type, loc: MCValue, val: MCValue) !void {
31803180fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void {
31813181 switch (mcv) {
31823182 .dead => unreachable,
3183 .ptr_stack_offset => unreachable,
31843183 .ptr_embedded_in_code => unreachable,
31853184 .unreach, .none => return, // Nothing to do.
31863185 .undef => {
......@@ -3194,6 +3193,10 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
31943193 else => return self.fail("TODO implement memset", .{}),
31953194 }
31963195 },
3196 .ptr_stack_offset => {
3197 const reg = try self.copyToTmpRegister(ty, mcv);
3198 return self.genSetStack(ty, stack_offset, MCValue{ .register = reg });
3199 },
31973200 .compare_flags_unsigned,
31983201 .compare_flags_signed,
31993202 .immediate,
......@@ -3858,9 +3861,7 @@ fn lowerDeclRef(self: *Self, tv: TypedValue, decl: *Module.Decl) InnerError!MCVa
38583861 const got_addr = got.p_vaddr + decl.link.elf.offset_table_index * ptr_bytes;
38593862 return MCValue{ .memory = got_addr };
38603863 } else if (self.bin_file.cast(link.File.MachO)) |_| {
3861 // TODO I'm hacking my way through here by repurposing .memory for storing
3862 // index to the GOT target symbol index.
3863 return MCValue{ .memory = decl.link.macho.local_sym_index };
3864 unreachable; // unsupported architecture for MachO
38643865 } else if (self.bin_file.cast(link.File.Coff)) |coff_file| {
38653866 const got_addr = coff_file.offset_table_virtual_address + decl.link.coff.offset_table_index * ptr_bytes;
38663867 return MCValue{ .memory = got_addr };
......@@ -3929,10 +3930,19 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue {
39293930 },
39303931 .Int => {
39313932 const info = typed_value.ty.intInfo(self.target.*);
3932 if (info.bits > ptr_bits or info.signedness == .signed) {
3933 return self.fail("TODO const int bigger than ptr and signed int", .{});
3933 if (info.bits <= ptr_bits) {
3934 const unsigned = switch (info.signedness) {
3935 .signed => blk: {
3936 const signed = @intCast(i32, typed_value.val.toSignedInt());
3937 break :blk @bitCast(u32, signed);
3938 },
3939 .unsigned => @intCast(u32, typed_value.val.toUnsignedInt()),
3940 };
3941
3942 return MCValue{ .immediate = unsigned };
3943 } else {
3944 return self.lowerUnnamedConst(typed_value);
39343945 }
3935 return MCValue{ .immediate = @intCast(u32, typed_value.val.toUnsignedInt()) };
39363946 },
39373947 .Bool => {
39383948 return MCValue{ .immediate = @boolToInt(typed_value.val.toBool()) };
test/behavior/align.zig-2
......@@ -93,8 +93,6 @@ test "@ptrCast preserves alignment of bigger source" {
9393}
9494
9595test "alignstack" {
96 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
97
9896 try expect(fnWithAlignedStack() == 1234);
9997}
10098
test/behavior/bugs/1277.zig-1
......@@ -12,6 +12,5 @@ fn f() i32 {
1212}
1313
1414test "don't emit an LLVM global for a const function when it's in an optional in a struct" {
15 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1615 try std.testing.expect(s.f.?() == 1234);
1716}
test/behavior/bugs/1310.zig-1
......@@ -23,6 +23,5 @@ fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 {
2323}
2424
2525test "fixed" {
26 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
2726 try expect(agent_callback(undefined, undefined) == 11);
2827}
test/behavior/bugs/2006.zig-1
......@@ -7,7 +7,6 @@ const S = struct {
77};
88test "bug 2006" {
99 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
10 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1110 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1211 var a: S = undefined;
1312 a = S{ .p = undefined };
test/behavior/cast.zig-4
......@@ -35,8 +35,6 @@ fn peerTypeTAndOptionalT(c: bool, b: bool) ?usize {
3535}
3636
3737test "resolve undefined with integer" {
38 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
39
4038 try testResolveUndefWithInt(true, 1234);
4139 comptime try testResolveUndefWithInt(true, 1234);
4240}
......@@ -205,8 +203,6 @@ test "implicit cast from *[N]T to [*c]T" {
205203}
206204
207205test "*usize to *void" {
208 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
209
210206 var i = @as(usize, 0);
211207 var v = @ptrCast(*void, &i);
212208 v.* = {};
test/behavior/struct.zig-6
......@@ -114,8 +114,6 @@ test "struct byval assign" {
114114}
115115
116116test "call struct static method" {
117 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
118
119117 const result = StructWithNoFields.add(3, 4);
120118 try expect(result == 7);
121119}
......@@ -193,8 +191,6 @@ test "store member function in variable" {
193191}
194192
195193test "member functions" {
196 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
197
198194 const r = MemberFnRand{ .seed = 1234 };
199195 try expect(r.getSeed() == 1234);
200196}
......@@ -244,8 +240,6 @@ test "call method with mutable reference to struct with no fields" {
244240}
245241
246242test "usingnamespace within struct scope" {
247 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
248
249243 const S = struct {
250244 usingnamespace struct {
251245 pub fn inner() i32 {