|
|
1.1 root 1: /*
2: * n1/i386/table1.c
3: * Machine specific tables used by the code generator coder.
4: * i386.
5: */
6:
7: #ifdef vax
8: #include "INC$LIB:cc1.h"
9: #else
10: #include "cc1.h"
11: #endif
12:
13: /*
14: * Width table.
15: * Indexed by type.
16: * Values determine relative order of widths for iswiden(),
17: * they are not widths in bytes.
18: */
19: char wtype[] = {
20: 0, 0, /* S8 U8 */
21: 1, 1, /* S16 U16 */
22: 2, 2, /* S32 U32 */
23: 3, 4, /* F32 F64 */
24: 5, /* BLK */
25: 0, 1, 2, /* FLD8 FLD16 FLD32 */
26: 2, 2 /* PTR PTRB */
27: };
28:
29: /*
30: * Register table.
31: * Indexed by 'real' register numbers (as defined in mch.h).
32: * Dword values go in EAX|EBX|ECX|EDX|EDI|ESI.
33: * The code selector selects byte and word registers
34: * by the corresponding dword register; thus,
35: * word values go in EAX|EBX|ECX|EDX|EDI|ESI (i.e. AX|BX|CX|DX|DI|SI), and
36: * byte values go in EAX|EBX|ECX|EDX (i.e. AL|BL|CL|DL; AH|BH|CH|DH are unused).
37: * This allows TREG sharing of e.g. EAX/AX/AL and makes it easy to generate
38: * decent code for the shorter types.
39: * gen1.c/coderinit() patches the EDX:EAX and FPAC entries if -VNDP;
40: * values below are for software fp, for NDP rvalue KD is FPAC, not EDX:EAX.
41: */
42: REGDESC reg[] = {
43:
44: /* KIND KIND int REGNAME REGNAME REGNAME PREGSET */
45: /* r_lvalue r_rvalue r_goal r_enpair r_hihalf r_lohalf r_phys */
46:
47: /* eax */ KBWL, KBWL, MRVALUE, EDXEAX, -1, AX, BEAX,
48: /* edx */ KBWL, KBWL, MRVALUE, EDXEAX, -1, DX, BEDX,
49: /* ebx */ KBWL, KBWL, MRVALUE, -1, -1, BX, BEBX,
50: /* ecx */ KBWL, KBWL, MRVALUE, -1, -1, CX, BECX,
51: /* esi */ KBWL, KWL, MRVALUE, -1, -1, SI, BESI,
52: /* edi */ KBWL, KWL, MRVALUE, -1, -1, DI, BEDI,
53: /* esp */ 0, 0, -1, -1, -1, -1, BESP,
54: /* ebp */ KBWL, 0, -1, -1, -1, -1, BEBP,
55:
56: /* edx:eax */ 0, KD, MRVALUE, -1, EDX, EAX, BEDX|BEAX,
57:
58: /* ax */ 0, 0, MRVALUE, EAX, AH, AL, BEAX,
59: /* dx */ 0, 0, MRVALUE, EDX, DH, DL, BEDX,
60: /* bx */ 0, 0, MRVALUE, EBX, BH, BL, BEBX,
61: /* cx */ 0, 0, MRVALUE, ECX, CH, CL, BECX,
62: /* si */ 0, 0, MRVALUE, -1, -1, -1, BESI,
63: /* di */ 0, 0, MRVALUE, -1, -1, -1, BEDI,
64: /* sp */ 0, 0, -1, -1, -1, -1, BESP,
65: /* bp */ 0, 0, -1, -1, -1, -1, BEBP,
66:
67: /* al */ 0, 0, -1, AX, -1, -1, BEAX,
68: /* bl */ 0, 0, -1, BX, -1, -1, BEBX,
69: /* cl */ 0, 0, -1, CX, -1, -1, BECX,
70: /* dl */ 0, 0, -1, DX, -1, -1, BEDX,
71: /* ah */ 0, 0, -1, AX, -1, -1, BEAX,
72: /* bh */ 0, 0, -1, BX, -1, -1, BEBX,
73: /* ch */ 0, 0, -1, CX, -1, -1, BECX,
74: /* dh */ 0, 0, -1, DX, -1, -1, BEDX,
75:
76: /* st */ 0, 0, MRVALUE, -1, -1, -1, BFPAC
77:
78: /* None */
79: /* Anyr */
80: /* Anyl */
81: /* Pair */
82: /* Temp */
83: /* Lo */
84: /* Hi */
85:
86: };
87:
88: /*
89: * The opcode table.
90: * Indexed by operation.
91: * The 0th and 1st entries of the relations are used by REL0 and by REL1.
92: * The 2nd entry is the special supress EQ/NE entry used by LREL1 and LREL0.
93: */
94: unsigned char optab[][3] = {
95:
96: { ZADD, ZINC, ZADC }, /* ADD */
97: { ZSUB, ZDEC, ZSBB }, /* SUB */
98: { ZMUL, 0, 0 }, /* MUL */
99: { ZDIV, 0, 0 }, /* DIV */
100: { ZDIV, 0, 0 }, /* REM */
101: { ZAND, ZTEST, ZSUB }, /* AND */
102: { ZOR, 0, 0 }, /* OR */
103: { ZXOR, ZNOT, 0 }, /* XOR */
104: { ZSAL, ZSHL, ZRCL }, /* SHL */
105: { ZSAR, ZSHR, ZRCR }, /* SHR */
106:
107: { ZADD, ZINC, ZADC }, /* AADD */
108: { ZSUB, ZDEC, ZSBB }, /* ASUB */
109: { ZMUL, ZMOV, ZMOVB }, /* AMUL */
110: { ZDIV, ZMOV, ZMOVB }, /* ADIV */
111: { ZDIV, ZMOV, ZMOVB }, /* AREM */
112: { ZAND, ZSUB, 0 }, /* AAND */
113: { ZOR, 0, 0 }, /* AOR */
114: { ZXOR, ZNOT, 0 }, /* AXOR */
115: { ZSAL, ZSHL, ZRCL }, /* ASHL */
116: { ZSAR, ZSHR, ZRCR }, /* ASHR */
117:
118: { ZJE, ZJE, 0 }, /* EQ */
119: { ZJNE, ZJNE, 0 }, /* NE */
120: { ZJG, 0, ZJG }, /* GT */
121: { ZJGE, ZJNS, ZJG }, /* GE */
122: { ZJLE, 0, ZJL }, /* LE */
123: { ZJL, ZJS, ZJL }, /* LT */
124: { ZJA, 0, ZJA }, /* UGT */
125: { ZJAE, 0, ZJA }, /* UGE */
126: { ZJBE, 0, ZJB }, /* ULE */
127: { ZJB, 0, ZJB }, /* ULT */
128:
129: { 0, 0, 0 }, /* STAR */
130: { 0, 0, 0 }, /* ADDR */
131: { ZNEG, ZSBB, 0 }, /* NEG */
132: { ZNOT, 0, 0 }, /* COM */
133: { 0, 0, 0 }, /* NOT */
134: { 0, 0, 0 }, /* QUEST */
135: { 0, 0, 0 }, /* COLON */
136: { ZADD, ZINC, 0 }, /* INCBEF */
137: { ZSUB, ZDEC, 0 }, /* DECBEF */
138: { ZADD, ZINC, 0 }, /* INCAFT */
139: { ZSUB, ZDEC, 0 }, /* DECAFT */
140: { 0, 0, 0 }, /* COMMA */
141: { 0, 0, 0 }, /* CALL */
142: { 0, 0, 0 }, /* ANDAND */
143: { 0, 0, 0 }, /* OROR */
144: { 0, 0, 0 }, /* CAST */
145: { 0, 0, 0 }, /* CONVERT */
146: { 0, 0, 0 }, /* FIELD */
147: { 0, 0, 0 }, /* SIZEOF */
148: { ZMOV, ZSUB, 0 }, /* ASSIGN */
149: { 0, 0, 0 }, /* NOP */
150: { 0, 0, 0 }, /* INIT */
151: { 0, 0, 0 }, /* ARGLST */
152: { 0, 0, 0 }, /* LEAF */
153: { 0, 0, 0 }, /* FIXUP */
154: { 0, 0, 0 } /* BLKMOVE */
155: };
156:
157: /*
158: * Per type info.
159: * Column 0 is function return register (-1 if never a return type).
160: * Column 1 is function return context, for select.
161: * Column 2 is size of a temp.
162: * Column 3 is the actual size in memory, for autoinc/autodec.
163: * Column 4 is bit set for searching pattern tables.
164: * Column 5 is register kind.
165: * Column 6 is register kind for a pair.
166: * gen1.c/coderinit() patches the F64 entry if -VNDP;
167: * its return register name below is for software fp but is FPAC if -VNDP.
168: */
169: PERTYPE pertype[] = {
170: /* REGNAME char char char TYPESET KIND KIND */
171: /* p_frreg p_frcat p_size p_incr p_type p_kind p_pair */
172: /* S8 */ { EAX, MRVALUE, 4, 1, FS8, KB, KL },
173: /* U8 */ { EAX, MRVALUE, 4, 1, FU8, KB, KL },
174: /* S16 */ { EAX, MRVALUE, 4, 2, FS16, KW, KL },
175: /* U16 */ { EAX, MRVALUE, 4, 2, FU16, KW, KL },
176: /* S32 */ { EAX, MRVALUE, 4, 4, FS32, KL, 0 },
177: /* U32 */ { EAX, MRVALUE, 4, 4, FU32, KL, 0 },
178: /* F32 */ { -1, MRVALUE, 8, 4, FF32, 0, 0 },
179: /* F64 */ { EDXEAX, MRVALUE, 8, 8, FF64, KD, 0 },
180: /* BLK */ { -1, MRVALUE, 0, 0, FBLK, 0, 0 },
181: /* FLD8 */ { -1, MRVALUE, 0, 0, FFLD8, 0, 0 },
182: /* FLD16 */ { -1, MRVALUE, 0, 0, FFLD16, 0, 0 },
183: /* FLD32 */ { -1, MRVALUE, 0, 0, FFLD32, 0, 0 },
184: /* PTR */ { EAX, MRVALUE, 4, 4, FPTR, KP, 0 },
185: /* PTB */ { EAX, MRVALUE, 4, 4, FPTB, KP, 0 }
186: };
187:
188: /*
189: * These tables adjust relational ops when the
190: * sense is reversed or when the subtrees are swapped.
191: */
192: char fliprel[] = {
193: EQ, NE, LT, LE, GE, GT, ULT, ULE, UGE, UGT
194: };
195:
196: char otherel[] = {
197: NE, EQ, LE, LT, GT, GE, ULE, ULT, UGT, UGE
198: };
199:
200: /*
201: * Type table.
202: * Indexed by machine type.
203: * Used by type testing macros defined in cc1mch.h.
204: */
205: char tinfo[] = {
206: 0060, 0064, /* S8 U8 */
207: 0022, 0026, /* S16 U16 */
208: 0021, 0025, /* S32 U32 */
209: 0010, 0010, /* F32 F64 */
210: 0100, /* BLK */
211: 0060, /* FLD8 */
212: 0022, /* FLD16 */
213: 0021, /* FLD32 */
214: 0205, 0305 /* PTR PTB */
215: };
216:
217: /* end of n1/i386/table1.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.