| author | |
| committer | |
| log | c256603eaef162e7df004d3508bbd4f2ec3470eb |
| tree | 60fd2c37a73f090facfacb89e72e394be37d07ed |
| parent | 37fea3e3ddc1f7d266d95789c3b1005291bcb96b |
| parent | 8fe9d2f9867101fc8d6a91c6e10c6f3b644ce6a8 |
| signature |
stage2 ARM: genTypedValue for all integer types7 files changed, 27 insertions(+), 27 deletions(-)
src/arch/arm/CodeGen.zig+27-8| ... | @@ -1703,9 +1703,18 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -1703,9 +1703,18 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { |
| 1703 | const struct_field_offset = @intCast(u32, struct_ty.structFieldOffset(index, self.target.*)); | 1703 | const struct_field_offset = @intCast(u32, struct_ty.structFieldOffset(index, self.target.*)); |
| 1704 | const struct_field_ty = struct_ty.structFieldType(index); | 1704 | const struct_field_ty = struct_ty.structFieldType(index); |
| 1705 | const struct_field_size = @intCast(u32, struct_field_ty.abiSize(self.target.*)); | 1705 | const struct_field_size = @intCast(u32, struct_field_ty.abiSize(self.target.*)); |
| 1706 | const adjusted_field_offset = struct_size - struct_field_offset - struct_field_size; | ||
| 1707 | |||
| 1706 | switch (mcv) { | 1708 | switch (mcv) { |
| 1709 | .dead, .unreach => unreachable, | ||
| 1710 | .stack_argument_offset => |off| { | ||
| 1711 | break :result MCValue{ .stack_argument_offset = off + adjusted_field_offset }; | ||
| 1712 | }, | ||
| 1707 | .stack_offset => |off| { | 1713 | .stack_offset => |off| { |
| 1708 | break :result MCValue{ .stack_offset = off + struct_size - struct_field_offset - struct_field_size }; | 1714 | break :result MCValue{ .stack_offset = off + adjusted_field_offset }; |
| 1715 | }, | ||
| 1716 | .memory => |addr| { | ||
| 1717 | break :result MCValue{ .memory = addr + adjusted_field_offset }; | ||
| 1709 | }, | 1718 | }, |
| 1710 | else => return self.fail("TODO implement codegen struct_field_val for {}", .{mcv}), | 1719 | else => return self.fail("TODO implement codegen struct_field_val for {}", .{mcv}), |
| 1711 | } | 1720 | } |
| ... | @@ -3180,7 +3189,6 @@ fn setRegOrMem(self: *Self, ty: Type, loc: MCValue, val: MCValue) !void { | ... | @@ -3180,7 +3189,6 @@ fn setRegOrMem(self: *Self, ty: Type, loc: MCValue, val: MCValue) !void { |
| 3180 | fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void { | 3189 | fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerError!void { |
| 3181 | switch (mcv) { | 3190 | switch (mcv) { |
| 3182 | .dead => unreachable, | 3191 | .dead => unreachable, |
| 3183 | .ptr_stack_offset => unreachable, | ||
| 3184 | .ptr_embedded_in_code => unreachable, | 3192 | .ptr_embedded_in_code => unreachable, |
| 3185 | .unreach, .none => return, // Nothing to do. | 3193 | .unreach, .none => return, // Nothing to do. |
| 3186 | .undef => { | 3194 | .undef => { |
| ... | @@ -3194,6 +3202,10 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro | ... | @@ -3194,6 +3202,10 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro |
| 3194 | else => return self.fail("TODO implement memset", .{}), | 3202 | else => return self.fail("TODO implement memset", .{}), |
| 3195 | } | 3203 | } |
| 3196 | }, | 3204 | }, |
| 3205 | .ptr_stack_offset => { | ||
| 3206 | const reg = try self.copyToTmpRegister(ty, mcv); | ||
| 3207 | return self.genSetStack(ty, stack_offset, MCValue{ .register = reg }); | ||
| 3208 | }, | ||
| 3197 | .compare_flags_unsigned, | 3209 | .compare_flags_unsigned, |
| 3198 | .compare_flags_signed, | 3210 | .compare_flags_signed, |
| 3199 | .immediate, | 3211 | .immediate, |
| ... | @@ -3858,9 +3870,7 @@ fn lowerDeclRef(self: *Self, tv: TypedValue, decl: *Module.Decl) InnerError!MCVa | ... | @@ -3858,9 +3870,7 @@ fn lowerDeclRef(self: *Self, tv: TypedValue, decl: *Module.Decl) InnerError!MCVa |
| 3858 | const got_addr = got.p_vaddr + decl.link.elf.offset_table_index * ptr_bytes; | 3870 | const got_addr = got.p_vaddr + decl.link.elf.offset_table_index * ptr_bytes; |
| 3859 | return MCValue{ .memory = got_addr }; | 3871 | return MCValue{ .memory = got_addr }; |
| 3860 | } else if (self.bin_file.cast(link.File.MachO)) |_| { | 3872 | } else if (self.bin_file.cast(link.File.MachO)) |_| { |
| 3861 | // TODO I'm hacking my way through here by repurposing .memory for storing | 3873 | unreachable; // unsupported architecture for MachO |
| 3862 | // index to the GOT target symbol index. | ||
| 3863 | return MCValue{ .memory = decl.link.macho.local_sym_index }; | ||
| 3864 | } else if (self.bin_file.cast(link.File.Coff)) |coff_file| { | 3874 | } else if (self.bin_file.cast(link.File.Coff)) |coff_file| { |
| 3865 | const got_addr = coff_file.offset_table_virtual_address + decl.link.coff.offset_table_index * ptr_bytes; | 3875 | const got_addr = coff_file.offset_table_virtual_address + decl.link.coff.offset_table_index * ptr_bytes; |
| 3866 | return MCValue{ .memory = got_addr }; | 3876 | return MCValue{ .memory = got_addr }; |
| ... | @@ -3929,10 +3939,19 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue { | ... | @@ -3929,10 +3939,19 @@ fn genTypedValue(self: *Self, typed_value: TypedValue) InnerError!MCValue { |
| 3929 | }, | 3939 | }, |
| 3930 | .Int => { | 3940 | .Int => { |
| 3931 | const info = typed_value.ty.intInfo(self.target.*); | 3941 | const info = typed_value.ty.intInfo(self.target.*); |
| 3932 | if (info.bits > ptr_bits or info.signedness == .signed) { | 3942 | if (info.bits <= ptr_bits) { |
| 3933 | return self.fail("TODO const int bigger than ptr and signed int", .{}); | 3943 | const unsigned = switch (info.signedness) { |
| 3944 | .signed => blk: { | ||
| 3945 | const signed = @intCast(i32, typed_value.val.toSignedInt()); | ||
| 3946 | break :blk @bitCast(u32, signed); | ||
| 3947 | }, | ||
| 3948 | .unsigned => @intCast(u32, typed_value.val.toUnsignedInt()), | ||
| 3949 | }; | ||
| 3950 | |||
| 3951 | return MCValue{ .immediate = unsigned }; | ||
| 3952 | } else { | ||
| 3953 | return self.lowerUnnamedConst(typed_value); | ||
| 3934 | } | 3954 | } |
| 3935 | return MCValue{ .immediate = @intCast(u32, typed_value.val.toUnsignedInt()) }; | ||
| 3936 | }, | 3955 | }, |
| 3937 | .Bool => { | 3956 | .Bool => { |
| 3938 | return MCValue{ .immediate = @boolToInt(typed_value.val.toBool()) }; | 3957 | return MCValue{ .immediate = @boolToInt(typed_value.val.toBool()) }; |
test/behavior/align.zig-2| ... | @@ -93,8 +93,6 @@ test "@ptrCast preserves alignment of bigger source" { | ... | @@ -93,8 +93,6 @@ test "@ptrCast preserves alignment of bigger source" { |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | test "alignstack" { | 95 | test "alignstack" { |
| 96 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 97 | |||
| 98 | try expect(fnWithAlignedStack() == 1234); | 96 | try expect(fnWithAlignedStack() == 1234); |
| 99 | } | 97 | } |
| 100 | 98 |
test/behavior/bugs/1277.zig-1| ... | @@ -12,6 +12,5 @@ fn f() i32 { | ... | @@ -12,6 +12,5 @@ fn f() i32 { |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | test "don't emit an LLVM global for a const function when it's in an optional in a struct" { | 14 | test "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; | ||
| 16 | try std.testing.expect(s.f.?() == 1234); | 15 | try std.testing.expect(s.f.?() == 1234); |
| 17 | } | 16 | } |
test/behavior/bugs/1310.zig-1| ... | @@ -23,6 +23,5 @@ fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 { | ... | @@ -23,6 +23,5 @@ fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 { |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | test "fixed" { | 25 | test "fixed" { |
| 26 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 27 | try expect(agent_callback(undefined, undefined) == 11); | 26 | try expect(agent_callback(undefined, undefined) == 11); |
| 28 | } | 27 | } |
test/behavior/bugs/2006.zig-1| ... | @@ -7,7 +7,6 @@ const S = struct { | ... | @@ -7,7 +7,6 @@ const S = struct { |
| 7 | }; | 7 | }; |
| 8 | test "bug 2006" { | 8 | test "bug 2006" { |
| 9 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 9 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 10 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 11 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | 10 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 12 | var a: S = undefined; | 11 | var a: S = undefined; |
| 13 | a = S{ .p = undefined }; | 12 | a = S{ .p = undefined }; |
test/behavior/cast.zig-4| ... | @@ -35,8 +35,6 @@ fn peerTypeTAndOptionalT(c: bool, b: bool) ?usize { | ... | @@ -35,8 +35,6 @@ fn peerTypeTAndOptionalT(c: bool, b: bool) ?usize { |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | test "resolve undefined with integer" { | 37 | test "resolve undefined with integer" { |
| 38 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 39 | |||
| 40 | try testResolveUndefWithInt(true, 1234); | 38 | try testResolveUndefWithInt(true, 1234); |
| 41 | comptime try testResolveUndefWithInt(true, 1234); | 39 | comptime try testResolveUndefWithInt(true, 1234); |
| 42 | } | 40 | } |
| ... | @@ -205,8 +203,6 @@ test "implicit cast from *[N]T to [*c]T" { | ... | @@ -205,8 +203,6 @@ test "implicit cast from *[N]T to [*c]T" { |
| 205 | } | 203 | } |
| 206 | 204 | ||
| 207 | test "*usize to *void" { | 205 | test "*usize to *void" { |
| 208 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 209 | |||
| 210 | var i = @as(usize, 0); | 206 | var i = @as(usize, 0); |
| 211 | var v = @ptrCast(*void, &i); | 207 | var v = @ptrCast(*void, &i); |
| 212 | v.* = {}; | 208 | v.* = {}; |
test/behavior/struct.zig-10| ... | @@ -114,8 +114,6 @@ test "struct byval assign" { | ... | @@ -114,8 +114,6 @@ test "struct byval assign" { |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | test "call struct static method" { | 116 | test "call struct static method" { |
| 117 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 118 | |||
| 119 | const result = StructWithNoFields.add(3, 4); | 117 | const result = StructWithNoFields.add(3, 4); |
| 120 | try expect(result == 7); | 118 | try expect(result == 7); |
| 121 | } | 119 | } |
| ... | @@ -176,16 +174,12 @@ const MemberFnTestFoo = struct { | ... | @@ -176,16 +174,12 @@ const MemberFnTestFoo = struct { |
| 176 | }; | 174 | }; |
| 177 | 175 | ||
| 178 | test "call member function directly" { | 176 | test "call member function directly" { |
| 179 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 180 | |||
| 181 | const instance = MemberFnTestFoo{ .x = 1234 }; | 177 | const instance = MemberFnTestFoo{ .x = 1234 }; |
| 182 | const result = MemberFnTestFoo.member(instance); | 178 | const result = MemberFnTestFoo.member(instance); |
| 183 | try expect(result == 1234); | 179 | try expect(result == 1234); |
| 184 | } | 180 | } |
| 185 | 181 | ||
| 186 | test "store member function in variable" { | 182 | test "store member function in variable" { |
| 187 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 188 | |||
| 189 | const instance = MemberFnTestFoo{ .x = 1234 }; | 183 | const instance = MemberFnTestFoo{ .x = 1234 }; |
| 190 | const memberFn = MemberFnTestFoo.member; | 184 | const memberFn = MemberFnTestFoo.member; |
| 191 | const result = memberFn(instance); | 185 | const result = memberFn(instance); |
| ... | @@ -193,8 +187,6 @@ test "store member function in variable" { | ... | @@ -193,8 +187,6 @@ test "store member function in variable" { |
| 193 | } | 187 | } |
| 194 | 188 | ||
| 195 | test "member functions" { | 189 | test "member functions" { |
| 196 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 197 | |||
| 198 | const r = MemberFnRand{ .seed = 1234 }; | 190 | const r = MemberFnRand{ .seed = 1234 }; |
| 199 | try expect(r.getSeed() == 1234); | 191 | try expect(r.getSeed() == 1234); |
| 200 | } | 192 | } |
| ... | @@ -244,8 +236,6 @@ test "call method with mutable reference to struct with no fields" { | ... | @@ -244,8 +236,6 @@ test "call method with mutable reference to struct with no fields" { |
| 244 | } | 236 | } |
| 245 | 237 | ||
| 246 | test "usingnamespace within struct scope" { | 238 | test "usingnamespace within struct scope" { |
| 247 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 248 | |||
| 249 | const S = struct { | 239 | const S = struct { |
| 250 | usingnamespace struct { | 240 | usingnamespace struct { |
| 251 | pub fn inner() i32 { | 241 | pub fn inner() i32 { |