tagged release 0.6.4
[parrot.git] / t / compilers / imcc / reg / alloc.t
blob77b3ace71a75d8670c6da461600c1eae157be706
1 #!perl
2 # Copyright (C) 2005-2007, The Perl Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use lib qw( . lib ../lib ../../lib );
8 use Parrot::Test tests => 11;
10 pir_output_is( <<'CODE', <<'OUT', "alligator" );
11 # if the side-effect of set_addr/continuation isn't
12 # detected this program prints "Hi\nalligator\n"
14 .sub main :main
15     $P0 = new 'String'
16     $P0 = "Hi\n"
17     $I0 = 2
18 lab:
19     print $P0
20     dec $I0
21     unless $I0 goto ex
22     new $P1, 'Continuation'
23     set_addr $P1, lab
24     $P2 = find_name "alligator"
25     set_args "0", $P1
26     invokecc $P2
27 ex:
28 .end
29 .sub alligator
30     get_params "0", $P0
31     invokecc $P0
32 .end
33 CODE
36 OUT
38 pir_output_is( <<'CODE', <<'OUT', "alligator 2 - r9629" );
39 .sub xyz
40     .local pmc args
41     args = new 'ResizablePMCArray'
42     push args, "abc"
43     push args, "def"
44     push args, "POPME"
46     $S0 = args[-1]
47     if $S0 != "POPME" goto start
48     $P0 = pop args
49   start:
50     $I1 = elements args
51     $I0 = 0
52   loop:
53     if $I0 >= $I1 goto end
54     $S0 = args[$I0]
55     print $S0
56     print "\n"
57     inc $I0
58     goto loop
59   end:
60 .end
61 CODE
62 abc
63 def
64 OUT
66 pir_2_pasm_is( <<'CODE', <<'OUT', ":unique_reg" );
67 .sub main
68     .param int i :unique_reg
69     .local int j :unique_reg
70     .local int k :unique_reg
71     i = 5
72     j = 2
73     k = j * 2
74 .end
75 CODE
76 # IMCC does produce b0rken PASM files
77 # see http://guest@rt.perl.org/rt3/Ticket/Display.html?id=32392
78 main:
79         get_params
80         set I0, 5
81         set I1, 2
82         mul I2, I1, 2
83         set_returns
84         returncc
85 OUT
87 pir_output_is( <<'CODE', <<'OUT', "Explicit large register: S, PIR" );
88 .sub main
89   S32 = "ok\n"
90   print S32
91 .end
92 CODE
94 OUT
96 pir_output_is( <<'CODE', <<'OUT', "Explicit large register: N, PIR" );
97 .sub main
98   N32 = 3.8
99   print N32
100   print "\n"
101 .end
102 CODE
103 3.800000
106 pir_output_is( <<'CODE', <<'OUT', "Explicit large register: I, PIR" );
107 .sub main
108   I32 = 123
109   print I32
110   print "\n"
111 .end
112 CODE
116 pir_output_is( <<'CODE', <<'OUT', "Explicit large register: P, PIR" );
117 .sub main
118   P32 = new 'String'
119   P32 = "ok\n"
120   print P32
121 .end
122 CODE
126 pasm_output_is( <<'CODE', <<'OUT', "Explicit large register: S, PASM" );
127   set S32, "ok\n"
128   print S32
129   end
130 CODE
134 pasm_output_is( <<'CODE', <<'OUT', "Explicit large register: N, PASM" );
135   set N32, 3.8
136   print N32
137   print "\n"
138   end
139 CODE
140 3.800000
143 pasm_output_is( <<'CODE', <<'OUT', "Explicit large register: I, PASM" );
144   set I32, 123
145   print I32
146   print "\n"
147   end
148 CODE
152 pasm_output_is( <<'CODE', <<'OUT', "Explicit large register: P, PASM" );
153   new P32, 'String'
154   set P32, "ok\n"
155   print P32
156   end
157 CODE
161 # Local Variables:
162 #   mode: cperl
163 #   cperl-indent-level: 4
164 #   fill-column: 100
165 # End:
166 # vim: expandtab shiftwidth=4: