Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include	"../cc/cc.h"
2
#include	"../qc/q.out.h"
3
 
4
/*
5
 * qc/power
6
 * powerpc
7
 */
8
#define	SZ_CHAR		1
9
#define	SZ_SHORT	2
10
#define	SZ_INT		4
11
#define	SZ_LONG		4
12
#define	SZ_IND		4
13
#define	SZ_FLOAT	4
14
#define	SZ_VLONG	8
15
#define	SZ_DOUBLE	8
16
#define	FNX		100
17
 
18
typedef	struct	Adr	Adr;
19
typedef	struct	Prog	Prog;
20
typedef	struct	Case	Case;
21
typedef	struct	C1	C1;
22
typedef	struct	Multab	Multab;
23
typedef	struct	Hintab	Hintab;
24
typedef	struct	Var	Var;
25
typedef	struct	Reg	Reg;
26
typedef	struct	Rgn	Rgn;
27
 
28
struct	Adr
29
{
30
	union
31
	{
32
		long	offset;
33
		double	dval;
34
		char	sval[NSNAME];
35
	};
36
	Sym*	sym;
37
	char	type;
38
	char	reg;
39
	char	name;
40
	char	etype;
41
};
42
#define	A	((Adr*)0)
43
 
44
#define	INDEXED	9
45
struct	Prog
46
{
47
	Adr	from;
48
	Adr	from3;		/* third argument for fmadd, fmsub, ... */
49
	Adr	to;
50
	Prog*	link;
51
	long	lineno;
52
	short	as;
53
	char	reg;
54
};
55
#define	P	((Prog*)0)
56
 
57
struct	Case
58
{
59
	Case*	link;
60
	vlong	val;
61
	long	label;
62
	char	def;
63
	char isv;
64
};
65
#define	C	((Case*)0)
66
 
67
struct	C1
68
{
69
	vlong	val;
70
	long	label;
71
};
72
 
73
struct	Multab
74
{
75
	long	val;
76
	char	code[20];
77
};
78
 
79
struct	Hintab
80
{
81
	ushort	val;
82
	char	hint[10];
83
};
84
 
85
struct	Var
86
{
87
	long	offset;
88
	Sym*	sym;
89
	char	name;
90
	char	etype;
91
};
92
 
93
struct	Reg
94
{
95
	long	pc;
96
	long	rpo;		/* reverse post ordering */
97
 
98
	Bits	set;
99
	Bits	use1;
100
	Bits	use2;
101
 
102
	Bits	refbehind;
103
	Bits	refahead;
104
	Bits	calbehind;
105
	Bits	calahead;
106
	Bits	regdiff;
107
	Bits	act;
108
 
109
	long	regu;
110
	long	loop;		/* could be shorter */
111
 
112
	union
113
	{
114
		Reg*	log5;
115
		long	active;
116
	};
117
	Reg*	p1;
118
	Reg*	p2;
119
	Reg*	p2link;
120
	Reg*	s1;
121
	Reg*	s2;
122
	Reg*	link;
123
	Prog*	prog;
124
};
125
#define	R	((Reg*)0)
126
 
127
#define	NRGN	600
128
struct	Rgn
129
{
130
	Reg*	enter;
131
	short	cost;
132
	short	varno;
133
	short	regno;
134
};
135
 
