Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:ragge:20070811090505

Diff

Diff from 1.52 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/pcc/pcc/arch/i386/local.c

Annotated File View

ragge
1.52
1 /*      $Id: local.c,v 1.52 2007/08/11 09:05:06 ragge Exp $     */
ragge
1.1
2 /*
3  * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28
29
ragge
1.48
30 #include "pass1.h"
ragge
1.1
31
32 /*      this file contains code which is dependent on the target machine */
33
ragge
1.48
34 /* clocal() is called to do local transformations on
35  * an expression tree preparitory to its being
36  * written out in intermediate code.
37  *
38  * the major essential job is rewriting the
39  * automatic variables and arguments in terms of
40  * REG and OREG nodes
41  * conversion ops which are not necessary are also clobbered here
42  * in addition, any special features (such as rewriting
43  * exclusive or) are easily handled here as well
44  */
ragge
1.1
45 NODE *
46 clocal(NODE *p)
47 {
48
49         register struct symtab *q;
ragge
1.2
50         register NODE *r, *l;
ragge
1.1
51         register int o;
ragge
1.40
52         register int m;
ragge
1.19
53         TWORD t;
ragge
1.1
54
ragge
1.24
55 //printf("in:\n");
56 //fwalk(p, eprint, 0);
ragge
1.1
57         switcho = p->n_op ){
58
59         case NAME:
60                 if ((q = p->n_sp) == NULL)
61                         return p/* Nothing to care about */
62
63                 switch (q->sclass) {
64
65                 case PARAM:
66                 case AUTO:
67                         /* fake up a structure reference */
68                         r = block(REGNILNILPTR+STRTY00);
69                         r->n_lval = 0;
70                         r->n_rval = FPREG;
71                         p = stref(block(STREFrp000));
72                         break;
73
74                 case STATIC:
75                         if (q->slevel == 0)
76                                 break;
77                         p->n_lval = 0;
78                         p->n_sp = q;
79                         break;
80
81                 case REGISTER:
82                         p->n_op = REG;
83                         p->n_lval = 0;
84                         p->n_rval = q->soffset;
85                         break;
86
87                         }
88                 break;
89
ragge
1.39
90         case STCALL:
ragge
1.37
91         case CALL:
92                 /* Fix function call arguments. On x86, just add funarg */
93                 for (r = p->n_rightr->n_op == CMr = r->n_left) {
ragge
1.38
94                         if (r->n_right->n_op != STARG &&
95                             r->n_right->n_op != FUNARG)
ragge
1.37
96                                 r->n_right = block(FUNARGr->n_rightNIL
97                                     r->n_right->n_typer->n_right->n_df,
98                                     r->n_right->n_sue);
99                 }
ragge
1.38
100                 if (r->n_op != STARG && r->n_op != FUNARG) {
ragge
1.37
101                         l = talloc();
102                         *l = *r;
103                         r->n_op = FUNARGr->n_left = lr->n_type = l->n_type;
104                 }
ragge
1.10
105                 break;
ragge
1.37
106                 
ragge
1.8
107         case CBRANCH:
108                 l = p->n_left;
109
110                 /*
111                  * Remove unneccessary conversion ops.
112                  */
ragge
1.10
113                 if (clogop(l->n_op) && l->n_left->n_op == SCONV) {
ragge
1.12
114                         if (coptype(l->n_op) != BITYPE)
115                                 break;
ragge
1.8
116                         if (l->n_right->n_op == ICON) {
117                                 r = l->n_left->n_left;
ragge
1.24
118                                 if (r->n_type >= FLOAT && r->n_type <= LDOUBLE)
119                                         break;
ragge
1.18
120                                 /* Type must be correct */
ragge
1.19
121                                 t = r->n_type;
ragge
1.8
122                                 nfree(l->n_left);
123                                 l->n_left = r;
ragge
1.19
124                                 l->n_type = t;
125                                 l->n_right->n_type = t;
ragge
1.17
126                         }
ragge
1.8
127                 }
128                 break;
129
ragge
1.1
130         case PCONV:
ragge
1.40
131                 /* Remove redundant PCONV's. Be careful */
ragge
1.1
132                 l = p->n_left;
ragge
1.40
133                 if (l->n_op == ICON) {
134                         l->n_lval = (unsigned)l->n_lval;
135                         goto delp;
136                 }
137                 if (l->n_type < INT || l->n_type == LONGLONG || 
138                     l->n_type == ULONGLONG) {
139                         /* float etc? */
140                         p->n_left = block(SCONVlNIL,
141                             UNSIGNED0MKSUE(UNSIGNED));
142                         break;
143                 }
144                 /* if left is SCONV, cannot remove */
145                 if (l->n_op == SCONV)
ragge
1.1
146                         break;
ragge
1.40
147                 /* if conversion to another pointer type, just remove */
148                 if (p->n_type > BTMASK && l->n_type > BTMASK)
149                         goto delp;
150                 break;
151
152         delp:   l->n_type = p->n_type;
ragge
1.1
153                 l->n_qual = p->n_qual;
154                 l->n_df = p->n_df;
155                 l->n_sue = p->n_sue;
156                 nfree(p);
157                 p = l;
158                 break;
ragge
1.40
159                 
ragge
1.1
160         case SCONV:
161                 l = p->n_left;
ragge
1.4
162
ragge
1.25
163                 if (p->n_type == l->n_type) {
164                         nfree(p);
165                         return l;
166                 }
167
ragge
1.4
168                 if ((p->n_type & TMASK) == 0 && (l->n_type & TMASK) == 0 &&
pj
1.30
169                     btdims[p->n_type].suesize == btdims[l->n_type].suesize) {
ragge
1.4
170                         if (p->n_type != FLOAT && p->n_type != DOUBLE &&
ragge
1.15
171                             l->n_type != FLOAT && l->n_type != DOUBLE &&
172                             l->n_type != LDOUBLE && p->n_type != LDOUBLE) {
ragge
1.41
173                                 if (l->n_op == NAME || l->n_op == UMUL ||
174                                     l->n_op == TEMP) {
ragge
1.15
175                                         l->n_type = p->n_type;
176                                         nfree(p);
177                                         return l;
178                                 }
ragge
1.4
179                         }
ragge
1.6
180                 }
181
ragge
1.42
182                 if (DEUNSIGN(p->n_type) == INT && DEUNSIGN(l->n_type) == INT &&
183                     coptype(l->n_op) == BITYPE) {
184                         l->n_type = p->n_type;
185                         nfree(p);
186                         return l;
187                 }
188
ragge
1.3
189                 o = l->n_op;
ragge
1.4
190                 m = p->n_type;
ragge
1.1
191
192                 if (o == ICON) {
193                         CONSZ val = l->n_lval;
194
ragge
1.29
195                         if (!ISPTR(m)) /* Pointers don't need to be conv'd */
196                             switch (m) {
ragge
1.52
197                         case BOOL:
198                                 l->n_lval = l->n_lval != 0;
199                                 break;
ragge
1.1
200                         case CHAR:
201                                 l->n_lval = (char)val;
202                                 break;
203                         case UCHAR:
204                                 l->n_lval = val & 0377;
205                                 break;
ragge
1.15
206                         case SHORT:
ragge
1.1
207                                 l->n_lval = (short)val;
208                                 break;
ragge
1.15
209                         case USHORT:
ragge
1.1
210                                 l->n_lval = val & 0177777;
211                                 break;
ragge
1.15
212                         case ULONG:
ragge
1.1
213                         case UNSIGNED:
214                                 l->n_lval = val & 0xffffffff;
215                                 break;
216                         case ENUMTY:
217                         case MOETY:
ragge
1.15
218                         case LONG:
ragge
1.1
219                         case INT:
220                                 l->n_lval = (int)val;
221                                 break;
222                         case LONGLONG:
223                                 l->n_lval = (long long)val;
ragge
1.15
224                                 break;
ragge
1.1
225                         case ULONGLONG:
226                                 l->n_lval = val;
227                                 break;
228                         case VOID:
229                                 break;
ragge
1.14
230                         case LDOUBLE:
ragge
1.1
231                         case DOUBLE:
232                         case FLOAT:
233                                 l->n_op = FCON;
234                                 l->n_dcon = val;
235                                 break;
236                         default:
237                                 cerror("unknown type %d"m);
238                         }
239                         l->n_type = m;
ragge
1.44
240                         l->n_sue = MKSUE(m);
ragge
1.1
241                         nfree(p);
242                         return l;
243                 }
ragge
1.17
244                 if (DEUNSIGN(p->n_type) == SHORT &&
245                     DEUNSIGN(l->n_type) == SHORT) {
246                         nfree(p);
247                         p = l;
248                 }
ragge
1.36
249                 if ((p->n_type == CHAR || p->n_type == UCHAR ||
250                     p->n_type == SHORT || p->n_type == USHORT) &&
251                     (l->n_type == FLOAT || l->n_type == DOUBLE ||
252                     l->n_type == LDOUBLE)) {
253                         p = block(SCONVpNILp->n_typep->n_dfp->n_sue);
254                         p->n_left->n_type = INT;
255                         return p;
256                 }
ragge
1.1
257                 break;
258
ragge
1.15
259         case MOD:
260         case DIV:
261                 if (o == DIV && p->n_type != CHAR && p->n_type != SHORT)
262                         break;
ragge
1.16
263                 if (o == MOD && p->n_type != CHAR && p->n_type != SHORT)
ragge
1.15
264                         break;
265                 /* make it an int division by inserting conversions */
266                 p->n_left = block(SCONVp->n_leftNILINT0MKSUE(INT));
267                 p->n_right = block(SCONVp->n_rightNILINT0MKSUE(INT));
268                 p = block(SCONVpNILp->n_type0MKSUE(p->n_type));
269                 p->n_left->n_type = INT;
270                 break;
271
ragge
1.1
272         case PMCONV:
273         case PVCONV:
274                 ifp->n_right->n_op != ICON ) cerror"bad conversion"0);
275                 nfree(p);
276                 return(buildtree(o==PMCONV?MUL:DIVp->n_leftp->n_right));
277
ragge
1.31
278         case FORCE:
ragge
1.32
279                 /* put return value in return reg */
280                 p->n_op = ASSIGN;
281                 p->n_right = p->n_left;
282                 p->n_left = block(REGNILNILp->n_type0MKSUE(INT));
ragge
1.35
283                 p->n_left->n_rval = RETREG(p->n_type);
ragge
1.31
284                 break;
ragge
1.39
285
286         case LS:
287         case RS:
288                 /* shift count must be in a char
289                  * unless longlong, where it must be int */
290                 if (p->n_right->n_op == ICON)
291                         break/* do not do anything */
292                 if (p->n_type == LONGLONG || p->n_type == ULONGLONG) {
293                         if (p->n_right->n_type != INT)
294                                 p->n_right = block(SCONVp->n_rightNIL,
295                                     INT0MKSUE(INT));
296                         break;
297                 }
298                 if (p->n_right->n_type == CHAR || p->n_right->n_type == UCHAR)
299                         break;
300                 p->n_right = block(SCONVp->n_rightNIL,
301                     CHAR0MKSUE(CHAR));
302                 break;
ragge
1.1
303         }
ragge
1.24
304 //printf("ut:\n");
305 //fwalk(p, eprint, 0);
ragge
1.1
306
307         return(p);
308 }
309
310 void
311 myp2tree(NODE *p)
312 {
313 }
314
315 /*ARGSUSED*/
316 int
317 andable(NODE *p)
318 {
319         return(1);  /* all names can have & taken on them */
320 }
321
322 /*
323  * at the end of the arguments of a ftn, set the automatic offset
324  */
325 void
326 cendarg()
327 {
328         autooff = AUTOINIT;
329 }
330
331 /*
ragge
1.36
332  * Return 1 if a variable of type type is OK to put in register.
333  */
334 int
335 cisreg(TWORD t)
336 {
337         if (t == FLOAT || t == DOUBLE || t == LDOUBLE)
338                 return 0/* not yet */
339         return 1;
340 }
341
342 /*
ragge
1.1
343  * return a node, for structure references, which is suitable for
344  * being added to a pointer of type t, in order to be off bits offset
345  * into a structure
346  * t, d, and s are the type, dimension offset, and sizeoffset
347  * For pdp10, return the type-specific index number which calculation
348  * is based on its size. For example, short a[3] would return 3.
349  * Be careful about only handling first-level pointers, the following
350  * indirections must be fullword.
351  */
352 NODE *
353 offcon(OFFSZ offTWORD tunion dimfun *dstruct suedef *sue)
354 {
355         register NODE *p;
356
357         if (xdebug)
358                 printf("offcon: OFFSZ %lld type %x dim %p siz %d\n",
359                     offtdsue->suesize);
360
361         p = bcon(0);
362         p->n_lval = off/SZCHAR/* Default */
363         return(p);
364 }
365
366 /*
367  * Allocate off bits on the stack.  p is a tree that when evaluated
ragge
1.45
368  * is the multiply count for off, t is a storeable node where to write
ragge
1.1
369  * the allocated address.
370  */
371 void
372 spalloc(NODE *tNODE *pOFFSZ off)
373 {
374         NODE *sp;
375
ragge
1.45
376         p = buildtree(MULpbcon(off/SZCHAR)); /* XXX word alignment? */
377
378         /* sub the size from sp */
379         sp = block(REGNILNILp->n_type00);
380         sp->n_lval = 0;
381         sp->n_rval = STKREG;
382         ecomp(buildtree(MINUSEQspp));
ragge
1.1
383
384         /* save the address of sp */
385         sp = block(REGNILNILPTR+INTt->n_dft->n_sue);
386         sp->n_lval = 0;
387         sp->n_rval = STKREG;
388         t->n_type = sp->n_type;
389         ecomp(buildtree(ASSIGNtsp)); /* Emit! */
390
391 }
392
ragge
1.49
393 #if 0
ragge
1.48
394 /*
395  * Print out an integer constant of size size.
396  * can only be sizes <= SZINT.
397  */
ragge
1.47
398 void
399 indata(CONSZ valint size)
400 {
401         switch (size) {
402         case SZCHAR:
403                 printf("\t.byte %d\n", (int)val & 0xff);
404                 break;
405         case SZSHORT:
406                 printf("\t.word %d\n", (int)val & 0xffff);
407                 break;
408         case SZINT:
409                 printf("\t.long %d\n", (int)val & 0xffffffff);
410                 break;
411         default:
412                 cerror("indata");
413         }
414 }
ragge
1.49
415 #endif
ragge
1.47
416
ragge
1.1
417 /*
ragge
1.48
418  * Print out a string of characters.
419  * Assume that the assembler understands C-style escape
420  * sequences.  Location is already set.
421  */
422 void
423 instring(char *str)
424 {
425         char *s;
426
427         /* be kind to assemblers and avoid long strings */
428         printf("\t.ascii \"");
ragge
1.51
429         for (s = str; *s != 0; ) {
430                 if (*s++ == '\\') {
ragge
1.48
431                         (void)esccon(&s);
ragge
1.51
432                 }
ragge
1.48
433                 if (s - str > 64) {
434                         fwrite(str1s - strstdout);
435                         printf("\"\n\t.ascii \"");
436                         str = s;
437                 }
438         }
439         fwrite(str1s - strstdout);
440         printf("\\0\"\n");
441 }
442
ragge
1.49
443 static int inbitsinval;
444
445 /*
446  * set fsz bits in sequence to zero.
447  */
448 void
449 zbits(OFFSZ offint fsz)
450 {
451         int m;
452
453         if (idebug)
ragge
1.51
454                 printf("zbits off %lld, fsz %d inbits %d\n"offfszinbits);
ragge
1.49
455         if ((m = (inbits % SZCHAR))) {
456                 m = SZCHAR - m;
457                 if (fsz < m) {
ragge
1.51
458                         inbits += fsz;
ragge
1.49
459                         return;
460                 } else {
461                         fsz -= m;
462                         printf("\t.byte %d\n"inval);
463                         inval = inbits = 0;
464                 }
465         }
466         if (fsz >= SZCHAR) {
467                 printf("\t.zero %d\n"fsz/SZCHAR);
ragge
1.51
468                 fsz -= (fsz/SZCHAR) * SZCHAR;
ragge
1.49
469         }
470         if (fsz) {
471                 inval = 0;
472                 inbits = fsz;
473         }
474 }
475
476 /*
477  * Initialize a bitfield.
478  */
479 void
480 infld(CONSZ offint fszCONSZ val)
481 {
482         if (idebug)
ragge
1.51
483                 printf("infld off %lld, fsz %d, val %lld inbits %d\n",
484                     offfszvalinbits);
ragge
1.49
485         val &= (1 << fsz)-1;
486         while (fsz + inbits >= SZCHAR) {
487                 inval |= (val << inbits);
488                 printf("\t.byte %d\n"inval & 255);
489                 fsz -= (SZCHAR - inbits);
490                 val >>= (SZCHAR - inbits);
491                 inval = inbits = 0;
492         }
ragge
1.51
493         if (fsz) {
494                 inval |= (val << inbits);
495                 inbits += fsz;
496         }
ragge
1.49
497 }
498
ragge
1.48
499 /*
ragge
1.46
500  * print out a constant node, may be associated with a label.
501  * Do not free the node after use.
ragge
1.49
502  * off is bit offset from the beginning of the aggregate
503  * fsz is the number of bits this is referring to
ragge
1.21
504  */
505 void
ragge
1.49
506 ninval(CONSZ offint fszNODE *p)
ragge
1.21
507 {
ragge
1.46
508         union { float fdouble dlong double lint i[3]; } u;
ragge
1.24
509         struct symtab *q;
ragge
1.23
510         TWORD t;
ragge
1.46
511         int i;
ragge
1.23
512
513         t = p->n_type;
514         if (t > BTMASK)
515                 t = INT/* pointer */
516
ragge
1.46
517         if (p->n_op != ICON && p->n_op != FCON)
ragge
1.40
518                 cerror("ninval: init node not constant");
519
ragge
1.49
520         if (p->n_op == ICON && p->n_sp != NULL && DEUNSIGN(t) != INT)
ragge
1.46
521                 uerror("element not constant");
522
ragge
1.23
523         switch (t) {
ragge
1.21
524         case LONGLONG:
525         case ULONGLONG:
ragge
1.46
526                 i = (p->n_lval >> 32);
527                 p->n_lval &= 0xffffffff;
ragge
1.51
528                 p->n_type = INT;
ragge
1.49
529                 ninval(off32p);
ragge
1.46
530                 p->n_lval = i;
ragge
1.49
531                 ninval(off+3232p);
ragge
1.21
532                 break;
533         case INT:
534         case UNSIGNED:
535                 printf("\t.long 0x%x", (int)p->n_lval);
ragge
1.24
536                 if ((q = p->n_sp) != NULL) {
537                         if ((q->sclass == STATIC && q->slevel > 0) ||
538                             q->sclass == ILABEL) {
539                                 printf("+" LABFMTq->soffset);
ragge
1.21
540                         } else
ragge
1.24
541                                 printf("+%s"exname(q->sname));
ragge
1.21
542                 }
543                 printf("\n");
544                 break;
ragge
1.46
545         case SHORT:
546         case USHORT:
547                 printf("\t.short 0x%x\n", (int)p->n_lval & 0xffff);
548                 break;
ragge
1.52
549         case BOOL:
550                 if (p->n_lval > 1)
551                         p->n_lval = p->n_lval != 0;
552                 /* FALLTHROUGH */
ragge
1.46
553         case CHAR:
554         case UCHAR:
ragge
1.50
555                 printf("\t.byte %d\n", (int)p->n_lval & 0xff);
ragge
1.46
556                 break;
557         case LDOUBLE:
558                 u.i[2] = 0;
559                 u.l = (long double)p->n_dcon;
560                 printf("\t.long\t0x%x,0x%x,0x%x\n"u.i[0], u.i[1], u.i[2]);
561                 break;
562         case DOUBLE:
563                 u.d = (double)p->n_dcon;
564                 printf("\t.long\t0x%x,0x%x\n"u.i[0], u.i[1]);
565                 break;
566         case FLOAT:
567                 u.f = (float)p->n_dcon;
568                 printf("\t.long\t0x%x\n"u.i[0]);
569                 break;
ragge
1.21
570         default:
571                 cerror("ninval");
572         }
573 }
574
ragge
1.46
575 #if 0
ragge
1.21
576 /*
ragge
1.17
577  * print out an integer.
ragge
1.1
578  */
579 void
ragge
1.17
580 inval(CONSZ word)
ragge
1.1
581 {
ragge
1.17
582         word &= 0xffffffff;
583         printf("        .long 0x%llx\n"word);
ragge
1.1
584 }
585
ragge
1.17
586 /* output code to initialize a floating point value */
ragge
1.1
587 /* the proper alignment has been obtained */
588 void
ragge
1.17
589 finval(NODE *p)
ragge
1.1
590 {
ragge
1.43
591         union { float fdouble dlong double lint i[3]; } u;
592
ragge
1.17
593         switch (p->n_type) {
594         case LDOUBLE:
ragge
1.43
595                 u.i[2] = 0;
596                 u.l = (long double)p->n_dcon;
597                 printf("\t.long\t0x%x,0x%x,0x%x\n"u.i[0], u.i[1], u.i[2]);
ragge
1.14
598                 break;
ragge
1.17
599         case DOUBLE:
ragge
1.43
600                 u.d = (double)p->n_dcon;
601                 printf("\t.long\t0x%x,0x%x\n"u.i[0], u.i[1]);
ragge
1.14
602                 break;
ragge
1.17
603         case FLOAT:
ragge
1.43
604                 u.f = (float)p->n_dcon;
605                 printf("\t.long\t0x%x\n"u.i[0]);
ragge
1.14
606                 break;
607         }
ragge
1.1
608 }
ragge
1.46
609 #endif
ragge
1.1
610
611 /* make a name look like an external name in the local machine */
612 char *
613 exname(char *p)
614 {
615         if (p == NULL)
616                 return "";
617         return p;
618 }
619
620 /*
621  * map types which are not defined on the local machine
622  */
ragge
1.15
623 TWORD
ragge
1.1
624 ctype(TWORD type)
625 {
626         switch (BTYPE(type)) {
627         case LONG:
628                 MODTYPE(type,INT);
629                 break;
630
631         case ULONG:
632                 MODTYPE(type,UNSIGNED);
ragge
1.13
633
ragge
1.1
634         }
635         return (type);
636 }
637
638 /* curid is a variable which is defined but
639  * is not initialized (and not a function );
ragge
1.17
640  * This routine returns the storage class for an uninitialized declaration
ragge
1.1
641  */
642 int
643 noinit()
644 {
645         return(EXTERN);
646 }
647
pj
1.30
648 void
649 calldec(NODE *pNODE *q
650 {
651 }
652
653 void
654 extdec(struct symtab *q)
655 {
656 }
657
ragge
1.1
658 /* make a common declaration for id, if reasonable */
659 void
660 commdec(struct symtab *q)
661 {
662         int off;
663
664         off = tsize(q->stypeq->sdfq->ssue);
ragge
1.8
665         off = (off+(SZCHAR-1))/SZCHAR;
ragge
1.7
666 #ifdef GCC_COMPAT
667         printf("        .comm %s,0%o\n"gcc_findname(q), off);
668 #else
ragge
1.1
669         printf("        .comm %s,0%o\n"exname(q->sname), off);
ragge
1.7
670 #endif
ragge
1.1
671 }
672
673 /* make a local common declaration for id, if reasonable */
674 void
675 lcommdec(struct symtab *q)
676 {
677         int off;
678
679         off = tsize(q->stypeq->sdfq->ssue);
ragge
1.8
680         off = (off+(SZCHAR-1))/SZCHAR;
ragge
1.1
681         if (q->slevel == 0)
ragge
1.7
682 #ifdef GCC_COMPAT
683                 printf("        .lcomm %s,0%o\n"gcc_findname(q), off);
684 #else
ragge
1.1
685                 printf("        .lcomm %s,0%o\n"exname(q->sname), off);
ragge
1.7
686 #endif
ragge
1.1
687         else
688                 printf("        .lcomm " LABFMT ",0%o\n"q->soffsetoff);
689 }
ragge
1.22
690
691 /*
692  * print a (non-prog) label.
693  */
694 void
695 deflab1(int label)
696 {
697         printf(LABFMT ":\n"label);
698 }
699
ragge
1.28
700 static char *loctbl[] = { "text""data""section .rodata""section .rodata" };
ragge
1.27
701
ragge
1.23
702 void
703 setloc1(int locc)
704 {
705         if (locc == lastloc)
706                 return;
707         lastloc = locc;
ragge
1.27
708         printf("        .%s\n"loctbl[locc]);
ragge
1.23
709 }
ragge
1.48
710
ragge
1.49
711 #if 0
ragge
1.48
712 int
713 ftoint(NODE *pCONSZ **c)
714 {
715         static CONSZ cc[3];
716         union { float fdouble dlong double lint i[3]; } u;
717         int n;
718
719         switch (p->n_type) {
720         case LDOUBLE:
721                 u.i[2] = 0;
722                 u.l = (long double)p->n_dcon;
723                 n = SZLDOUBLE;
724                 break;
725         case DOUBLE:
726                 u.d = (double)p->n_dcon;
727                 n = SZDOUBLE;
728                 break;
729         case FLOAT:
730                 u.f = (float)p->n_dcon;
731                 n = SZFLOAT;
732                 break;
733         }
734         cc[0] = u.i[0];
735         cc[1] = u.i[1];
736         cc[2] = u.i[2];
737         *c = cc;
738         return n;
739 }
ragge
1.49
740 #endif
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-08-23 09:30 +0200