OSDN Git Service

* config/cris/cris.c: Remove whitespace at end of line.
[pf3gnuchains/gcc-fork.git] / gcc / config / pj / lib1funcs.S
1 ! lib1funcs.S for picoJava.
2 !   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
3
4 ! This file is free software; you can redistribute it and/or modify it
5 ! under the terms of the GNU General Public License as published by the
6 ! Free Software Foundation; either version 2, or (at your option) any
7 ! later version.
8
9 ! In addition to the permissions in the GNU General Public License, the
10 ! Free Software Foundation gives you unlimited permission to link the
11 ! compiled version of this file into combinations with other programs,
12 ! and to distribute those combinations without any restriction coming
13 ! from the use of this file.  (The General Public License restrictions
14 ! do apply in other respects; for example, they cover modification of
15 ! the file, and distribution when not linked into a combine
16 ! executable.)
17
18 ! This file is distributed in the hope that it will be useful, but
19 ! WITHOUT ANY WARRANTY; without even the implied warranty of
20 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ! General Public License for more details.
22
23 ! You should have received a copy of the GNU General Public License
24 ! along with this program; see the file COPYING.  If not, write to
25 ! the Free Software Foundation, 59 Temple Place - Suite 330,
26 ! Boston, MA 02111-1307, USA.
27
28
29
30 #ifdef Lvhelper
31
32 ! The vhelper copies unnamed args in a varargs function from the
33 ! opstack onto the aggregate stack.  It is a bit tricky since the
34 ! opstack does not exist in real memory, so can not have its address taken,
35 ! and since the opstack is being played with, there is nowhere to stick
36 ! the temporaries.
37         
38         .globl __vhelper
39 __vhelper:
40
41
42 ! incoming
43 ! vars->  named0
44 !         named1
45 !         ...
46 !         unnamed0
47 !         unnamed1
48 !         ...
49 !         pc
50 !         vars
51 !         #named
52 !         return pc
53
54         ! work out total size everything below the named args and       
55         ! allocate that space on the aggregate stack + 3 extra words
56         ! for some temps.
57         ! g0   = old g0
58         ! g0+4 = vars
59         ! g0+8 = pc
60         ! g0+12 = last unnamed arg
61         ! ....
62
63         write_global1
64         write_global2
65
66         ! tos = #named args provided by callee.
67
68         ! move down the aggstack to make room for all the unnamed args
69         ! and the 12 bytes of extra stuff we have to pay attention to.
70         ! g0 = old_g0 - ((vars - optop) + named_bytes + 12) - stuff we just pushed
71
72         ! build new global0
73         read_global0
74          read_vars
75           read_optop
76          isub                ! tos = vars - optop (# bytes in all args)
77           bipush 4
78          isub                ! subtract out fudge for current stuff on stack.
79           read_global2
80          isub                ! subtract out # words named.
81         isub
82
83         dup
84         dup
85         ! store old global0 in new global0 spot.
86         
87         read_global0
88         swap
89         store_word
90
91         ! store new global0 value into global0
92         write_global0
93
94         ! work out address to stop copying, which is vars - #named args bytes
95         ! but since we will have pushed stuff onto the stack when the comparison
96         ! is made, adjust by the fudge factor.
97          read_vars
98           read_global2
99            bipush 12
100           iadd
101          isub
102
103         ! optop= finish, vars, pc, ... 
104         ! now pop off args from the opstack and copy to aggstack till all done.
105         ! during the loop the opstack looks like
106         ! (optop_finish_addr) (destination_addr) (named_n) (named_n-1) ....
107         ! each iteration pops off one more element.
108
109
110 again:
111           dup_x2
112            read_optop
113          if_icmpeq done
114           iconst_4
115          iadd 
116           dup_x2
117         store_word
118         goto again
119
120 done:
121         dup2_x1 ; pop2 ; pop   !leave pointer on top.
122
123         ! return to caller with varargs pointer as      
124         ! the next argument and the restoring global0 as the next. 
125
126         read_global0 ; load_word
127
128         ! restore returning pc and vars
129         read_global0 ; bipush 8; iadd; load_word
130         read_global0 ; bipush 4; iadd; load_word
131
132         ! return to caller.
133         read_global1
134         write_pc
135 #endif
136
137
138 #ifdef __LITTLE_ENDIAN__
139 #define AL iload_1
140 #define AH iload_0
141 #define BL iload_3      
142 #define BH iload_2
143 #else
144 #define AL iload_0
145 #define AH iload_1
146 #define BL iload_2
147 #define BH iload_3
148 #endif  
149 #ifdef Lpjucmpdi2
150
151 ! like ucmpdi2, but returns <0,0,>0 depending on comparison input.
152 ! and returns answer on the stack, not in global1.  - much like an
153 ! actual lucmp instruction would do if there was one.
154 !             big         little
155 !  
156 !  vars-> 0 a low         high
157 !         1 a high        low
158 !         2 b low         high
159 !         3 b high        low
160 !
161 ! compares a to b
162 ! a > b return 1
163 ! a = b return 0
164 ! a < b return -1               
165         
166         .globl __pjucmpdi2
167 __pjucmpdi2:
168
169 ! first see if we can compare the numbers using
170 ! the signed instruction.
171         
172         AH
173         BH
174         if_icmpne       high_words_diff
175         AL
176         BL
177         iucmp
178         return1
179
180 ! and low word if high word is equal.   
181
182 high_words_diff:                
183         AH
184         BH
185         iucmp
186         return1
187 #endif