source: release/1.9/source/lisp-kernel/ppc-constants32.s @ 16083

Last change on this file since 16083 was 15371, checked in by gb, 7 years ago

Ensure that lisp_globals_limit is defined before lisp_globals.s
is included. (Newer versions of gas can handle forward references
better than older versions do.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.8 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
17define(`rcontext',`r13')
18       
19nbits_in_word = 32
20nbits_in_byte = 8
21ntagbits = 3    /* But only 2 are significant to lisp */
22nlisptagbits = 2
23nfixnumtagbits = 2
24num_subtag_bits = 8
25fixnumshift = 2
26fixnum_shift = 2
27fulltagmask = 7
28tagmask = 3
29fixnummask = 3
30ncharcodebits = 24              /* arguably, we're only using the low 8 */
31charcode_shift = nbits_in_word-ncharcodebits
32word_shift = 2
33node_size = 4
34dnode_size = 8
35dnode_align_bits = 3
36dnode_shift = dnode_align_bits
37bitmap_shift = 5
38
39
40fixnumone = (1<<fixnumshift)
41fixnum_one = fixnumone
42fixnum1 = fixnumone
43
44
45/* Tags. */
46/* There are two-bit tags and three-bit tags. */
47/* A FULLTAG is the value of the low three bits of a tagged object. */
48/* A TAG is the value of the low two bits of a tagged object. */
49/* A TYPECODE is either a TAG or the value of a "tag-misc" objects header-byte. */
50
51/* There are 4 primary TAG values.  Any object which lisp can "see" can be classified */
52/* by its TAG.  (Some headers have FULLTAGS that are congruent modulo 4 with the */
53/* TAGS of other objects, but lisp can't "see" headers.) */
54
55
56tag_fixnum = 0  /* All fixnums, whether odd or even */
57tag_list = 1    /* Conses and NIL */
58tag_misc = 2    /* Heap-consed objects other than lists: vectors, symbols, functions, floats ... */
59tag_imm = 3     /* Immediate-objects: characters, UNBOUND, other markers. */
60
61
62/*  And there are 8 FULLTAG values.  Note that NIL has its own FULLTAG (congruent mod 4 to tag-list), */
63/*  that FULLTAG-MISC is > 4 (so that code-vector entry-points can be branched to, since the low */
64/*  two bits of the PC are ignored) and that both FULLTAG-MISC and FULLTAG-IMM have header fulltags */
65/*  that share the same TAG. */
66/*  Things that walk memory (and the stack) have to be careful to look at the FULLTAG of each */
67/*  object that they see. */
68
69
70fulltag_even_fixnum = 0 /* I suppose EVENP/ODDP might care; nothing else does. */
71fulltag_cons = 1        /* a real (non_null) cons.  Shares TAG with fulltag_nil. */
72fulltag_nodeheader = 2  /* Header of heap_allocated object that contains lisp_object pointers */
73fulltag_imm = 3 /* a "real" immediate object.  Shares TAG with fulltag_immheader. */
74fulltag_odd_fixnum = 4  /* */
75fulltag_nil = 5 /* NIL and nothing but.  (Note that there's still a hidden NILSYM.) */
76fulltag_misc = 6        /* Pointer "real" tag_misc object.  Shares TAG with fulltag_nodeheader. */
77fulltag_immheader = 7   /* Header of heap-allocated object that contains unboxed data. */
78
79nil_value = 0x00003015+LOWMEM_BIAS
80misc_bias = fulltag_misc
81cons_bias = tag_list       
82
83/* Functions are of (conceptually) unlimited size. */
84        _struct(_function,-misc_bias)
85         _node(header)
86         _node(codevector)
87        _ends
88
89        _struct(tsp_frame,0)
90         _node(backlink)
91         _node(type)
92         _struct_label(fixed_overhead)
93         _struct_label(data_offset)
94        _ends
95
96/* Order of CAR and CDR doesn't seem to matter much - there aren't */
97/* too many tricks to be played with predecrement/preincrement addressing. */
98/* Keep them in the confusing MCL 3.0 order, to avoid confusion. */
99        _struct(cons,-cons_bias)
100         _node(cdr)
101         _node(car)
102        _ends
103       
104misc_header_offset = -fulltag_misc
105misc_subtag_offset = misc_header_offset+3               /* low byte of header */
106misc_data_offset = misc_header_offset+4         /* first word of data */
107misc_dfloat_offset = misc_header_offset+8               /* double-floats are doubleword-aligned */
108
109max_64_bit_constant_index = ((0x7fff + misc_dfloat_offset)>>3)
110max_32_bit_constant_index = ((0x7fff + misc_data_offset)>>2)
111max_16_bit_constant_index = ((0x7fff + misc_data_offset)>>1)
112max_8_bit_constant_index = (0x7fff + misc_data_offset)
113max_1_bit_constant_index = ((0x7fff + misc_data_offset)<<5)
114
115/* T is almost adjacent to NIL: since NIL is a misaligned CONS, it spans */
116/* two doublewords.  The arithmetic difference between T and NIL is */
117/* such that the least-significant bit and exactly one other bit is */
118/* set in the result. */
119
120t_offset = (8+(8-fulltag_nil)+fulltag_misc)
121t_value = nil_value+t_offset
122
123/* The order in which various header values are defined is significant in several ways: */
124/* 1) Numeric subtags precede non-numeric ones; there are further orderings among numeric subtags. */
125/* 2) All subtags which denote CL arrays are preceded by those that don't, */
126/*    with a further ordering which requires that (< header-arrayH header-vectorH ,@all-other-CL-vector-types) */
127/* 3) The element-size of ivectors is determined by the ordering of ivector subtags. */
128/* 4) All subtags are >= fulltag-immheader . */
129
130define(`define_subtag',`
131subtag_$1 = $2|($3<<ntagbits)')
132       
133define(`define_imm_subtag',`
134        define_subtag($1,fulltag_immheader,$2)')
135
136       
137define(`define_node_subtag',`
138        define_subtag($1,fulltag_nodeheader,$2)')
139
140               
141/*Immediate subtags. */
142        define_subtag(character,fulltag_imm,9)
143        define_subtag(unbound,fulltag_imm,6)
144        define_subtag(illegal,fulltag_imm,10)
145        define_subtag(go_tag,fulltag_imm,12)
146        define_subtag(block_tag,fulltag_imm,24)
147        define_subtag(vsp_protect,fulltag_imm,7)
148        define_subtag(no_thread_local_binding,fulltag_imm,30)
149unbound_marker = subtag_unbound
150undefined = unbound_marker
151illegal_marker = subtag_illegal
152no_thread_local_binding_marker = subtag_no_thread_local_binding
153/*Numeric subtags. */
154
155        define_imm_subtag(bignum,0)
156min_numeric_subtag = subtag_bignum
157
158        define_node_subtag(ratio,1)
159max_rational_subtag = subtag_ratio
160
161        define_imm_subtag(single_float,1)
162        define_imm_subtag(double_float,2)
163min_float_subtag = subtag_single_float
164max_float_subtag = subtag_double_float
165max_real_subtag = subtag_double_float
166
167        define_node_subtag(complex,3)
168max_numeric_subtag = subtag_complex
169
170
171/* CL array types.  There are more immediate types than node types; all CL array subtags must be > than */
172/* all non-CL-array subtags.  So we start by defining the immediate subtags in decreasing order, starting */
173/* with that subtag whose element size isn't an integral number of bits and ending with those whose */
174/* element size - like all non-CL-array fulltag-immheader types - is 32 bits. */
175
176        define_imm_subtag(bit_vector,31)
177        define_imm_subtag(double_float_vector,30)
178        define_imm_subtag(s16_vector,29)
179        define_imm_subtag(u16_vector,28)
180min_16_bit_ivector_subtag = subtag_u16_vector
181max_16_bit_ivector_subtag = subtag_s16_vector
182        define_imm_subtag(s8_vector,26)
183        define_imm_subtag(u8_vector,25)
184min_8_bit_ivector_subtag = subtag_u8_vector
185max_8_bit_ivector_subtag = fulltag_immheader|(27<<ntagbits)
186        define_imm_subtag(simple_base_string,24)
187        define_imm_subtag(fixnum_vector,23)
188        define_imm_subtag(s32_vector,22)
189        define_imm_subtag(u32_vector,21)
190        define_imm_subtag(single_float_vector,20)
191max_32_bit_ivector_subtag = fulltag_immheader|(24<<ntagbits)
192min_cl_ivector_subtag = subtag_single_float_vector
193
194
195        define_node_subtag(vectorH,20)
196        define_node_subtag(arrayH,19)
197        define_node_subtag(simple_vector,21)
198min_vector_subtag = subtag_vectorH
199min_array_subtag = subtag_arrayH
200
201/* So, we get the remaining subtags (n: (n > max-numeric-subtag) & (n < min-array-subtag)) */
202/* for various immediate/node object types. */
203
204        define_imm_subtag(macptr,3)
205min_non_numeric_imm_subtag = subtag_macptr
206
207        define_imm_subtag(dead_macptr,4)
208        define_imm_subtag(code_vector,5)
209        define_imm_subtag(creole,6)
210
211max_non_array_imm_subtag = (18<<ntagbits)|fulltag_immheader
212
213        define_node_subtag(catch_frame,4)
214        define_node_subtag(function,5)
215        define_node_subtag(basic_stream,6)
216        define_node_subtag(symbol,7)
217        define_node_subtag(lock,8)
218        define_node_subtag(hash_vector,9)
219        define_node_subtag(pool,10)
220        define_node_subtag(weak,11)
221        define_node_subtag(package,12)
222        define_node_subtag(slot_vector,13)
223        define_node_subtag(instance,14)
224        define_node_subtag(struct,15)
225        define_node_subtag(istruct,16)
226        define_node_subtag(value_cell,17)
227        define_node_subtag(xfunction,18)
228max_non_array_node_subtag = (18<<ntagbits)|fulltag_immheader
229       
230/* The objects themselves look something like this: */
231        _structf(ratio)
232         _node(numer)
233         _node(denom)
234        _endstructf
235
236        _structf(single_float)
237         _word(value)
238        _endstructf
239
240        _structf(double_float)
241         _word(pad)
242         _dword(value)
243        _endstructf
244
245        _structf(symbol)
246         _node(pname)
247         _node(vcell)
248         _node(fcell)
249         _node(package_predicate)
250         _node(flags)
251         _node(plist)
252         _node(binding_index)
253        _endstructf
254
255        _structf(catch_frame)
256         _node(catch_tag)       /* #<unbound> -> unwind-protect, else catch */
257         _node(link)            /* backpointer to previous catch frame */
258         _node(mvflag)          /* 0 if single-valued catch, fixnum 1 otherwise */
259         _node(csp)             /* pointer to lisp_frame on csp */
260         _node(db_link)         /* head of special-binding chain */
261         _field(regs,8*node_size)       /* save7-save0 */
262         _node(xframe)          /* exception frame chain */
263         _node(tsp_segment)     /* maybe someday; padding for now */
264        _endstructf
265
266        _structf(macptr)
267         _node(address)
268         _node(domain)
269         _node(type)
270        _endstructf
271
272        _structf(vectorH)
273         _node(logsize)
274         _node(physsize)
275         _node(data_vector)
276         _node(displacement)
277         _node(flags)
278        _endstructf
279
280        _structf(arrayH)
281         _node(rank)
282         _node(physsize)
283         _node(data_vector)
284         _node(displacement)
285         _node(flags)
286         _struct_label(dim0)
287        _endstructf
288       
289       
290       
291        _struct(c_frame,0)      /* PowerOpen ABI C stack frame */
292         _node(backlink)
293         _node(crsave)
294         _node(savelr)
295         _field(unused, 8)
296         _node(savetoc)
297         _struct_label(params)
298         _node(param0)
299         _node(param1)
300         _node(param2)
301         _node(param3)
302         _node(param4)
303         _node(param5)
304         _node(param6)
305         _node(param7)
306         _struct_label(minsiz)
307        _ends
308
309
310        _struct(eabi_c_frame,0)
311         _word(backlink) 
312         _word(savelr)
313         _word(param0)
314         _word(param1)
315         _word(param2)
316         _word(param3)
317         _word(param4)
318         _word(param5)
319         _word(param6)
320         _word(param7)
321         _struct_label(minsiz)
322        _ends
323
324        /* For entry to variable-argument-list functions */
325/*        (e.g., via callback) */
326        _struct(varargs_eabi_c_frame,0)
327         _word(backlink)
328         _word(savelr)
329         _struct_label(va_list)
330         _word(flags)           /* gpr count byte, fpr count byte, padding */
331         _word(overflow_arg_area)
332         _word(reg_save_area)
333         _field(padding,4)
334         _struct_label(regsave)
335         _field(gp_save,8*node_size)
336         _field(fp_save,8*8)
337         _word(old_backlink)
338         _word(old_savelr)
339         _struct_label(incoming_stack_args)
340        _ends
341               
342        _struct(lisp_frame,0)
343         _node(backlink) 
344         _node(savefn) 
345         _node(savelr) 
346         _node(savevsp) 
347        _ends
348
349        _struct(vector,-fulltag_misc)
350         _node(header)
351         _struct_label(data)
352        _ends
353
354        _struct(binding,0)
355         _node(link)
356         _node(sym)
357         _node(val)
358        _ends
359
360
361nrs_origin = (nil_value+(16-fulltag_nil))
362nrs_symbol_fulltag = fulltag_misc       
363lisp_globals_limit = (0x3010+(LOWMEM_BIAS))
364
365        include(lisp_globals.s)
366
367define(`def_header',`
368$1 = ($2<<num_subtag_bits)|$3')
369
370        def_header(single_float_header,single_float.element_count,subtag_single_float)
371        def_header(double_float_header,double_float.element_count,subtag_double_float)
372        def_header(one_digit_bignum_header,1,subtag_bignum)
373        def_header(two_digit_bignum_header,2,subtag_bignum)
374        def_header(three_digit_bignum_header,3,subtag_bignum)
375        def_header(symbol_header,symbol.element_count,subtag_symbol)
376        def_header(value_cell_header,1,subtag_value_cell        )
377        def_header(macptr_header,macptr.element_count,subtag_macptr)
378        def_header(vectorH_header,vectorH.element_count,subtag_vectorH)
379
380        include(errors.s)
381
382/* Symbol bits that we care about */
383sym_vbit_bound = (0+fixnum_shift)
384sym_vbit_bound_mask = (1<<sym_vbit_bound)
385sym_vbit_const = (1+fixnum_shift)
386sym_vbit_const_mask = (1<<sym_vbit_const)
387
388        _struct(area,0)
389         _node(pred)
390         _node(succ)
391         _node(low)
392         _node(high)
393         _node(active)
394         _node(softlimit)
395         _node(hardlimit)
396         _node(code)
397         _node(markbits)
398         _node(ndwords)
399         _node(older)
400         _node(younger)
401         _node(h)
402         _node(sofprot)
403         _node(hardprot)
404         _node(owner)
405         _node(refbits)
406         _node(nextref)
407        _ends
408
409
410/* This is only referenced by c->lisp code that needs to save/restore C NVRs in a TSP frame. */
411        _struct(c_reg_save,0)
412         _node(tsp_link)        /* backpointer */
413         _node(tsp_mark)        /* frame type */
414         _node(save_fpscr)      /* for Cs FPSCR */
415         _field(save_gprs,19*4) /* r13-r31 */
416         _dword(save_fp_zero)   /* for fp_zero */
417         _dword(save_fps32conv)
418         _field(save_fprs,13*8)
419        _ends
420
421
422TCR_BIAS = 0
423/* TCR_BIAS = 0x7000 */
424       
425/*  Thread context record. */
426
427        _struct(tcr,-TCR_BIAS)
428         _node(prev)            /* in doubly-linked list */
429         _node(next)            /* in doubly-linked list */
430         _node(lisp_fpscr)      /* lisp thread's fpscr (in low word) */
431         _node(lisp_fpscr_low)
432         _node(db_link)         /* special binding chain head */
433         _node(catch_top)       /* top catch frame */
434         _node(save_vsp)        /* VSP when in foreign code */
435         _node(save_tsp)        /* TSP when in foreign code */
436         _node(cs_area)         /* cstack area pointer */
437         _node(vs_area)         /* vstack area pointer */
438         _node(ts_area)         /* tstack area pointer */
439         _node(cs_limit)        /* cstack overflow limit */
440         _node(bytes_consed_high)
441         _node(bytes_consed_low)
442         _node(log2_allocation_quantum)
443         _node(interrupt_pending)
444         _node(xframe)          /* per-thread exception frame list */
445         _node(errno_loc)       /* per-thread  errno location */
446         _node(ffi_exception)   /* fpscr exception bits from ff-call */
447         _node(osid)            /* OS thread id */
448         _node(valence)         /* odd when in foreign code */
449         _node(foreign_exception_status)
450         _node(native_thread_info)
451         _node(native_thread_id)
452         _node(last_allocptr)
453         _node(save_allocptr)
454         _node(save_allocbase)
455         _node(reset_completion)
456         _node(activate)
457         _node(suspend_count)
458         _node(suspend_context)
459         _node(pending_exception_context)
460         _node(suspend)         /* semaphore for suspension notify */
461         _node(resume)          /* sempahore for resumption notify */
462         _node(flags)     
463         _node(gc_context)
464         _node(termination_semaphore)
465         _node(unwinding)
466         _node(tlb_limit)
467         _node(tlb_pointer)     /* Consider using tcr+N as tlb_pointer */
468         _node(shutdown_count)
469         _node(safe_ref_address)
470        _ends
471
472TCR_FLAG_BIT_FOREIGN = fixnum_shift
473TCR_FLAG_BIT_AWAITING_PRESET = (fixnum_shift+1)
474TCR_FLAG_BIT_ALT_SUSPEND = (fixnumshift+2)
475TCR_FLAG_BIT_PROPAGATE_EXCEPTION = (fixnumshift+3)
476TCR_FLAG_BIT_SUSPEND_ACK_PENDING = (fixnumshift+4)
477TCR_FLAG_BIT_PENDING_EXCEPTION = (fixnumshift+5)
478TCR_FLAG_BIT_FOREIGN_EXCEPTION = (fixnumshift+6)
479TCR_FLAG_BIT_PENDING_SUSPEND = (fixnumshift+7)       
480       
481r0 = 0
482r1 = 1
483r2 = 2
484r3 = 3
485r4 = 4
486r5 = 5
487r6 = 6
488r7 = 7
489r8 = 8
490r9 = 9
491r10 = 10
492r11 = 11
493r12 = 12
494r13 = 13
495r14 = 14
496r15 = 15
497r16 = 16
498r17 = 17
499r18 = 18
500r19 = 19
501r20 = 20
502r21 = 21
503r22 = 22
504r23 = 23
505r24 = 24
506r25 = 25
507r26 = 26
508r27 = 27
509r28 = 28
510r29 = 29
511r30 = 30
512r31 = 31
513
514/* Lisp code keeps 0.0 in fp_zero */
515define(`fp_zero',`f31')   /* a non-volatile reg as far as FFI is concerned. */
516define(`fp_s32conv',`f30')   /* for s32->fp conversion */
517       
518/* registers, as used in destrucuring-bind/macro-bind */
519
520define(`whole_reg',`temp1')
521define(`arg_reg',`temp3')
522define(`keyvect_reg',`temp2')
523define(`mask_req_start',`24')
524define(`mask_req_width',`8')
525define(`mask_opt_start',`16')
526define(`mask_opt_width',`8')
527define(`mask_key_start',`8')
528define(`mask_key_width',`8')
529define(`mask_initopt',`7')
530define(`mask_keyp',`6') /*  note that keyp can be true even when 0 keys. */
531define(`mask_aok',`5')
532define(`mask_restp',`4')
533
534ifdef(`DARWIN',`
535        define(`STACK_ALIGN',16)
536        define(`STACK_ALIGN_MASK',15)
537',`
538        define(`STACK_ALIGN',8)
539        define(`STACK_ALIGN_MASK',7)
540')
541
542define(`TCR_STATE_FOREIGN',1)
543define(`TCR_STATE_LISP',0)
544define(`TCR_STATE_EXCEPTION_WAIT',2)
545define(`TCR_STATE_EXCEPTION_RETURN',4)
546
547define(`RESERVATION_DISCHARGE',0x2004)
548
549
550       
551INTERRUPT_LEVEL_BINDING_INDEX = fixnumone
Note: See TracBrowser for help on using the repository browser.