136
EXTERN	long	breakpc;
137
EXTERN	long	nbreak;
138
EXTERN	Case*	cases;
139
EXTERN	Node	constnode;
140
EXTERN	Node	fconstnode;
141
EXTERN	long	continpc;
142
EXTERN	long	curarg;
143
EXTERN	long	cursafe;
144
EXTERN	Prog*	firstp;
145
EXTERN	Prog*	lastp;
146
EXTERN	int	hintabsize;
147
EXTERN	long	maxargsafe;
148
EXTERN	Multab	multab[20];
149
EXTERN	int	mnstring;
150
EXTERN	Node*	nodrat;
151
EXTERN	Node*	nodret;
152
EXTERN	Node*	nodsafe;
153
EXTERN	Node*	nodretv;
154
EXTERN	long	nrathole;
155
EXTERN	long	nstring;
156
EXTERN	Prog*	p;
157
EXTERN	long	pc;
158
EXTERN	Node	regnode;
159
EXTERN	char	string[NSNAME];
160
EXTERN	Sym*	symrathole;
161
EXTERN	Node	znode;
162
EXTERN	Prog	zprog;
163
EXTERN	int	reg[NREG+NREG];
164
EXTERN	long	exregoffset;
165
EXTERN	long	exfregoffset;
166
 
167
#define	BLOAD(r)	band(bnot(r->refbehind), r->refahead)
168
#define	BSTORE(r)	band(bnot(r->calbehind), r->calahead)
169
#define	LOAD(r)		(~r->refbehind.b[z] & r->refahead.b[z])
170
#define	STORE(r)	(~r->calbehind.b[z] & r->calahead.b[z])
171
 
172
#define	bset(a,n)	((a).b[(n)/32]&(1L<<(n)%32))
173
 
174
#define	CLOAD	5
175
#define	CREF	5
176
#define	CINF	1000
177
#define	LOOP	3
178
 
179
EXTERN	Rgn	region[NRGN];
180
EXTERN	Rgn*	rgp;
181
EXTERN	int	nregion;
182
EXTERN	int	nvar;
183
 
184
EXTERN	Bits	externs;
185
EXTERN	Bits	params;
186
EXTERN	Bits	consts;
187
EXTERN	Bits	addrs;
188
 
189
EXTERN	long	regbits;
190
EXTERN	long	exregbits;
191
 
192
EXTERN	int	change;
193
EXTERN	int	suppress;
194
 
195
EXTERN	Reg*	firstr;
196
EXTERN	Reg*	lastr;
197
EXTERN	Reg	zreg;
198
EXTERN	Reg*	freer;
199
EXTERN	Var	var[NVAR];
200
EXTERN	long*	idom;
201
EXTERN	Reg**	rpo2r;
202
EXTERN	long	maxnr;
203
 
204
#define	R0ISZERO	(debug['0']==0)
205
 
206
extern	char*	anames[];
207
extern	Hintab	hintab[];
208
 
209
/*
210
 * sgen.c
211
 */
212
void	codgen(Node*, Node*);
213
void	gen(Node*);
214
void	usedset(Node*, int);
215
void	noretval(int);
216
void	xcom(Node*);
217
int	bcomplex(Node*, Node*);
218
 
219
/*
220
 * cgen.c
221
 */
222
void	cgen(Node*, Node*);
223
void	reglcgen(Node*, Node*, Node*);
224
void	lcgen(Node*, Node*);
225
void	bcgen(Node*, int);
226
void	boolgen(Node*, int, Node*);
227
void	sugen(Node*, Node*, long);
228
void	layout(Node*, Node*, int, int, Node*);
229
 
230
/*
231
 * txt.c
232
 */
233
void	ginit(void);
234
void	gclean(void);
235
void	nextpc(void);
236
void	gargs(Node*, Node*, Node*);
237
void	garg1(Node*, Node*, Node*, int, Node**);
238
Node*	nodconst(long);
239
Node*	nod32const(vlong);
240
Node*	nodfconst(double);
241
void	nodreg(Node*, Node*, int);
242
void	regret(Node*, Node*);
243
void	regalloc(Node*, Node*, Node*);
244
void	regfree(Node*);
245
void	regialloc(Node*, Node*, Node*);
246
void	regsalloc(Node*, Node*);
247
void	regaalloc1(Node*, Node*);
248
void	regaalloc(Node*, Node*);
249
void	regind(Node*, Node*);
250
void	gprep(Node*, Node*);
251
void	raddr(Node*, Prog*);
252
void	naddr(Node*, Adr*);
253
void	gloadhi(Node*, Node*, int);
254
void	gloadlo(Node*, Node*, int);
255
void	gmove(Node*, Node*);
256
void	gins(int a, Node*, Node*);
257
void	gins3(int a, Node*, Node*, Node*);
258
void	gopcode(int, Node*, Node*, Node*);
259
int	samaddr(Node*, Node*);
260
void	gbranch(int);
261
void	patch(Prog*, long);
262
int	sconst(Node*);
263
int	sval(long);
264
int	uconst(Node*);
265
long	hi64v(Node*);
266
long	lo64v(Node*);
267
Node*	hi64(Node*);
268
Node*	lo64(Node*);
269
void	gpseudo(int, Sym*, Node*);
270
 
