summaryrefslogtreecommitdiff
path: root/testsuite/tests/asmgen/even-odd-spill.cmm
blob: 9e392445ce3998335632a6d9b6c301c6594185e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(* TEST
readonly_files = "main.c"
arguments = "-DINT_INT -DFUN=is_even main.c"
* asmgen
*)

("format_odd": string "odd %d\n\000")
("format_even": string "even %d\n\000")

(function "force_spill" (a:int) 0)

(function "is_even" (b:int)
  (catch (exit even b)
   with (odd v:val)
     (if (== v 0) 0
         (seq
           (extcall "printf_int" "format_odd" v unit)
           (let v2 (- v 1)
             (app "force_spill" 0 int)
             (exit even v2))))
   and (even v:val)
     (if (== v 0) 1
         (seq
           (extcall "printf_int" "format_even" v unit)
           (exit odd (- v 1))))))