source: branches/rme-logops/compiler/nxenv.lisp @ 15706

Last change on this file since 15706 was 13876, checked in by rme, 9 years ago

purported improvements to logand

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 33.7 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     (%fixnum-mask-to-natural  . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask)))))
374
375(defmacro %nx1-operator (sym)
376  (let ((op (assq sym *next-nx-operators*)))
377    (if op (logior (%cdr op) (length (%cdr (memq op *next-nx-operators*))))
378        (error "Bug - operator not found for ~S" sym))))
379
380(declaim (special *nx1-alphatizers* *nx1-operators*))
381
382(defmacro %nx1-default-operator ()
383  `(nx1-default-operator))
384
385(defmacro defnx1 (name sym arglist &body forms)
386  (let ((fn `(nfunction ,name ,(parse-macro name arglist forms)))
387        (theprogn ())
388        (ysym (gensym)))
389    `(let ((,ysym ,fn))
390       ,(if (symbolp sym)
391          `(progn
392             (setf (gethash ',sym *nx1-alphatizers*) ,ysym)
393             ;(proclaim '(inline ,sym))
394             (pushnew ',sym *nx1-compiler-special-forms*))
395          (dolist (x sym `(progn ,@(nreverse theprogn)))
396            (if (consp x)
397              (setq x (%car x))
398              (push `(pushnew ',x *nx1-compiler-special-forms*) theprogn))
399            ;(push `(proclaim '(inline ,x)) theprogn)
400            (push `(setf (gethash ',x *nx1-alphatizers*) ,ysym) theprogn)))
401       (record-source-file ',name 'function)
402       ,ysym)))
403
404(defmacro next-nx-num-ops ()
405  (length *next-nx-operators*))
406
407(defmacro next-nx-defops (&aux (ops (gensym)) 
408                                (num (gensym)) 
409                                (flags (gensym)) 
410                                (op (gensym)))
411  `(let ((,num ,(length *next-nx-operators*)) 
412         (,ops ',*next-nx-operators*) 
413         (,flags nil)
414         (,op nil))
415     (while ,ops
416       (setq ,op (%car ,ops)  ,flags (cdr ,op))
417       (setf (gethash (car ,op) *nx1-operators*) 
418             (logior ,flags (setq ,num (%i- ,num 1))))
419       (setq ,ops (cdr ,ops)))))
420
421(defconstant $fbitnextmethargsp 0)
422(defconstant $fbitmethodp 1)
423(defconstant $fbitnextmethp 2)
424(defconstant $fbitnoregs 3)
425(defconstant $fbitdownward 4)
426(defconstant $fbitresident 5)
427(defconstant $fbitbounddownward 6)
428(defconstant $fbitembeddedlap 7)
429(defconstant $fbitruntimedef 8)
430(defconstant $fbitnonnullenv 9)
431(defconstant $fbitccoverage 10)
432
433(defconstant $eaclosedbit 24)
434
435(defmacro %temp-push (value place &environment env)
436  (if (not (consp place))
437    `(setq ,place (%temp-cons ,value ,place))
438    (multiple-value-bind (dummies vals store-var setter getter)
439                         (get-setf-expansion place env)
440      (let ((valvar (gensym)))
441        `(let* ((,valvar ,value)
442                ,@(mapcar #'list dummies vals)
443                (,(car store-var) (%temp-cons ,valvar ,getter)))
444           ,@dummies
445           ,(car store-var)
446           ,setter)))))
447
448; undo tokens :
449
450(defconstant $undocatch 0)  ; do some nthrowing
451(defconstant $undovalues 1) ; flush pending multiple values
452(defconstant $undostkblk 2) ; discard "variable stack block"
453(defconstant $undospecial 3) ; restore dynamic binding
454(defconstant $undointerruptlevel 4) ; restore dynamic binding of *interrupt-level*
455(defconstant $undomvexpect 5) ; stop expecting values
456(defconstant $undoregs 6)   ; allocated regs when dynamic extent var bound.
457
458; Stuff having to do with lisp:
459
460(defmacro make-acode (operator &rest args)
461  `(%temp-list ,operator ,@args))
462
463(defmacro make-acode* (operator &rest args)
464  `(%temp-cons ,operator (mapcar #'nx1-form ,@args)))
465
466; More Bootstrapping Shit.
467(defmacro acode-operator (form)
468  ;; Gak.
469  `(%car ,form))
470
471(defmacro acode-operand (n form)
472  ;; Gak. Gak.
473  `(nth ,n (the list ,form)))
474
475(defmacro acode-operands (form)
476  ;; Gak. Gak. Gak.
477  `(%cdr ,form))
478
479(defmacro acode-p (x)
480  " A big help this is ..."
481  `(consp ,x))
482
483
484(defmacro defnxdecl (sym lambda-list &body forms)
485  (multiple-value-bind (body decls) (parse-body forms nil t)
486    `(setf (getf *nx-standard-declaration-handlers* ',sym )
487           (function (lambda ,lambda-list
488                       ,@decls
489                       ,@body)))))
490
491(defmacro with-declarations ((pending new-env-var &optional old-env) &body body)
492  `(let* ((,pending (make-pending-declarations))
493          (,new-env-var (new-lexical-environment ,old-env)))
494     ,@body))
495
496(defmacro with-nx-declarations ((pending) &body body)
497  `(let* ((*nx-new-p2decls* nil)
498          (*nx-inlined-self* *nx-inlined-self*))
499    (with-declarations (,pending *nx-lexical-environment* *nx-lexical-environment*)
500      ,@body)))
501
502
503(eval-when (:compile-toplevel :load-toplevel :execute)
504
505(declaim (inline 
506          nx-decl-set-fbit
507          nx-adjust-setq-count
508          nx-init-var
509          nx1-sysnode
510          ))
511
512(defun nx-init-var (state node)
513  (let* ((sym (var-name node))
514         (env *nx-lexical-environment*)
515         (bits (%i+
516                (if (nx-proclaimed-special-p sym)
517                 (if (nx-proclaimed-parameter-p sym)
518                   (%ilogior (ash -1 $vbitspecial) (%ilsl $vbitparameter 1))
519                   (ash -1 $vbitspecial))
520                 0)
521                (if (proclaimed-ignore-p sym) (%ilsl $vbitignore 1) 0))))
522    (push node (lexenv.variables env))
523    (%temp-push node *nx-all-vars*)
524    (setf (var-binding-info node) *nx-bound-vars*)
525    (%temp-push node *nx-bound-vars*)
526    (dolist (decl (nx-effect-vdecls state sym env) (setf (var-bits node) bits))
527      (case (car decl)
528        (special (setq bits (%ilogior bits (ash -1 $vbitspecial) (%ilsl $vbitparameter 1))))
529        (ignore (setq bits (%ilogior bits (%ilsl $vbitignore 1))))
530        ((ignorable ignore-if-unused) (setq bits (%ilogior bits (%ilsl $vbitignoreunused 1))))
531        (dynamic-extent (setq bits (%ilogior bits (%ilsl $vbitdynamicextent 1))))))
532    node))
533
534(defun nx-decl-set-fbit (bit)
535  (when *nx-parsing-lambda-decls*
536    (let* ((afunc *nx-current-function*))
537      (setf (afunc-bits afunc)
538            (%ilogior (%ilsl bit 1)
539                      (afunc-bits afunc))))))
540
541(defun nx-adjust-setq-count (var &optional (by 1) catchp)
542  (let* ((bits (nx-var-bits var))
543         (scaled-by (if (%ilogbitp $vbittemporary bits)
544                      by
545                      (expt 4 *nx-loop-nesting-level*)))
546         (new (%i+ (%ilsr 8 (%ilogand2 $vsetqmask bits)) scaled-by)))
547    (if (%i> new 255) (setq new 255))
548    (setq bits (nx-set-var-bits var (%ilogior (%ilogand (%ilognot $vsetqmask) bits) (%ilsl 8 new))))
549    ;; If a variable is setq'ed from a catch nested within the construct that
550    ;; bound it, it can't be allocated to a register. *
551    ;; * unless it can be proved that the variable isn't referenced
552    ;;   after that catch construct has been exited. **
553    ;; ** or unless the saved value of the register in the catch frame
554    ;;    is also updated.
555    (when catchp
556      (nx-set-var-bits var (%ilogior2 bits (%ilsl $vbitnoreg 1))))
557    (setf (var-refs var) (+ (the fixnum (var-refs var)) by))
558    new))
559
560
561(defun nx1-sysnode (form)
562  (if form
563    (if (eq form t)
564      *nx-t*)
565    *nx-nil*))
566)
567
568(defmacro make-mask (&rest weights)
569  `(logior ,@(mapcar #'(lambda (w) `(ash 1 ,w)) weights)))
570
571(provide "NXENV")
572
Note: See TracBrowser for help on using the repository browser.