source: release/1.9/source/lisp-kernel/arm-constants.s @ 16083

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

armcl. armcl.image: new binaries
compiler/ARM/arm-arch.lisp: add tcr.architecture-version. Bump fasl version,

image version.

compiler/ARM/arm-asm.lisp: don't define ARMv7-specific instructions.
compiler/ARM/arm-lap.lisp: new :opcode directive, assembles arbitrary word

in code section.

compiler/ARM/arm-lapmacros.lisp: don't use v7-specific instructions. Define

clrex, dmb as macros which test architecture version at runtime. Remove
some unused things.

compiler/ARM/arm-vinsns.lisp: don't use v7-specific instructions. Remove

some more unused things.

compiler/ARM/arm2.lisp: Remove still more unused things.
level-0/ARM/arm-bignum.lisp: don't use v7-specific instructions.
level-0/l0-cfm-support.lisp: hack to try to avoid treating dynamic linker

as a shared library on Linux. (Different dynamic linkers are used for
softfp/hard float on ARM; we don't a saved image to try to re-open the
wrong one.

level-1/arm-callback-support.lisp: don't use movw instruction in callback

trampolines.

lisp-kernel/arm-asmutils.s: don't use v7-specific instructions (unless we're

sure that we're on v7 or later.)

lisp-kernel/arm-constants.h: tcr.architecture_version. Bump image version.

Define ARM CPU architecture constants.

lisp-kernel/arm-constants.s: tcr.architecture_version.
lisp-kernel/arm-macros.s: define _clrex and _dmb macros which test

tcr.arm_architecture_version at runtime.

lisp-kernel/arm-spentry.s: use _clrex macro. In _SPcheck_fpu_exception,

look for offending instuction 4 bytes further before lr (change in
subprim call mechanism.)

lisp-kernel/linuxarm/Makefile: compile/assemble for ARMv6.
lisp-kernel/lisp_globals.s: don't need to define NUM_LISP_GLOBALS anymore.
lisp-kernel/pmcl-kernel.c: check_arm_cpu() accepts ARMv6 or later.
lisp-kernel/thread-manager.c: when creating a TCR on ARM, set

tcr.architecture_version to fixnum representation of architecture - 7 (so
ARMv6 is -1, ARMv7 is 0, etc.)

File size: 16.9 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       
18nbits_in_word = 32
19nbits_in_byte = 8
20ntagbits = 3    /* But only 2 are significant to lisp */
21nlisptagbits = 2
22nfixnumtagbits = 2
23num_subtag_bits = 8
24fixnumshift = 2
25fixnum_shift = 2
26fulltagmask = 7
27tagmask = 3
28fixnummask = 3
29subtag_mask = 0xff       
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/* registers.  These assignments may not be viable. */
45
46define(`imm0',`r0')             /* even, so ldrd/strd can use imm0/imm1 */
47define(`imm1',`r1')
48define(`imm2',`r2')
49/* rcontext = r3 can be used as an imm reg in certain contexts
50   (its value must be easily recovered, but that value never changes
51   during a thread's lifetime.)
52*/       
53define(`rcontext',`r3')         
54define(`arg_z',`r4')
55define(`arg_y',`r5')
56define(`arg_x',`r6')
57define(`temp0',`r7')
58define(`temp1',`r8')
59define(`temp2',`r9')
60define(`vsp',`r10')
61define(`fn',`r11')
62define(`allocptr',`r12')
63define(`sp',`r13')
64define(`lr',`r14')
65define(`pc',`r15')
66
67                                               
68nargregs = 3
69               
70define(`fname',`temp1')
71define(`nfn',`temp2')
72define(`next_method_context',`temp1')
73define(`nargs',`imm2')
74define(`allocbase',`temp0')     /* while consing */
75
76define(`double_float_zero',`d7')
77define(`single_float_zero',`s14')
78                       
79/* ARM conditions */
80eq = 0
81ne = 1
82cs = 2
83hs = cs       
84cc = 3
85lo = cc       
86mi = 4
87pl = 5
88vs = 6
89vc = 7
90hi = 8
91ls = 9
92ge = 10
93lt = 11
94gt = 12
95le = 13
96al = 14
97
98/* Tags. */
99/* There are two-bit tags and three-bit tags. */
100/* A FULLTAG is the value of the low three bits of a tagged object. */
101/* A TAG is the value of the low two bits of a tagged object. */
102/* A TYPECODE is either a TAG or the value of a "tag-misc" objects header-byte. */
103
104/* There are 4 primary TAG values.  Any object which lisp can "see" can be classified */
105/* by its TAG.  (Some headers have FULLTAGS that are congruent modulo 4 with the */
106/* TAGS of other objects, but lisp can't "see" headers.) */
107
108
109tag_fixnum = 0  /* All fixnums, whether odd or even */
110tag_list = 1    /* Conses and NIL */
111tag_misc = 2    /* Heap-consed objects other than lists: vectors, symbols, functions, floats ... */
112tag_imm = 3     /* Immediate-objects: characters, UNBOUND, other markers. */
113
114
115/*  And there are 8 FULLTAG values.  Note that NIL has its own FULLTAG (congruent mod 4 to tag-list), */
116/*  that FULLTAG-MISC is > 4 (so that code-vector entry-points can be branched to, since the low */
117/*  two bits of the PC are ignored) and that both FULLTAG-MISC and FULLTAG-IMM have header fulltags */
118/*  that share the same TAG. */
119/*  Things that walk memory (and the stack) have to be careful to look at the FULLTAG of each */
120/*  object that they see. */
121
122
123fulltag_even_fixnum = 0 /* I suppose EVENP/ODDP might care; nothing else does. */
124fulltag_nil = 1 /* NIL and nothing but.  (Note that there's still a hidden NILSYM.) */
125fulltag_nodeheader = 2  /* Header of heap_allocated object that contains lisp_object pointers */
126fulltag_imm = 3 /* a "real" immediate object.  Shares TAG with fulltag_immheader. */
127fulltag_odd_fixnum = 4  /* */
128fulltag_cons = 5        /* a real (non_null) cons.  Shares TAG with fulltag_nil. */
129fulltag_misc = 6        /* Pointer "real" tag_misc object.  Shares TAG with fulltag_nodeheader. */
130fulltag_immheader = 7   /* Header of heap-allocated object that contains unboxed data. */
131
132nil_value = (0x04000000+fulltag_nil)
133misc_bias = fulltag_misc
134cons_bias = fulltag_cons   
135       
136unsigned_byte_24_mask = 0xe0000003 /* bits that should be clear in a boxed */
137                                   /* (UNSIGNED-BYTE 24) */
138           
139
140/* Functions are of (conceptually) unlimited size. */
141        _struct(_function,-misc_bias)
142         _node(header)
143         _node(entrypoint)      /* codevector & ~tagmask */
144         _node(codevector)
145        _ends
146
147        _struct(tsp_frame,0)
148         _node(backlink)
149         _node(type)
150         _struct_label(fixed_overhead)
151         _struct_label(data_offset)
152        _ends
153
154/* Order of CAR and CDR doesn't seem to matter much - there aren't */
155/* too many tricks to be played with predecrement/preincrement addressing. */
156/* Keep them in the confusing MCL 3.0 order, to avoid confusion. */
157        _struct(cons,-cons_bias)
158         _node(cdr)
159         _node(car)
160        _ends
161       
162misc_header_offset = -fulltag_misc
163misc_subtag_offset = misc_header_offset         /* low byte of header */
164misc_data_offset = misc_header_offset+4         /* first word of data */
165misc_dfloat_offset = misc_header_offset+8               /* double-floats are doubleword-aligned */
166
167max_64_bit_constant_index = ((0x0fff + misc_dfloat_offset)>>3)
168max_32_bit_constant_index = ((0x0fff + misc_data_offset)>>2)
169max_16_bit_constant_index = ((0x0fff + misc_data_offset)>>1)
170max_8_bit_constant_index = (0x0fff + misc_data_offset)
171max_1_bit_constant_index = ((0x0fff + misc_data_offset)<<5)
172
173/* T is almost adjacent to NIL: since NIL is a misaligned CONS, it spans */
174/* two doublewords.  The arithmetic difference between T and NIL is */
175/* such that the least-significant bit and exactly one other bit is */
176/* set in the result. */
177
178t_offset = ((dnode_size-fulltag_nil)+fulltag_misc)
179t_value = nil_value+t_offset
180
181/* The order in which various header values are defined is significant in several ways: */
182/* 1) Numeric subtags precede non-numeric ones; there are further orderings among numeric subtags. */
183/* 2) All subtags which denote CL arrays are preceded by those that don't, */
184/*    with a further ordering which requires that (< header-arrayH header-vectorH ,@all-other-CL-vector-types) */
185/* 3) The element-size of ivectors is determined by the ordering of ivector subtags. */
186/* 4) All subtags are >= fulltag-immheader . */
187
188define(`define_subtag',`
189subtag_$1 = $2|($3<<ntagbits)')
190       
191define(`define_imm_subtag',`
192        define_subtag($1,fulltag_immheader,$2)')
193
194       
195define(`define_node_subtag',`
196        define_subtag($1,fulltag_nodeheader,$2)')
197
198               
199/*Immediate subtags. */
200        define_subtag(stack_alloc_marker,fulltag_imm,1)
201        define_subtag(lisp_frame_marker,fulltag_imm,2)
202        define_subtag(character,fulltag_imm,9)
203        define_subtag(unbound,fulltag_imm,6)
204        define_subtag(illegal,fulltag_imm,10)
205        define_subtag(go_tag,fulltag_imm,12)
206        define_subtag(block_tag,fulltag_imm,24)
207        define_subtag(vsp_protect,fulltag_imm,7)
208        define_subtag(no_thread_local_binding,fulltag_imm,30)
209unbound_marker = subtag_unbound
210undefined = unbound_marker
211illegal_marker = subtag_illegal
212no_thread_local_binding_marker = subtag_no_thread_local_binding
213lisp_frame_marker = subtag_lisp_frame_marker
214stack_alloc_marker = subtag_stack_alloc_marker       
215       
216
217/*Numeric subtags. We want to keep these small, so that things like
218  NUMBERP can do LOGBITP of a bitmask that fits in a machine word/fixnum,
219  but we don't want to assume that all small typecodes are numbers.
220  Trying to enforce that assumption has wasted a few typecodes, and it's
221  not like we have so many that we can afford to do that.
222*/       
223
224        define_imm_subtag(bignum,0)
225        define_node_subtag(ratio,1)
226        define_imm_subtag(single_float,1)
227        define_imm_subtag(double_float,2)
228        define_node_subtag(complex,3)
229
230
231
232/* CL array types.  There are more immediate types than node types; all CL array subtags must be > than */
233/* all non-CL-array subtags.  So we start by defining the immediate subtags in decreasing order, starting */
234/* with that subtag whose element size isn't an integral number of bits and ending with those whose */
235/* element size - like all non-CL-array fulltag-immheader types - is 32 bits. */
236
237        define_imm_subtag(bit_vector,31)
238        define_imm_subtag(double_float_vector,30)
239        define_imm_subtag(s16_vector,29)
240        define_imm_subtag(u16_vector,28)
241min_16_bit_ivector_subtag = subtag_u16_vector
242max_16_bit_ivector_subtag = subtag_s16_vector
243        define_imm_subtag(s8_vector,26)
244        define_imm_subtag(u8_vector,25)
245min_8_bit_ivector_subtag = subtag_u8_vector
246max_8_bit_ivector_subtag = fulltag_immheader|(27<<ntagbits)
247        define_imm_subtag(simple_base_string,24)
248        define_imm_subtag(fixnum_vector,23)
249        define_imm_subtag(s32_vector,22)
250        define_imm_subtag(u32_vector,21)
251        define_imm_subtag(single_float_vector,20)
252max_32_bit_ivector_subtag = fulltag_immheader|(24<<ntagbits)
253min_cl_ivector_subtag = subtag_single_float_vector
254
255
256        define_node_subtag(vectorH,20)
257        define_node_subtag(arrayH,19)
258        define_node_subtag(simple_vector,21)
259min_vector_subtag = subtag_vectorH
260min_array_subtag = subtag_arrayH
261
262/* So, we get the remaining subtags (n: (n > max-numeric-subtag) & (n < min-array-subtag)) */
263/* for various immediate/node object types. */
264
265        define_imm_subtag(macptr,3)
266        define_imm_subtag(dead_macptr,4)
267        define_imm_subtag(code_vector,5)
268        define_imm_subtag(creole,6)
269
270max_non_array_imm_subtag = (18<<ntagbits)|fulltag_immheader
271        define_node_subtag(pseudofunction,0)
272        define_node_subtag(catch_frame,4)
273        define_node_subtag(function,5)
274        define_node_subtag(basic_stream,6)
275        define_node_subtag(symbol,7)
276        define_node_subtag(lock,8)
277        define_node_subtag(hash_vector,9)
278        define_node_subtag(pool,10)
279        define_node_subtag(weak,11)
280        define_node_subtag(package,12)
281        define_node_subtag(slot_vector,13)
282        define_node_subtag(instance,14)
283        define_node_subtag(struct,15)
284        define_node_subtag(istruct,16)
285        define_node_subtag(value_cell,17)
286        define_node_subtag(xfunction,18)
287max_non_array_node_subtag = (18<<ntagbits)|fulltag_immheader
288       
289/* The objects themselves look something like this: */
290        _structf(ratio)
291         _node(numer)
292         _node(denom)
293        _endstructf
294
295        _structf(single_float)
296         _word(value)
297        _endstructf
298
299        _structf(double_float)
300         _word(pad)
301         _dword(value)
302        _endstructf
303
304        _structf(symbol)
305         _node(pname)
306         _node(vcell)
307         _node(fcell)
308         _node(package_predicate)
309         _node(flags)
310         _node(plist)
311         _node(binding_index)
312        _endstructf
313
314        _structf(catch_frame)
315         _node(link)            /* backpointer to previous catch frame */
316         _node(mvflag)          /* 0 if single-valued catch, fixnum 1 otherwise */
317         _node(catch_tag)       /* #<unbound> -> unwind-protect, else catch */
318         _node(db_link)         /* head of special-binding chain */
319         _node(xframe)          /* exception frame chain */
320         _node(last_lisp_frame) /* from TCR */
321         _node(code_vector)     /* of fn in lisp_frame, or 0 */
322        _endstructf
323
324        _structf(macptr)
325         _node(address)
326         _node(domain)
327         _node(type)
328        _endstructf
329
330        _structf(vectorH)
331         _node(logsize)
332         _node(physsize)
333         _node(data_vector)
334         _node(displacement)
335         _node(flags)
336        _endstructf
337
338        _structf(arrayH)
339         _node(rank)
340         _node(physsize)
341         _node(data_vector)
342         _node(displacement)
343         _node(flags)
344         _struct_label(dim0)
345        _endstructf
346       
347       
348               
349        _struct(lisp_frame,0)
350         _node(marker)
351         _node(savevsp) 
352         _node(savefn) 
353         _node(savelr) 
354        _ends
355       
356
357
358        _struct(vector,-fulltag_misc)
359         _node(header)
360         _struct_label(data)
361        _ends
362
363        _struct(binding,0)
364         _node(link)
365         _node(sym)
366         _node(val)
367        _ends
368
369/* Indices in %builtin-functions% */
370_builtin_plus = 0       /* +-2 */
371_builtin_minus = 1      /* --2 */
372_builtin_times = 2      /* *-2 */
373_builtin_div = 3        /* /-2 */
374_builtin_eq = 4         /* =-2 */
375_builtin_ne = 5         /* /-2 */
376_builtin_gt = 6         /* >-2 */
377_builtin_ge = 7         /* >=-2 */
378_builtin_lt = 8         /* <-2 */
379_builtin_le = 9         /* <=-2 */
380_builtin_eql = 10       /* eql */
381_builtin_length = 11    /* length */
382_builtin_seqtype = 12   /* sequence-type */
383_builtin_assq = 13      /* assq */
384_builtin_memq = 14      /* memq */
385_builtin_logbitp = 15   /* logbitp */
386_builtin_logior = 16    /* logior-2 */
387_builtin_logand = 17    /* logand-2 */
388_builtin_ash = 18       /* ash */
389_builtin_negate = 19    /* %negate */
390_builtin_logxor = 20    /* logxor-2 */
391_builtin_aref1 = 21     /* %aref1 */
392_builtin_aset1 = 22     /* %aset1 */
393
394nrs_origin = (dnode_size-fulltag_nil)
395nrs_symbol_fulltag = fulltag_misc       
396lisp_globals_limit = -(fulltag_nil+dnode_size)
397       
398        include(lisp_globals.s)
399       
400define(`def_header',`
401$1 = ($2<<num_subtag_bits)|$3')
402
403        def_header(single_float_header,single_float.element_count,subtag_single_float)
404        def_header(double_float_header,double_float.element_count,subtag_double_float)
405        def_header(one_digit_bignum_header,1,subtag_bignum)
406        def_header(two_digit_bignum_header,2,subtag_bignum)
407        def_header(three_digit_bignum_header,3,subtag_bignum)
408        def_header(symbol_header,symbol.element_count,subtag_symbol)
409        def_header(value_cell_header,1,subtag_value_cell        )
410        def_header(macptr_header,macptr.element_count,subtag_macptr)
411        def_header(vectorH_header,vectorH.element_count,subtag_vectorH)
412
413        include(errors.s)
414
415/* Symbol bits that we care about */
416sym_vbit_bound = (0+fixnum_shift)
417sym_vbit_bound_mask = (1<<sym_vbit_bound)
418sym_vbit_const = (1+fixnum_shift)
419sym_vbit_const_mask = (1<<sym_vbit_const)
420
421        _struct(area,0)
422         _node(pred)
423         _node(succ)
424         _node(low)
425         _node(high)
426         _node(active)
427         _node(softlimit)
428         _node(hardlimit)
429         _node(code)
430         _node(markbits)
431         _node(ndwords)
432         _node(older)
433         _node(younger)
434         _node(h)
435         _node(sofprot)
436         _node(hardprot)
437         _node(owner)
438         _node(refbits)
439         _node(nextref)
440        _ends
441
442
443
444
445TCR_BIAS = 0
446/* TCR_BIAS = 0x7000 */
447       
448/*  Thread context record. */
449
450        _struct(tcr,-TCR_BIAS)
451         _node(prev)            /* in doubly-linked list */
452         _node(next)            /* in doubly-linked list */
453         _node(lisp_fpscr)      /* lisp thread's fpscr (in low word) */
454         _node(pad)
455         _node(db_link)         /* special binding chain head */
456         _node(catch_top)       /* top catch frame */
457         _node(save_vsp)        /* VSP when in foreign code */
458         _node(save_tsp)        /* TSP when in foreign code */
459         _node(cs_area)         /* cstack area pointer */
460         _node(vs_area)         /* vstack area pointer */
461         _node(last_lisp_frame) /* when in foreign code */
462         _node(cs_limit)        /* cstack overflow limit */
463         _node(bytes_consed_low)
464         _node(bytes_consed_high)
465         _node(log2_allocation_quantum)
466         _node(interrupt_pending)
467         _node(xframe)          /* per-thread exception frame list */
468         _node(errno_loc)       /* per-thread  errno location */
469         _node(ffi_exception)   /* fpscr exception bits from ff-call */
470         _node(osid)            /* OS thread id */
471         _node(valence)         /* odd when in foreign code */
472         _node(foreign_exception_status)
473         _node(native_thread_info)
474         _node(native_thread_id)
475         _node(last_allocptr)
476         _node(save_allocptr)
477         _node(save_allocbase)
478         _node(reset_completion)
479         _node(activate)
480         _node(suspend_count)
481         _node(suspend_context)
482         _node(pending_exception_context)
483         _node(suspend)         /* semaphore for suspension notify */
484         _node(resume)          /* sempahore for resumption notify */
485         _node(flags)     
486         _node(gc_context)
487         _node(termination_semaphore)
488         _node(unwinding)
489         _node(tlb_limit)
490         _node(tlb_pointer)     /* Consider using tcr+N as tlb_pointer */
491         _node(shutdown_count)
492         _node(safe_ref_address)
493         _node(architecture_version)
494        _ends
495
496TCR_FLAG_BIT_FOREIGN = fixnum_shift       
497TCR_FLAG_BIT_AWAITING_PRESET = (fixnum_shift+1)
498TCR_FLAG_BIT_ALT_SUSPEND = (fixnumshift+2)
499TCR_FLAG_BIT_PROPAGATE_EXCEPTION = (fixnumshift+3)
500TCR_FLAG_BIT_SUSPEND_ACK_PENDING = (fixnumshift+4)
501TCR_FLAG_BIT_PENDING_EXCEPTION = (fixnumshift+5)
502TCR_FLAG_BIT_FOREIGN_EXCEPTION = (fixnumshift+6)
503TCR_FLAG_BIT_PENDING_SUSPEND = (fixnumshift+7) 
504TCR_FLAG_BIT_ALLOCPTR_FOREIGN = (fixnumshift+8)
505       
506r0 = 0
507r1 = 1
508r2 = 2
509r3 = 3
510r4 = 4
511r5 = 5
512r6 = 6
513r7 = 7
514r8 = 8
515r9 = 9
516r10 = 10
517r11 = 11
518r12 = 12
519r13 = 13
520sp = 13       
521r14 = 14
522lr = 14
523r15 = 15
524pc = 15
525               
526       
527       
528/* registers, as used in destrucuring-bind/macro-bind */
529
530define(`arg_reg',`arg_z')
531define(`keyvect_reg',`temp2')
532define(`mask_keyp',`(1<<25)') /*  note that keyp can be true even when 0 keys. */
533define(`mask_aok',`(1<<26)')
534define(`mask_restp',`(1<<27)')
535define(`mask_aok_seen',`(1<<30)')
536define(`mask_aok_this',`(1<<31)')       
537define(`mask_unknown_keyword_seen',`(1<<28)')               
538define(`mask_initopt',`(1<<29)')
539
540define(`STACK_ALIGN',8)
541define(`STACK_ALIGN_MASK',7)
542
543
544define(`TCR_STATE_FOREIGN',1)
545define(`TCR_STATE_LISP',0)
546define(`TCR_STATE_EXCEPTION_WAIT',2)
547define(`TCR_STATE_EXCEPTION_RETURN',4)
548
549
550
551/* extended type codes, for UUOs.  Shouldn't conflict with defined subtags */
552
553xtype_unsigned_byte_24 = 252
554xtype_array2d = 248
555xtype_array3d = 244
556xtype_integer = 4
557xtype_s64 = 8
558xtype_u64 = 12
559xtype_s32 = 16
560xtype_u32 = 20
561xtype_s16 = 24
562xtype_u16 = 28
563xtype_s8 = 32
564xtype_u8 = 36
565xtype_bit = 40                               
566                                               
567stack_alloc_limit = 0x8000                       
568                       
569INTERRUPT_LEVEL_BINDING_INDEX = fixnumone
570VOID_ALLOCPTR = 0xfffffff8
Note: See TracBrowser for help on using the repository browser.