aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNoam Preil <noam@pixelhero.dev>2020-08-09 19:44:16 -0400
committerAndrew Kelley <andrew@ziglang.org>2020-08-12 21:58:21 -0700
commitdbd1e42ef227bf55e9356b2d1a1cbde1fbec0e82 (patch)
treee9f750a333568308eeed154fe23de362752622ba /test
parent78fe86dcd23821b6a40bc5a0067513c452e50265 (diff)
downloadzig-dbd1e42ef227bf55e9356b2d1a1cbde1fbec0e82.tar.gz
zig-dbd1e42ef227bf55e9356b2d1a1cbde1fbec0e82.zip
CBE: Sorta working intcasts?
Diffstat (limited to 'test')
-rw-r--r--test/stage2/cbe.zig36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/stage2/cbe.zig b/test/stage2/cbe.zig
index 59bc062b74..4b35286f94 100644
--- a/test/stage2/cbe.zig
+++ b/test/stage2/cbe.zig
@@ -100,4 +100,40 @@ pub fn addCases(ctx: *TestContext) !void {
\\}
\\
);
+ ctx.c("exit with u8 parameter", linux_x64,
+ \\export fn _start() noreturn {
+ \\ exit(0);
+ \\}
+ \\
+ \\fn exit(code: u8) noreturn {
+ \\ asm volatile ("syscall"
+ \\ :
+ \\ : [number] "{rax}" (231),
+ \\ [arg1] "{rdi}" (code)
+ \\ );
+ \\ unreachable;
+ \\}
+ \\
+ ,
+ \\#include <stddef.h>
+ \\#include <stdint.h>
+ \\
+ \\zig_noreturn void exit(uint8_t arg0);
+ \\
+ \\const char *const exit__anon_0 = "{rax}";
+ \\const char *const exit__anon_1 = "{rdi}";
+ \\const char *const exit__anon_2 = "syscall";
+ \\
+ \\zig_noreturn void _start(void) {
+ \\ exit(0);
+ \\}
+ \\
+ \\zig_noreturn void exit(uint8_t arg0) {
+ \\ register size_t rax_constant __asm__("rax") = 231;
+ \\ register size_t rdi_constant __asm__("rdi") = (size_t)arg0;
+ \\ __asm volatile ("syscall" :: ""(rax_constant), ""(rdi_constant));
+ \\ zig_unreachable();
+ \\}
+ \\
+ );
}