source: trunk/source/compiler/X86/x86-arch.lisp @ 15196

Last change on this file since 15196 was 15196, checked in by gb, 8 years ago

Rename a couple of (unused) nil-relative-symbols. No bootstrapping issues
(yet, modulo any typos), but there may be when we start to use them.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.1 KB
Line 
1;;;-*- Mode: Lisp; Package: (X86 :use CL) -*-
2;;;
3;;;   Copyright (C) 2005-2009 Clozure Associates and contributors.
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(defpackage "X86"
18  (:use "CL"))
19
20(in-package "X86")
21
22(require "ARCH")
23
24;;; Kernel globals are allocated "below" nil.  This list (used to map
25;;; symbolic names to rnil-relative offsets) must (of course) exactly
26;;; match the kernel's notion of where things are.
27;;; The order here matches "ccl:lisp-kernel;lisp_globals.h" & the
28;;; lisp_globals record in "ccl:lisp-kernel;constants.s"
29(defparameter *x86-kernel-globals*
30  '(get-tcr                             ; callback to obtain (real) tcr
31    tcr-count
32    interrupt-signal                    ; used by PROCESS-INTERRUPT
33    kernel-imports                      ; some things we need to have imported for us.
34    objc-2-personality
35    savetoc                  ; used to save TOC on some platforms
36    saver13                             ; used to save r13 on some platforms
37    subprims-base                       ; start of dynamic subprims jump table
38    ret1valaddr                         ; magic multiple-values return address.
39    tcr-key                             ; tsd key for thread's tcr
40    area-lock                           ; serialize access to gc
41    exception-lock                      ; serialize exception handling
42    static-conses                       ; when FREEZE is in effect
43    default-allocation-quantum          ; log2_heap_segment_size, as a fixnum.
44    intflag                             ; interrupt-pending flag
45    gc-inhibit-count                    ; for gc locking
46    refbits                             ; oldspace refbits
47    oldspace-dnode-count                ; number of dnodes in dynamic space that are older than
48                                        ; youngest generation
49    altivec-present                     ; non-zero if cpu supports AltiVec
50    fwdnum                              ; fixnum: GC "forwarder" call count.
51    gc-count                            ; fixnum: GC call count.
52    gcable-pointers                     ; linked-list of weak macptrs.
53    heap-start                          ; start of lisp heap
54    heap-end                            ; end of lisp heap
55    statically-linked                   ; true if the lisp kernel is statically linked
56    stack-size                          ; value of --stack-size arg
57    objc-2-begin-catch                  ; objc_begin_catch
58    kernel-path
59    all-areas                           ; doubly-linked area list
60    lexpr-return                        ; multiple-value lexpr return address
61    lexpr-return1v                      ; single-value lexpr return address
62    in-gc                               ; non-zero when GC-ish thing active
63    free-static-conses                  ; fixnum
64    objc-2-end-catch                    ; _objc_end_catch
65    short-float-zero                    ; low half of 1.0d0
66    double-float-one                    ; high half of 1.0d0
67    static-cons-area                    ;
68    exception-saved-registers           ; saved registers from exception frame
69    oldest-ephemeral                    ; doublenode address of oldest ephemeral object or 0
70    tenured-area                        ; the tenured_area.
71    errno                               ; address of C lib errno
72    argv                                ; address of C lib argv
73    host-platform                       ; 0 on MacOS, 1 on PPC Linux, 2 on VxWorks ...
74    batch-flag                          ; non-zero if --batch specified
75    unwind-resume                       ; _Unwind_Resume
76    weak-gc-method                      ; weak gc algorithm.
77    image-name                          ; current image name
78    initial-tcr                         ; initial thread's context record
79    weakvll                             ; all populations as of last GC
80    ))
81
82;;; The order here matches "ccl:lisp-kernel;lisp_globals.h" and the nrs record
83;;; in "ccl:lisp-kernel;constants.s".
84(defparameter *x86-nil-relative-symbols*
85  '(t
86    nil
87    ccl::%err-disp
88    ccl::cmain
89    eval
90    ccl::apply-evaluated-function
91    error   
92    ccl::%defun
93    ccl::%defvar
94    ccl::%defconstant
95    ccl::%macro
96    ccl::%kernel-restart
97    *package*
98    ccl::*total-bytes-freed*
99    :allow-other-keys   
100    ccl::%toplevel-catch%
101    ccl::%toplevel-function%
102    ccl::%pascal-functions%   
103    ccl::*heap-init-function*
104    ccl::*total-gc-microseconds*
105    ccl::%builtin-functions%
106    ccl::%unbound-function%
107    ccl::%init-misc
108    ccl::%macro-code%
109    ccl::%closure-code%
110    ccl::%new-gcable-ptr
111    ccl::*gc-event-status-bits*
112    ccl::*post-gc-hook*
113    ccl::%handlers%
114    ccl::%all-packages%
115    ccl::*keyword-package* 
116    ccl::%os-init-function%
117    ccl::%foreign-thread-control
118    ))
119
120;;; Old (and slightly confusing) name; NIL used to be in a register.
121(defparameter *x86-nilreg-relative-symbols* *x86-nil-relative-symbols*)
122
123
124;;; mxcsr bits.  (Unlike the convention used on the PPC, bit 0 is the
125;;; least significant bit of the containing byte/word.)
126
127(ccl::defenum (:prefix "MXCSR-" :suffix "-BIT")
128  ie                                    ;invalid exception
129  de                                    ;denormal exception
130  ze                                    ;divide-by-zero exception
131  oe                                    ;overflow exception
132  ue                                    ;underflow exception
133  pe                                    ;precision exception
134  daz                                   ;denorms-are-zeros (not-IEEE)
135  im                                    ;invalid masked
136  dm                                    ;denormals masked
137  zm                                    ;divide-by-zero masked
138  om                                    ;overflow masked
139  um                                    ;underflow masked
140  pm                                    ;precision masked
141  rc0                                   ;rounding control bit 0
142  rc1                                   ;rounding control bit 1
143  fz                                    ;flush-to-zero (not-IEEE)
144)
145
146(defconstant mxcsr-status-mask
147  (logior (ash 1 mxcsr-ie-bit)
148          (ash 1 mxcsr-de-bit)
149          (ash 1 mxcsr-ze-bit)
150          (ash 1 mxcsr-oe-bit)
151          (ash 1 mxcsr-ue-bit)
152          (ash 1 mxcsr-pe-bit)))
153
154(defconstant mxcsr-control-and-rounding-mask
155  (logior (ash 1 mxcsr-im-bit)
156          (ash 1 mxcsr-dm-bit)
157          (ash 1 mxcsr-zm-bit)
158          (ash 1 mxcsr-om-bit)
159          (ash 1 mxcsr-um-bit)
160          (ash 1 mxcsr-pm-bit)
161          (ash 1 mxcsr-rc0-bit)
162          (ash 1 mxcsr-rc1-bit)))
163
164;;; There's a fairly hairy method of determining which MXCSR bits are
165;;; available on a given proccessor version.  In practice, the bits
166;;; that might not be supported are bits that select non-IEE754-compliant
167;;; behavior (DenormsAreZeros and FlushtoZerop), and we don't really
168;;; want to activate either of those things, anyway.
169
170(defconstant mxcsr-write-mask (lognot (logior (ash 1 mxcsr-daz-bit)
171                                              (ash 1 mxcsr-fz-bit))))
172
173
174
175;;; Condition bitfields, used in jcc, cmovcc, setcc.
176(defconstant x86-o-bits #x0)
177(defconstant x86-no-bit #x1)
178(defconstant x86-b-bits #x2)
179(defconstant x86-ae-bits #x3)
180(defconstant x86-e-bits #x4)
181(defconstant x86-ne-bits #x5)
182(defconstant x86-be-bits #x6)
183(defconstant x86-a-bits #x7)
184(defconstant x86-s-bits #x8)
185(defconstant x86-ns-bits #x9)
186(defconstant x86-pe-bits #xa)
187(defconstant x86-po-bits #xb)
188(defconstant x86-l-bits #xc)
189(defconstant x86-ge-bits #xd)
190(defconstant x86-le-bits #xe)
191(defconstant x86-g-bits #xf)
192
193;;; Bits in the xFLAGS register
194(defconstant x86-carry-flag-bit 0)
195(defconstant x86-parity-flag-bit 2)
196(defconstant x86-aux-carry-flag-bit 4)
197(defconstant x86-zero-flag-bit 6)
198(defconstant x86-sign-flag-bit 7)
199(defconstant x86-direction-flag-bit 10)
200(defconstant x86-overflow-flag-bit 11)
201
202
203(provide "X86-ARCH")
Note: See TracBrowser for help on using the repository browser.