diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-01-03 16:09:14 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-03 16:09:14 -0800 |
| commit | f6644255f595fb0bbfb2fa4276804ef7031330b1 (patch) | |
| tree | 2b43d96fec97caec177fb0851b63d5fa2729efa3 /test | |
| parent | 5cc131030c01e178453b12f235823124aa6a2d12 (diff) | |
| parent | 0151f3b76ad9dca6c73d44876c263d5e27d92ab3 (diff) | |
| download | zig-f6644255f595fb0bbfb2fa4276804ef7031330b1.tar.gz zig-f6644255f595fb0bbfb2fa4276804ef7031330b1.zip | |
Merge pull request #7598 from FireFox317/more-llvm-stage2
stage2: More improvements to self-hosted LLVM backend
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage2/llvm_backend.zig | 30 | ||||
| -rw-r--r-- | test/stage2/test.zig | 1 |
2 files changed, 31 insertions, 0 deletions
diff --git a/test/stage2/llvm_backend.zig b/test/stage2/llvm_backend.zig new file mode 100644 index 0000000000..1b753621ea --- /dev/null +++ b/test/stage2/llvm_backend.zig @@ -0,0 +1,30 @@ +const std = @import("std"); +const TestContext = @import("../../src/test.zig").TestContext; +const build_options = @import("build_options"); + +// These tests should work with all platforms, but we're using linux_x64 for +// now for consistency. Will be expanded eventually. +const linux_x64 = std.zig.CrossTarget{ + .cpu_arch = .x86_64, + .os_tag = .linux, +}; + +pub fn addCases(ctx: *TestContext) !void { + { + var case = ctx.exeUsingLlvmBackend("simple addition and subtraction", linux_x64); + + case.addCompareOutput( + \\fn add(a: i32, b: i32) i32 { + \\ return a + b; + \\} + \\ + \\export fn main() c_int { + \\ var a: i32 = -5; + \\ const x = add(a, 7); + \\ var y = add(2, 0); + \\ y -= x; + \\ return y; + \\} + , ""); + } +} diff --git a/test/stage2/test.zig b/test/stage2/test.zig index 9a74e9ee09..6e25dc283b 100644 --- a/test/stage2/test.zig +++ b/test/stage2/test.zig @@ -31,6 +31,7 @@ pub fn addCases(ctx: *TestContext) !void { try @import("spu-ii.zig").addCases(ctx); try @import("arm.zig").addCases(ctx); try @import("aarch64.zig").addCases(ctx); + try @import("llvm_backend.zig").addCases(ctx); { var case = ctx.exe("hello world with updates", linux_x64); |
