mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 07:03:11 +00:00
stage2: implement integer pointer constants
This commit is contained in:
parent
b0dc61fae2
commit
b642fa24a6
@ -303,6 +303,20 @@ pub fn generateSymbol(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
.Pointer => switch (typed_value.val.tag()) {
|
.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 => {
|
.variable => {
|
||||||
const decl = typed_value.val.castTag(.variable).?.data.owner_decl;
|
const decl = typed_value.val.castTag(.variable).?.data.owner_decl;
|
||||||
return lowerDeclRef(bin_file, src_loc, typed_value, decl, code, debug_output, reloc_info);
|
return lowerDeclRef(bin_file, src_loc, typed_value, decl, code, debug_output, reloc_info);
|
||||||
|
|||||||
@ -719,7 +719,7 @@ test "string concatenation" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "thread local variable" {
|
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 {
|
const S = struct {
|
||||||
threadlocal var t: i32 = 1234;
|
threadlocal var t: i32 = 1234;
|
||||||
|
|||||||
@ -14,10 +14,7 @@ threadlocal var g_uart0 = nrfx_uart_t{
|
|||||||
};
|
};
|
||||||
|
|
||||||
test "reference a global threadlocal variable" {
|
test "reference a global threadlocal variable" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||||
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;
|
|
||||||
_ = nrfx_uart_rx(&g_uart0);
|
_ = nrfx_uart_rx(&g_uart0);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user