[Sbcl-devel] howto: add a new immediate primitive to sbcl

This is a rough list of what I had to do to get a new immediate
primitive into sbcl-0.6.13.
Since I wasn't sure of why I was doing a lot of what I was doing at the
time, it's a bit short on reasoning.
One day, I might go though this and try to give proper reasons for each
step, but that's a ways off.
TOP
[package-data-list.lisp-expr] ; note this requires a clean rebuild to
propagate
"UNICODE-CHAR-P"
"OBJECT-NOT-UNICODE-CHAR-ERROR"
"UNICODE-CHAR-TYPE"
[common-lisp-exports.lisp-expr] ; note this probably does too
"UNICODE-CHAR"
COMPILER
[compiler/generic/primtype.lisp]
(/show0 "primtype.lisp 69")
(!def-primitive-type unicode-char (any-reg)) ; <- not sure about any-reg
[compiler/generic/interr.lisp]
(object-not-unicode-char
"Object is not of type UNICODE-CHAR.")
[compiler/generic/early-objdef.lisp]
unicode-char
This actually makes the type reference value I think.
[compiler/generic/vm-typetran.lisp]
(define-type-predicate unicode-char-p unicode-char)
[compiler/generic/vm-fndb.lisp]
unicode-char-p
Defknown predicate form.
[compiler/generic/primtype.lisp] (maybe)
(unicode-char
(exactly unicode-char))
[compiler/x86/type-vops.lisp]
unicode-char-type
Add to immediate types list
(def-type-vops unicode-char-p check-unicode-char unicode-char
object-not-unicode-char-error unicode-char-type)
CODE
[code/class.lisp]
(unicode-char
:enumerable t
:translation unicode-char
:codes (#.sb!vm:unicode-char-type))
Commented this out for now...
[code/interr.lisp]
(deferr object-not-unicode-char-error (object)
(error 'type-error
:datum object
:expected-type 'unicode-char))
[code/pred.lisp]
(def-type-predicate-wrapper unicode-char-p)
[code/early-cl.lisp]
unicode-char
[code/class.lisp]
(unicode-char
:translation unicode-char
:inherits (character)
:codes (#.sb!vm:unicode-char-type))
Plus a bunch of incidental changes in the Runtime c code.
And some incidentals to fix up sbcl's rather fragile 'immediate value'
detection code in lisp.
All in all, a lot of stuffing about, but hopefully this will be more
helpful than confusing to someone trying to do similarly.
Regards,
Brian

Thread view

This is a rough list of what I had to do to get a new immediate
primitive into sbcl-0.6.13.
Since I wasn't sure of why I was doing a lot of what I was doing at the
time, it's a bit short on reasoning.
One day, I might go though this and try to give proper reasons for each
step, but that's a ways off.
TOP
[package-data-list.lisp-expr] ; note this requires a clean rebuild to
propagate
"UNICODE-CHAR-P"
"OBJECT-NOT-UNICODE-CHAR-ERROR"
"UNICODE-CHAR-TYPE"
[common-lisp-exports.lisp-expr] ; note this probably does too
"UNICODE-CHAR"
COMPILER
[compiler/generic/primtype.lisp]
(/show0 "primtype.lisp 69")
(!def-primitive-type unicode-char (any-reg)) ; <- not sure about any-reg
[compiler/generic/interr.lisp]
(object-not-unicode-char
"Object is not of type UNICODE-CHAR.")
[compiler/generic/early-objdef.lisp]
unicode-char
This actually makes the type reference value I think.
[compiler/generic/vm-typetran.lisp]
(define-type-predicate unicode-char-p unicode-char)
[compiler/generic/vm-fndb.lisp]
unicode-char-p
Defknown predicate form.
[compiler/generic/primtype.lisp] (maybe)
(unicode-char
(exactly unicode-char))
[compiler/x86/type-vops.lisp]
unicode-char-type
Add to immediate types list
(def-type-vops unicode-char-p check-unicode-char unicode-char
object-not-unicode-char-error unicode-char-type)
CODE
[code/class.lisp]
(unicode-char
:enumerable t
:translation unicode-char
:codes (#.sb!vm:unicode-char-type))
Commented this out for now...
[code/interr.lisp]
(deferr object-not-unicode-char-error (object)
(error 'type-error
:datum object
:expected-type 'unicode-char))
[code/pred.lisp]
(def-type-predicate-wrapper unicode-char-p)
[code/early-cl.lisp]
unicode-char
[code/class.lisp]
(unicode-char
:translation unicode-char
:inherits (character)
:codes (#.sb!vm:unicode-char-type))
Plus a bunch of incidental changes in the Runtime c code.
And some incidentals to fix up sbcl's rather fragile 'immediate value'
detection code in lisp.
All in all, a lot of stuffing about, but hopefully this will be more
helpful than confusing to someone trying to do similarly.
Regards,
Brian