* added compilers lcc and bcc (linux86)
[mascara-docs.git] / compilers / linux86-0.16.17 / bcc / dbnode.c
blobe4a944cd129465d75659e68ae1a339ef00f120ce
1 /* dbnode.c - print debug messages for operators for bcc */
3 /* Copyright (C) 1992 Bruce Evans */
5 #include "bcc.h"
7 #ifdef DBNODE
8 #include "gencode.h"
9 #include "reg.h"
10 #include "sc.h"
11 #include "scan.h"
12 #include "type.h"
14 PRIVATE char *opname[LASTOP - FIRSTOP + 1] = /* operator names */
15 { /* order must agree with op.h */
16 "cond?",
17 "or",
18 "eor",
19 "and",
20 "gt", "lt",
21 "add",
22 "div", "mod",
23 "lognot", "not",
24 "strucelt", "strucptr",
25 "eq",
26 "addab", "andab", "divab", "eorab", "modab", "mulab", "orab",
27 "slab", "srab", "subab",
28 "comma",
29 "cond:",
30 "logor",
31 "logand",
32 "logeq",
33 "ne",
34 "ge", "le",
35 "sl", "sr",
36 "sub",
37 "mul",
38 "address", "cast", "indirect", "neg",
39 "predec", "preinc", "postdec", "postinc",
40 "func", "list", "rootlist",
41 "leaf",
42 "ptraddab", "ptradd", "ptrsub",
45 FORWARD void outindchars P((int byte, indn_pt count));
47 PUBLIC void dbitem(item)
48 struct symstruct *item;
50 dbtype(item->type);
51 if (item->storage == NOSTORAGE)
53 outbyte(' ');
54 outstr(item->name.namep + 2);
55 outstr(" (offset ");
56 outshex(item->offset.offi);
57 outbyte(')');
58 return;
60 if (item->storage == LOCAL)
62 outbyte(' ');
63 if (item->flags == TEMP)
64 outstr("(temp)");
65 else
66 outstr(item->name.namep);
68 outstr(" = ");
69 outindchars('[', item->indcount);
70 switch (item->storage)
72 case CONSTANT:
73 outstr("const ");
74 if (item->type->scalar & RSCALAR)
75 outstr("(whatever)");
76 else if (item->type->scalar & UNSIGNED)
77 outuvalue((uvalue_t) item->offset.offv);
78 else
79 outvalue(item->offset.offv);
80 break;
81 case BREG:
82 case DREG:
83 case INDREG0:
84 case INDREG1:
85 case INDREG2:
86 #ifdef DATREG1
87 case DATREG1:
88 #endif
89 #ifdef DATREG2
90 case DATREG2:
91 #endif
92 outregname(item->storage);
93 if (item->level == OFFKLUDGELEVEL)
95 outplus();
96 if (item->flags & LABELLED)
97 outlabel(item->name.label);
98 else
99 outccname(item->name.namep);
101 break;
102 case LOCAL:
103 outbyte('S');
104 if (sp <= 0)
105 outplus();
106 outshex(-sp);
107 break;
108 case GLOBAL:
109 if (item->flags & LABELLED)
110 outlabel(item->name.label);
111 else
112 outstr(item->name.namep);
113 break;
114 default:
115 outstr("bad storage (");
116 outhex((uoffset_T) item->storage);
117 outbyte(')');
118 outstr(" offset ");
120 if (item->storage != CONSTANT)
122 if (item->offset.offi >= 0)
123 outplus();
124 outshex(item->offset.offi);
126 outindchars(']', item->indcount);
129 PUBLIC void dbtype(type)
130 struct typestruct *type;
132 for ( ; type != NULL; type = type->nexttype)
134 outbyte(' ');
135 switch (type->constructor)
137 case ARRAY:
138 outbyte('[');
139 outhex(type->typesize / type->nexttype->typesize);
140 outbyte(']');
141 break;
142 case FUNCTION:
143 outstr("()");
144 break;
145 case POINTER:
146 outbyte('*');
147 break;
148 case STRUCTU:
149 outstr("struct ");
150 default:
151 if (type->scalar & UNSIGNED)
152 outstr("unsigned ");
153 outstr(type->tname);
154 break;
159 PUBLIC void dbnode(exp) /* sub-nodes must be leaves */
160 struct nodestruct *exp;
162 if (!dbnodeon)
163 return;
164 outstr("! Debug: ");
165 if (exp->tag < FIRSTOP && exp->tag > LASTOP)
166 outstr("unknown op");
167 else
168 outstr(opname[exp->tag - FIRSTOP]);
169 if (exp->right != NULL && exp->tag != FUNCOP &&
170 exp->tag != LISTOP && exp->tag != ROOTLISTOP)
172 dbitem(exp->right->left.symptr);
173 outstr(" to");
175 dbitem(exp->left.nodeptr->left.symptr);
176 outstr(" (used reg = ");
177 if (reguse & INDREG0)
178 outregname(INDREG0);
179 if (reguse & INDREG1)
180 outregname(INDREG1);
181 if (reguse & INDREG2)
182 outregname(INDREG2);
183 outnstr(")");
186 PUBLIC void dbnodeswap()
188 if (dbnodeon)
189 outnstr("! Debug: expression subtree swapping");
192 PRIVATE void outindchars(byte, count)
193 int byte;
194 indn_pt count;
196 while (count--)
197 outbyte(byte);
200 #endif /* DBNODE */