source: branches/arm/lisp-kernel/arm-constants.h @ 13645

Last change on this file since 13645 was 13645, checked in by gb, 10 years ago

Some new files (just started to define things based on ppc32 versions,
tried to pick off low-hanging fruit) and changes. (Way too early to
consider changes significant.)

File size: 11.1 KB
Line 
1/*
2   Copyright (C) 2009 Clozure Associates
3   Copyright (C) 1994-2001 Digitool, Inc
4   This file is part of Clozure CL. 
5
6   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
7   License , known as the LLGPL and distributed with Clozure CL as the
8   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
9   which is distributed with Clozure CL as the file "LGPL".  Where these
10   conflict, the preamble takes precedence. 
11
12   Clozure CL is referenced in the preamble as the "LIBRARY."
13
14   The LLGPL is also available online at
15   http://opensource.franz.com/preamble.html
16*/
17
18#include "constants.h"
19
20#define arg_z 0
21#define arg_y 1
22#define arg_x 2
23#define temp0 3
24#define temp1 4
25#define temp2 5
26#define fn    6
27#define rcontext 7
28#define imm0 8
29#define imm1 9
30#define imm2 10
31#define allocptr 11
32#define vsp 12
33#define sp 13
34#define lr 14
35#define pc 15
36
37#define fname temp1
38#define nfn temp2
39#define next_method_context temp1
40#define nargs imm2
41#define allocbase temp0         /* while consing */
42
43#define nbits_in_word 32
44#define log2_nbits_in_word 5
45#define nbits_in_byte 8
46#define ntagbits 3      /* But only 2 are significant to lisp */
47#define nlisptagbits 2
48#define nfixnumtagbits 2
49#define num_subtag_bits 8
50#define fixnumshift 2
51#define fixnum_shift 2
52#define fulltagmask 7
53#define tagmask  3
54#define fixnummask 3
55#define subtagmask ((1<<num_subtag_bits)-1)
56#define ncharcodebits 24        /* Only the low 8 are used currently */
57#define charcode_shift (nbits_in_word-ncharcodebits)
58#define node_size 4
59#define node_shift 2
60
61
62/*  Tags. */
63/*  There are two-bit tags and three-bit tags. */
64/*  A FULLTAG is the value of the low three bits of a tagged object. */
65/*  A TAG is the value of the low two bits of a tagged object. */
66/*  A TYPECODE is either a TAG or the value of a "tag-misc" object's header-byte. */
67
68/*  There are 4 primary TAG values.  Any object which lisp can "see" can be classified  */
69/*  by its TAG.  (Some headers have FULLTAGS that are congruent modulo 4 with the */
70/*  TAGS of other objects, but lisp can't "see" headers.) */
71
72
73#define tag_fixnum 0    /*  All fixnums, whether odd or even */
74#define tag_list 1      /*  Conses and NIL */
75#define tag_misc 2      /*  Heap-consed objects other than lists: vectors, symbols, functions, floats ... */
76#define tag_imm  3      /*  Immediate-objects: characters, UNBOUND, other markers. */
77
78/*  And there are 8 FULLTAG values.  Note that NIL has its own FULLTAG (congruent mod 4 to tag-list), */
79/*  that FULLTAG-MISC is > 4 (so that code-vector entry-points can be branched to, since the low */
80/*  two bits of the PC are ignored) and that both FULLTAG-MISC and FULLTAG-IMM have header fulltags */
81/*  that share the same TAG. */
82/*  Things that walk memory (and the stack) have to be careful to look at the FULLTAG of each */
83/*  object that they see. */
84
85#define fulltag_even_fixnum 0   /*  I suppose EVENP/ODDP might care; nothing else does. */
86#define fulltag_cons     1      /*  a real (non_null) cons.  Shares TAG with fulltag_nil. */
87#define fulltag_nodeheader 2    /*  Header of heap_allocated object that contains lisp_object pointers */
88#define fulltag_imm      3      /*  a "real" immediate object.  Shares TAG with fulltag_immheader. */
89#define fulltag_odd_fixnum 4    /*   */
90#define fulltag_nil      5      /*  NIL and nothing but.  (Note that there's still a hidden NILSYM.) */
91#define fulltag_misc     6      /*  Pointer "real" tag_misc object.  Shares TAG with fulltag_nodeheader. */
92#define fulltag_immheader 7     /*  Header of heap-allocated object that contains unboxed data. */
93
94
95
96
97
98#define misc_header_offset -fulltag_misc
99/* Most ARM OSes run in little-endian mode; most ARMs can run
100   in either endianness.  Assume little-endian, for now. */
101#define misc_subtag_offset misc_header_offset           /*  low byte of header */
102#define misc_data_offset misc_header_offset+4           /*  first word of data */
103#define misc_dfloat_offset misc_header_offset+8         /*  double-floats are doubleword-aligned */
104
105#define max_64_bit_constant_index ((0x0fff + misc_dfloat_offset)>>3)
106#define max_32_bit_constant_index ((0x0fff + misc_data_offset)>>2)
107#define max_16_bit_constant_index ((0x0fff + misc_data_offset)>>1)
108#define max_8_bit_constant_index (0x0fff + misc_data_offset)
109#define max_1_bit_constant_index ((0x0fff + misc_data_offset)<<5)
110
111/*  T is almost adjacent to NIL: since NIL is a misaligned CONS, it spans */
112/*  two doublewords.  The arithmetic difference between T and NIL is */
113/*  such that the least-significant bit and exactly one other bit is */
114/*  set in the result. */
115
116#define t_offset (8+(8-fulltag_nil)+fulltag_misc)
117#define t_value (lisp_nil+t_offset)
118
119/*  The order in which various header values are defined is significant in several ways: */
120/*  1) Numeric subtags precede non-numeric ones; there are further orderings among numeric subtags. */
121/*  2) All subtags which denote CL arrays are preceded by those that don't, */
122/*     with a further ordering which requires that (< header-arrayH header-vectorH ,@all-other-CL-vector-types) */
123/*  3) The element-size of ivectors is determined by the ordering of ivector subtags. */
124/*  4) All subtags are >= fulltag-immheader . */
125
126#define SUBTAG(tag,subtag) ((tag) | ((subtag) << ntagbits))
127#define IMM_SUBTAG(subtag) SUBTAG(fulltag_immheader,(subtag))
128#define NODE_SUBTAG(subtag) SUBTAG(fulltag_nodeheader,(subtag))
129
130       
131/* Numeric subtags. */
132
133#define subtag_bignum IMM_SUBTAG(0)
134#define min_numeric_subtag subtag_bignum
135
136#define subtag_ratio NODE_SUBTAG(1)
137#define max_rational_subtag subtag_ratio
138
139#define subtag_single_float IMM_SUBTAG(1)
140#define subtag_double_float IMM_SUBTAG(2)
141#define min_float_subtag subtag_single_float
142#define max_float_subtag subtag_double_float
143#define max_real_subtag subtag_double_float
144
145#define subtag_complex NODE_SUBTAG(3)
146#define max_numeric_subtag subtag_complex
147
148
149/*  CL array types.  There are more immediate types than node types; all CL array subtags must be > than */
150/*  all non-CL-array subtags.  So we start by defining the immediate subtags in decreasing order, starting */
151/*  with that subtag whose element size isn't an integral number of bits and ending with those whose */
152/*  element size - like all non-CL-array fulltag-immheader types - is 32 bits. */
153
154#define subtag_bit_vector IMM_SUBTAG(31)
155#define subtag_double_float_vector IMM_SUBTAG(30)
156#define subtag_s16_vector IMM_SUBTAG(29)
157#define subtag_u16_vector IMM_SUBTAG(28)
158#define min_16_bit_ivector_subtag subtag_u16_vector
159#define max_16_bit_ivector_subtag subtag_s16_vector
160
161#define subtag_s8_vector IMM_SUBTAG(26)
162#define subtag_u8_vector IMM_SUBTAG(25)
163#define min_8_bit_ivector_subtag subtag_u8_vector
164#define max_8_bit_ivector_subtag IMM_SUBTAG(27)
165
166#define subtag_simple_base_string IMM_SUBTAG(24)
167#define subtag_fixnum_vector IMM_SUBTAG(23)
168#define subtag_s32_vector IMM_SUBTAG(22)
169#define subtag_u32_vector IMM_SUBTAG(21)
170#define subtag_single_float_vector IMM_SUBTAG(20)
171#define max_32_bit_ivector_subtag IMM_SUBTAG(24)
172#define min_cl_ivector_subtag subtag_single_float_vector
173
174
175#define subtag_vectorH NODE_SUBTAG(20)
176#define subtag_arrayH NODE_SUBTAG(19)
177#define subtag_simple_vector NODE_SUBTAG(21)    /*  Only one such subtag) */
178#define min_vector_subtag subtag_vectorH
179#define min_array_subtag subtag_arrayH
180
181/*  So, we get the remaining subtags (n: (n > max-numeric-subtag) & (n < min-array-subtag)) */
182/*  for various immediate/node object types. */
183
184#define subtag_macptr IMM_SUBTAG(3)
185#define min_non_numeric_imm_subtag subtag_macptr
186
187#define subtag_dead_macptr IMM_SUBTAG(4)
188#define subtag_code_vector IMM_SUBTAG(5)
189#define subtag_creole IMM_SUBTAG(6)
190
191#define max_non_array_imm_subtag ((19<<ntagbits)|fulltag_immheader)
192
193#define subtag_catch_frame NODE_SUBTAG(4)
194#define subtag_function NODE_SUBTAG(5)
195#define subtag_basic_stream NODE_SUBTAG(6)
196#define subtag_symbol NODE_SUBTAG(7)
197#define subtag_lock NODE_SUBTAG(8)
198#define subtag_hash_vector NODE_SUBTAG(9)
199#define subtag_pool NODE_SUBTAG(10)
200#define subtag_weak NODE_SUBTAG(11)
201#define subtag_package NODE_SUBTAG(12)
202#define subtag_slot_vector NODE_SUBTAG(13)
203#define subtag_instance NODE_SUBTAG(14)
204#define subtag_struct NODE_SUBTAG(15)
205#define subtag_istruct NODE_SUBTAG(16)
206#define max_non_array_node_subtag ((19<<ntagbits)|fulltag_immheader)
207       
208
209typedef struct double_float {
210  LispObj header;
211  LispObj pad;
212  LispObj value_high;
213  LispObj value_low;
214} double_float;
215
216typedef struct single_float {
217  LispObj header;
218  LispObj value;
219} single_float;
220
221
222/*
223  The GC also needs to know what a catch_frame looks like.
224*/
225
226typedef struct catch_frame {
227  LispObj header;
228  LispObj catch_tag;
229  LispObj link;
230  LispObj mvflag;
231  LispObj csp;
232  LispObj db_link;
233  LispObj regs[8];
234  LispObj xframe;
235  LispObj tsp_segment;
236} catch_frame;
237
238#define catch_frame_element_count ((sizeof(catch_frame)/sizeof(LispObj))-1)
239#define catch_frame_header make_header(subtag_catch_frame,catch_frame_element_count)
240
241#define unbound SUBTAG(fulltag_imm, 6)
242#define undefined unbound
243#define unbound_marker unbound
244#define subtag_character SUBTAG(fulltag_imm, 9)
245#define slot_unbound SUBTAG(fulltag_imm, 10)
246#define slot_unbound_marker slot_unbound
247#define no_thread_local_binding_marker SUBTAG(fulltag_imm,30)
248
249/*
250  All exception frames in a thread are linked together
251  */
252typedef struct xframe_list {
253  ExceptionInformation *curr;
254  struct xframe_list *prev;
255} xframe_list;
256
257#include "lisp-errors.h"
258
259
260
261
262#define nil_value (0x10000000+fulltag_nil)
263
264#define TCR_BIAS (0)
265
266typedef struct tcr {
267  struct tcr *next;
268  struct tcr *prev;
269  union {
270    double d;
271    struct {unsigned h, l;} words;
272  } lisp_fpscr;                 /* lisp thread's fpscr (in low word) */
273  special_binding *db_link;     /* special binding chain head */
274  LispObj catch_top;            /* top catch frame */
275  LispObj *save_vsp;            /* VSP when in foreign code */
276  LispObj *save_tsp;            /* TSP when in foreign code */
277  struct area *cs_area;         /* cstack area pointer */
278  struct area *vs_area;         /* vstack area pointer */
279  struct area *ts_area;         /* tstack area pointer */
280  LispObj cs_limit;             /* stack overflow limit */
281  unsigned long long bytes_allocated;
282  natural log2_allocation_quantum;  /* for per-thread consing */
283  int interrupt_pending;        /* deferred-interrupt pending */
284  xframe_list *xframe;          /* exception-frame linked list */
285  int *errno_loc;               /* per-thread (?) errno location */
286  LispObj ffi_exception;        /* fpscr bits from ff-call */
287  LispObj osid;                 /* OS thread id */
288  int valence;                  /* odd when in foreign code */
289  int foreign_exception_status; /* non-zero -> call lisp_exit_hook */
290  void *native_thread_info;     /* platform-dependent */
291  void *native_thread_id;       /* mach_thread_t, pid_t, etc. */
292  void *last_allocptr;
293  void *save_allocptr;
294  void *save_allocbase;
295  void *reset_completion;
296  void *activate;
297  int suspend_count;
298  ExceptionInformation *suspend_context;
299  ExceptionInformation *pending_exception_context;
300  void *suspend;                /* suspension semaphore */
301  void *resume;                 /* resumption semaphore */
302  natural flags;
303  ExceptionInformation *gc_context;
304  void *termination_semaphore;
305  int unwinding;
306  unsigned tlb_limit;
307  LispObj *tlb_pointer;
308  unsigned shutdown_count;
309  void *safe_ref_address;
310} TCR;
311
312/*
313  These were previously global variables.  There are lots of implicit
314  assumptions about the size of a heap segment, so they might as well
315  be constants.
316*/
317
318#define heap_segment_size 0x00010000
319#define log2_heap_segment_size 16
320
321
322
323
324
325
Note: See TracBrowser for help on using the repository browser.