-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patharriter.pir
143 lines (126 loc) · 3.14 KB
/
arriter.pir
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Copyright (C) 2001-2008, Parrot Foundation.
=head1 NAME
examples/benchmarks/arriter.pir - Iterator Benchmark
=head1 SYNOPSIS
% time ./parrot examples/benchmarks/arriter.pir
=head1 DESCRIPTION
Hand crafted PIR code version of F<examples/benchmarks/arriter.pl> as
it might come out of a compiler.
=head1 SEE ALSO
F<examples/benchmarks/arriter.pl>,
F<examples/benchmarks/arriter_o1.pir>.
=cut
.sub arriter :main
# declaration of lexicals
$P20 = new 'Hash'
.lex "%ha", $P20
$P21 = new 'Undef'
.lex "$i", $P21
$P22 = new 'ResizablePMCArray'
.lex "@k", $P22
$P23 = new 'ResizablePMCArray'
.lex "@nk", $P23
$P24 = new 'Undef'
.lex "$s", $P24
# same as @k = qw( A B C D E F G H I J );
find_lex $P29 , "$i"
$P29 = 0
for_1_start:
unless $P29 < 10 goto for_1_end
$P26 = new 'Undef'
$P26 = 65
$P27 = new 'Undef'
$P27 = add $P26, $P29
$I0 = $P27
$S0 = chr $I0
find_lex $P28 , "$s"
$P28 = new 'Undef'
$P28 = $S0
push $P22, $P28
inc $P29
branch for_1_start
for_1_end:
# set up all 5 element permutations of qw( A B C D E F G H I J )
$P29 = new 'Undef'
.lex "e", $P29
$P29 = 0
for_2_start:
unless $P29 <= 3 goto for_2_end
find_lex $P30 , "$i"
$P30 = 0
for_3_start:
unless $P30 < 10 goto for_3_end
find_lex $P31 , "@k"
$P32 = iter $P31
iter_1_start:
unless $P32 goto iter_1_end
$P33 = new 'Undef'
$P33 = 65
$P34 = new 'Undef'
add $P34, $P33, $P30 # 65 + $i
$I0 = $P34
$S0 = chr $I0
$P35 = new 'Undef'
$P35 = $S0
shift $P36, $P32 # $s
# $P37 goes into the aggregate and can not be
# pulled out of loop
$P37 = new 'Undef'
concat $P37, $P36, $P35
$P38 = find_lex "@nk"
push $P38, $P37
branch iter_1_start
iter_1_end:
inc $P30
branch for_3_start
for_3_end:
$P39 = find_lex "@nk"
# XXX why does this not work ?
# $P40 = find_lex "@k"
# clone $P40, $P39
clone $P22, $P39
$P39 = 0
inc $P29
branch for_2_start
for_2_end:
# XXX why does this not work ?
# $P41 = find_lex "@k"
# $I0 = $P22
$I0 = $P22
print $I0
print "\n"
$P42 = iter $P22
$P43 = find_lex "%ha"
$I1 = 0
iter_2_start:
unless $P42 goto iter_2_end
inc $I1
shift $P44, $P42
$S0 = $P44
$P43[$S0] = 1
branch iter_2_start
iter_2_end:
print $I1
print "\n"
$I0 = $P43
print $I0
print "\n"
$I0 = defined $P43["AAAAA"]
print $I0
$I0 = defined $P43["ABCDE"]
print $I0
$I0 = defined $P43["BBBBB"]
print $I0
$I0 = defined $P43["CCCCC"]
print $I0
$I0 = defined $P43["HHHHH"]
print $I0
$I0 = defined $P43["IIIII"]
print $I0
print "\n"
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: