Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:ragge:20050917075840

Diff

Diff from 1.13 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/pcc/pcc/mip/mkext.c

Annotated File View

ragge
1.1
1
2 /*
3  * Generate defines for the needed hardops.
4  */
5 #include "pass2.h"
6
7 int chkop[MAXOP];
8
ragge
1.2
9 void mktables(void);
10
ragge
1.1
11 char *cname = "external.c";
12 char *hname = "external.h";
ragge
1.2
13 FILE *fc, *fh;
ragge
1.1
14
ragge
1.4
15 /*
16  * masks for matching dope with shapes
17  */
18 int mamask[] = {
19         SIMPFLG,                /* OPSIMP */
20         SIMPFLG|ASGFLG,         /* ASG OPSIMP */
21         COMMFLG,        /* OPCOMM */
22         COMMFLG|ASGFLG/* ASG OPCOMM */
23         MULFLG,         /* OPMUL */
24         MULFLG|ASGFLG,  /* ASG OPMUL */
25         DIVFLG,         /* OPDIV */
26         DIVFLG|ASGFLG,  /* ASG OPDIV */
27         UTYPE,          /* OPUNARY */
28         TYFLG,          /* ASG OPUNARY is senseless */
29         LTYPE,          /* OPLEAF */
30         TYFLG,          /* ASG OPLEAF is senseless */
31         0,              /* OPANY */
32         ASGOPFLG|ASGFLG,        /* ASG OPANY */
33         LOGFLG,         /* OPLOG */
34         TYFLG,          /* ASG OPLOG is senseless */
35         FLOFLG,         /* OPFLOAT */
36         FLOFLG|ASGFLG,  /* ASG OPFLOAT */
37         SHFFLG,         /* OPSHFT */
38         SHFFLG|ASGFLG,  /* ASG OPSHIFT */
39         SPFLG,          /* OPLTYPE */
40         TYFLG,          /* ASG OPLTYPE is senseless */
41         };
42
43
ragge
1.1
44 struct checks {
45         int optype;
46         char *name;
47 checks[] = {
48         { MULTLONGLONG"SMULLL", },
49         { DIVTLONGLONG"SDIVLL", },
50         { MODTLONGLONG"SMODLL", },
51         { PLUSTLONGLONG"SPLUSLL", },
52         { MINUSTLONGLONG"SMINUSLL", },
53         { MULTULONGLONG"UMULLL", },
54         { DIVTULONGLONG"UDIVLL", },
55         { MODTULONGLONG"UMODLL", },
56         { PLUSTULONGLONG"UPLUSLL", },
57         { MINUSTULONGLONG"UMINUSLL", },
58         { 000, },
59 };
60
61 int
62 main(int argcchar *argv[])
63 {
64         struct optab *op;
65         struct checks *ch;
ragge
1.9
66         int ifregs;
ragge
1.10
67         char *bitary;
68         int bitsz;
ragge
1.2
69
70         mkdope();
ragge
1.1
71
72         for (op = tableop->op != FREEop++) {
73                 if (op->op >= OPSIMP)
74                         continue;
ragge
1.8
75                 if ((op->ltype & TLONGLONG) &&
76                     (op->rtype & TLONGLONG))
ragge
1.1
77                         chkop[op->op] |= TLONGLONG;
ragge
1.8
78                 if ((op->ltype & TULONGLONG) &&
79                     (op->rtype & TULONGLONG))
ragge
1.1
80                         chkop[op->op] |= TULONGLONG;
81         }
82         if ((fc = fopen(cname"w")) == NULL) {
83                 perror("open cfile");
84                 return(1);
85         }
86         if ((fh = fopen(hname"w")) == NULL) {
87                 perror("open hfile");
88                 return(1);
89         }
90         for (ch = checksch->op != 0ch++) {
ragge
1.5
91                 if ((chkop[ch->op] & ch->type) == 0)
ragge
1.1
92                         fprintf(fh"#define NEED_%s\n"ch->name);
93         }
ragge
1.2
94         mktables();
ragge
1.9
95
96         /* calculate number of temporary regs */
97         for (fregs = 0i = (TAREGS|TBREGS); ii >>= 1)
98                 if (i & 1)
99                         fregs++;
100
101         fprintf(fh"#define FREGS %d\n"fregs);
102
ragge
1.10
103         /* create efficient bitset sizes */
104         if (sizeof(long) == 8) { /* 64-bit arch */
105                 bitary = "long";
106                 bitsz = 64;
107         } else {
108                 bitary = "int";
109                 bitsz = sizeof(int) == 4 ? 32 : 16;
110         }
111         fprintf(fh"#define NUMBITS %d\n"bitsz);
112         fprintf(fh"#define BITSET(arr, bit) "
113              "(arr[bit/NUMBITS] |= (1 << (bit & (NUMBITS-1))))\n");
ragge
1.11
114         fprintf(fh"#define BITCLEAR(arr, bit) "
115              "(arr[bit/NUMBITS] &= ~(1 << (bit & (NUMBITS-1))))\n");
ragge
1.10
116         fprintf(fh"#define TESTBIT(arr, bit) "
117              "(arr[bit/NUMBITS] & (1 << (bit & (NUMBITS-1))))\n");
118         fprintf(fh"typedef %s bittype;\n"bitary);
119
ragge
1.13
120         /* register class definitions, used by graph-coloring */
121
ragge
1.1
122         fclose(fc);
123         fclose(fh);
124         return 0;
ragge
1.2
125 }
126
127 #define P(x)    fprintf x
128
129 void
130 mktables()
131 {
132         struct optab *op;
133         int mxalen = 0curalen;
134         int i;
135
ragge
1.10
136 //      P((fc, "#include \"pass2.h\"\n\n"));
ragge
1.2
137         for (i = 0i <= MAXOPi++) {
138                 curalen = 0;
139                 P((fc"static int op%d[] = { "i));
140                 if (dope[i] != 0)
141                 for (op = tableop->op != FREEop++) {
142                         if (op->op < OPSIMP) {
143                                 if (op->op == i) {
144                                         P((fc"%d, "op - table));
145                                         curalen++;
146                                 }
147                         } else {
148                                 int opmtemp;
149                                 if ((opmtemp=mamask[op->op - OPSIMP])&SPFLG) {
ragge
1.12
150                                         if (i==NAME || i==ICON || i==TEMP ||
ragge
1.2
151                                             i==OREG || i == REG) {
152                                                 P((fc"%d, "op - table));
153                                                 curalen++;
154                                         }
155                                 } else if ((dope[i]&(opmtemp|ASGFLG))==opmtemp){
156                                         P((fc"%d, "op - table));
157                                         curalen++;
158                                 }
159                         }
160                 }
161                 if (curalen > mxalen)
162                         mxalen = curalen;
ragge
1.3
163                 P((fc"-1 };\n"));
ragge
1.2
164         }
165         P((fc"\n"));
166
167         P((fc"int *qtable[] = { \n"));
168         for (i = 0i <= MAXOPi++) {
169                 P((fc"        op%d,\n"i));
170         }
171         P((fc"};\n"));
172         P((fh"#define MAXOPLEN %d\n"mxalen+1));
ragge
1.1
173 }
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-10-01 16:16 +0200