OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [lcc/] [src/] [dagcheck.md] - Blame information for rev 193

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 hellwig
%{
2
#include "c.h"
3
typedef Node NODEPTR_TYPE;
4
#define OP_LABEL(p)     (specific((p)->op))
5
#define LEFT_CHILD(p)   ((p)->kids[0])
6
#define RIGHT_CHILD(p)  ((p)->kids[1])
7
#define STATE_LABEL(p)  ((p)->x.state)
8
#define PANIC      error
9
%}
10
%term CNSTF=17 CNSTI=21 CNSTP=23 CNSTU=22
11
%term ARGB=41 ARGF=33 ARGI=37 ARGP=39 ARGU=38
12
%term ASGNB=57 ASGNF=49 ASGNI=53 ASGNP=55 ASGNU=54
13
%term INDIRB=73 INDIRF=65 INDIRI=69 INDIRP=71 INDIRU=70
14
%term CVFF=113 CVFI=117
15
%term CVIF=129 CVII=133 CVIU=134
16
%term CVPP=151 CVPU=150
17
%term CVUI=181 CVUP=183 CVUU=182
18
%term NEGF=193 NEGI=197
19
%term CALLB=217 CALLF=209 CALLI=213 CALLP=215 CALLU=214 CALLV=216
20
%term RETF=241 RETI=245 RETP=247 RETU=246 RETV=248
21
%term ADDRGP=263
22
%term ADDRFP=279
23
%term ADDRLP=295
24
%term ADDF=305 ADDI=309 ADDP=311 ADDU=310
25
%term SUBF=321 SUBI=325 SUBP=327 SUBU=326
26
%term LSHI=341 LSHU=342
27
%term MODI=357 MODU=358
28
%term RSHI=373 RSHU=374
29
%term BANDI=389 BANDU=390
30
%term BCOMI=405 BCOMU=406
31
%term BORI=421 BORU=422
32
%term BXORI=437 BXORU=438
33
%term DIVF=449 DIVI=453 DIVU=454
34
%term MULF=465 MULI=469 MULU=470
35
%term EQF=481 EQI=485 EQU=486
36
%term GEF=497 GEI=501 GEU=502
37
%term GTF=513 GTI=517 GTU=518
38
%term LEF=529 LEI=533 LEU=534
39
%term LTF=545 LTI=549 LTU=550
40
%term NEF=561 NEI=565 NEU=566
41
%term JUMPV=584
42
%term LABELV=600
43
%%
44
stmt: INDIRB(P) ""
45
stmt: INDIRF(P) ""
46
stmt: INDIRI(P) ""
47
stmt: INDIRU(P) ""
48
stmt: INDIRP(P) ""
49
stmt: CALLF(P) ""
50
stmt: CALLI(P) ""
51
stmt: CALLU(P) ""
52
stmt: CALLP(P) ""
53
stmt: V ""
54
bogus: I "" 1
55
bogus: U "" 1
56
bogus: P "" 1
57
bogus: F "" 1
58
bogus: B "" 1
59
bogus: V "" 1
60
I: bogus "" 1
61
U: bogus "" 1
62
P: bogus "" 1
63
F: bogus "" 1
64
B: bogus "" 1
65
V: bogus "" 1
66
F: CNSTF ""
67
I: CNSTI ""
68
P: CNSTP ""
69
U: CNSTU ""
70
V: ARGB(B) ""
71
V: ARGF(F) ""
72
V: ARGI(I) ""
73
V: ARGU(U) ""
74
V: ARGP(P) ""
75
V: ASGNB(P,B) ""
76
V: ASGNF(P,F) ""
77
V: ASGNI(P,I) ""
78
V: ASGNU(P,U) ""
79
V: ASGNP(P,P) ""
80
B: INDIRB(P) ""
81
F: INDIRF(P) ""
82
I: INDIRI(P) ""
83
U: INDIRU(P) ""
84
P: INDIRP(P) ""
85
I: CVII(I) ""
86
I: CVUI(U) ""
87
I: CVFI(F) ""
88
U: CVIU(I) ""
89
U: CVUU(U) ""
90
U: CVPU(P) ""
91
F: CVIF(I) ""
92
F: CVFF(F) ""
93
P: CVUP(U) ""
94
P: CVPP(P) ""
95
F: NEGF(F) ""
96
I: NEGI(I) ""
97
V: CALLB(P,P) ""
98
F: CALLF(P) ""
99
I: CALLI(P) ""
100
U: CALLU(P) ""
101
P: CALLP(P) ""
102
V: CALLV(P) ""
103
V: RETF(F) ""
104
V: RETI(I) ""
105
V: RETU(U) ""
106
V: RETP(P) ""
107
V: RETV ""
108
P: ADDRGP ""
109
P: ADDRFP ""
110
P: ADDRLP ""
111
F: ADDF(F,F) ""
112
I: ADDI(I,I) ""
113
P: ADDP(P,I) ""
114
P: ADDP(I,P) ""
115
P: ADDP(U,P) ""
116
P: ADDP(P,U) ""
117
U: ADDU(U,U) ""
118
F: SUBF(F,F) ""
119
I: SUBI(I,I) ""
120
P: SUBP(P,I) ""
121
P: SUBP(P,U) ""
122
U: SUBU(U,U) ""
123
I: LSHI(I,I) ""
124
U: LSHU(U,I) ""
125
I: MODI(I,I) ""
126
U: MODU(U,U) ""
127
I: RSHI(I,I) ""
128
U: RSHU(U,I) ""
129
U: BANDU(U,U) ""
130
I: BANDI(I,I) ""
131
U: BCOMU(U) ""
132
I: BCOMI(I) ""
133
I: BORI(I,I) ""
134
U: BORU(U,U) ""
135
U: BXORU(U,U) ""
136
I: BXORI(I,I) ""
137
F: DIVF(F,F) ""
138
I: DIVI(I,I) ""
139
U: DIVU(U,U) ""
140
F: MULF(F,F) ""
141
I: MULI(I,I) ""
142
U: MULU(U,U) ""
143
V: EQF(F,F) ""
144
V: EQI(I,I) ""
145
V: EQU(U,U) ""
146
V: GEF(F,F) ""
147
V: GEI(I,I) ""
148
V: GEU(U,U) ""
149
V: GTF(F,F) ""
150
V: GTI(I,I) ""
151
V: GTU(U,U) ""
152
V: LEF(F,F) ""
153
V: LEI(I,I) ""
154
V: LEU(U,U) ""
155
V: LTF(F,F) ""
156
V: LTI(I,I) ""
157
V: LTU(U,U) ""
158
V: NEF(F,F) ""
159
V: NEI(I,I) ""
160
V: NEU(U,U) ""
161
V: JUMPV(P) ""
162
V: LABELV ""
163
%%
164
 
