source: release/1.4/source/level-0/X86/X8632/x8632-array.lisp

Last change on this file was 13075, checked in by R. Matthew Emerson, 15 years ago

Merge trunk changes r13066 through r13067.
(copyright notices)

File size: 8.9 KB
RevLine 
[13075]1;;; Copyright 2009 Clozure Associates
2;;; This file is part of Clozure CL.
3;;;
4;;; Clozure CL is licensed under the terms of the Lisp Lesser GNU
5;;; Public License , known as the LLGPL and distributed with Clozure
6;;; CL as the file "LICENSE". The LLGPL consists of a preamble and
7;;; the LGPL, which is distributed with Clozure CL as the file "LGPL".
8;;; Where these conflict, the preamble takes precedence.
9;;;
10;;; Clozure CL is referenced in the preamble as the "LIBRARY."
11;;;
12;;; The LLGPL is also available online at
13;;; http://opensource.franz.com/preamble.html
14
[7332]15(in-package "CCL")
16
17(eval-when (:compile-toplevel :execute)
18 (require "X8632-ARCH")
19 (require "X86-LAPMACROS"))
20
[7910]21;; rewrite in LAP someday (soon).
22(defun %init-misc (val uvector)
23 (dotimes (i (uvsize uvector) uvector)
24 (setf (uvref uvector i) val)))
25
26;;; Make a new vector of size newsize whose subtag matches that of oldv-arg.
27;;; Blast the contents of the old vector into the new one as quickly as
28;;; possible; leave remaining elements of new vector undefined (0).
29;;; Return new-vector.
30(defun %extend-vector (start oldv newsize)
31 (declare (fixnum start))
32 (let* ((new (%alloc-misc newsize (typecode oldv)))
33 (oldsize (uvsize oldv)))
34 (declare (fixnum oldsize))
35 (do* ((i 0 (1+ i))
36 (j start (1+ j)))
37 ((= i oldsize) new)
38 (declare (fixnum i j))
39 (setf (uvref new j) (uvref oldv i)))))
40
[7349]41;;; argument is a vector header or an array header. Or else.
[7910]42(defx8632lapfunction %array-header-data-and-offset ((a arg_z))
[7349]43 (let ((offset arg_y)
44 (temp temp1))
45 (movl (% esp) (% temp0))
46 (movl ($ '0) (%l offset))
47 (movl (% a) (% temp))
48 @loop
49 (movl (@ target::arrayH.data-vector (% temp)) (% a))
50 (extract-subtag a imm0)
51 (addl (@ target::arrayH.displacement (% temp)) (% offset))
52 (rcmp (% imm0) ($ target::subtag-vectorH))
53 (movl (% a) (% temp))
54 (jle @loop)
55 (push (% a))
56 (push (% offset))
57 (set-nargs 2)
58 (jmp-subprim .SPvalues)))
59
[7910]60(defx8632lapfunction %boole-clr ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]61 (movl (@ idx (% esp)) (% temp0))
62 (movl ($ 0) (@ x8632::misc-data-offset (% dest) (% temp0)))
63 (single-value-return 4))
64
[7910]65(defx8632lapfunction %boole-set ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]66 (movl (@ idx (% esp)) (% temp0))
67 (movl ($ -1) (@ x8632::misc-data-offset (% dest) (% temp0)))
68 (single-value-return 4))
69
[7910]70(defx8632lapfunction %boole-1 ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]71 (movl (@ idx (% esp)) (% temp0))
72 (movl (@ b0 (% esp)) (% temp1))
73 (movl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
74 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
75 (single-value-return 4))
76
[7910]77(defx8632lapfunction %boole-2 ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]78 (movl (@ idx (% esp)) (% temp0))
79 (movl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
80 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
81 (single-value-return 4))
82
[7910]83(defx8632lapfunction %boole-c1 ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]84 (movl (@ idx (% esp)) (% temp0))
85 (movl (@ b0 (% esp)) (% temp1))
86 (movl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
87 (notl (% imm0))
88 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
89 (single-value-return 4))
90
[7910]91(defx8632lapfunction %boole-c2 ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]92 (movl (@ idx (% esp)) (% temp0))
93 (movl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
94 (notl (% imm0))
95 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
96 (single-value-return 4))
97
[7910]98(defx8632lapfunction %boole-and ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]99 (movl (@ idx (% esp)) (% temp0))
100 (movl (@ b0 (% esp)) (% temp1))
101 (movl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
102 (andl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
103 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
104 (single-value-return 4))
105
[7910]106(defx8632lapfunction %boole-ior ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]107 (movl (@ idx (% esp)) (% temp0))
108 (movl (@ b0 (% esp)) (% temp1))
109 (movl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
110 (orl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
111 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
112 (single-value-return 4))
113
[7910]114(defx8632lapfunction %boole-xor ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]115 (movl (@ idx (% esp)) (% temp0))
116 (movl (@ b0 (% esp)) (% temp1))
117 (movl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
118 (xorl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
119 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
120 (single-value-return 4))
121
[7910]122(defx8632lapfunction %boole-eqv ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]123 (movl (@ idx (% esp)) (% temp0))
124 (movl (@ b0 (% esp)) (% temp1))
125 (movl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
126 (xorl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
127 (notl (% imm0))
128 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
129 (single-value-return 4))
130
[7910]131(defx8632lapfunction %boole-nand ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]132 (movl (@ idx (% esp)) (% temp0))
133 (movl (@ b0 (% esp)) (% temp1))
134 (movl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
135 (andl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
136 (notl (% imm0))
137 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
138 (single-value-return 4))
139
[7910]140(defx8632lapfunction %boole-nor ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]141 (movl (@ idx (% esp)) (% temp0))
142 (movl (@ b0 (% esp)) (% temp1))
143 (movl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
144 (orl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
145 (notl (% imm0))
146 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
147 (single-value-return 4))
148
[7910]149(defx8632lapfunction %boole-andc1 ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]150 (movl (@ idx (% esp)) (% temp0))
151 (movl (@ b0 (% esp)) (% temp1))
152 (movl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
153 (notl (% imm0))
154 (andl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
155 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
156 (single-value-return 4))
157
[7910]158(defx8632lapfunction %boole-andc2 ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]159 (movl (@ idx (% esp)) (% temp0))
160 (movl (@ b0 (% esp)) (% temp1))
161 (movl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
162 (notl (% imm0))
163 (andl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
164 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
165 (single-value-return 4))
166
[7910]167(defx8632lapfunction %boole-orc1 ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]168 (movl (@ idx (% esp)) (% temp0))
169 (movl (@ b0 (% esp)) (% temp1))
170 (movl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
171 (notl (% imm0))
172 (orl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
173 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
174 (single-value-return 4))
175
[7910]176(defx8632lapfunction %boole-orc2 ((idx 8) (b0 4) #|(ra 0)|# (b1 arg_y) (dest arg_z))
[7349]177 (movl (@ idx (% esp)) (% temp0))
178 (movl (@ b0 (% esp)) (% temp1))
179 (movl (@ x8632::misc-data-offset (% b1) (% temp0)) (% imm0))
180 (notl (% imm0))
181 (orl (@ x8632::misc-data-offset (% temp1) (% temp0)) (% imm0))
182 (movl (% imm0) (@ x8632::misc-data-offset (% dest) (% temp0)))
183 (single-value-return 4))
184
[7910]185(defparameter *simple-bit-boole-functions* ())
186
187(setq *simple-bit-boole-functions*
188 (vector
189 #'%boole-clr
190 #'%boole-set
191 #'%boole-1
192 #'%boole-2
193 #'%boole-c1
194 #'%boole-c2
195 #'%boole-and
196 #'%boole-ior
197 #'%boole-xor
198 #'%boole-eqv
199 #'%boole-nand
200 #'%boole-nor
201 #'%boole-andc1
202 #'%boole-andc2
203 #'%boole-orc1
204 #'%boole-orc2))
205
206(defun %simple-bit-boole (op b1 b2 result)
207 (let* ((f (svref *simple-bit-boole-functions* op)))
208 (dotimes (i (ash (the fixnum (+ (length result) 31)) -5) result)
209 (funcall f i b1 b2 result))))
210
[9673]211(defx8632lapfunction %aref2 ((array 4) #|(ra 0)|# (i arg_y) (j arg_z))
212 (check-nargs 3)
213 (popl (@ 8 (% esp))) ;ra to first word of reserved frame
214 (pop (% temp0))
215 (addl ($ '1) (% esp)) ;discard other word of reserved frame
216 (jmp-subprim .SParef2))
[7332]217
[9673]218(defx8632lapfunction %aref3 ((array 8) (i 4) #|(ra 0)|# (j arg_y) (k arg_z))
219 (check-nargs 4)
220 (popl (@ 12 (% esp)))
221 (pop (% temp0))
222 (pop (% temp1))
223 (addl ($ '1) (% esp))
224 (jmp-subprim .SParef3))
[7332]225
[9673]226(defx8632lapfunction %aset2 ((array 8) (i 4) #|(ra 0)|# (j arg_y) (newval arg_z))
227 (check-nargs 4)
228 (popl (@ 12 (% esp)))
229 (pop (% temp0))
230 (pop (% temp1))
231 (addl ($ '1) (% esp))
232 (jmp-subprim .SPaset2))
[7332]233
[11238]234;;; We're out of registers. Put i on the stack.
[11222]235(defx8632lapfunction %aset3 ((array 12) (i 8) (j 4) #|(ra 0)|# (k arg_y) (newval arg_z))
[9673]236 (check-nargs 5)
237 (popl (@ 16 (% esp)))
238 (pop (% temp0))
[11238]239 (popl (@ 4 (% esp)))
[9673]240 (pop (% temp1))
241 (jmp-subprim .SPaset3))
[7332]242
Note: See TracBrowser for help on using the repository browser.