mirror of
https://github.com/ziglang/zig.git
synced 2026-02-04 13:43:46 +00:00
Merge pull request #12228 from nektro/stage2-arch
remove 'builtin.stage2_arch', Sema is smart enough now
This commit is contained in:
commit
396eb730e5
@ -1,7 +1,7 @@
|
||||
const std = @import("../std.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub const syscall_bits = switch (builtin.stage2_arch) {
|
||||
pub const syscall_bits = switch (builtin.cpu.arch) {
|
||||
.x86_64 => @import("plan9/x86_64.zig"),
|
||||
else => @compileError("more plan9 syscall implementations (needs more inline asm in stage2"),
|
||||
};
|
||||
|
||||
@ -131,7 +131,7 @@ fn wWinMainCRTStartup2() callconv(.C) noreturn {
|
||||
|
||||
fn exit2(code: usize) noreturn {
|
||||
switch (native_os) {
|
||||
.linux => switch (builtin.stage2_arch) {
|
||||
.linux => switch (builtin.cpu.arch) {
|
||||
.x86_64 => {
|
||||
asm volatile ("syscall"
|
||||
:
|
||||
@ -175,7 +175,7 @@ fn exit2(code: usize) noreturn {
|
||||
else => @compileError("TODO"),
|
||||
},
|
||||
// exits(0)
|
||||
.plan9 => switch (builtin.stage2_arch) {
|
||||
.plan9 => switch (builtin.cpu.arch) {
|
||||
.x86_64 => {
|
||||
asm volatile (
|
||||
\\push $0
|
||||
|
||||
@ -4763,8 +4763,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
|
||||
\\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
|
||||
\\pub const zig_version = std.SemanticVersion.parse("{s}") catch unreachable;
|
||||
\\pub const zig_backend = std.builtin.CompilerBackend.{};
|
||||
\\/// Temporary until self-hosted supports the `cpu.arch` value.
|
||||
\\pub const stage2_arch: std.Target.Cpu.Arch = .{};
|
||||
\\
|
||||
\\pub const output_mode = std.builtin.OutputMode.{};
|
||||
\\pub const link_mode = std.builtin.LinkMode.{};
|
||||
@ -4779,7 +4777,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
|
||||
, .{
|
||||
build_options.version,
|
||||
std.zig.fmtId(@tagName(zig_backend)),
|
||||
std.zig.fmtId(@tagName(target.cpu.arch)),
|
||||
std.zig.fmtId(@tagName(comp.bin_file.options.output_mode)),
|
||||
std.zig.fmtId(@tagName(comp.bin_file.options.link_mode)),
|
||||
comp.bin_file.options.is_test,
|
||||
|
||||
@ -10076,7 +10076,6 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
|
||||
buf_appendf(contents, "pub const single_threaded = %s;\n", bool_to_str(g->is_single_threaded));
|
||||
buf_appendf(contents, "pub const abi = std.Target.Abi.%s;\n", cur_abi);
|
||||
buf_appendf(contents, "pub const cpu = std.Target.Cpu.baseline(.%s);\n", cur_arch);
|
||||
buf_appendf(contents, "pub const stage2_arch: std.Target.Cpu.Arch = .%s;\n", cur_arch);
|
||||
buf_appendf(contents, "pub const os = std.Target.Os.Tag.defaultVersionRange(.%s, .%s);\n", cur_os, cur_arch);
|
||||
buf_appendf(contents,
|
||||
"pub const target = std.Target{\n"
|
||||
|
||||
@ -159,7 +159,7 @@ test {
|
||||
_ = @import("behavior/while.zig");
|
||||
_ = @import("behavior/widening.zig");
|
||||
|
||||
if (builtin.stage2_arch == .wasm32) {
|
||||
if (builtin.cpu.arch == .wasm32) {
|
||||
_ = @import("behavior/wasm.zig");
|
||||
}
|
||||
|
||||
|
||||
@ -963,7 +963,7 @@ test "tuple assigned to variable" {
|
||||
|
||||
test "comptime struct field" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.stage2_arch == .arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.cpu.arch == .arm) return error.SkipZigTest; // TODO
|
||||
|
||||
const T = struct {
|
||||
a: i32,
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
const Tag = @Type(.{
|
||||
.Enum = .{
|
||||
.layout = .Auto,
|
||||
.tag_type = u1,
|
||||
.fields = &.{
|
||||
.{ .name = "signed", .value = 0 },
|
||||
.{ .name = "unsigned", .value = 1 },
|
||||
},
|
||||
.decls = &.{},
|
||||
.is_exhaustive = true,
|
||||
},
|
||||
});
|
||||
const Tagged = @Type(.{
|
||||
.Union = .{
|
||||
.layout = .Auto,
|
||||
.tag_type = Tag,
|
||||
.fields = &.{
|
||||
.{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) },
|
||||
.{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) },
|
||||
.{ .name = "arst", .field_type = f32, .alignment = @alignOf(f32) },
|
||||
},
|
||||
.decls = &.{},
|
||||
},
|
||||
});
|
||||
export fn entry() void {
|
||||
var tagged = Tagged{ .signed = -1 };
|
||||
tagged = .{ .unsigned = 1 };
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :13:16: error: no field named 'arst' in enum 'tmp.Tag__enum_266'
|
||||
// :1:13: note: enum declared here
|
||||
@ -1,21 +0,0 @@
|
||||
pub fn main() void {
|
||||
print();
|
||||
}
|
||||
|
||||
fn print() void {
|
||||
asm volatile ("ecall"
|
||||
:
|
||||
: [number] "{a7}" (64),
|
||||
[arg1] "{a0}" (1),
|
||||
[arg2] "{a1}" (@ptrToInt("Hello, World!\n")),
|
||||
[arg3] "{a2}" ("Hello, World!\n".len),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// run
|
||||
// target=riscv64-linux
|
||||
//
|
||||
// Hello, World!
|
||||
//
|
||||
@ -1,27 +0,0 @@
|
||||
pub fn main() void {
|
||||
print();
|
||||
print();
|
||||
print();
|
||||
print();
|
||||
}
|
||||
|
||||
fn print() void {
|
||||
asm volatile ("ecall"
|
||||
:
|
||||
: [number] "{a7}" (64),
|
||||
[arg1] "{a0}" (1),
|
||||
[arg2] "{a1}" (@ptrToInt("Hello, World!\n")),
|
||||
[arg3] "{a2}" ("Hello, World!\n".len),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// run
|
||||
// target=riscv64-linux
|
||||
//
|
||||
// Hello, World!
|
||||
// Hello, World!
|
||||
// Hello, World!
|
||||
// Hello, World!
|
||||
//
|
||||
Loading…
x
Reference in New Issue
Block a user