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 {
12771277 mem.writeIntBig(u32, try self.code.addManyAsArray(4), Instruction.bkpt(0).toU32());
12781278 },
12791279 else => return self.fail(src, "TODO implement @breakpoint() for {}", .{self.target.cpu.arch}),
1280 }
1280 }
12811281 return .none;
12821282 }
12831283
test/stage2/test.zig+40
......@@ -18,6 +18,11 @@ const linux_riscv64 = std.zig.CrossTarget{
1818 .os_tag = .linux,
1919};
2020
21const linux_arm = std.zig.CrossTarget{
22 .cpu_arch = .arm,
23 .os_tag = .linux,
24};
25
2126const wasi = std.zig.CrossTarget{
2227 .cpu_arch = .wasm32,
2328 .os_tag = .wasi,
......@@ -181,6 +186,41 @@ pub fn addCases(ctx: *TestContext) !void {
181186 );
182187 }
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
184224 {
185225 var case = ctx.exe("adding numbers at comptime", linux_x64);
186226 case.addCompareOutput(