271
/*
272
 * swt.c
273
 */
274
int	swcmp(void*, void*);
275
void	doswit(Node*);
276
void	swit1(C1*, int, long, Node*);
277
void	swit2(C1*, int, long, Node*, Node*);
278
void	casf(void);
279
void	bitload(Node*, Node*, Node*, Node*, Node*);
280
void	bitstore(Node*, Node*, Node*, Node*, Node*);
281
long	outstring(char*, long);
282
int	mulcon(Node*, Node*);
283
Multab*	mulcon0(Node*, long);
284
int	mulcon1(Node*, long, Node*);
285
void	nullwarn(Node*, Node*);
286
void	gextern(Sym*, Node*, long, long);
287
void	outcode(void);
288
void	ieeedtod(Ieee*, double);
289
 
290
/*
291
 * list
292
 */
293
void	listinit(void);
294
int	Pconv(Fmt*);
295
int	Aconv(Fmt*);
296
int	Dconv(Fmt*);
297
int	Sconv(Fmt*);
298
int	Nconv(Fmt*);
299
int	Bconv(Fmt*);
300
 
301
/*
302
 * reg.c
303
 */
304
Reg*	rega(void);
305
int	rcmp(void*, void*);
306
void	regopt(Prog*);
307
void	addmove(Reg*, int, int, int);
308
Bits	mkvar(Adr*, int);
309
void	prop(Reg*, Bits, Bits);
310
void	loopit(Reg*, long);
311
void	synch(Reg*, Bits);
312
ulong	allreg(ulong, Rgn*);
313
void	paint1(Reg*, int);
314
ulong	paint2(Reg*, int);
315
void	paint3(Reg*, int, long, int);
316
void	addreg(Adr*, int);
317
 
318
/*
319
 * peep.c
320
 */
321
void	peep(void);
322
void	excise(Reg*);
323
Reg*	uniqp(Reg*);
324
Reg*	uniqs(Reg*);
325
int	regtyp(Adr*);
326
int	regzer(Adr*);
327
int	anyvar(Adr*);
328
int	subprop(Reg*);
329
int	copyprop(Reg*);
330
int	copy1(Adr*, Adr*, Reg*, int);
331
int	copyu(Prog*, Adr*, Adr*);
332
 
333
int	copyas(Adr*, Adr*);
334
int	copyau(Adr*, Adr*);
335
int	copyau1(Prog*, Adr*);
336
int	copysub(Adr*, Adr*, Adr*, int);
337
int	copysub1(Prog*, Adr*, Adr*, int);
338
 
339
long	RtoB(int);
340
long	FtoB(int);
341
int	BtoR(long);
342
int	BtoF(long);
343
 
344
/*
345
 * com64.c
346
 */
347
int	com64(Node*);
348
void	com64init(void);
349
void	bool64(Node*);
350
 
351
#pragma	varargck	type	"A"	int
352
#pragma	varargck	type	"B"	Bits
353
#pragma	varargck	type	"D"	Adr*
354
#pragma	varargck	type	"N"	Adr*
355
#pragma	varargck	type	"P"	Prog*
356
#pragma	varargck	type	"S"	char*