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

Last change on this file since 12994 was 12994, checked in by gz, 10 years ago

Merge watchpoints from trunk

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