authorgravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2020-08-23 23:10:19+02:00
committergravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2020-08-23 23:13:41+02:00
log4f2618e75bfbaaea755c7fec14f5ae844eb3d0f8
tree21e958ed9c4d9fb2be60e052d4df6ef63ca7b7ec
parentb2254023e464027abfcbff809e991ff22cf581e0

stage2: Add Hello World test for ARM backend


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

src-self-hosted/codegen.zig+1-1
...@@ -1277,7 +1277,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -1277,7 +1277,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
1277 mem.writeIntBig(u32, try self.code.addManyAsArray(4), Instruction.bkpt(0).toU32());1277 mem.writeIntBig(u32, try self.code.addManyAsArray(4), Instruction.bkpt(0).toU32());
1278 },1278 },
1279 else => return self.fail(src, "TODO implement @breakpoint() for {}", .{self.target.cpu.arch}),1279 else => return self.fail(src, "TODO implement @breakpoint() for {}", .{self.target.cpu.arch}),
1280 }1280 }
1281 return .none;1281 return .none;
1282 }1282 }
12831283
test/stage2/test.zig+40
...@@ -18,6 +18,11 @@ const linux_riscv64 = std.zig.CrossTarget{...@@ -18,6 +18,11 @@ const linux_riscv64 = std.zig.CrossTarget{
18 .os_tag = .linux,18 .os_tag = .linux,
19};19};
2020
21const linux_arm = std.zig.CrossTarget{
22 .cpu_arch = .arm,
23 .os_tag = .linux,
24};
25
21const wasi = std.zig.CrossTarget{26const wasi = std.zig.CrossTarget{
22 .cpu_arch = .wasm32,27 .cpu_arch = .wasm32,
23 .os_tag = .wasi,28 .os_tag = .wasi,
...@@ -181,6 +186,41 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -181,6 +186,41 @@ pub fn addCases(ctx: *TestContext) !void {
181 );186 );
182 }187 }
183188
189 {
190 var case = ctx.exe("hello world", linux_arm);
191 // Regular old hello world
192 case.addCompareOutput(
193 \\export fn _start() noreturn {
194 \\ print();
195 \\ exit();
196 \\}
197 \\
198 \\fn print() void {
199 \\ asm volatile ("svc #0"
200 \\ :
201 \\ : [number] "{r7}" (4),
202 \\ [arg1] "{r0}" (1),
203 \\ [arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
204 \\ [arg3] "{r2}" (14)
205 \\ : "memory"
206 \\ );
207 \\ return;
208 \\}
209 \\
210 \\fn exit() noreturn {
211 \\ asm volatile ("svc #0"
212 \\ :
213 \\ : [number] "{r7}" (1),
214 \\ [arg1] "{r0}" (0)
215 \\ : "memory"
216 \\ );
217 \\ unreachable;
218 \\}
219 ,
220 "Hello, World!\n",
221 );
222 }
223
184 {224 {
185 var case = ctx.exe("adding numbers at comptime", linux_x64);225 var case = ctx.exe("adding numbers at comptime", linux_x64);
186 case.addCompareOutput(226 case.addCompareOutput(