source: branches/1.2-devel/ccl/compiler/arch.lisp @ 15278

Last change on this file since 15278 was 7624, checked in by gb, 12 years ago

Merge changes form working-0710 branch.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
1;;;-*- Mode: Lisp; Package: (ARCH :use CL) -*-
2;;;
3;;;   Copyright (C) 1994-2001 Digitool, Inc
4;;;   This file is part of OpenMCL. 
5;;;
6;;;   OpenMCL is licensed under the terms of the Lisp Lesser GNU Public
7;;;   License , known as the LLGPL and distributed with OpenMCL as the
8;;;   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
9;;;   which is distributed with OpenMCL as the file "LGPL".  Where these
10;;;   conflict, the preamble takes precedence. 
11;;;
12;;;   OpenMCL 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(defpackage "ARCH"
18  (:use "CL"))
19
20(in-package "ARCH")
21
22
23
24(eval-when (:compile-toplevel :load-toplevel :execute)
25
26
27
28(defconstant tcr-flag-bit-foreign 0)
29(defconstant tcr-flag-bit-awaiting-preset 1)
30(defconstant tcr-flag-bit-alt-suspend 2)
31(defconstant tcr-flag-bit-propagate-exception 3)
32(defconstant tcr-flag-bit-suspend-ack-pending 4)
33(defconstant tcr-flag-bit-pending-exception 5)
34(defconstant tcr-flag-bit-foreign-exception 6)
35(defconstant tcr-flag-bit-pending-suspend 7)       
36
37
38
39)
40
41(defmacro make-vheader (element-count subtag)
42  `(logior ,subtag (ash ,element-count 8)))
43
44
45
46;;; Error numbers, as used in UU0s and such.
47;;; These match constants defined in the kernel sources.
48(defconstant error-reg-regnum 0)        ; "real" error number is in RB field of UU0.
49                                        ; Currently only used for :errchk in emulated traps
50                                        ; The errchk macro should expand into a check-trap-error vinsn, too.
51(defconstant error-udf 1)               ; Undefined function (reported by symbol-function)
52(defconstant error-udf-call 2)          ; Attempt to call undefined function
53(defconstant error-throw-tag-missing 3)
54(defconstant error-alloc-failed 4)      ; can't allocate (largish) vector
55(defconstant error-stack-overflow 5)    ; some stack overflowed.
56(defconstant error-excised-function-call 6)     ; excised function was called.
57(defconstant error-too-many-values 7)   ; too many values returned
58(defconstant error-cant-take-car 8)
59(defconstant error-cant-take-cdr 9)
60(defconstant error-propagate-suspend 10)
61(defconstant error-cant-call 17)        ; Attempt to funcall something that is not a symbol or function.
62(eval-when (:compile-toplevel :load-toplevel :execute)
63  (defconstant error-type-error 128)
64)
65
66(defconstant error-fpu-exception-double 1024)   ; FPU exception, binary double-float op
67(defconstant error-fpu-exception-single 1025)
68
69(defconstant error-memory-full 2048)
70
71;; These are now supposed to match (mod ERROR-TYPE-ERROR) the %type-error-typespecs%
72;; array that %err-disp looks at.
73(ccl::defenum (:start  error-type-error :prefix "ERROR-OBJECT-NOT-")
74  array
75  bignum
76  fixnum
77  character
78  integer
79  list
80  number
81  sequence
82  simple-string
83  simple-vector
84  string
85  symbol
86  macptr
87  real
88  cons
89  unsigned-byte
90  radix
91  float 
92  rational
93  ratio
94  short-float
95  double-float
96  complex
97  vector
98  simple-base-string
99  function
100  unsigned-byte-16
101  unsigned-byte-8
102  unsigned-byte-32
103  signed-byte-32
104  signed-byte-16
105  signed-byte-8
106  base-char
107  bit
108  unsigned-byte-24
109  unsigned-byte-64
110  signed-byte-64
111  unsigned-byte-56
112  simple-array-double-float-2d
113  simple-array-single-float-2d
114  mod-char-code-limit
115  array-2d
116  array-3d
117  array-t
118  array-bit
119  array-s8
120  array-u8
121  array-s16
122  array-u16
123  array-s32
124  array-u32
125  array-s64
126  array-u64
127  array-fixnum
128  array-single-float
129  array-double-float
130  array-char
131  array-t-2d
132  array-bit-2d
133  array-s8-2d
134  array-u8-2d
135  array-s16-2d
136  array-u16-2d
137  array-s32-2d
138  array-u32-2d
139  array-s64-2d
140  array-u64-2d
141  array-fixnum-2d
142  array-single-float-2d
143  array-double-float-2d
144  array-char-2d
145  simple-array-t-2d
146  simple-array-bit-2d
147  simple-array-s8-2d
148  simple-array-u8-2d
149  simple-array-s16-2d
150  simple-array-u16-2d
151  simple-array-s32-2d
152  simple-array-u32-2d
153  simple-array-s64-2d
154  simple-array-u64-2d
155  simple-array-fixnum-2d
156  simple-array-char-2d
157  array-t-3d
158  array-bit-3d
159  array-s8-3d
160  array-u8-3d
161  array-s16-3d
162  array-u16-3d
163  array-s32-3d
164  array-u32-3d
165  array-s64-3d
166  array-u64-3d
167  array-fixnum-3d
168  array-single-float-3d
169  array-double-float-3d
170  array-char-3d
171  simple-array-t-3d
172  simple-array-bit-3d
173  simple-array-s8-3d
174  simple-array-u8-3d
175  simple-array-s16-3d
176  simple-array-u16-3d
177  simple-array-s32-3d
178  simple-array-u32-3d
179  simple-array-s64-3d
180  simple-array-u64-3d
181  simple-array-fixnum-3d
182  simple-array-single-float-3d
183  simple-array-double-float-3d
184  simple-array-char-3d
185
186  ;; Sentinel
187  unused-max-type-error
188  )
189
190(assert (<= error-object-not-unused-max-type-error (* 2 error-type-error)))
191
192
193
194
195
196(defun builtin-function-name-offset (name)
197  (and name (position name ccl::%builtin-functions% :test #'eq)))
198
199(ccl::defenum ()
200  storage-class-lisp                    ; General lisp objects
201  storage-class-imm                     ; Fixnums, chars, NIL: not relocatable
202  storage-class-wordptr                 ; "Raw" (fixnum-tagged) pointers to stack,etc
203  storage-class-u8                      ; Unsigned, untagged, 8-bit objects
204  storage-class-s8                      ; Signed, untagged, 8-bit objects
205  storage-class-u16                     ; Unsigned, untagged, 16-bit objects
206  storage-class-s16                     ; Signed, untagged, 16-bit objects
207  storage-class-u32                     ; Unsigned, untagged, 8-bit objects
208  storage-class-s32                     ; Signed, untagged, 8-bit objects
209  storage-class-address                 ; "raw" (untagged) 32-bit addresses.
210  storage-class-single-float            ; 32-bit single-float objects
211  storage-class-double-float            ; 64-bit double-float objects
212  storage-class-pc                      ; pointer to/into code vector
213  storage-class-locative                ; pointer to/into node-misc object
214  storage-class-crf                     ; condition register field
215  storage-class-crbit                   ; condition register bit: 0-31
216  storage-class-crfbit                  ; bit within condition register field : 0-3
217  storage-class-u64                     ; (unsigned-byte 64)
218  storage-class-s64                     ; (signed-byte 64)
219)
220
221
222(defvar *known-target-archs* ())
223
224(defstruct (target-arch (:conc-name target-)
225                        (:constructor %make-target-arch))
226  (name nil)
227  (lisp-node-size 0)
228  (nil-value 0)
229  (fixnum-shift 0)
230  (most-positive-fixnum 0)
231  (most-negative-fixnum 0)
232  (misc-data-offset 0)
233  (misc-dfloat-offset 0)
234  (nbits-in-word 0)
235  (ntagbits 0)
236  (nlisptagbits 0)
237  (uvector-subtags 0)
238  (max-64-bit-constant-index 0)
239  (max-32-bit-constant-index 0)
240  (max-16-bit-constant-index 0)
241  (max-8-bit-constant-index 0)
242  (max-1-bit-constant-index 0)
243  (word-shift 0)
244  (code-vector-prefix ())
245  (gvector-types ())
246  (1-bit-ivector-types ())
247  (8-bit-ivector-types ())
248  (16-bit-ivector-types ())
249  (32-bit-ivector-types ())
250  (64-bit-ivector-types ())
251  (array-type-name-from-ctype-function ())
252  (package-name ())
253  (t-offset ())
254  (array-data-size-function ())
255  (numeric-type-name-to-typecode-function ())
256  (subprims-base ())
257  (subprims-shift ())
258  (subprims-table ())
259  (primitive->subprims ())
260  (unbound-marker-value ())
261  (slot-unbound-marker-value ())
262  (fixnum-tag 0)
263  (single-float-tag nil)
264  (single-float-tag-is-subtag nil)
265  (double-float-tag nil)
266  (cons-tag nil)
267  (null-tag nil)
268  (symbol-tag nil)
269  (symbol-tag-is-subtag nil)
270  (function-tag nil)
271  (function-tag-is-subtag nil)
272  (big-endian t)
273  (target-macros (make-hash-table :test #'eq))
274  (misc-subtag-offset 0)
275  (car-offset 0)
276  (cdr-offset 0)
277  (subtag-char 0)
278  (charcode-shift 0)
279  (fulltagmask 0)
280  (fulltag-misc 0)
281  (char-code-limit nil))
282 
283
284 
285 
286 
287(defun make-target-arch (&rest keys)
288  (declare (dynamic-extent keys))
289  (let* ((arch (apply #'%make-target-arch keys))
290         (tail (member (target-name arch) *known-target-archs*
291                       :key #'target-name
292                       :test #'eq)))
293    (if tail
294      (rplaca tail arch)
295      (push arch *known-target-archs*))
296    arch))
297
298(defun find-target-arch (name)
299  (car (member name *known-target-archs*
300               :key #'target-name
301               :test #'eq)))
302
303(defun target-arch-macros (arch-name)
304  (let* ((arch (or (find-target-arch arch-name)
305                   (error "unknown arch: ~s" arch-name))))
306    (target-target-macros arch)))
307
308(defmacro defarchmacro (arch-name name arglist &body body &environment env)
309  (let* ((lambda-form (ccl::parse-macro-1 name arglist body env)))
310    `(progn
311      (setf (gethash ',name (target-arch-macros ',arch-name))
312       (ccl::nfunction ,name ,lambda-form))
313      ',name)))
314
315(defun arch-macro-function (arch-name name)
316  (gethash name (target-arch-macros arch-name)))
317   
318
319
320;;; GC related operations
321(defconstant gc-trap-function-immediate-gc -1)
322(defconstant gc-trap-function-gc 0)
323(defconstant gc-trap-function-purify 1)
324(defconstant gc-trap-function-impurify 2)
325(defconstant gc-trap-function-save-application 8)
326(defconstant gc-trap-function-get-lisp-heap-threshold 16)
327(defconstant gc-trap-function-set-lisp-heap-threshold 17)
328(defconstant gc-trap-function-use-lisp-heap-threshold 18)
329(defconstant gc-trap-function-egc-control 32)
330(defconstant gc-trap-function-configure-egc 64)
331(defconstant gc-trap-function-set-hons-area-size 128)
332(defconstant gc-trap-function-freeze 129)
333(defconstant gc-trap-function-thaw 130)
334
335
336
337(provide "ARCH")
Note: See TracBrowser for help on using the repository browser.