1 ;;;; target-only stuff from CMU CL's src/compiler/x86/insts.lisp
3 ;;;; i.e. stuff which was in CMU CL's insts.lisp file, but which in
4 ;;;; the SBCL build process can't be compiled into code for the
5 ;;;; cross-compilation host
7 ;;;; This software is part of the SBCL system. See the README file for
10 ;;;; This software is derived from the CMU CL system, which was
11 ;;;; written at Carnegie Mellon University and released into the
12 ;;;; public domain. The software is in the public domain and is
13 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
14 ;;;; files for more information.
18 ;;; Prints a memory reference to STREAM. VALUE is a list of
19 ;;; (BASE-REG OFFSET INDEX-REG INDEX-SCALE), where any component may be
20 ;;; missing or nil to indicate that it's not used or has the obvious
21 ;;; default value (e.g., 1 for the index-scale). BASE-REG can be the
22 ;;; symbol RIP or a full register, INDEX-REG a full register. If WIDTH
23 ;;; is non-nil it should be one of the symbols :BYTE, :WORD, :DWORD or
24 ;;; :QWORD and a corresponding size indicator is printed first.
25 (defun print-mem-access (value width stream dstate
)
26 (declare (type list value
)
27 (type (member nil
:byte
:word
:dword
:qword
) width
)
29 (type sb
!disassem
:disassem-state dstate
))
32 (princ '| PTR | stream
))
33 (write-char #\
[ stream
)
34 (let ((firstp t
) (rip-p nil
))
35 (macrolet ((pel ((var val
) &body body
)
36 ;; Print an element of the address, maybe with
37 ;; a leading separator.
41 (write-char #\
+ stream
))
44 (pel (base-reg (first value
))
45 (cond ((eql 'rip base-reg
)
47 (princ base-reg stream
))
49 (print-addr-reg base-reg stream dstate
))))
50 (pel (index-reg (third value
))
51 (print-addr-reg index-reg stream dstate
)
52 (let ((index-scale (fourth value
)))
53 (when (and index-scale
(not (= index-scale
1)))
54 (write-char #\
* stream
)
55 (princ index-scale stream
))))
56 (let ((offset (second value
)))
57 (when (and offset
(or firstp
(not (zerop offset
))))
58 (unless (or firstp
(minusp offset
))
59 (write-char #\
+ stream
))
63 (let ((addr (+ offset
(sb!disassem
:dstate-next-addr dstate
))))
66 (sb!disassem
::note-code-constant-absolute
68 (sb!disassem
:maybe-note-assembler-routine addr
73 (sb!disassem
:princ16 offset stream
)
76 (sb!disassem
::note-code-constant-absolute offset dstate
))
77 (sb!disassem
:maybe-note-assembler-routine offset
81 (princ offset stream
)))))))
82 (write-char #\
] stream
))