Debian Codegraph @

arch/i86/flocal.c

raw symbols SCIP
1 /* $Id: flocal.c,v 1.1 2014/09/16 10:47:35 ragge Exp $ */
2 /*
3 * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
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.
21 *
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.
34 */
35 #include <stdio.h>
36
37 #include "defines.h"
38 #include "defs.h"
39
40 void
41 prchars(int *s)
42 {
43 printf("\t.byte 0%o,0%o\n", s[0], s[1]);
44 }
45
46 void
47 setloc(int l)
48 {
49 static int lastloc = -1;
50 static char *loctbl[] =
51 { "text", "data", "data", "data", "bss" };
52 if (l == lastloc)
53 return;
54 printf("\t.%s\n", loctbl[l]);
55 lastloc = l;
56 }
57
58 #ifdef FCOM
59
60
61 /*
62 8086 - SPECIFIC PRINTING ROUTINES
63 */
64
65 /*
66 * Called just before return from a subroutine.
67 */
68 void
69 goret(int type)
70 {
71 }
72
73 /*
74 * Print out a label.
75 */
76 void
77 prlabel(int k)
78 {
79 printf(LABFMT ":\n", k);
80 }
81
82 /*
83 * Print naming for location.
84 * name[0] is location type.
85 */
86 void
87 prnloc(char *name)
88 {
89 if (*name == '0')
90 setloc(DATA);
91 else
92 fatal("unhandled prnloc %c", *name);
93 printf("%s:\n", name+1);
94 }
95
96 /*
97 * Print integer constant.
98 */
99 void
100 prconi(FILE *fp, int type, ftnint n)
101 {
102 fprintf(fp, "\t%s\t%ld\n", (type==TYSHORT ? ".word" : ".long"), n);
103 }
104
105 /*
106 * Print address constant, given as a label number.
107 */
108 void
109 prcona(ftnint a)
110 {
111 printf("\t.long\t" LABFMT "\n", (int)a);
112 }
113
114 /*
115 * Print out a floating constant.
116 */
117 void
118 prconr(FILE *fp, int type, double x)
119 {
120 fprintf(fp, "\t%s\t0f%e\n", (type==TYREAL ? ".float" : ".double"), x);
121 }
122
123 void
124 preven(int k)
125 {
126 if (k > 1)
127 printf("\t.align\t%d\n", k);
128 }
129
130 /*
131 * Convert a tag and offset into the symtab table to a string.
132 * An external string is never longer than XL bytes.
133 */
134 char *
135 memname(int stg, int mem)
136 {
137 #define MLEN (XL + 10)
138 char *s = malloc(MLEN);
139
140 switch(stg) {
141 case STGCOMMON:
142 case STGEXT:
143 snprintf(s, MLEN, "%s", varstr(XL, extsymtab[mem].extname));
144 break;
145
146 case STGBSS:
147 case STGINIT:
148 snprintf(s, MLEN, "v.%d", mem);
149 break;
150
151 case STGCONST:
152 snprintf(s, MLEN, ".L%d", mem);
153 break;
154
155 case STGEQUIV:
156 snprintf(s, MLEN, "q.%d", mem);
157 break;
158
159 default:
160 fatal1("memname: invalid vstg %d", stg);
161 }
162 return(s);
163 }
164
165 void
166 prlocvar(char *s, ftnint len)
167 {
168 printf("%s:\t.blkb\t%ld\n", s, len);
169 }
170
171
172 void
173 prext(char *name, ftnint leng, int init)
174 {
175 if(leng == 0)
176 printf("\t.globl\t%s\n", name);
177 else
178 printf("%s:\t.blkb %ld\n", name, leng);
179 }
180
181 void
182 prendproc(void)
183 {
184 }
185
186 void
187 prtail(void)
188 {
189 }
190
191 void
192 prolog(struct entrypoint *ep, struct bigblock *argvec)
193 {
194 /* Ignore for now. ENTRY is not supported */
195 }
196
197 void
198 prdbginfo(void)
199 {
200 }
201
202 static void
203 fcheck(NODE *p, void *arg)
204 {
205 NODE *r, *l;
206
207 switch (p->n_op) {
208 case CALL: /* fix arguments */
209 for (r = p->n_right; r->n_op == CM; r = r->n_left) {
210 r->n_right = mkunode(FUNARG, r->n_right, 0,
211 r->n_right->n_type);
212 }
213 l = talloc();
214 *l = *r;
215 r->n_op = FUNARG;
216 r->n_left = l;
217 r->n_type = l->n_type;
218 break;
219 }
220 }
221
222 /*
223 * Called just before the tree is written out to pass2.
224 */
225 void p2tree(NODE *p);
226 void
227 p2tree(NODE *p)
228 {
229 walkf(p, fcheck, 0);
230 }
231 #endif /* FCOM */