source: branches/arm/lisp-kernel/ppc-subprims.s @ 13923

Last change on this file since 13923 was 13337, checked in by plkrueger, 10 years ago

Don't change the m4 quoting characters from their defaults (`').
(On the ARM, square brackets are used to denote memory operands, curly
braces surround register lists, and multicharacter quoting delimeters
look funny ...)

Some versions (at least) of m4 are confused by quoting characters in
comments, so try to refrain from using contractions ...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 KB
Line 
1/*   Copyright (C) 2009 Clozure Associates */
2/*   Copyright (C) 1994-2001 Digitool, Inc */
3/*   This file is part of Clozure CL.  */
4
5/*   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public */
6/*   License , known as the LLGPL and distributed with Clozure CL as the */
7/*   file "LICENSE".  The LLGPL consists of a preamble and the LGPL, */
8/*   which is distributed with Clozure CL as the file "LGPL".  Where these */
9/*   conflict, the preamble takes precedence.   */
10
11/*   Clozure CL is referenced in the preamble as the "LIBRARY." */
12
13/*   The LLGPL is also available online at */
14/*   http://opensource.franz.com/preamble.html */
15
16
17
18        include(lisp.s)
19        _beginfile
20
21        .globl _SPmkcatch1v
22        .globl _SPnthrow1value
23
24
25/* This is called from a c-style context and calls a lisp function. */
26/* This does the moral equivalent of */
27/*   (loop  */
28/*      (let* ((fn (%function_on_top_of_lisp_stack))) */
29/*        (if fn */
30/*           (catch %toplevel-catch% */
31/*             (funcall fn)) */
32/*            (return nil)))) */
33
34_exportfn(toplevel_loop)
35        __(mflr imm0)
36        __ifdef(`POWEROPENABI')
37         __(str(imm0,c_frame.savelr(sp)))
38        __else
39         __(str(imm0,eabi_c_frame.savelr(sp)))
40        __endif
41        __(b local_label(test))
42local_label(loop):
43        __(ref_nrs_value(arg_z,toplcatch))
44        __(bl _SPmkcatch1v)
45        __(b local_label(test))                 /* cleanup address, not really a branch */
46
47        __(set_nargs(0))
48        __(bl _SPfuncall)
49        __(li arg_z,nil_value)
50        __(li imm0,fixnum_one)
51        __(bl _SPnthrow1value)
52local_label(test):
53        __(ldr(temp0,0(vsp)))
54        __(cmpri(cr0,temp0,nil_value))
55        __(bne cr0,local_label(loop))
56local_label(back_to_c):
57        __ifdef(`POWEROPENABI')
58         __(ldr(imm0,c_frame.savelr(sp)))
59        __else
60         __(ldr(imm0,eabi_c_frame.savelr(sp)))
61        __endif
62        __(mtlr imm0)
63        __(blr)
64        _endfn
65
66
67/* This sucker gets called with R3 pointing to the current TCR. */
68/* r4 is 0 if we want to start the whole thing rolling, */
69/* non-zero if we want to reset the current process */
70/* by throwing to toplevel */
71
72        .globl _SPreset
73_exportfn(C(start_lisp))
74        __(mflr r0)
75        __ifdef(`POWEROPENABI')
76         __(str(r0,c_frame.savelr(sp)))
77         __ifdef(`rTOC')
78          __(str(rTOC,c_frame.savetoc(sp)))
79         __endif
80         __(stru(sp,-(stack_align(c_frame.minsiz+(32*node_size)))(sp)))
81         __(str(r13,c_frame.minsiz+(0*node_size)(sp)))
82         __(str(r14,c_frame.minsiz+(1*node_size)(sp)))
83         __(str(r15,c_frame.minsiz+(2*node_size)(sp)))
84         __(str(r16,c_frame.minsiz+(3*node_size)(sp)))
85         __(str(r17,c_frame.minsiz+(4*node_size)(sp)))
86         __(str(r18,c_frame.minsiz+(5*node_size)(sp)))
87         __(str(r19,c_frame.minsiz+(6*node_size)(sp)))
88         __(str(r20,c_frame.minsiz+(7*node_size)(sp)))
89         __(str(r21,c_frame.minsiz+(8*node_size)(sp)))
90         __(str(r22,c_frame.minsiz+(9*node_size)(sp)))
91         __(str(r23,c_frame.minsiz+(10*node_size)(sp)))
92         __(str(r24,c_frame.minsiz+(11*node_size)(sp)))
93         __(str(r25,c_frame.minsiz+(12*node_size)(sp)))
94         __(str(r26,c_frame.minsiz+(13*node_size)(sp)))
95         __(str(r27,c_frame.minsiz+(14*node_size)(sp)))
96         __(str(r28,c_frame.minsiz+(15*node_size)(sp)))
97         __(str(r29,c_frame.minsiz+(16*node_size)(sp)))
98         __(str(r30,c_frame.minsiz+(17*node_size)(sp)))
99         __(str(r31,c_frame.minsiz+(18*node_size)(sp)))
100         __(stfd fp_s32conv,c_frame.minsiz+(22*node_size)(sp))
101        __else
102         __(str(r0,eabi_c_frame.savelr(sp)))
103         __(stru(sp,-(eabi_c_frame.minsiz+(32*node_size))(sp)))
104         __(str(r13,eabi_c_frame.minsiz+(0*node_size)(sp)))
105         __(str(r14,eabi_c_frame.minsiz+(1*node_size)(sp)))
106         __(str(r15,eabi_c_frame.minsiz+(2*node_size)(sp)))
107         __(str(r16,eabi_c_frame.minsiz+(3*node_size)(sp)))
108         __(str(r17,eabi_c_frame.minsiz+(4*node_size)(sp)))
109         __(str(r18,eabi_c_frame.minsiz+(5*node_size)(sp)))
110         __(str(r19,eabi_c_frame.minsiz+(6*node_size)(sp)))
111         __(str(r20,eabi_c_frame.minsiz+(7*node_size)(sp)))
112         __(str(r21,eabi_c_frame.minsiz+(8*node_size)(sp)))
113         __(str(r22,eabi_c_frame.minsiz+(9*node_size)(sp)))
114         __(str(r23,eabi_c_frame.minsiz+(10*node_size)(sp)))
115         __(str(r24,eabi_c_frame.minsiz+(11*node_size)(sp)))
116         __(str(r25,eabi_c_frame.minsiz+(12*node_size)(sp)))
117         __(str(r26,eabi_c_frame.minsiz+(13*node_size)(sp)))
118         __(str(r27,eabi_c_frame.minsiz+(14*node_size)(sp)))
119         __(str(r28,eabi_c_frame.minsiz+(15*node_size)(sp)))
120         __(str(r29,eabi_c_frame.minsiz+(16*node_size)(sp)))
121         __(str(r30,eabi_c_frame.minsiz+(17*node_size)(sp)))
122         __(str(r31,eabi_c_frame.minsiz+(18*node_size)(sp)))
123         __(stfd fp_s32conv,eabi_c_frame.minsiz+(22*node_size)(sp))
124        __endif
125        __(mr rcontext,r3)
126        __(lwi(r30,0x43300000))
127        __(lwi(r31,0x80000000))
128        __ifdef(`POWEROPENABI')
129         __(stw r30,c_frame.minsiz+(20*node_size)(sp))
130         __(stw r31,c_frame.minsiz+(20*node_size)+4(sp))
131         __(lfd fp_s32conv,c_frame.minsiz+(20*node_size)(sp))
132         __(stfd fp_zero,c_frame.minsiz+(20*node_size)(sp))
133        __else               
134         __(stw r30,eabi_c_frame.minsiz+(20*node_size)(sp))
135         __(stw r31,eabi_c_frame.minsiz+(20*node_size)+4(sp))
136         __(lfd fp_s32conv,eabi_c_frame.minsiz+(20*node_size)(sp))
137         __(stfd fp_zero,eabi_c_frame.minsiz+(20*node_size)(sp))
138        __endif
139        __(lfs fp_zero,lisp_globals.short_float_zero(0))
140        __(lfd f0,tcr.lisp_fpscr(rcontext))
141        __(mtfsf 0xff,f0)
142        __(li rzero,0)
143        __(mr save0,rzero)
144        __(mr save1,rzero)
145        __(mr save2,rzero)
146        __(mr save3,rzero)
147        __(mr save4,rzero)
148        __(mr save5,rzero)
149        __(mr save6,rzero)
150        __(mr save7,rzero)
151        __(mr arg_z,rzero)
152        __(mr arg_y,rzero)
153        __(mr arg_x,rzero)
154        __(mr temp0,rzero)
155        __(mr temp1,rzero)
156        __(mr temp2,rzero)
157        __(mr temp3,rzero)
158        __(li loc_pc,0)
159        __(li fn,0)
160        __(cmpri(cr0,r4,0))
161        __(mtxer rzero)  /* start lisp with the overflow bit clear */
162        __(ldr(vsp,tcr.save_vsp(rcontext)))
163        __(ldr(tsp,tcr.save_tsp(rcontext)))
164        __(ldr(allocptr,tcr.save_allocptr(rcontext)))
165        __(ldr(allocbase,tcr.save_allocbase(rcontext)))
166        __(li imm0,TCR_STATE_LISP)
167        __(str(imm0,tcr.valence(rcontext)))
168        __(bne cr0,1f)
169        __(bl toplevel_loop)
170        __(b 2f)
1711:
172        __(bl _SPreset)
1732:
174        __(str(allocptr,tcr.save_allocptr(rcontext)))
175        __(str(allocbase,tcr.save_allocbase(rcontext)))
176        __(str(tsp,tcr.save_tsp(rcontext)))
177        __(str(vsp,tcr.save_vsp(rcontext)))
178        __(li imm0,TCR_STATE_FOREIGN)
179        __(str(imm0,tcr.valence(rcontext)))
180        __ifdef(`POWEROPENABI')
181         __(ldr(r13,c_frame.minsiz+(0*node_size)(sp)))
182         __(ldr(r14,c_frame.minsiz+(1*node_size)(sp)))
183         __(ldr(r15,c_frame.minsiz+(2*node_size)(sp)))
184         __(ldr(r16,c_frame.minsiz+(3*node_size)(sp)))
185         __(ldr(r17,c_frame.minsiz+(4*node_size)(sp)))
186         __(ldr(r18,c_frame.minsiz+(5*node_size)(sp)))
187         __(ldr(r19,c_frame.minsiz+(6*node_size)(sp)))
188         __(ldr(r20,c_frame.minsiz+(7*node_size)(sp)))
189         __(ldr(r21,c_frame.minsiz+(8*node_size)(sp)))
190         __(ldr(r22,c_frame.minsiz+(9*node_size)(sp)))
191         __(ldr(r23,c_frame.minsiz+(10*node_size)(sp)))
192         __(ldr(r24,c_frame.minsiz+(11*node_size)(sp)))
193         __(ldr(r25,c_frame.minsiz+(12*node_size)(sp)))
194         __(ldr(r26,c_frame.minsiz+(13*node_size)(sp)))
195         __(ldr(r27,c_frame.minsiz+(14*node_size)(sp)))
196         __(ldr(r28,c_frame.minsiz+(15*node_size)(sp)))
197         __(ldr(r29,c_frame.minsiz+(16*node_size)(sp)))
198         __(ldr(r30,c_frame.minsiz+(17*node_size)(sp)))
199         __(ldr(r31,c_frame.minsiz+(18*node_size)(sp)))
200        __else
201         __(ldr(r13,eabi_c_frame.minsiz+(0*node_size)(sp)))
202         __(ldr(r14,eabi_c_frame.minsiz+(1*node_size)(sp)))
203         __(ldr(r15,eabi_c_frame.minsiz+(2*node_size)(sp)))
204         __(ldr(r16,eabi_c_frame.minsiz+(3*node_size)(sp)))
205         __(ldr(r17,eabi_c_frame.minsiz+(4*node_size)(sp)))
206         __(ldr(r18,eabi_c_frame.minsiz+(5*node_size)(sp)))
207         __(ldr(r19,eabi_c_frame.minsiz+(6*node_size)(sp)))
208         __(ldr(r20,eabi_c_frame.minsiz+(7*node_size)(sp)))
209         __(ldr(r21,eabi_c_frame.minsiz+(8*node_size)(sp)))
210         __(ldr(r22,eabi_c_frame.minsiz+(9*node_size)(sp)))
211         __(ldr(r23,eabi_c_frame.minsiz+(10*node_size)(sp)))
212         __(ldr(r24,eabi_c_frame.minsiz+(11*node_size)(sp)))
213         __(ldr(r25,eabi_c_frame.minsiz+(12*node_size)(sp)))
214         __(ldr(r26,eabi_c_frame.minsiz+(13*node_size)(sp)))
215         __(ldr(r27,eabi_c_frame.minsiz+(14*node_size)(sp)))
216         __(ldr(r28,eabi_c_frame.minsiz+(15*node_size)(sp)))
217         __(ldr(r29,eabi_c_frame.minsiz+(16*node_size)(sp)))
218         __(ldr(r30,eabi_c_frame.minsiz+(17*node_size)(sp)))
219         __(ldr(r31,eabi_c_frame.minsiz+(18*node_size)(sp)))
220        __endif
221        __(li r3,nil_value)
222        __ifdef(`POWEROPENABI')
223         __(lfd fp_zero,c_frame.minsiz+(20*node_size)(sp))
224         __(lfd fp_s32conv,c_frame.minsiz+(22*node_size)(sp))
225         __(ldr(r0,((stack_align(c_frame.minsiz+(32*node_size)))+c_frame.savelr)(sp)))
226        __else
227         __(lfd fp_zero,eabi_c_frame.minsiz+(20*4)(sp))
228         __(lfd fp_s32conv,eabi_c_frame.minsiz+(22*4)(sp))
229         __(ldr(r0,(eabi_c_frame.minsiz+(32*node_size)+eabi_c_frame.savelr)(sp)))
230        __endif
231        __(mtlr r0)
232        __(ldr(sp,0(sp)))
233         __ifdef(`rTOC')
234          __(ld rTOC,c_frame.savetoc(sp))
235         __endif
236        __(blr)
237
238_exportfn(_SPsp_end)
239        nop
240        _endfile
241
Note: See TracBrowser for help on using the repository browser.