stage2: implement integer pointer constants

This commit is contained in:
Andrew Kelley 2022-03-10 15:32:10 -07:00
parent b0dc61fae2
commit b642fa24a6
3 changed files with 17 additions and 6 deletions

View File

@ -303,6 +303,20 @@ pub fn generateSymbol(
},
},
.Pointer => switch (typed_value.val.tag()) {
.zero, .one, .int_u64, .int_big_positive => {
switch (target.cpu.arch.ptrBitWidth()) {
32 => {
const x = typed_value.val.toUnsignedInt();
mem.writeInt(u32, try code.addManyAsArray(4), @intCast(u32, x), endian);
},
64 => {
const x = typed_value.val.toUnsignedInt();
mem.writeInt(u64, try code.addManyAsArray(8), x, endian);
},
else => unreachable,
}
return Result{ .appended = {} };
},
.variable => {
const decl = typed_value.val.castTag(.variable).?.data.owner_decl;
return lowerDeclRef(bin_file, src_loc, typed_value, decl, code, debug_output, reloc_info);

View File

@ -719,7 +719,7 @@ test "string concatenation" {
}
test "thread local variable" {
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
const S = struct {
threadlocal var t: i32 = 1234;

View File

@ -14,10 +14,7 @@ threadlocal var g_uart0 = nrfx_uart_t{
};
test "reference a global threadlocal variable" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
_ = nrfx_uart_rx(&g_uart0);
}