Fix make-array transforms.
[sbcl.git] / src / compiler / fixup.lisp
1 ;;;; fixups, extracted from codegen.lisp by WHN 19990227 in order
2 ;;;; to help with cross-compiling bootstrapping
3
4 ;;;; This software is part of the SBCL system. See the README file for
5 ;;;; more information.
6 ;;;;
7 ;;;; This software is derived from the CMU CL system, which was
8 ;;;; written at Carnegie Mellon University and released into the
9 ;;;; public domain. The software is in the public domain and is
10 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
11 ;;;; files for more information.
12
13 (in-package "SB!C")
14
15 ;;; a fixup of some kind
16 (defstruct (fixup
17             (:constructor make-fixup (name flavor &optional offset))
18             (:copier nil))
19   ;; the name and flavor of the fixup. The assembler makes no
20   ;; assumptions about the contents of these fields; their semantics
21   ;; are imposed by the dumper.
22   name
23   flavor
24   ;; OFFSET is an optional offset from whatever external label this
25   ;; fixup refers to. Or in the case of the :CODE-OBJECT flavor of
26   ;; fixups on the :X86 architecture, NAME is always NIL, so this
27   ;; fixup doesn't refer to an external label, and OFFSET is an offset
28   ;; from the beginning of the current code block.
29   offset)
30
31 (defstruct (fixup-note
32              (:constructor make-fixup-note (kind fixup position))
33              (:copier nil))
34   kind
35   fixup
36   position)
37
38 (defvar *fixup-notes*)
39
40 ;;; Setting this variable lets you see what's going on as items are
41 ;;; being pushed onto *FIXUPS*.
42 #!+sb-show (defvar *show-fixups-being-pushed-p* nil)
43
44 ;;; This function is called by assembler instruction emitters when
45 ;;; they find themselves trying to deal with a fixup.
46 (defun note-fixup (segment kind fixup)
47   (sb!assem:emit-back-patch segment
48                             0
49                             (lambda (segment posn)
50                               (declare (ignore segment))
51                               ;; Why use EMIT-BACK-PATCH to cause this PUSH to
52                               ;; be done later, instead of just doing it now?
53                               ;; I'm not sure. Perhaps there's some concern
54                               ;; that POSN isn't known accurately now? Perhaps
55                               ;; there's a desire for all fixing up to go
56                               ;; through EMIT-BACK-PATCH whether it needs to or
57                               ;; not? -- WHN 19990905
58                               #!+sb-show
59                               (when *show-fixups-being-pushed-p*
60                                 (/show "PUSHING FIXUP" kind fixup posn))
61                               (push (make-fixup-note kind fixup posn) *fixup-notes*)))
62   (values))