source: release/1.7/source/lisp-kernel/arm-uuo.s @ 15267

Last change on this file since 15267 was 14267, checked in by rme, 9 years ago

Sprinkle some parentheses around to avoid trouble with operator
precedence when constructing a UUO instruction.

This problem was made evident when I mistakenly typed (uvref 0 #'car)
and got a crash instead of an error. The correct UUO is 0x17f065f3,
but we were generating 0x17f060f7 instead:

.word (uuo_base_opcode|(ne<<28)|uuo_format_error_fulltag|(r5|(fulltag_misc<<4)<<8))

With the extra parens, we get it right:

.word (uuo_base_opcode|((ne)<<28)|(uuo_format_error_fulltag)|((r5|(fulltag_misc<<4))<<8))

File size: 5.7 KB
Line 
1/*   Copyright (C) 2010 Clozure Associates */
2/*   Copyright (C) 1994-2001 Digitool, Inc */
3/*   This file is part of Clozure CL. */
4 
5/*   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public */
6/*   License , known as the LLGPL and distributed with Clozure CL as the */
7/*   file "LICENSE".  The LLGPL consists of a preamble and the LGPL, */
8/*   which is distributed with Clozure CL as the file "LGPL".  Where these */
9/*   conflict, the preamble takes precedence. */
10 
11/*   Clozure CL is referenced in the preamble as the "LIBRARY." */
12 
13/*   The LLGPL is also available online at */
14/*   http://opensource.franz.com/preamble.html */
15
16
17/* As of the 2005 edition of the ARM Architecture Reference Manual */
18/* ("ARM ARM"), instructions I for which:        */
19/* (logand i (logior (ash 255 20) (ash 15 4))) =  */
20/*           (logior (ash 127 20) (ash 15 4))  is true are considered */
21/* "architecturally undefined", e.g., unlikely to be implemented on */
22/* future versions of the architecture.  I haven't seen anything that */
23/* supersedes or contradicts this, but I'm not entirely sure that I would. */
24
25uuo_base_opcode = ((127<<20)|(15<<4))
26                       
27/* Like most 32-bit ARM instructions, these instructions are only executed */
28/* (and therefore only raise exceptions) if their condition field (in bits */
29/* 28:31) is true.  We also have a 12-bit field at bit 20 and a 4-bit field */
30/* at bit 0 in which to encode variable information.  This encoding uses */
31/* the 4-bit field to describe the format of the 12-bit field, which can */
32/* encode 12 bits of "error code", or 8 bits of code and a 4 bit register */
33/* number, or 4 bits of code and 2 4-bit register numbers. */
34       
35uuo_format_nullary = 0          /* 12 bits of code */
36uuo_format_unary = 1            /* 8 bits of info - NOT type info - 4-bit reg */
37uuo_format_error_lisptag = 2    /* 2 bits of lisptag info, 4-bit reg */
38uuo_format_error_fulltag = 3    /* 3 bits of fulltag info, 4 bit reg */
39
40uuo_format_error_xtype = 4      /* 8 bits of extended type/subtag info, 4 bit reg */
41uuo_format_binary = 7           /* 4 bits of code, r1, r0 */
42uuo_format_nullary_error = 8    /* nullary, call out to lisp */
43uuo_format_unary_error = 9      /* like unary, but call out to lisp */
44uuo_format_cerror_lisptag = 10 /* continuable, lisptag, reg */
45uuo_format_cerror_fulltag = 11 /* continuable, fulltag, reg */
46uuo_format_cerror_xtype = 12   /* continuable, xtype, reg */
47uuo_format_kernel_service = 13 /* 8 bits of info */ 
48uuo_format_ternary_error = 14   /* SLOT-UNBOUND only */             
49uuo_format_binary_error = 15    /* binary format, call out to lisp */
50
51/* Encode a UUO with cond = $1, format = $2, info = $3 */
52define(`UUO',`
53        .word (uuo_base_opcode|(($1)<<28)|($2)|(($3)<<8))
54')
55/* Nullary UUO with cond = $1, info = $2 */       
56define(`nullaryUUO',`UUO($1,uuo_format_nullary,$2)')
57define(`nullary_errorUUO',`UUO($1,uuo_format_nullary_error,$2)')
58/* Simple (non-TYPE) unary uuo with cond = $1, reg = $2, info = $3 */
59define(`unaryUUO',`UUO($1,uuo_format_unary,($2|($3<<4)))')
60define(`unary_errorUUO',`UUO($1,uuo_format_unary_error,($2|($3<<4)))')
61
62define(`binaryUUO',`UUO($1,uuo_format_binary,($2|($3<<4)|($4<<8)))')
63define(`binary_errorUUO',`UUO($1,uuo_format_binary_error,($2|($3<<4)|($4<<8)))')
64
65/* Simple type error (reg not lisptag), cond = $1, reg = $2, lisptag = $3 */
66define(`uuo_error_reg_not_lisptag',`UUO($1,uuo_format_error_lisptag,$2|($3<<4))')
67/* Likewise, for fulltag.  (Can distinguish between tag_list/fulltag_cons) */
68define(`uuo_error_reg_not_fulltag',`UUO($1,uuo_format_error_fulltag,$2|($3<<4))')
69/* As used here, an 'xtype' is an 8-bit value that's either a defined */
70/* subtag/tag/lisptag value or some encoding of something like 'integer' */
71define(`uuo_error_reg_not_xtype',`UUO($1,uuo_format_error_xtype,$2|($3<<4))')
72/* Continuable type errors */
73define(`uuo_cerror_reg_not_lisptag',`UUO($1,uuo_format_cerror_lisptag,$2|($3<<4))')
74define(`uuo_cerror_reg_not_fulltag',`UUO($1,uuo_format_cerror_fulltag,$2|($3<<4))')
75define(`uuo_cerror_reg_not_xtype',`UUO($1,uuo_format_cerror_xtype,$2|($3<<4))')
76       
77/* Nullary UUOs.  Define them as being conditional, even if the condition is */
78/*  'al' (always). $1=cond, $2=8-bit-code */
79define(`uuo_alloc_trap',`nullaryUUO($1,0)')
80define(`uuo_error_wrong_nargs',`nullary_errorUUO($1,1)') /* can use CC field */
81define(`uuo_gc_trap',`nullaryUUO($1,2)') /* probably unconditional */
82define(`uuo_debug_trap',`nullaryUUO($1,3)')
83define(`uuo_interrupt_now',`nullaryUUO($1,4)')
84define(`uuo_suspend_now',`nullaryUUO($1,5)')
85
86/* Unary UUOs */
87define(`uuo_error_unbound',`unary_errorUUO($1,$2,0)')
88define(`uuo_cerror_unbound',`unary_errorUUO($1,$2,1)')
89define(`uuo_error_not_callable',`unary_errorUUO($1,$2,2)')
90define(`uuo_tlb_too_small',`unaryUUO($1,$2,3)')
91define(`uuo_error_no_throw_tag',`unary_errorUUO($1,$2,4)')
92define(`uuo_error_udf_call',`unary_errorUUO($1,$2,5)')       
93define(`uuo_error_udf',`unary_errorUUO($1,$2,6)')
94       
95/* Binary UUOs */
96define(`uuo_error_vector_bounds',`binary_errorUUO($1,$2,$3,0)')
97define(`uuo_error_array_bounds',`binary_errorUUO($1,$2,$3,1)')
98define(`uuo_error_integer_divide_by_zero',`binary_errorUUO($1,$2,$3,2)')
99define(`uuo_error_slot_unbound',`binary_errorUUO($1,$2,$3,3)')
100define(`uuo_error_eep_unresolved',`binary_errorUUO($1,$2,$3,4)')       
101define(`uuo_error_fpu_exception',`binary_errorUUO($1,$2,$3,5)')
102define(`uuo_error_array_rank',`binary_errorUUO($1,$2,$3,6)')
103define(`uuo_error_array_flags',`binary_errorUUO($1,$2,$3,7)')
104       
105/* This should never be generated (never be a legal instruction in a code
106   vector); it should only be used by purify/impurify. */
107define(`forward_marker',`UUO(al,uuo_format_unary,0xfff)')
108/* Used by Mach exception return */
109define(`uuo_pseudo_sigreturn',`UUO(al,uuo_format_unary,0xffe)')
Note: See TracBrowser for help on using the repository browser.