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

Last change on this file since 16083 was 15620, checked in by gb, 6 years ago

Support t/nil operators in PPC backend.
Change image version for PPC32/PPC64.
LinuxPPC binaries.

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