source: trunk/source/lisp-kernel/ppc-constants64.h

Last change on this file was 16782, checked in by rme, 4 years ago

Undo r16779.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.1 KB
Line 
1/*
2 * Copyright 1994-2009 Clozure Associates
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18#include "ppc-constants.h"
19
20#define rcontext 2
21
22#define nbits_in_word 64L
23#define log2_nbits_in_word 6L
24#define nbits_in_byte 8L
25#define ntagbits 4L
26#define nlisptagbits 3L
27#define nfixnumtagbits 2L
28#define num_subtag_bits 8L
29#define fixnumshift 3L
30#define fixnum_shift 3L
31#define fulltagmask 15L
32#define tagmask  7L
33#define fixnummask 3
34#define subtagmask ((1L<<num_subtag_bits)-1L)
35#define ncharcodebits 8L
36#define charcode_shift 8L
37#define node_size 8L
38#define node_shift 3L
39
40#define lowtagmask 3L
41#define lowtag_mask lowtagmask
42
43#define lowtag_primary 0L
44#define lowtag_imm 1L
45#define lowtag_immheader 2L
46#define lowtag_nodeheader 3L
47
48#define tag_fixnum 0L
49
50#define fulltag_even_fixnum 0L
51#define fulltag_imm_0 1L
52#define fulltag_immheader_0 2L
53#define fulltag_nodeheader_0 3L
54#define fulltag_cons 4L
55#define fulltag_imm_1 5L
56#define fulltag_immheader_1 6L
57#define fulltag_nodeheader_1 7L
58#define fulltag_odd_fixnum 8L
59#define fulltag_imm_2 9L
60#define fulltag_immheader_2 10L
61#define fulltag_nodeheader_2 11L
62#define fulltag_misc 12L
63#define fulltag_imm_3 13L
64#define fulltag_immheader_3 14L
65#define fulltag_nodeheader_3 15L
66
67#define SUBTAG(tag,subtag) ((tag) | ((subtag) << ntagbits))
68#define cl_array_subtag_mask 0x80L
69#define CL_ARRAY_SUBTAG(tag,subtag) (cl_array_subtag_mask | (SUBTAG(tag,subtag)))
70
71#define subtag_arrayH CL_ARRAY_SUBTAG(fulltag_nodeheader_1,0L)
72#define subtag_vectorH CL_ARRAY_SUBTAG(fulltag_nodeheader_2,0L)
73#define subtag_simple_vector CL_ARRAY_SUBTAG(fulltag_nodeheader_3,0L)
74#define min_vector_subtag subtag_vectorH       
75
76#define ivector_class_64_bit fulltag_immheader_3
77#define ivector_class_32_bit fulltag_immheader_2
78#define ivector_class_other_bit fulltag_immheader_1
79#define ivector_class_8_bit fulltag_immheader_0
80
81#define subtag_s64_vector CL_ARRAY_SUBTAG(ivector_class_64_bit,1)
82#define subtag_u64_vector CL_ARRAY_SUBTAG(ivector_class_64_bit,2)
83#define subtag_fixnum_vector CL_ARRAY_SUBTAG(ivector_class_64_bit,3)
84#define subtag_double_float_vector CL_ARRAY_SUBTAG(ivector_class_64_bit,4)
85#define subtag_complex_single_float_vector CL_ARRAY_SUBTAG(ivector_class_64_bit,5)
86#define subtag_s32_vector CL_ARRAY_SUBTAG(ivector_class_32_bit,1)
87#define subtag_u32_vector CL_ARRAY_SUBTAG(ivector_class_32_bit,2)
88#define subtag_single_float_vector CL_ARRAY_SUBTAG(ivector_class_32_bit,3)
89#define subtag_simple_base_string CL_ARRAY_SUBTAG(ivector_class_32_bit,5)
90#define subtag_s16_vector CL_ARRAY_SUBTAG(ivector_class_other_bit,1)
91#define subtag_u16_vector CL_ARRAY_SUBTAG(ivector_class_other_bit,2)
92#define subtag_complex_double_float_vector CL_ARRAY_SUBTAG(ivector_class_other_bit,3)
93#define subtag_bit_vector CL_ARRAY_SUBTAG(ivector_class_other_bit,7)
94#define subtag_s8_vector CL_ARRAY_SUBTAG(ivector_class_8_bit,1)
95#define subtag_u8_vector CL_ARRAY_SUBTAG(ivector_class_8_bit,2)
96
97/* There's some room for expansion in non-array ivector space. */
98#define subtag_macptr SUBTAG(ivector_class_64_bit,1)
99#define subtag_dead_macptr SUBTAG(ivector_class_64_bit,2)
100#define subtag_code_vector SUBTAG(ivector_class_32_bit,0)
101#define subtag_xcode_vector SUBTAG(ivector_class_32_bit,1)
102#define subtag_bignum SUBTAG(ivector_class_32_bit,2)
103#define subtag_double_float SUBTAG(ivector_class_32_bit,3)
104#define subtag_complex_single_float SUBTAG(ivector_class_32_bit,4)
105#define subtag_complex_double_float SUBTAG(ivector_class_32_bit,5)
106
107/*
108 Size doesn't matter for non-CL-array gvectors; I can't think of a good
109 reason to classify them in any particular way.  Let's put funcallable
110 things in the first slice by themselves, though it's not clear that
111 that helps FUNCALL much.
112*/
113#define gvector_funcallable fulltag_nodeheader_0
114       
115#define subtag_function SUBTAG(gvector_funcallable,0)
116#define subtag_symbol SUBTAG(gvector_funcallable,1)
117#define subtag_catch_frame SUBTAG(fulltag_nodeheader_1,0)
118#define subtag_basic_stream SUBTAG(fulltag_nodeheader_1,1)
119#define subtag_lock SUBTAG(fulltag_nodeheader_1,2)
120#define subtag_hash_vector SUBTAG(fulltag_nodeheader_1,3)
121#define subtag_pool SUBTAG(fulltag_nodeheader_1,4)
122#define subtag_weak SUBTAG(fulltag_nodeheader_1,5)
123#define subtag_package SUBTAG(fulltag_nodeheader_1,6)
124
125#define subtag_slot_vector SUBTAG(fulltag_nodeheader_2,0)
126#define subtag_instance SUBTAG(fulltag_nodeheader_2,1)
127#define subtag_struct SUBTAG(fulltag_nodeheader_2,2)
128#define subtag_istruct SUBTAG(fulltag_nodeheader_2,3)
129#define subtag_value_cell SUBTAG(fulltag_nodeheader_2,4)
130#define subtag_xfunction SUBTAG(fulltag_nodeheader_2,5)
131
132#define subtag_ratio SUBTAG(fulltag_nodeheader_3,0)
133#define subtag_complex SUBTAG(fulltag_nodeheader_3,1)
134
135
136
137#define nil_value (0x3000+fulltag_misc+sizeof(struct lispsymbol)+(LOWMEM_BIAS))
138#define t_value (0x3000+fulltag_misc+(LOWMEM_BIAS))     
139#define misc_bias fulltag_misc
140#define cons_bias fulltag_cons
141
142       
143#define misc_header_offset -fulltag_misc
144#define misc_subtag_offset misc_header_offset+7       /* low byte of header */
145#define misc_data_offset misc_header_offset+8           /* first word of data */
146#define misc_dfloat_offset misc_header_offset           /* double-floats are doubleword-aligned */
147
148#define subtag_single_float SUBTAG(fulltag_imm_0,0)
149
150#define subtag_go_tag SUBTAG(fulltag_imm_1,2) /* deprecated */
151#define subtag_block_tag SUBTAG(fulltag_imm_1,3) /* deprecated */
152
153#define subtag_character SUBTAG(fulltag_imm_1,0)
154
155#define subtag_unbound SUBTAG(fulltag_imm_3,0)
156#define unbound_marker subtag_unbound
157#define undefined unbound_marker
158#define unbound unbound_marker
159#define subtag_slot_unbound SUBTAG(fulltag_imm_3,1)
160#define slot_unbound_marker subtag_slot_unbound
161#define slot_unbound slot_unbound_marker
162#define subtag_illegal SUBTAG(fulltag_imm_3,2)
163#define illegal_marker subtag_illegal
164#define subtag_no_thread_local_binding SUBTAG(fulltag_imm_3,3)
165#define no_thread_local_binding_marker subtag_no_thread_local_binding       
166#define subtag_forward_marker SUBTAG(fulltag_imm_3,7)
167       
168#define max_64_bit_constant_index ((0x7fff + misc_dfloat_offset)>>3)
169#define max_32_bit_constant_index ((0x7fff + misc_data_offset)>>2)
170#define max_16_bit_constant_index ((0x7fff + misc_data_offset)>>1)
171#define max_8_bit_constant_index (0x7fff + misc_data_offset)
172#define max_1_bit_constant_index ((0x7fff + misc_data_offset)<<5)
173
174
175/* The objects themselves look something like this: */
176
177typedef struct double_float {
178  LispObj header;
179  LispObj value;
180} double_float;
181
182
183
184typedef struct eabi_c_frame {
185  struct eabi_c_frame *backlink;
186  unsigned savelr;
187  LispObj params[8];
188} eabi_c_frame;
189
190/* PowerOpen ABI C frame */
191
192typedef struct c_frame {
193  struct c_frame *backlink;
194  natural crsave;
195  natural savelr;
196  natural unused[2];
197  natural savetoc;              /* Used with CFM (and on Linux.) */
198  natural params[8];            /* Space for callee to save r3-r10 */
199} c_frame;
200
201typedef struct lisp_frame {
202  struct lisp_frame *backlink;
203  LispObj savefn;
204  LispObj savelr;
205  LispObj savevsp;
206} lisp_frame;
207
208
209/*
210  The GC also needs to know what a catch_frame looks like.
211*/
212
213typedef struct catch_frame {
214  LispObj header;
215  LispObj catch_tag;
216  LispObj link;
217  LispObj mvflag;
218  LispObj csp;
219  LispObj db_link;
220  LispObj regs[8];
221  LispObj xframe;
222  LispObj tsp_segment;
223} catch_frame;
224
225#define catch_frame_element_count ((sizeof(catch_frame)/sizeof(LispObj))-1)
226#define catch_frame_header make_header(subtag_catch_frame,catch_frame_element_count)
227
228
229/*
230  All exception frames in a thread are linked together
231  */
232typedef struct xframe_list {
233  ExceptionInformation *curr;
234  struct xframe_list *prev;
235} xframe_list;
236
237#define fixnum_bitmask(n)  (1LL<<((n)+fixnumshift))
238
239
240#include "lisp-errors.h"
241
242
243
244#define TCR_BIAS (0x0)
245
246typedef struct tcr {
247  struct tcr* next;
248  struct tcr* prev;
249  struct {
250    float f;
251    uint32_t tag;
252  } single_float_convert;
253  union {
254    double d;
255    struct {uint32_t h, l;} words;
256  } lisp_fpscr;                 /* lisp thread's fpscr (in low word) */
257  special_binding* db_link;     /* special binding chain head */
258  LispObj catch_top;            /* top catch frame */
259  LispObj* save_vsp;  /* VSP when in foreign code */
260  LispObj* save_tsp;  /* TSP when in foreign code */
261  struct area* cs_area; /* cstack area pointer */
262  struct area* vs_area; /* vstack area pointer */
263  struct area* ts_area; /* tstack area pointer */
264  LispObj cs_limit;             /* stack overflow limit */
265  natural bytes_allocated;
266  natural log2_allocation_quantum;      /* for per-tread consing */
267  signed_natural interrupt_pending;     /* pending interrupt flag */
268  xframe_list* xframe; /* exception-frame linked list */
269  int* errno_loc;               /* per-thread (?) errno location */
270  LispObj ffi_exception;        /* fpscr bits from ff-call */
271  LispObj osid;                 /* OS thread id */
272  signed_natural valence;                       /* odd when in foreign code */
273  signed_natural foreign_exception_status;      /* non-zero -> call lisp_exit_hook */
274  void* native_thread_info;     /* platform-dependent */
275  void* native_thread_id;       /* mach_thread_t, pid_t, etc. */
276  void* last_allocptr;
277  void* save_allocptr;
278  void* save_allocbase;
279  void* reset_completion;
280  void* activate;
281  signed_natural suspend_count;
282  ExceptionInformation* suspend_context;
283  ExceptionInformation* pending_exception_context;
284  void* suspend;                /* suspension semaphore */
285  void* resume;                 /* resumption semaphore */
286  natural flags;
287  ExceptionInformation* gc_context;
288  void* termination_semaphore;
289  signed_natural unwinding;
290  natural tlb_limit;
291  LispObj* tlb_pointer;
292  natural shutdown_count;
293  void *safe_ref_address;
294  void *nfp;
295} TCR;
296
297#define t_offset -(sizeof(lispsymbol))
298
299/*
300  These were previously global variables.  There are lots of implicit
301  assumptions about the size of a heap segment, so they might as well
302  be constants.
303*/
304
305#define heap_segment_size 0x00020000L
306#define log2_heap_segment_size 17L
307
308#define ABI_VERSION_MIN 1040
309#define ABI_VERSION_CURRENT 1040
310#define ABI_VERSION_MAX 1040
Note: See TracBrowser for help on using the repository browser.