authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-07 19:37:05-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-08-07 19:37:05-07:00
log396eb730e5133c150134bb675ee43d5323e2bb6d
treebbaf10846313527b723e390aa7c72ebc9530a1ad
parentae16c1d0835b517cb858cb9615888cdab1e351c5
parentec7f7131473a5648703c48422b449c12ed4524aa
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #12228 from nektro/stage2-arch

remove 'builtin.stage2_arch', Sema is smart enough now

9 files changed, 5 insertions(+), 92 deletions(-)

lib/std/os/plan9.zig+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1const std = @import("../std.zig");1const std = @import("../std.zig");
2const builtin = @import("builtin");2const builtin = @import("builtin");
33
4pub const syscall_bits = switch (builtin.stage2_arch) {4pub const syscall_bits = switch (builtin.cpu.arch) {
5 .x86_64 => @import("plan9/x86_64.zig"),5 .x86_64 => @import("plan9/x86_64.zig"),
6 else => @compileError("more plan9 syscall implementations (needs more inline asm in stage2"),6 else => @compileError("more plan9 syscall implementations (needs more inline asm in stage2"),
7};7};
lib/std/start.zig+2-2
...@@ -131,7 +131,7 @@ fn wWinMainCRTStartup2() callconv(.C) noreturn {...@@ -131,7 +131,7 @@ fn wWinMainCRTStartup2() callconv(.C) noreturn {
131131
132fn exit2(code: usize) noreturn {132fn exit2(code: usize) noreturn {
133 switch (native_os) {133 switch (native_os) {
134 .linux => switch (builtin.stage2_arch) {134 .linux => switch (builtin.cpu.arch) {
135 .x86_64 => {135 .x86_64 => {
136 asm volatile ("syscall"136 asm volatile ("syscall"
137 :137 :
...@@ -175,7 +175,7 @@ fn exit2(code: usize) noreturn {...@@ -175,7 +175,7 @@ fn exit2(code: usize) noreturn {
175 else => @compileError("TODO"),175 else => @compileError("TODO"),
176 },176 },
177 // exits(0)177 // exits(0)
178 .plan9 => switch (builtin.stage2_arch) {178 .plan9 => switch (builtin.cpu.arch) {
179 .x86_64 => {179 .x86_64 => {
180 asm volatile (180 asm volatile (
181 \\push $0181 \\push $0
src/Compilation.zig-3
...@@ -4763,8 +4763,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca...@@ -4763,8 +4763,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
4763 \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.4763 \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
4764 \\pub const zig_version = std.SemanticVersion.parse("{s}") catch unreachable;4764 \\pub const zig_version = std.SemanticVersion.parse("{s}") catch unreachable;
4765 \\pub const zig_backend = std.builtin.CompilerBackend.{};4765 \\pub const zig_backend = std.builtin.CompilerBackend.{};
4766 \\/// Temporary until self-hosted supports the `cpu.arch` value.
4767 \\pub const stage2_arch: std.Target.Cpu.Arch = .{};
4768 \\4766 \\
4769 \\pub const output_mode = std.builtin.OutputMode.{};4767 \\pub const output_mode = std.builtin.OutputMode.{};
4770 \\pub const link_mode = std.builtin.LinkMode.{};4768 \\pub const link_mode = std.builtin.LinkMode.{};
...@@ -4779,7 +4777,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca...@@ -4779,7 +4777,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
4779 , .{4777 , .{
4780 build_options.version,4778 build_options.version,
4781 std.zig.fmtId(@tagName(zig_backend)),4779 std.zig.fmtId(@tagName(zig_backend)),
4782 std.zig.fmtId(@tagName(target.cpu.arch)),
4783 std.zig.fmtId(@tagName(comp.bin_file.options.output_mode)),4780 std.zig.fmtId(@tagName(comp.bin_file.options.output_mode)),
4784 std.zig.fmtId(@tagName(comp.bin_file.options.link_mode)),4781 std.zig.fmtId(@tagName(comp.bin_file.options.link_mode)),
4785 comp.bin_file.options.is_test,4782 comp.bin_file.options.is_test,
src/stage1/codegen.cpp-1
...@@ -10076,7 +10076,6 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {...@@ -10076,7 +10076,6 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
10076 buf_appendf(contents, "pub const single_threaded = %s;\n", bool_to_str(g->is_single_threaded));10076 buf_appendf(contents, "pub const single_threaded = %s;\n", bool_to_str(g->is_single_threaded));
10077 buf_appendf(contents, "pub const abi = std.Target.Abi.%s;\n", cur_abi);10077 buf_appendf(contents, "pub const abi = std.Target.Abi.%s;\n", cur_abi);
10078 buf_appendf(contents, "pub const cpu = std.Target.Cpu.baseline(.%s);\n", cur_arch);10078 buf_appendf(contents, "pub const cpu = std.Target.Cpu.baseline(.%s);\n", cur_arch);
10079 buf_appendf(contents, "pub const stage2_arch: std.Target.Cpu.Arch = .%s;\n", cur_arch);
10080 buf_appendf(contents, "pub const os = std.Target.Os.Tag.defaultVersionRange(.%s, .%s);\n", cur_os, cur_arch);10079 buf_appendf(contents, "pub const os = std.Target.Os.Tag.defaultVersionRange(.%s, .%s);\n", cur_os, cur_arch);
10081 buf_appendf(contents,10080 buf_appendf(contents,
10082 "pub const target = std.Target{\n"10081 "pub const target = std.Target{\n"
test/behavior.zig+1-1
...@@ -159,7 +159,7 @@ test {...@@ -159,7 +159,7 @@ test {
159 _ = @import("behavior/while.zig");159 _ = @import("behavior/while.zig");
160 _ = @import("behavior/widening.zig");160 _ = @import("behavior/widening.zig");
161161
162 if (builtin.stage2_arch == .wasm32) {162 if (builtin.cpu.arch == .wasm32) {
163 _ = @import("behavior/wasm.zig");163 _ = @import("behavior/wasm.zig");
164 }164 }
165165
test/behavior/struct.zig+1-1
...@@ -963,7 +963,7 @@ test "tuple assigned to variable" {...@@ -963,7 +963,7 @@ test "tuple assigned to variable" {
963963
964test "comptime struct field" {964test "comptime struct field" {
965 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO965 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
966 if (builtin.stage2_arch == .arm) return error.SkipZigTest; // TODO966 if (builtin.cpu.arch == .arm) return error.SkipZigTest; // TODO
967967
968 const T = struct {968 const T = struct {
969 a: i32,969 a: i32,
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig deleted-35
...@@ -1,35 +0,0 @@
1const Tag = @Type(.{
2 .Enum = .{
3 .layout = .Auto,
4 .tag_type = u1,
5 .fields = &.{
6 .{ .name = "signed", .value = 0 },
7 .{ .name = "unsigned", .value = 1 },
8 },
9 .decls = &.{},
10 .is_exhaustive = true,
11 },
12});
13const Tagged = @Type(.{
14 .Union = .{
15 .layout = .Auto,
16 .tag_type = Tag,
17 .fields = &.{
18 .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) },
19 .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) },
20 .{ .name = "arst", .field_type = f32, .alignment = @alignOf(f32) },
21 },
22 .decls = &.{},
23 },
24});
25export fn entry() void {
26 var tagged = Tagged{ .signed = -1 };
27 tagged = .{ .unsigned = 1 };
28}
29
30// error
31// backend=stage2
32// target=native
33//
34// :13:16: error: no field named 'arst' in enum 'tmp.Tag__enum_266'
35// :1:13: note: enum declared here
test/cases/riscv64-linux/hello_world_with_updates.0.zig deleted-21
...@@ -1,21 +0,0 @@
1pub fn main() void {
2 print();
3}
4
5fn print() void {
6 asm volatile ("ecall"
7 :
8 : [number] "{a7}" (64),
9 [arg1] "{a0}" (1),
10 [arg2] "{a1}" (@ptrToInt("Hello, World!\n")),
11 [arg3] "{a2}" ("Hello, World!\n".len),
12 : "rcx", "r11", "memory"
13 );
14 return;
15}
16
17// run
18// target=riscv64-linux
19//
20// Hello, World!
21//
test/cases/riscv64-linux/hello_world_with_updates.1.zig deleted-27
...@@ -1,27 +0,0 @@
1pub fn main() void {
2 print();
3 print();
4 print();
5 print();
6}
7
8fn print() void {
9 asm volatile ("ecall"
10 :
11 : [number] "{a7}" (64),
12 [arg1] "{a0}" (1),
13 [arg2] "{a1}" (@ptrToInt("Hello, World!\n")),
14 [arg3] "{a2}" ("Hello, World!\n".len),
15 : "rcx", "r11", "memory"
16 );
17 return;
18}
19
20// run
21// target=riscv64-linux
22//
23// Hello, World!
24// Hello, World!
25// Hello, World!
26// Hello, World!
27//