source: branches/working-0711/ccl/compiler/arch.lisp @ 12077

Last change on this file since 12077 was 12077, checked in by gz, 11 years ago

r11869 from trunk: type-error constants for more vector types

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.6 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-interrupt 11)
62(defconstant error-suspend 12)
63(defconstant error-suspend-all 13)
64(defconstant error-resume 14)
65(defconstant error-resume-all 15)
66(defconstant error-kill 16)
67(defconstant error-cant-call 17)        ; Attempt to funcall something that is not a symbol or function.
68(eval-when (:compile-toplevel :load-toplevel :execute)
69  (defconstant error-type-error 128)
70)
71
72
73(defconstant error-fpu-exception-double 1024)   ; FPU exception, binary double-float op
74(defconstant error-fpu-exception-single 1025)
75
76(defconstant error-memory-full 2048)
77
78;; These are now supposed to match (mod ERROR-TYPE-ERROR) the %type-error-typespecs%
79;; array that %err-disp looks at.
80(ccl::defenum (:start  error-type-error :prefix "ERROR-OBJECT-NOT-")
81  array
82  bignum
83  fixnum
84  character
85  integer
86  list
87  number
88  sequence
89  simple-string
90  simple-vector
91  string
92  symbol
93  macptr
94  real
95  cons
96  unsigned-byte
97  radix
98  float 
99  rational
100  ratio
101  short-float
102  double-float
103  complex
104  vector
105  simple-base-string
106  function
107  unsigned-byte-16
108  unsigned-byte-8
109  unsigned-byte-32
110  signed-byte-32
111  signed-byte-16
112  signed-byte-8
113  base-char
114  bit
115  unsigned-byte-24
116  unsigned-byte-64
117  signed-byte-64
118  unsigned-byte-56
119  simple-array-double-float-2d
120  simple-array-single-float-2d
121  mod-char-code-limit
122  array-2d
123  array-3d
124  array-t
125  array-bit
126  array-s8
127  array-u8
128  array-s16
129  array-u16
130  array-s32
131  array-u32
132  array-s64
133  array-u64
134  array-fixnum
135  array-single-float
136  array-double-float
137  array-char
138  array-t-2d
139  array-bit-2d
140  array-s8-2d
141  array-u8-2d
142  array-s16-2d
143  array-u16-2d
144  array-s32-2d
145  array-u32-2d
146  array-s64-2d
147  array-u64-2d
148  array-fixnum-2d
149  array-single-float-2d
150  array-double-float-2d
151  array-char-2d
152  simple-array-t-2d
153  simple-array-bit-2d
154  simple-array-s8-2d
155  simple-array-u8-2d
156  simple-array-s16-2d
157  simple-array-u16-2d
158  simple-array-s32-2d
159  simple-array-u32-2d
160  simple-array-s64-2d
161  simple-array-u64-2d
162  simple-array-fixnum-2d
163  simple-array-char-2d
164  array-t-3d
165  array-bit-3d
166  array-s8-3d
167  array-u8-3d
168  array-s16-3d
169  array-u16-3d
170  array-s32-3d
171  array-u32-3d
172  array-s64-3d
173  array-u64-3d
174  array-fixnum-3d
175  array-single-float-3d
176  array-double-float-3d
177  array-char-3d
178  simple-array-t-3d
179  simple-array-bit-3d
180  simple-array-s8-3d
181  simple-array-u8-3d
182  simple-array-s16-3d
183  simple-array-u16-3d
184  simple-array-s32-3d
185  simple-array-u32-3d
186  simple-array-s64-3d
187  simple-array-u64-3d
188  simple-array-fixnum-3d
189  simple-array-single-float-3d
190  simple-array-double-float-3d
191  simple-array-char-3d
192
193  ;;
194  vector-t
195  bit-vector
196  vector-s8
197  vector-u8
198  vector-s16
199  vector-u16
200  vector-s32
201  vector-u32
202  vector-s64
203  vector-u64
204  vector-fixnum
205  vector-single-float
206  vector-double-float
207 
208  ;; Sentinel
209  unused-max-type-error
210  )
211
212(assert (<= error-object-not-unused-max-type-error (* 2 error-type-error)))
213
214
215
216
217
218(defun builtin-function-name-offset (name)
219  (and name (position name ccl::%builtin-functions% :test #'eq)))
220
221(ccl::defenum ()
222  storage-class-lisp                    ; General lisp objects
223  storage-class-imm                     ; Fixnums, chars, NIL: not relocatable
224  storage-class-wordptr                 ; "Raw" (fixnum-tagged) pointers to stack,etc
225  storage-class-u8                      ; Unsigned, untagged, 8-bit objects
226  storage-class-s8                      ; Signed, untagged, 8-bit objects
227  storage-class-u16                     ; Unsigned, untagged, 16-bit objects
228  storage-class-s16                     ; Signed, untagged, 16-bit objects
229  storage-class-u32                     ; Unsigned, untagged, 8-bit objects
230  storage-class-s32                     ; Signed, untagged, 8-bit objects
231  storage-class-address                 ; "raw" (untagged) 32-bit addresses.
232  storage-class-single-float            ; 32-bit single-float objects
233  storage-class-double-float            ; 64-bit double-float objects
234  storage-class-pc                      ; pointer to/into code vector
235  storage-class-locative                ; pointer to/into node-misc object
236  storage-class-crf                     ; condition register field
237  storage-class-crbit                   ; condition register bit: 0-31
238  storage-class-crfbit                  ; bit within condition register field : 0-3
239  storage-class-u64                     ; (unsigned-byte 64)
240  storage-class-s64                     ; (signed-byte 64)
241)
242
243
244(defvar *known-target-archs* ())
245
246(defstruct (target-arch (:conc-name target-)
247                        (:constructor %make-target-arch))
248  (name nil)
249  (lisp-node-size 0)
250  (nil-value 0)
251  (fixnum-shift 0)
252  (most-positive-fixnum 0)
253  (most-negative-fixnum 0)
254  (misc-data-offset 0)
255  (misc-dfloat-offset 0)
256  (nbits-in-word 0)
257  (ntagbits 0)
258  (nlisptagbits 0)
259  (uvector-subtags 0)
260  (max-64-bit-constant-index 0)
261  (max-32-bit-constant-index 0)
262  (max-16-bit-constant-index 0)
263  (max-8-bit-constant-index 0)
264  (max-1-bit-constant-index 0)
265  (word-shift 0)
266  (code-vector-prefix ())
267  (gvector-types ())
268  (1-bit-ivector-types ())
269  (8-bit-ivector-types ())
270  (16-bit-ivector-types ())
271  (32-bit-ivector-types ())
272  (64-bit-ivector-types ())
273  (array-type-name-from-ctype-function ())
274  (package-name ())
275  (t-offset ())
276  (array-data-size-function ())
277  (numeric-type-name-to-typecode-function ())
278  (subprims-base ())
279  (subprims-shift ())
280  (subprims-table ())
281  (primitive->subprims ())
282  (unbound-marker-value ())
283  (slot-unbound-marker-value ())
284  (fixnum-tag 0)
285  (single-float-tag nil)
286  (single-float-tag-is-subtag nil)
287  (double-float-tag nil)
288  (cons-tag nil)
289  (null-tag nil)
290  (symbol-tag nil)
291  (symbol-tag-is-subtag nil)
292  (function-tag nil)
293  (function-tag-is-subtag nil)
294  (big-endian t)
295  (target-macros (make-hash-table :test #'eq))
296  (misc-subtag-offset 0)
297  (car-offset 0)
298  (cdr-offset 0)
299  (subtag-char 0)
300  (charcode-shift 0)
301  (fulltagmask 0)
302  (fulltag-misc 0)
303  (char-code-limit nil))
304 
305
306 
307 
308 
309(defun make-target-arch (&rest keys)
310  (declare (dynamic-extent keys))
311  (let* ((arch (apply #'%make-target-arch keys))
312         (tail (member (target-name arch) *known-target-archs*
313                       :key #'target-name
314                       :test #'eq)))
315    (if tail
316      (rplaca tail arch)
317      (push arch *known-target-archs*))
318    arch))
319
320(defun find-target-arch (name)
321  (car (member name *known-target-archs*
322               :key #'target-name
323               :test #'eq)))
324
325(defun target-arch-macros (arch-name)
326  (let* ((arch (or (find-target-arch arch-name)
327                   (error "unknown arch: ~s" arch-name))))
328    (target-target-macros arch)))
329
330(defmacro defarchmacro (arch-name name arglist &body body &environment env)
331  (let* ((lambda-form (ccl::parse-macro-1 name arglist body env)))
332    `(progn
333      (setf (gethash ',name (target-arch-macros ',arch-name))
334       (ccl::nfunction ,name ,lambda-form))
335      ',name)))
336
337(defun arch-macro-function (arch-name name)
338  (gethash name (target-arch-macros arch-name)))
339   
340
341
342;;; GC related operations
343(defconstant gc-trap-function-immediate-gc -1)
344(defconstant gc-trap-function-gc 0)
345(defconstant gc-trap-function-purify 1)
346(defconstant gc-trap-function-impurify 2)
347(defconstant gc-trap-function-save-application 8)
348(defconstant gc-trap-function-get-lisp-heap-threshold 16)
349(defconstant gc-trap-function-set-lisp-heap-threshold 17)
350(defconstant gc-trap-function-use-lisp-heap-threshold 18)
351(defconstant gc-trap-function-egc-control 32)
352(defconstant gc-trap-function-configure-egc 64)
353(defconstant gc-trap-function-set-hons-area-size 128)
354(defconstant gc-trap-function-freeze 129)
355(defconstant gc-trap-function-thaw 130)
356
357
358
359(provide "ARCH")
Note: See TracBrowser for help on using the repository browser.