diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-05-19 13:51:46 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-05-19 13:51:46 -0400 |
| commit | 8d3cca7fc2e7b34486cc56951bb0dadb75e498a0 (patch) | |
| tree | 089289335a3e6374c88ccb54c5879806132503a6 /test | |
| parent | 8d812dba30fe3c17e9d64607fdf813977eaf0496 (diff) | |
| download | zig-8d3cca7fc2e7b34486cc56951bb0dadb75e498a0.tar.gz zig-8d3cca7fc2e7b34486cc56951bb0dadb75e498a0.zip | |
stage2: function calls using the global offset table
so far they don't support parameters or return values
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage2/zir.zig | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/stage2/zir.zig b/test/stage2/zir.zig index afee3e7895..d06f38d0ad 100644 --- a/test/stage2/zir.zig +++ b/test/stage2/zir.zig @@ -209,4 +209,57 @@ pub fn addCases(ctx: *TestContext) void { \\ }, ); + + ctx.addZIRCompareOutput( + "function call with no args no return value", + &[_][]const u8{ + \\@noreturn = primitive(noreturn) + \\@void = primitive(void) + \\@usize = primitive(usize) + \\@0 = int(0) + \\@1 = int(1) + \\@2 = int(2) + \\@3 = int(3) + \\ + \\@syscall_array = str("syscall") + \\@sysoutreg_array = str("={rax}") + \\@rax_array = str("{rax}") + \\@rdi_array = str("{rdi}") + \\@rcx_array = str("rcx") + \\@r11_array = str("r11") + \\@memory_array = str("memory") + \\ + \\@exit0_fnty = fntype([], @noreturn) + \\@exit0 = fn(@exit0_fnty, { + \\ %SYS_exit_group = int(231) + \\ %exit_code = as(@usize, @0) + \\ + \\ %syscall = ref(@syscall_array) + \\ %sysoutreg = ref(@sysoutreg_array) + \\ %rax = ref(@rax_array) + \\ %rdi = ref(@rdi_array) + \\ %rcx = ref(@rcx_array) + \\ %r11 = ref(@r11_array) + \\ %memory = ref(@memory_array) + \\ + \\ %rc = asm(%syscall, @usize, + \\ volatile=1, + \\ output=%sysoutreg, + \\ inputs=[%rax, %rdi], + \\ clobbers=[%rcx, %r11, %memory], + \\ args=[%SYS_exit_group, %exit_code]) + \\ + \\ %99 = unreachable() + \\}); + \\ + \\@start_fnty = fntype([], @noreturn, cc=Naked) + \\@start = fn(@start_fnty, { + \\ %0 = call(@exit0, []) + \\}) + \\@9 = str("_start") + \\@10 = ref(@9) + \\@11 = export(@10, @start) + }, + &[_][]const u8{""}, + ); } |
