62f3561cd90597443ee482a9dccd9b2821283913
[sbcl.git] / src / compiler / early-assem.lisp
1 ;;;; constants and types for assembly
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!ASSEM")
13
14 (sb!int:file-comment
15   "$Header$")
16
17 ;;; FIXME: It might make sense to use SB!VM:BYTE-FOO values here
18 ;;; instead of the various ASSEMBLY-UNIT-FOO things, and then define a
19 ;;; BYTE type. One problem: BYTE is exported from the CL package, so
20 ;;; ANSI says that we're not supposed to be attaching any new meanings
21 ;;; to it. Perhaps rename SB!VM:BYTE-FOO to SB!VM:VMBYTE-FOO or
22 ;;; SB!VM:VM-BYTE-FOO, and then define the SB!VM:VMBYTE or
23 ;;; SB!VM:VM-BYTE types?
24 ;;;
25 ;;; If this was done, some of this file could go away, and the rest
26 ;;; could probably be merged back into assem.lisp. (This file was
27 ;;; created simply in order to move the ASSEMBLY-UNIT-related
28 ;;; definitions before compiler/generic/core.lisp in the build
29 ;;; sequence.)
30
31 ;;; ASSEMBLY-UNIT-BITS -- the number of bits in the minimum assembly
32 ;;; unit, (also refered to as a ``byte''). Hopefully, different
33 ;;; instruction sets won't require changing this.
34 (defconstant assembly-unit-bits 8)
35 (defconstant assembly-unit-mask (1- (ash 1 assembly-unit-bits)))
36
37 (deftype assembly-unit ()
38   `(unsigned-byte ,assembly-unit-bits))
39
40 ;;; Some functions which accept assembly units can meaningfully accept
41 ;;; signed values with the same number of bits and silently munge them
42 ;;; into appropriate unsigned values. (This is handy behavior e.g.
43 ;;; when assembling branch instructions on the X86.)
44 (deftype possibly-signed-assembly-unit ()
45   `(or assembly-unit
46        (signed-byte ,assembly-unit-bits)))
47
48 ;;; the maximum alignment we can guarantee given the object format. If
49 ;;; the loader only loads objects 8-byte aligned, we can't do any
50 ;;; better then that ourselves.
51 (defconstant max-alignment 3)
52
53 (deftype alignment ()
54   `(integer 0 ,max-alignment))