[ Home ]
SBCL Internals

The pages on this CLiki-driven site can be edited by anybody at any time. No warranty of any kind can therefore be made; any implied warranties of merchantability or fitness for a particular purpose are expressly disclaimed
[ Home ] [ Recent Changes ] [ About CLiki ] [ Text Formatting ]

Register usage varies significantly between x86 and the other ports, and this drives a lot of the other differences (such as Conservative GC? between that port and the others.

On non-x86 ports, we typically have a reasonable number of general-purpose registers, and we can partition the set into descriptor? (boxed) and non-descriptor? registers. The former are expected to be usable as roots for GC, and the latter can be used for intermediate values that may look like but aren't actually Lisp objects.

x86 doesn't have enough registers to split them this way, so we don't. This means that we have to be conservative about collecting garbage.

This page deals mostly with sane architectures - intel users should not assume this page is correct for their port.

SBCL divides registers into Boxed Registers and Unboxed Registers?, and gives them all funny names to annoy you when you're using gdb. The SBCL names for registers are however (mostly) consistent between backends, except where they don't exist (some architectures have more argument passing registers, others have more unboxed FFI argument registers, etc)

This example is from the PPC. Ignore the actual numbers, which are out of date; if you want up to date information, look at src/runtime/ppc-lispregs.h or the equivalent for your port. This also lists which registers are boxed.

Note also that this file is manually kept in sync with the information in src/compiler/$SBCL_ARCH/vm.lisp. Once And Only Once?

#define reg_ZERO      REG(0) /* Should always contain 0 in lisp */
#define reg_NSP       REG(1) /* The Number Stack pointer */
#define reg_POLL      REG(2) /* Lisp preemption/Mystery SVR4 ABI reg */
#define reg_NL0       REG(3) /* FF param/result 1 */
#define reg_NL1       REG(4) /* FF param/result 2 */
#define reg_NL2       REG(5) /* FF param 3 */
#define reg_NL3       REG(6)
#define reg_NL4       REG(7)
#define reg_NL5       REG(8)
#define reg_NL6       REG(9)
#define reg_NL7       REG(10) /* Last (8th) FF param */
#define reg_NARGS     REG(11)   /* Number of args passed/values returned to/from a function */
#define reg_NFP       REG(12) /* Number stack frame pointer */
#define reg_CFUNC     REG(13) /* Silly to blow a reg on FF-name */
#define reg_BSP       REG(14)   /* Binding Stack? pointer */
#define reg_CFP       REG(15) /* Control Stack frame pointer */
#define reg_CSP       REG(16) /* Control Stack top */
#define reg_ALLOC     REG(17) /* (Global) dynamic free pointer */
#define reg_NULL      REG(18) /* NIL and globals nearby */
#define reg_CODE      REG(19) /* Current function object */
#define reg_CNAME?     REG(20) /* Current function name */
#define reg_LEXENV    REG(21) /* And why burn a register for this ? */
#define reg_OCFP      REG(22)   /* The caller's reg_CFP */
#define reg_LRA       REG(23) /* Tagged lisp return address */
#define reg_A0        REG(24) /* First function arg/return value */
#define reg_A1        REG(25) /* Second. */
#define reg_A2        REG(26) /*  */
#define reg_A3        REG(27) /* Last of (only) 4 arg regs */
#define reg_L0       REG(28) /* Tagged temp regs */
#define reg_L1        REG(29)
#define reg_L2        REG(30) /* Last lisp temp reg */
#define reg_LIP?       REG(31) /* Lisp Interior Pointer, e.g., locative */

In Lisp (primarily in the context of VOPs), the registers are specified using TNs. Important registers get their own names; for example, reg_Alloc is alloc-tn?, reg_CSP is csp-tn?. Presumably these TNs are marked as always live, so that other values never get packed into them

For more information on register usage, see Calling Convention


This page is linked from: Bill Newman   control stack   SB   x86  

CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively