Use SB!IMPL as the implementation package for PARSE-BODY
[sbcl.git] / src / code / cross-byte.lisp
blobc6e95d654064014f81447b4ffb31fed33d5ec89c
1 ;;;; cross-compile-time-only replacements for byte-specifier
2 ;;;; machinery.
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.
13 (in-package "SB!INT")
15 ;; Inlining these allows type inference to work.
16 (declaim (inline sb!xc:dpb sb!xc:ldb sb!xc:mask-field))
18 (defun sb!xc:byte (size position)
19 (cons size position))
21 (defun sb!xc:byte-size (cross-byte)
22 (car cross-byte))
24 (defun sb!xc:byte-position (cross-byte)
25 (cdr cross-byte))
27 (defun uncross-byte (cross-byte)
28 (cl:byte (sb!xc:byte-size cross-byte) (sb!xc:byte-position cross-byte)))
30 (defun sb!xc:ldb (cross-byte int)
31 (cl:ldb (uncross-byte cross-byte) int))
33 (defun sb!xc:ldb-test (cross-byte int)
34 (cl:ldb-test (uncross-byte cross-byte) int))
36 (defun sb!xc:dpb (new cross-byte int)
37 (cl:dpb new (uncross-byte cross-byte) int))
39 (defun sb!xc:mask-field (cross-byte int)
40 (cl:mask-field (uncross-byte cross-byte) int))
42 (defun sb!xc:deposit-field (new cross-byte int)
43 (cl:deposit-field new (uncross-byte cross-byte) int))
45 (declaim (ftype function bug))
46 (define-setf-expander sb!xc:ldb (cross-byte int &environment env)
47 (multiple-value-bind (temps vals stores store-form access-form)
48 (get-setf-expansion int env)
49 (when (cdr stores)
50 (bug "SETF SB!XC:LDB too hairy!"))
51 (let ((btemp (gensym))
52 (store (gensym)))
53 (values (cons btemp temps)
54 (cons cross-byte vals)
55 (list store)
56 `(let ((,(car stores) (cl:dpb ,store (uncross-byte ,btemp) ,access-form)))
57 ,store-form
58 ,store)
59 `(cl:ldb (uncross-byte ,btemp) ,access-form)))))
61 (define-setf-expander sb!xc:mask-field (cross-byte int &environment env)
62 (multiple-value-bind (temps vals stores store-form access-form)
63 (get-setf-expansion int env)
64 (when (cdr stores)
65 (bug "SETF SB!XC:MASK-FIELD too hairy!"))
66 (let ((btemp (gensym))
67 (store (gensym)))
68 (values (cons btemp temps)
69 (cons cross-byte vals)
70 (list store)
71 `(let ((,(car stores) (cl:deposit-field ,store (uncross-byte ,btemp) ,access-form)))
72 ,store-form
73 ,store)
74 `(cl:mask-field (uncross-byte ,btemp) ,access-form)))))