X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fx86-64%2Ftarget-insts.lisp;h=8f48d181c0177ab902b9696140666c1681a248b2;hb=69d60b456b07a0256f08df0d02484f361ce5737c;hp=c021af1b2ec44e42e3263654abc66ee6e0eaff5f;hpb=4ebdc81b1a9c6dbed6e98b112afc8dd32b17a2dd;p=sbcl.git diff --git a/src/compiler/x86-64/target-insts.lisp b/src/compiler/x86-64/target-insts.lisp index c021af1..8f48d18 100644 --- a/src/compiler/x86-64/target-insts.lisp +++ b/src/compiler/x86-64/target-insts.lisp @@ -15,16 +15,23 @@ (in-package "SB!VM") -(defun print-mem-access (value stream print-size-p dstate) +;;; Prints a memory reference to STREAM. VALUE is a list of +;;; (BASE-REG OFFSET INDEX-REG INDEX-SCALE), where any component may be +;;; missing or nil to indicate that it's not used or has the obvious +;;; default value (e.g., 1 for the index-scale). BASE-REG can be the +;;; symbol RIP or a full register, INDEX-REG a full register. If WIDTH +;;; is non-nil it should be one of the symbols :BYTE, :WORD, :DWORD or +;;; :QWORD and a corresponding size indicator is printed first. +(defun print-mem-access (value width stream dstate) (declare (type list value) + (type (member nil :byte :word :dword :qword) width) (type stream stream) - (type (member t nil) print-size-p) (type sb!disassem:disassem-state dstate)) - (when print-size-p - (princ (sb!disassem:dstate-get-prop dstate 'width) stream) + (when width + (princ width stream) (princ '| PTR | stream)) (write-char #\[ stream) - (let ((firstp t)) + (let ((firstp t) (rip-p nil)) (macrolet ((pel ((var val) &body body) ;; Print an element of the address, maybe with ;; a leading separator. @@ -35,7 +42,11 @@ ,@body (setq firstp nil))))) (pel (base-reg (first value)) - (print-addr-reg base-reg stream dstate)) + (cond ((eql 'rip base-reg) + (setf rip-p t) + (princ base-reg stream)) + (t + (print-addr-reg base-reg stream dstate)))) (pel (index-reg (third value)) (print-addr-reg index-reg stream dstate) (let ((index-scale (fourth value))) @@ -46,14 +57,26 @@ (when (and offset (or firstp (not (zerop offset)))) (unless (or firstp (minusp offset)) (write-char #\+ stream)) - (if firstp - (progn - (sb!disassem:princ16 offset stream) - (or (minusp offset) - (nth-value 1 - (sb!disassem::note-code-constant-absolute offset dstate)) - (sb!disassem:maybe-note-assembler-routine offset - nil - dstate))) - (princ offset stream)))))) + (cond + (rip-p + (princ offset stream) + (let ((addr (+ offset (sb!disassem:dstate-next-addr dstate)))) + (when (plusp addr) + (or (nth-value 1 + (sb!disassem::note-code-constant-absolute + addr dstate)) + (sb!disassem:maybe-note-assembler-routine addr + nil + dstate))))) + (firstp + (progn + (sb!disassem:princ16 offset stream) + (or (minusp offset) + (nth-value 1 + (sb!disassem::note-code-constant-absolute offset dstate)) + (sb!disassem:maybe-note-assembler-routine offset + nil + dstate)))) + (t + (princ offset stream))))))) (write-char #\] stream))