DEADSOFTWARE

Patched for Linux
[mp3cc.git] / MPC.3.5.LINUX / preverifier / typecodes.h
1 /*
2 * @(#)typecodes.h 1.2 02/09/27
3 *
4 * Copyright 1995-1998 by Sun Microsystems, Inc.,
5 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
6 * All rights reserved.
7 *
8 * This software is the confidential and proprietary information
9 * of Sun Microsystems, Inc. ("Confidential Information"). You
10 * shall not disclose such Confidential Information and shall use
11 * it only in accordance with the terms of the license agreement
12 * you entered into with Sun.
13 * Use is subject to license terms.
14 */
16 /*
17 * Type codes 6/12/91
19 This typecode system allows us to represent the type
20 of scalars in a uniform way. For instance, all integer types
21 have some bits in common, and are distinguished by a built-in
22 size field. Types without multiple sizes don't have a size field.
24 Scalars may only have sizes which are powers of 2. The size
25 field holds the log-based-2 of the object's size.
27 All run-time types can be encoded in 4 bits. There are more
28 compile- time types. These fit in 5 bits.
29 Schematically, we have:
30 +----+----+----+----+----+
31 | c | t | s |
32 +----+----+----+----+----+
34 Encoding is:
35 c t s type
36 -------------------------
37 0 00 00 unassigned
38 0 00 01 array
39 0 00 10 class
40 0 00 11 proxy (OBSOLETE)
41 0 01 00 boolean (1 byte)
42 0 01 01 char (2 bytes)
43 0 01 1s float (single=1; double=2)
44 0 1u xx integer (byte=0; short=1; int=2; long=3;
45 u=1 => unsigned)
47 For runtime types, the size of an object
48 is 1<<(t&3)
50 1 00 00 typedef (compiler only)
51 1 00 01 void (compiler only)
52 1 00 10 func (compiler only)
53 1 00 11 unknown (compiler only)
54 1 01 00 error (compiler only)
56 Char and Boolean are not int's because they need a different signature,
57 so have to be distinguishable, even at runtime. We allow arrays
58 of objects, arrays(?), booleans, char, integers, and floats.
59 Note that the low-order two bits of all these gives the log of
60 the size, except for arrays, of course.
62 I would prefer not to have unsigned int in the language, but
63 don't want to make that decision at this level. We could come up
64 with a better encoding of boolean and char if there were no
65 unsigned.
67 The compile-only type values that could be confused with the
68 integer and float scalar types must not ever be used. Value 0 must
69 not be assigned a runtime type, as this is used for some sleazy
70 trickery in punning types and pointer. In fact, we even have a name
71 for it.
72 */
74 /* If you change these typecodes, you'll have to fix the arrayinfo table
75 in gc.c and the {in,}direct_{load,store}_ops tables in
76 compiler/tree2code.c */
78 #ifndef _TYPECODES_H_
79 #define _TYPECODES_H_
81 #define T_NORMAL_OBJECT 0
82 #define T_XXUNUSEDXX1 1 /* Used to be T_ARRAY */
83 #define T_CLASS 2
84 #define T_BOOLEAN 4
85 #define T_CHAR 5
87 #define T_FLOATING 4 /* add log2 size to get correct code:
88 float has code 6,
89 double has code 7 */
90 #define T_INTEGER 010
91 #define T_UINTEGER 014
93 #define T_MAXNUMERIC 020
95 #define T_XXUNUSEDXX2 020
96 #define T_VOID 021
97 #define T_FUNC 022
98 #define T_UNKNOWN 023
99 #define T_ERROR 024
101 /* for type construction */
102 #define T_TMASK 034
103 #define T_LMASK 003
104 #define T_LSIZE 2
105 #define T_MKTYPE( t, l ) ( ( (t)&T_TMASK ) | ( (l)&T_LMASK) )
107 /* for type deconstruction */
108 /*
109 * Because we promise always to let ints and compile-only types be
110 * distinguished by the "t" and "s" bits above, we can simplify
111 * some of our predicates by masking out the "c" bit when testing
112 * for integers. Thus the T_TS_MASK...
113 */
114 #define T_TS_MASK 034
115 #define T_ISINTEGER(t) ( ((t)&030) == T_INTEGER )
116 #define T_ISFLOATING(t) ( ((t)&036) == T_FLOAT )
117 #define T_ISNUMERIC(t) ( (t) >= T_CHAR && (t) < T_MAXNUMERIC )
118 #define T_SIZEFIELD(t) ((t)&T_LMASK)
119 #define T_ELEMENT_SIZE(t) (1<<T_SIZEFIELD(t)) /* only for some!! */
121 #define T_IS_BIG_TYPE(t) ((t == T_DOUBLE) || (t == T_LONG))
122 #define T_TYPE_WORDS(t) (T_IS_BIG_TYPE(t) ? 2 : 1)
124 /* nick-names for the usual scalar types */
125 #define T_FLOAT T_MKTYPE(T_FLOATING,2)
126 #define T_DOUBLE T_MKTYPE(T_FLOATING,3)
127 #define T_BYTE T_MKTYPE(T_INTEGER,0)
128 #define T_SHORT T_MKTYPE(T_INTEGER,1)
129 #define T_INT T_MKTYPE(T_INTEGER,2)
130 #define T_LONG T_MKTYPE(T_INTEGER,3)
132 #ifdef NO_LONGER_USED
133 /* We no longer support these types */
134 #define T_UBYTE T_MKTYPE(T_UINTEGER,0)
135 #define T_USHORT T_MKTYPE(T_UINTEGER,1)
136 #define T_UINT T_MKTYPE(T_UINTEGER,2)
137 #define T_ULONG T_MKTYPE(T_UINTEGER,3)
139 #endif
141 /* only a slight exaggeration */
142 #define N_TYPECODES (1<<6)
143 #define N_TYPEMASK (N_TYPECODES-1)
145 #endif /* !_TYPECODES_H_ */