* add p cc
[mascara-docs.git] / compilers / pcc / pcc-1.0.0 / arch / i386 / flocal.c
blob0abd71399039552defcb815ef5dd65d239131ff5
1 /* $Id: flocal.c,v 1.16 2008/12/19 20:26:50 ragge Exp $ */
2 /*
3 * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * Redistributions of source code and documentation must retain the above
10 * copyright notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditionsand the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed or owned by Caldera
17 * International, Inc.
18 * Neither the name of Caldera International, Inc. nor the names of other
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
22 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
23 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
27 * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
35 #include <stdio.h>
37 #include "defines.h"
38 #include "defs.h"
40 void
41 prchars(int *s)
43 printf("\t.byte 0%o,0%o\n", s[0], s[1]);
47 void
48 setloc(int l)
50 static int lastloc = -1;
51 static char *loctbl[] =
52 { "text", "data", "section .rodata", "section .rodata", "bss" };
53 if (l == lastloc)
54 return;
55 printf("\t.%s\n", loctbl[l]);
56 lastloc = l;
59 #ifdef FCOM
63 PDP11-780/VAX - SPECIFIC PRINTING ROUTINES
67 * Called just before return from a subroutine.
69 void
70 goret(int type)
75 * Print out a label.
77 void
78 prlabel(int k)
80 printf(LABFMT ":\n", k);
84 * Print naming for location.
85 * name[0] is location type.
87 void
88 prnloc(char *name)
90 if (*name == '0')
91 setloc(DATA);
92 else
93 fatal("unhandled prnloc %c", *name);
94 printf("%s:\n", name+1);
98 * Print integer constant.
100 void
101 prconi(FILE *fp, int type, ftnint n)
103 fprintf(fp, "\t%s\t%ld\n", (type==TYSHORT ? ".word" : ".long"), n);
107 * Print address constant, given as a label number.
109 void
110 prcona(ftnint a)
112 printf("\t.long\t" LABFMT "\n", (int)a);
116 * Print out a floating constant.
118 void
119 prconr(FILE *fp, int type, double x)
121 fprintf(fp, "\t%s\t0f%e\n", (type==TYREAL ? ".float" : ".double"), x);
124 void
125 preven(int k)
127 if (k > 1)
128 printf("\t.align\t%d\n", k);
132 * Convert a tag and offset into the symtab table to a string.
133 * An external string is never longer than XL bytes.
135 char *
136 memname(int stg, int mem)
138 #define MLEN (XL + 10)
139 char *s = malloc(MLEN);
141 switch(stg) {
142 case STGCOMMON:
143 case STGEXT:
144 snprintf(s, MLEN, "%s", varstr(XL, extsymtab[mem].extname));
145 break;
147 case STGBSS:
148 case STGINIT:
149 snprintf(s, MLEN, "v.%d", mem);
150 break;
152 case STGCONST:
153 snprintf(s, MLEN, ".L%d", mem);
154 break;
156 case STGEQUIV:
157 snprintf(s, MLEN, "q.%d", mem);
158 break;
160 default:
161 fatal1("memname: invalid vstg %d", stg);
163 return(s);
166 void
167 prlocvar(char *s, ftnint len)
169 printf("\t.lcomm\t%s,%ld\n", s, len);
173 void
174 prext(char *name, ftnint leng, int init)
176 if(leng == 0)
177 printf("\t.globl\t%s\n", name);
178 else
179 printf("\t.comm\t%s,%ld\n", name, leng);
182 void
183 prendproc()
187 void
188 prtail()
192 void
193 prolog(struct entrypoint *ep, struct bigblock *argvec)
195 /* Ignore for now. ENTRY is not supported */
200 void
201 prdbginfo()
205 static void
206 fcheck(NODE *p, void *arg)
208 NODE *r, *l;
210 switch (p->n_op) {
211 case CALL: /* fix arguments */
212 for (r = p->n_right; r->n_op == CM; r = r->n_left) {
213 r->n_right = mkunode(FUNARG, r->n_right, 0,
214 r->n_right->n_type);
216 l = talloc();
217 *l = *r;
218 r->n_op = FUNARG;
219 r->n_left = l;
220 r->n_type = l->n_type;
221 break;
226 * Called just before the tree is written out to pass2.
228 void p2tree(NODE *p);
229 void
230 p2tree(NODE *p)
232 walkf(p, fcheck, 0);
234 #endif /* FCOM */