authorgravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2021-05-08 15:38:48+08:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-05-09 08:48:58+02:00
logf2a33688913cd36b1aee0b27a4a1de2cfb1cc04e
tree52ae14da99142a28722fb11f83efcfd57ca81a9d
parentd211dc37c800c1e0f235b1fe0a9c4fb376524b5a

stage2 ARM: Add spill registers test


1 files changed, 53 insertions(+), 0 deletions(-)

test/stage2/arm.zig+53
...@@ -458,4 +458,57 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -458,4 +458,57 @@ pub fn addCases(ctx: *TestContext) !void {
458 "",458 "",
459 );459 );
460 }460 }
461
462 {
463 var case = ctx.exe("spilling registers", linux_arm);
464 case.addCompareOutput(
465 \\export fn _start() noreturn {
466 \\ assert(add(3, 4) == 791);
467 \\ exit();
468 \\}
469 \\
470 \\fn add(a: u32, b: u32) u32 {
471 \\ const x: u32 = blk: {
472 \\ const c = a + b; // 7
473 \\ const d = a + c; // 10
474 \\ const e = d + b; // 14
475 \\ const f = d + e; // 24
476 \\ const g = e + f; // 38
477 \\ const h = f + g; // 62
478 \\ const i = g + h; // 100
479 \\ const j = i + d; // 110
480 \\ const k = i + j; // 210
481 \\ const l = k + c; // 217
482 \\ const m = l + d; // 227
483 \\ const n = m + e; // 241
484 \\ const o = n + f; // 265
485 \\ const p = o + g; // 303
486 \\ const q = p + h; // 365
487 \\ const r = q + i; // 465
488 \\ const s = r + j; // 575
489 \\ const t = s + k; // 785
490 \\ break :blk t;
491 \\ };
492 \\ const y = x + a; // 788
493 \\ const z = y + a; // 791
494 \\ return z;
495 \\}
496 \\
497 \\fn assert(ok: bool) void {
498 \\ if (!ok) unreachable;
499 \\}
500 \\
501 \\fn exit() noreturn {
502 \\ asm volatile ("svc #0"
503 \\ :
504 \\ : [number] "{r7}" (1),
505 \\ [arg1] "{r0}" (0)
506 \\ : "memory"
507 \\ );
508 \\ unreachable;
509 \\}
510 ,
511 "",
512 );
513 }
461}514}