-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaddit2.pir
82 lines (66 loc) · 1.47 KB
/
addit2.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
# Copyright (C) 2001-2008, Parrot Foundation.
=head1 NAME
examples/benchmarks/addit2.pir - Variable Argument Subroutines
=head1 SYNOPSIS
% time ./parrot examples/benchmarks/addit2.pir
=head1 DESCRIPTION
An optimized IMC version of Joe Wilson's original PASM version of his
C<varargs> subroutines benchmark rewritten as it would be generated by a
compiler using Parrot calling conventions (PDD 3).
It calls an "add it" function 50000 times in a loop and prints the
result (21001097.970000).
=cut
.sub addit2 :main
.local pmc a0
a0 = new 'Integer'
a0 = 1000
.local pmc a1
a1 = new 'Float'
a1 = 7.100
.local pmc a2
a2 = new 'Integer'
a2 = 87
.local pmc a3
a3 = new 'String'
a3 = "3.87"
.local pmc a4
a4 = new 'String'
a4 = "21000000"
.local pmc x
x = new 'Integer'
x = 50000
.local pmc result
AGAIN:
dec x
lt x, 0, FIN
result = adder(a0, a1, a2, a3, a4)
branch AGAIN
FIN:
print result
print "\n"
end
.end
.sub adder
.param pmc a0
.param pmc a1
.param pmc a2
.param pmc a3
.param pmc a4
.local pmc sum
sum = new 'Float'
sum += a0
sum += a1
sum += a2
sum += a3
sum += a4
.return(sum)
.end
=head1 SEE ALSO
F<examples/benchmarks/addit.pl>, F<examples/benchmarks/addit.pasm>,
F<examples/benchmarks/addit.pir>.
=cut
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: