Throw in more PA-RISC assembler.
[openssl.git] / crypto / pariscid.pl
1 #!/usr/bin/env perl
2
3 $flavour = shift;
4 $output = shift;
5 open STDOUT,">$output";
6
7 if ($flavour =~ /64/) {
8         $LEVEL          ="2.0W";
9         $SIZE_T         =8;
10         $ST             ="std";
11 } else {
12         $LEVEL          ="1.1";
13         $SIZE_T         =4;
14         $ST             ="stw";
15 }
16
17 $rp="%r2";
18 $sp="%r30";
19 $rv="%r28";
20
21 $code=<<___;
22         .LEVEL  $LEVEL
23         .SPACE  \$TEXT\$
24         .SUBSPA \$CODE\$,QUAD=0,ALIGN=8,ACCESS=0x2C,CODE_ONLY
25
26         .EXPORT OPENSSL_rdtsc,ENTRY
27         .ALIGN  8
28 OPENSSL_rdtsc
29         .PROC
30         .CALLINFO       NO_CALLS
31         .ENTRY
32         mfctl   %cr16,$rv
33         bv      ($rp)
34         .EXIT
35         nop
36         .PROCEND
37
38         .EXPORT OPENSSL_wipe_cpu,ENTRY
39         .ALIGN  8
40 OPENSSL_wipe_cpu
41         .PROC
42         .CALLINFO       NO_CALLS
43         .ENTRY
44         xor             %r0,%r0,%r1
45         fcpy,dbl        %fr0,%fr4
46         xor             %r0,%r0,%r19
47         fcpy,dbl        %fr0,%fr5
48         xor             %r0,%r0,%r20
49         fcpy,dbl        %fr0,%fr6
50         xor             %r0,%r0,%r21
51         fcpy,dbl        %fr0,%fr7
52         xor             %r0,%r0,%r22
53         fcpy,dbl        %fr0,%fr8
54         xor             %r0,%r0,%r23
55         fcpy,dbl        %fr0,%fr9
56         xor             %r0,%r0,%r24
57         fcpy,dbl        %fr0,%fr10
58         xor             %r0,%r0,%r25
59         fcpy,dbl        %fr0,%fr11
60         xor             %r0,%r0,%r26
61         fcpy,dbl        %fr0,%fr22
62         xor             %r0,%r0,%r29
63         fcpy,dbl        %fr0,%fr23
64         xor             %r0,%r0,%r31
65         fcpy,dbl        %fr0,%fr24
66         fcpy,dbl        %fr0,%fr25
67         fcpy,dbl        %fr0,%fr26
68         fcpy,dbl        %fr0,%fr27
69         fcpy,dbl        %fr0,%fr28
70         fcpy,dbl        %fr0,%fr29
71         fcpy,dbl        %fr0,%fr30
72         fcpy,dbl        %fr0,%fr31
73         bv              ($rp)
74         .EXIT
75         ldo             0($sp),$rv
76         .PROCEND
77 ___
78 {
79 $inp="%r26";
80 $len="%r25";
81
82 $code.=<<___;
83         .EXPORT OPENSSL_cleanse,ENTRY,ARGW0=GR,ARGW1=GR
84         .ALIGN  8
85 OPENSSL_cleanse
86         .PROC
87         .CALLINFO       NO_CALLS
88         .ENTRY
89         cmpib,*>>       15,$len,Little
90         ldi             $SIZE_T-1,%r1
91
92 Lalign
93         and,*<>         $inp,%r1,%r28
94         b,n             Laligned
95         stb             %r0,0($inp)
96         ldo             -1($len),$len
97         b               Lalign
98         ldo             1($inp),$inp
99
100 Laligned
101         andcm           $len,%r1,%r28
102 Loop
103         $ST             %r0,0($inp)
104         addib,*vnz      -$SIZE_T,%r28,Loop
105         ldo             $SIZE_T($inp),$inp
106
107         and,*<>         $len,%r1,$len
108         b,n             Ldone
109 Little
110         stb             %r0,0($inp)
111         addib,*vnz      -1,$len,Little
112         ldo             1($inp),$inp
113 Ldone
114         bv              ($rp)
115         .EXIT
116         nop
117         .PROCEND
118 ___
119 }
120
121 $code =~ s/cmpib,\*/comib,/gm if ($SIZE_T==4);
122 $code =~ s/,\*/,/gm if ($SIZE_T==4);
123 print $code;
124 close STDOUT;
125