165
static void reduce(NODEPTR_TYPE p, int goalnt) {
166
        int i, sz = opsize(p->op), rulenumber = _rule(p->x.state, goalnt);
167
        short *nts = _nts[rulenumber];
168
        NODEPTR_TYPE kids[10];
169
 
170
        assert(rulenumber);
171
        _kids(p, rulenumber, kids);
172
        for (i = 0; nts[i]; i++)
173
                reduce(kids[i], nts[i]);
174
        switch (optype(p->op)) {
175
#define xx(ty) if (sz == ty->size) return
176
        case I:
177
        case U:
178
                xx(chartype);
179
                xx(shorttype);
180
                xx(inttype);
181
                xx(longtype);
182
                xx(longlong);
183
                xx(signedptr);
184
                xx(unsignedptr);
185
                break;
186
        case F:
187
                xx(floattype);
188
                xx(doubletype);
189
                xx(longdouble);
190
                break;
191
        case P:
192
                xx(voidptype);
193
                xx(funcptype);
194
                break;
195
        case V:
196
        case B: if (sz == 0) return;
197
#undef xx
198
        }
199
        printdag(p, 2);
200
        assert(0);
201
}
202
 
203
void check(Node p) {
204
        struct _state { short cost[1]; };
205
 
206
        _label(p);
207
        if (((struct _state *)p->x.state)->cost[1] > 0) {
208
                printdag(p, 2);
209
                assert(0);
210
        }
211
        reduce(p, 1);
212
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.