authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-07-08 18:25:21-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-07-09 14:20:36-04:00
log7b5d139fd30a7225f073125b8a53e51a2454d223
tree10d811434cc6515f17c759a9cefa9b7afcf66d5d
parent7b8a968f14a8405c209f35d8a0f904d6f722e713

plan9 codegen, add tests

They generate an object file, but do not execute yet, since we don't have something to execute them with.

2 files changed, 41 insertions(+), 0 deletions(-)

test/cases.zig+1
......@@ -20,6 +20,7 @@ pub fn addCases(ctx: *TestContext) !void {
2020 try @import("stage2/wasm.zig").addCases(ctx);
2121 try @import("stage2/darwin.zig").addCases(ctx);
2222 try @import("stage2/riscv64.zig").addCases(ctx);
23 try @import("stage2/plan9.zig").addCases(ctx);
2324
2425 {
2526 var case = ctx.exe("hello world with updates", linux_x64);
test/stage2/plan9.zig created+40
......@@ -0,0 +1,40 @@
1const std = @import("std");
2const TestContext = @import("../../src/test.zig").TestContext;
3
4pub fn addCases(ctx: *TestContext) !void {
5 const target: std.zig.CrossTarget = .{
6 .cpu_arch = .x86_64,
7 .os_tag = .plan9,
8 };
9 {
10 var case = ctx.exe("plan9: exiting correctly", target);
11 case.addCompareOutput("pub fn main() void {}", "");
12 }
13 {
14 var case = ctx.exe("plan9: hello world", target);
15 case.addCompareOutput(
16 \\pub fn main() void {
17 \\ const str = "Hello World!\n";
18 \\ asm volatile (
19 \\ \\push $0
20 \\ \\push %%r10
21 \\ \\push %%r11
22 \\ \\push $1
23 \\ \\push $0
24 \\ \\syscall
25 \\ \\pop %%r11
26 \\ \\pop %%r11
27 \\ \\pop %%r11
28 \\ \\pop %%r11
29 \\ \\pop %%r11
30 \\ :
31 \\ // pwrite
32 \\ : [syscall_number] "{rbp}" (51),
33 \\ [hey] "{r11}" (@ptrToInt(str)),
34 \\ [strlen] "{r10}" (str.len)
35 \\ : "rcx", "rbp", "r11", "memory"
36 \\ );
37 \\}
38 , "");
39 }
40}