source: branches/qres/ccl/compiler/nxenv.lisp @ 15278

Last change on this file since 15278 was 14049, checked in by gz, 9 years ago

Misc tweaks and fixes from trunk (r13550,r13560,r13568,r13569,r13581,r13583,r13633-13636,r13647,r13648,r13657-r13659,r13675,r13678,r13688,r13743,r13744,r13769,r13773,r13782,r13813,r13814,r13869,r13870,r13873,r13901,r13930,r13943,r13946,r13954,r13961,r13974,r13975,r13978,r13990,r14010,r14012,r14020,r14028-r14030)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 33.5 KB
Line 
1;;; -*- Mode: Lisp; Package: CCL -*-
2;;;
3;;;   Copyright (C) 2009 Clozure Associates
4;;;   Copyright (C) 1994-2001 Digitool, Inc
5;;;   This file is part of Clozure CL. 
6;;;
7;;;   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
8;;;   License , known as the LLGPL and distributed with Clozure CL as the
9;;;   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
10;;;   which is distributed with Clozure CL as the file "LGPL".  Where these
11;;;   conflict, the preamble takes precedence. 
12;;;
13;;;   Clozure CL is referenced in the preamble as the "LIBRARY."
14;;;
15;;;   The LLGPL is also available online at
16;;;   http://opensource.franz.com/preamble.html
17
18
19;;; Compile-time environment for the compiler.
20
21
22(in-package "CCL")
23
24(eval-when (:execute :compile-toplevel)
25  (require'backquote)
26  (require 'lispequ)
27)
28
29#+ppc-target (require "PPCENV")
30#+x8632-target (require "X8632ENV")
31#+x8664-target (require "X8664ENV")
32
33(defconstant $vbittemporary 16)    ; a compiler temporary
34(defconstant $vbitreg 17)          ; really wants to live in a register.
35(defconstant $vbitnoreg 18)        ; something inhibits register allocation
36(defconstant $vbitdynamicextent 19)
37(defconstant $vbitparameter 20)    ; iff special
38(defconstant $vbitpunted 20)       ; iff lexical
39(defconstant $vbitignoreunused 21)
40(defconstant $vbitignorable 21)
41(defconstant $vbitcloseddownward 22) 
42(defconstant $vbitsetq 23)
43(defconstant $vbitpuntable 24)
44(defconstant $vbitclosed 25)
45(defconstant $vbitignore 26)
46(defconstant $vbitreffed 27)
47(defconstant $vbitspecial 28)
48(defconstant $vsetqmask #xff00)
49(defconstant $vrefmask #xff)
50
51(defconstant $decl_optimize (%ilsl 16 0))  ; today's chuckle
52(defconstant $decl_tailcalls (ash 1 16))
53(defconstant $decl_opencodeinline (ash 4 16))
54(defconstant $decl_eventchk (ash 8 16))
55(defconstant $decl_unsafe (ash 16 16))
56(defconstant $decl_trustdecls (ash 32 16))
57(defconstant $decl_full_safety (ash 64 16))
58
59(defconstant $regnote-ea 1)
60
61(defmacro nx-null (x)
62 `(eq ,x *nx-nil*))
63
64(defmacro nx-t (x)
65 `(eq ,x *nx-t*))
66
67(eval-when (:compile-toplevel :load-toplevel :execute)
68
69  (defconstant operator-id-mask (1- (%ilsl 10 1)))
70  (defconstant operator-acode-subforms-bit 10)
71  (defconstant operator-acode-subforms-mask (%ilsl operator-acode-subforms-bit 1))
72  (defconstant operator-acode-list-bit 11)
73  (defconstant operator-acode-list-mask (%ilsl operator-acode-list-bit 1))
74  (defconstant operator-side-effect-free-bit 12) ; operator is side-effect free; subforms may not be ...
75  (defconstant operator-side-effect-free-mask 
76    (%ilsl operator-side-effect-free-bit 1))
77  (defconstant operator-single-valued-bit 13)
78  (defconstant operator-single-valued-mask
79    (%ilsl operator-single-valued-bit 1))
80  (defconstant operator-assignment-free-bit 14)
81  (defconstant operator-assignment-free-mask
82    (%ilsl operator-assignment-free-bit 1))
83  (defconstant operator-cc-invertable-bit 15)
84  (defconstant operator-cc-invertable-mask (ash 1 operator-cc-invertable-bit))
85  (defconstant operator-boolean-bit 16)
86  (defconstant operator-boolean-mask (ash 1 operator-boolean-bit))
87  (defconstant operator-returns-address-bit 17)
88  (defconstant operator-returns-address-mask (ash 1 operator-returns-address-bit))
89
90  )
91
92(defparameter *next-nx-operators*
93  (reverse
94   '((%primitive . 0)
95     (progn . #.(logior operator-acode-list-mask operator-assignment-free-mask operator-side-effect-free-mask))
96     (not . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
97     (%i+ . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask))
98     (%i- . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask))
99     (cxxr . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask))
100     (%dfp-combine . 0)
101     (%ilsl . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask))
102     (%ilogand2 . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask))
103     (%ilogior2 . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask))
104     (%ilogbitp . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
105     (eq . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
106     (neq . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
107     (list . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-list-mask operator-side-effect-free-mask))
108     (values . #.(logior operator-acode-list-mask operator-assignment-free-mask operator-side-effect-free-mask))
109     (if . #.(logior operator-acode-subforms-mask operator-side-effect-free-mask))
110     (or . 0)
111     (without-interrupts . 0)
112     (%fixnum-ref . #.operator-single-valued-mask)
113     (%fixnum-ref-natural . #.operator-single-valued-mask)
114     (%current-tcr . #.operator-single-valued-mask)
115     (%stack-trap . #.operator-single-valued-mask)
116     (multiple-value-prog1 . 0)
117     (multiple-value-bind . 0)
118     (multiple-value-call . 0)
119     (put-xxx . #.operator-single-valued-mask)
120     (get-xxx . #.operator-single-valued-mask)
121     (typed-form . 0)
122     (let . 0)
123     (let* . 0)
124     (tag-label . 0)
125     (local-tagbody . #.operator-single-valued-mask)
126     (%fixnum-set-natural . #.operator-single-valued-mask)
127     (type-asserted-form . 0)
128     (spushp . #.operator-single-valued-mask)
129     (simple-function . #.operator-single-valued-mask)
130     (closed-function . #.operator-single-valued-mask)
131     (setq-lexical . #.operator-single-valued-mask)
132     (lexical-reference . #.(logior operator-assignment-free-mask operator-single-valued-mask))
133     (free-reference . #.(logior operator-assignment-free-mask operator-single-valued-mask))
134     (immediate . #.(logior operator-assignment-free-mask operator-single-valued-mask))
135     (fixnum . #.(logior operator-assignment-free-mask operator-single-valued-mask ))
136     (call . 0)
137     (local-go . 0)
138     (local-block . 0)
139     (local-return-from . 0)
140     (%car . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
141     (%cdr . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
142     (%rplaca . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
143     (%rplacd . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
144     (cons . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask))
145     (simple-typed-aref2 . #.(logior operator-acode-subforms-mask operator-assignment-free-mask operator-single-valued-mask))
146     (setq-free . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
147     (prog1 . 0)
148     (catch . 0)
149     (throw . 0)
150     (unwind-protect . 0)
151     (characterp . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
152     (multiple-value-list . 0)
153     (%izerop . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
154     (%immediate-ptr-to-int . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
155     (%immediate-int-to-ptr . #.(logior operator-returns-address-mask operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
156     (immediate-get-xxx . 0)
157     (immediate-put-xxx . 0)
158     (setq-special . 0)
159     (special-ref . 0)
160     (1+ . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
161     (1- . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
162     (add2 . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
163     (sub2 . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
164     (numeric-comparison . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-cc-invertable-mask))
165     (numcmp . #.(logior operator-assignment-free-mask operator-acode-subforms-mask operator-single-valued-mask operator-cc-invertable-mask))
166     (struct-ref . 0)
167     (struct-set . 0)
168     (%aref1 . #.(logior operator-acode-subforms-mask operator-assignment-free-mask operator-single-valued-mask operator-side-effect-free-mask))
169     (embedded-nlexit . 0)
170     (embedded-conditional . 0) 
171     (%word-to-int . #.(logior operator-assignment-free-mask operator-single-valued-mask))
172     (%svref . #.(logior operator-acode-subforms-mask operator-assignment-free-mask operator-single-valued-mask))
173     (%svset . #.(logior operator-acode-subforms-mask operator-single-valued-mask))
174     (%consmacptr% . 0)
175     (%macptrptr% . 0)
176     (%ptr-eql . #.operator-cc-invertable-mask)
177     (%setf-macptr . 0)
178     (bound-special-ref . 0)
179     (%char-code . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
180     (%code-char . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
181     (lap . 0)
182     (lap-inline . 0)
183     (%function . #.operator-single-valued-mask)
184     (%valid-code-char . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
185     (%ttag . #.operator-single-valued-mask) 
186     (uvsize . #.operator-single-valued-mask)
187     (endp . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
188     (sequence-type . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
189     (fixnum-overflow . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
190     (vector . #.(logior operator-assignment-free-mask operator-single-valued-mask))
191     (%immediate-inc-ptr . #.(logior operator-returns-address-mask operator-single-valued-mask))
192     (general-aref3 . #.(logior operator-acode-subforms-mask operator-single-valued-mask))
193     (general-aset2 . #.(logior operator-acode-subforms-mask operator-single-valued-mask))
194     (%new-ptr . 0)
195     (%schar . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
196     (%set-schar . #.(logior operator-single-valued-mask operator-acode-subforms-mask)) ;??
197     (debind . 0)
198     (lambda-bind . 0)
199     (general-aset3 . #.(logior operator-acode-subforms-mask operator-single-valued-mask))
200     (simple-typed-aref3 . #.(logior operator-acode-subforms-mask operator-assignment-free-mask operator-single-valued-mask))
201     (simple-typed-aset3 . #.(logior operator-acode-subforms-mask  operator-single-valued-mask))
202     (nth-value . 0)
203     (progv . 0)
204     (svref . #.(logior operator-assignment-free-mask operator-single-valued-mask))
205     (svset . #.operator-single-valued-mask)
206     (make-list . #.(logior operator-assignment-free-mask operator-single-valued-mask)) ; exists only so we can stack-cons
207     (%badarg1 . 0)
208     (%badarg2 . 0)
209     (newblocktag . 0)
210     (newgotag . 0)
211     (flet . 0)                         ; may not be necessary - for dynamic-extent, mostly
212                                        ; for dynamic-extent, forward refs, etc.
213     (labels . 0)                       ; removes 75% of LABELS bogosity
214     (lexical-function-call . 0)        ; most of other 25%
215     (with-downward-closures . 0)
216     (self-call . 0)
217     (inherited-arg . #.operator-single-valued-mask)
218     (ff-call . 0)
219     (commutative-subprim-binop . 0)
220     (%immediate-set-xxx . #.(logior operator-acode-subforms-mask))
221     (symbol-name . #.(logior operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask))
222     (memq . #.(logior operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask))
223     (assq . #.(logior operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask))
224     (simple-typed-aset2 . #.(logior operator-acode-subforms-mask operator-single-valued-mask))
225     (consp . #.(logior operator-cc-invertable-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-boolean-mask))
226     (aset1 . #.(logior operator-acode-subforms-mask))
227     (syscall . 0)
228     (car . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
229     (cdr . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
230     (length . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
231     (list-length . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
232     (ensure-simple-string . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
233     (%ilsr . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
234     (set . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
235     (eql . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-boolean-mask))
236     (%iasr . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
237     (logand2 . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
238     (logior2 . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
239     (logxor2 . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
240     (%i<> . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
241     (set-car . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
242     (set-cdr . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
243     (rplaca . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
244     (rplacd . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
245     (with-variable-c-frame . #.(logior operator-acode-list-mask operator-assignment-free-mask))
246     (uvref . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
247     (uvset . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
248     (%temp-cons . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
249     (%temp-List . #.(logior operator-single-valued-mask operator-side-effect-free-mask))
250     (%make-uvector . #.(logior operator-assignment-free-mask operator-single-valued-mask  operator-side-effect-free-mask))
251     (%decls-body . 0)
252     (%old-gvector . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
253     (%typed-uvref . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
254     (%typed-uvset . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
255     (schar . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
256     (set-schar . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
257     (code-char . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
258     (char-code . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
259     (list* . #.(logior operator-assignment-free-mask operator-single-valued-mask  operator-side-effect-free-mask))
260     (append . #.(logior operator-assignment-free-mask operator-single-valued-mask  operator-side-effect-free-mask))
261     (symbolp . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-boolean-mask))
262     (integer-point-h . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
263     (integer-point-v . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
264     (int>0-p . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
265     (immediate-constant .  #.(logior operator-assignment-free-mask operator-single-valued-mask ))
266     (with-stack-double-floats . 0)
267     (short-float . #.operator-single-valued-mask)
268     (istruct-typep . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
269     (%ilogxor2 . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
270     (%err-disp . 0)
271     (%quo2 . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
272     (minus1 . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
273     (%ineg . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
274     (%i* . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
275     (logbitp . #.(logior operator-single-valued-mask operator-assignment-free-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-boolean-mask))
276     (%sbchar . 0)
277     (%sechar . 0)
278     (%set-sbchar . 0)
279     (%scharcode . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
280     (%set-scharcode . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
281     (lambda-list . 0)
282     (ppc-lap-function . 0)
283     (lisptag . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
284     (fulltag . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
285     (typecode . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
286     (require-simple-vector . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
287     (require-simple-string . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
288     (require-integer . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
289     (require-fixnum . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
290     (require-real . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
291     (require-list . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
292     (require-character . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
293     (require-number . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
294     (require-symbol . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
295     (base-char-p . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
296     (%vect-subtype . #.operator-single-valued-mask)
297     (%unbound-marker . #.operator-single-valued-mask)
298     (%slot-unbound-marker . #.operator-single-valued-mask)
299     (%gvector . #.(logior operator-assignment-free-mask operator-single-valued-mask))
300     (immediate-get-ptr . #.operator-returns-address-mask)
301     (%lisp-word-ref . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
302     (%lisp-lowbyte-ref . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
303     (poweropen-ff-call . 0)
304     (double-float-compare . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
305     (builtin-call . 0)
306     (%setf-double-float . 0)
307     (%double-float+-2 . #.(logior operator-single-valued-mask operator-side-effect-free-mask operator-acode-subforms-mask))
308     (%double-float--2 .  #.(logior operator-single-valued-mask operator-side-effect-free-mask operator-acode-subforms-mask))
309     (%double-float*-2 .  #.(logior operator-single-valued-mask operator-side-effect-free-mask operator-acode-subforms-mask))
310     (%double-float/-2 .  #.(logior operator-single-valued-mask operator-side-effect-free-mask operator-acode-subforms-mask))
311     (%double-float+-2! . 0)
312     (%double-float--2! . 0)
313     (%double-float*-2! . 0)
314     (%double-float/-2! . 0)
315     (poweropen-syscall . 0)
316     (%debug-trap . 0)
317     (%%ineg . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
318     (%setf-short-float . 0)
319     (%short-float+-2 .  #.(logior operator-single-valued-mask operator-side-effect-free-mask operator-acode-subforms-mask))
320     (%short-float--2 .  #.(logior operator-single-valued-mask operator-side-effect-free-mask operator-acode-subforms-mask))
321     (%short-float*-2 .  #.(logior operator-single-valued-mask operator-side-effect-free-mask operator-acode-subforms-mask))
322     (%short-float/-2 .  #.(logior operator-single-valued-mask operator-side-effect-free-mask operator-acode-subforms-mask))
323     (short-float-compare . 0)
324     (eabi-ff-call . 0)
325     (%reference-external-entry-point . 0)
326     (eabi-syscall . 0)
327     (%get-bit . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
328     (%set-bit   . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
329     (%natural+ . 0)
330     (%natural- . 0)
331     (%natural-logand . 0)
332     (%natural-logior . 0)
333     (%natural-logxor . 0)
334     (%natural<> . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask operator-cc-invertable-mask))
335     (%get-double-float . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
336     (%get-single-float . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
337     (%set-double-float . #.(logior operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
338      (%set-single-float . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
339     (natural-shift-right  . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
340     (natural-shift-left  . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
341     (global-ref . 0)
342     (global-setq . 0)
343     (disable-interrupts . #.(logior operator-assignment-free-mask operator-single-valued-mask))
344
345     (%interrupt-poll  . #.(logior operator-assignment-free-mask operator-single-valued-mask))
346     (with-c-frame . #.(logior operator-acode-list-mask operator-assignment-free-mask operator-side-effect-free-mask))   
347     (%current-frame-ptr . 0)
348     (%slot-ref . 0)
349     (%illegal-marker . #.operator-single-valued-mask)
350     (%symbol->symptr . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
351     (%single-to-double  . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
352     (%double-to-single . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
353     (%symptr->symvector  . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
354     (%symvector->symptr  . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
355     (%foreign-stack-pointer . 0)
356     (mul2 . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
357     (div2 . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
358     (%fixnum-to-single  . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
359     (%fixnum-to-double .  #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask))
360     (require-s8 . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
361     (require-u8 . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
362     (require-s16 . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
363     (require-u16 . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
364     (require-s32 . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
365     (require-u32 . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
366     (require-s64 . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
367     (require-u64 . #.(logior operator-single-valued-mask operator-acode-subforms-mask))
368     (general-aref2 .  #.(logior operator-acode-subforms-mask operator-assignment-free-mask operator-single-valued-mask))
369     (%single-float .  #.(logior operator-acode-subforms-mask operator-assignment-free-mask operator-single-valued-mask))
370     (%double-float . #. #.(logior operator-acode-subforms-mask operator-assignment-free-mask operator-single-valued-mask))
371     (i386-ff-call . 0)
372     (i386-syscall . 0))))
373
374(defmacro %nx1-operator (sym)
375  (let ((op (assq sym *next-nx-operators*)))
376    (if op (logior (%cdr op) (length (%cdr (memq op *next-nx-operators*))))
377        (error "Bug - operator not found for ~S" sym))))
378
379(declaim (special *nx1-alphatizers* *nx1-operators*))
380
381(defmacro %nx1-default-operator ()
382  `(nx1-default-operator))
383
384(defmacro defnx1 (name sym arglist &body forms)
385  (let ((fn `(nfunction ,name ,(parse-macro name arglist forms)))
386        (theprogn ())
387        (ysym (gensym)))
388    `(let ((,ysym ,fn))
389       ,(if (symbolp sym)
390          `(progn
391             (setf (gethash ',sym *nx1-alphatizers*) ,ysym)
392             ;(proclaim '(inline ,sym))
393             (pushnew ',sym *nx1-compiler-special-forms*))
394          (dolist (x sym `(progn ,@(nreverse theprogn)))
395            (if (consp x)
396              (setq x (%car x))
397              (push `(pushnew ',x *nx1-compiler-special-forms*) theprogn))
398            ;(push `(proclaim '(inline ,x)) theprogn)
399            (push `(setf (gethash ',x *nx1-alphatizers*) ,ysym) theprogn)))
400       (record-source-file ',name 'function)
401       ,ysym)))
402
403(defmacro next-nx-num-ops ()
404  (length *next-nx-operators*))
405
406(defmacro next-nx-defops (&aux (ops (gensym)) 
407                                (num (gensym)) 
408                                (flags (gensym)) 
409                                (op (gensym)))
410  `(let ((,num ,(length *next-nx-operators*)) 
411         (,ops ',*next-nx-operators*) 
412         (,flags nil)
413         (,op nil))
414     (while ,ops
415       (setq ,op (%car ,ops)  ,flags (cdr ,op))
416       (setf (gethash (car ,op) *nx1-operators*) 
417             (logior ,flags (setq ,num (%i- ,num 1))))
418       (setq ,ops (cdr ,ops)))))
419
420(defconstant $fbitnextmethargsp 0)
421(defconstant $fbitmethodp 1)
422(defconstant $fbitnextmethp 2)
423(defconstant $fbitnoregs 3)
424(defconstant $fbitdownward 4)
425(defconstant $fbitresident 5)
426(defconstant $fbitbounddownward 6)
427(defconstant $fbitembeddedlap 7)
428(defconstant $fbitruntimedef 8)
429(defconstant $fbitnonnullenv 9)
430(defconstant $fbitccoverage 10)
431
432(defconstant $eaclosedbit 24)
433
434(defmacro %temp-push (value place &environment env)
435  (if (not (consp place))
436    `(setq ,place (%temp-cons ,value ,place))
437    (multiple-value-bind (dummies vals store-var setter getter)
438                         (get-setf-expansion place env)
439      (let ((valvar (gensym)))
440        `(let* ((,valvar ,value)
441                ,@(mapcar #'list dummies vals)
442                (,(car store-var) (%temp-cons ,valvar ,getter)))
443           ,@dummies
444           ,(car store-var)
445           ,setter)))))
446
447; undo tokens :
448
449(defconstant $undocatch 0)  ; do some nthrowing
450(defconstant $undovalues 1) ; flush pending multiple values
451(defconstant $undostkblk 2) ; discard "variable stack block"
452(defconstant $undospecial 3) ; restore dynamic binding
453(defconstant $undointerruptlevel 4) ; restore dynamic binding of *interrupt-level*
454(defconstant $undomvexpect 5) ; stop expecting values
455(defconstant $undoregs 6)   ; allocated regs when dynamic extent var bound.
456
457; Stuff having to do with lisp:
458
459(defmacro make-acode (operator &rest args)
460  `(%temp-list ,operator ,@args))
461
462(defmacro make-acode* (operator &rest args)
463  `(%temp-cons ,operator (mapcar #'nx1-form ,@args)))
464
465; More Bootstrapping Shit.
466(defmacro acode-operator (form)
467  ;; Gak.
468  `(%car ,form))
469
470(defmacro acode-operand (n form)
471  ;; Gak. Gak.
472  `(nth ,n (the list ,form)))
473
474(defmacro acode-operands (form)
475  ;; Gak. Gak. Gak.
476  `(%cdr ,form))
477
478(defmacro acode-p (x)
479  " A big help this is ..."
480  `(consp ,x))
481
482
483(defmacro defnxdecl (sym lambda-list &body forms)
484  (multiple-value-bind (body decls) (parse-body forms nil t)
485    `(setf (getf *nx-standard-declaration-handlers* ',sym )
486           (function (lambda ,lambda-list
487                       ,@decls
488                       ,@body)))))
489
490(defmacro with-declarations ((pending new-env-var &optional old-env) &body body)
491  `(let* ((,pending (make-pending-declarations))
492          (,new-env-var (new-lexical-environment ,old-env)))
493     ,@body))
494
495(defmacro with-nx-declarations ((pending) &body body)
496  `(let* ((*nx-new-p2decls* nil)
497          (*nx-inlined-self* *nx-inlined-self*))
498    (with-declarations (,pending *nx-lexical-environment* *nx-lexical-environment*)
499      ,@body)))
500
501
502(eval-when (:compile-toplevel :load-toplevel :execute)
503
504(declaim (inline 
505          nx-decl-set-fbit
506          nx-adjust-setq-count
507          nx-init-var
508          nx1-sysnode
509          ))
510
511(defun nx-init-var (state node)
512  (let* ((sym (var-name node))
513         (env *nx-lexical-environment*)
514         (bits (%i+
515                (if (nx-proclaimed-special-p sym)
516                 (if (nx-proclaimed-parameter-p sym)
517                   (%ilogior (ash -1 $vbitspecial) (%ilsl $vbitparameter 1))
518                   (ash -1 $vbitspecial))
519                 0)
520                (if (proclaimed-ignore-p sym) (%ilsl $vbitignore 1) 0))))
521    (push node (lexenv.variables env))
522    (%temp-push node *nx-all-vars*)
523    (setf (var-binding-info node) *nx-bound-vars*)
524    (%temp-push node *nx-bound-vars*)
525    (dolist (decl (nx-effect-vdecls state sym env) (setf (var-bits node) bits))
526      (case (car decl)
527        (special (setq bits (%ilogior bits (ash -1 $vbitspecial) (%ilsl $vbitparameter 1))))
528        (ignore (setq bits (%ilogior bits (%ilsl $vbitignore 1))))
529        ((ignorable ignore-if-unused) (setq bits (%ilogior bits (%ilsl $vbitignoreunused 1))))
530        (dynamic-extent (setq bits (%ilogior bits (%ilsl $vbitdynamicextent 1))))))
531    node))
532
533(defun nx-decl-set-fbit (bit)
534  (when *nx-parsing-lambda-decls*
535    (let* ((afunc *nx-current-function*))
536      (setf (afunc-bits afunc)
537            (%ilogior (%ilsl bit 1)
538                      (afunc-bits afunc))))))
539
540(defun nx-adjust-setq-count (var &optional (by 1) catchp)
541  (let* ((bits (nx-var-bits var))
542         (scaled-by (if (%ilogbitp $vbittemporary bits)
543                      by
544                      (expt 4 *nx-loop-nesting-level*)))
545         (new (%i+ (%ilsr 8 (%ilogand2 $vsetqmask bits)) scaled-by)))
546    (if (%i> new 255) (setq new 255))
547    (setq bits (nx-set-var-bits var (%ilogior (%ilogand (%ilognot $vsetqmask) bits) (%ilsl 8 new))))
548    ;; If a variable is setq'ed from a catch nested within the construct that
549    ;; bound it, it can't be allocated to a register. *
550    ;; * unless it can be proved that the variable isn't referenced
551    ;;   after that catch construct has been exited. **
552    ;; ** or unless the saved value of the register in the catch frame
553    ;;    is also updated.
554    (when catchp
555      (nx-set-var-bits var (%ilogior2 bits (%ilsl $vbitnoreg 1))))
556    (setf (var-refs var) (+ (the fixnum (var-refs var)) by))
557    new))
558
559
560(defun nx1-sysnode (form)
561  (if form
562    (if (eq form t)
563      *nx-t*)
564    *nx-nil*))
565)
566
567(defmacro make-mask (&rest weights)
568  `(logior ,@(mapcar #'(lambda (w) `(ash 1 ,w)) weights)))
569
570(provide "NXENV")
571
Note: See TracBrowser for help on using the repository browser.