Initial revision
[sbcl.git] / src / compiler / x86 / target-insts.lisp
1 ;;;; target-only stuff from CMU CL's src/compiler/x86/insts.lisp
2
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
11
12 (in-package "SB!VM")
13
14 (file-comment
15   "$Header$")
16
17 (defun print-mem-access (value stream print-size-p dstate)
18   (declare (type list value)
19            (type stream stream)
20            (type (member t nil) print-size-p)
21            (type sb!disassem:disassem-state dstate))
22   (when print-size-p
23     (princ (sb!disassem:dstate-get-prop dstate 'width) stream)
24     (princ '| PTR | stream))
25   (write-char #\[ stream)
26   (let ((firstp t))
27     (macrolet ((pel ((var val) &body body)
28                  ;; Print an element of the address, maybe with
29                  ;; a leading separator.
30                  `(let ((,var ,val))
31                     (when ,var
32                       (unless firstp
33                         (write-char #\+ stream))
34                       ,@body
35                       (setq firstp nil)))))
36       (pel (base-reg (first value))
37         (print-addr-reg base-reg stream dstate))
38       (pel (index-reg (third value))
39         (print-addr-reg index-reg stream dstate)
40         (let ((index-scale (fourth value)))
41           (when (and index-scale (not (= index-scale 1)))
42             (write-char #\* stream)
43             (princ index-scale stream))))
44       (let ((offset (second value)))
45         (when (and offset (or firstp (not (zerop offset))))
46           (unless (or firstp (minusp offset))
47             (write-char #\+ stream))
48           (if firstp
49               (sb!disassem:princ16 offset stream)
50               (princ offset stream))))))
51   (write-char #\] stream))