Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.25
 
1.26
 
MAIN:ragge:20050917075840
 
order.c
_>3131 
 3232 int canaddr(NODE *);
 3333 
<>34 -/*
 35 - * should the assignment op p be stored,
 36 - * given that it lies as the right operand of o
 37 - * (or the left, if o==UNARY MUL)
 38 - */
 39 -void
 40 -stoasg(NODE *p, int o)
 41 -{
 42 -        if (x2debug)
 43 -                printf("stoasg(%p, %o)\n", p, o);
 44 -}
 45 -
4634 /* should we delay the INCR or DECR operation p */
 4735 int
 4836 deltest(NODE *p)
     
 !
152140  * - res is in which register the result will end up.
 153141  * - mask is registers that will be clobbered.
 154142  */
<>155 -void
 156 -nspecial(struct optab *q, int *left, int *right, int *res, int *mask)
  143+struct rspecial *
  144+nspecial(struct optab *q)
157145 {
<> 146+        static int eax[] = { EAX, -1 };
  147+        static int eaxedx[] = { EAX, EDX, -1 };
  148+        static int edx[] = { EDX, -1 };
  149+        static struct rspecial div = { eax, 0, eaxedx, eax },
  150+            mod = { eax, 0, eaxedx, edx },
  151+            scconv = { 0, 0, 0, eaxedx },
  152+            ipconv = { eax, 0, 0, eaxedx };
  153+
158154         switch (q->op) {
 159155         case DIV:
<> 156+                return &div;
160157         case MOD:
<> 158+                return &mod;
  159+#if 0
161160                 *left = REGBIT(EAX);
 162161                 *right = 0;
 163162                 *res = q->op == DIV ? REGBIT(EAX) : REGBIT(EDX);
 164163                 *mask = REGBIT(EAX)|REGBIT(EDX);
<>165 -                break;
  164+#endif
166165         case SCONV:
 167166                 if ((q->ltype == TSHORT || q->ltype == TCHAR) &&
 168167                     (q->rtype & (TLONGLONG|TULONGLONG))) {
<> 168+                        return &scconv;
  169+#if 0
169170                         *mask = *left = *right = 0;
 170171                         *res = REGBIT(EAX)|REGBIT(EDX);
 171172                         break;
<> 173+#endif
172174                 } else if ((q->ltype & (TINT|TUNSIGNED|TPOINT)) &&
 173175                     (q->rtype & (TLONGLONG|TULONGLONG))) {
<> 176+                        return &ipconv;
  177+#if 0
174178                         *left = REGBIT(EAX);
 175179                         *mask = *right = 0;
 176180                         *res = REGBIT(EAX)|REGBIT(EDX);
 177181                         break;
<> 182+#endif
178183                 }
 179184         default:
 180185                 comperr("nspecial entry %d", q - table);
 181186         }
<> 187+        return 0; /* XXX gcc */
182188 }
 183189 
<>184 -#ifdef OLDSTYLE
 185 -/* register allocation */
 186 -regcode
 187 -regalloc(NODE *p, struct optab *q, int wantreg)
 188 -{
 189 -        regcode regc, regc2;
 190 -
 191 -        if (q->op == SCONV && (q->rtype & TLONGLONG)) {
 192 -                /*
 193 -                 * Cast to longlong from char->short->int.
 194 -                 * cltd instruction; input in eax, out in eax+edx.
 195 -                 */
 196 -                if (regblk[EAX] & 1 || regblk[EDX] & 1)
 197 -                        comperr("regalloc: needed regs inuse, node %p", p);
 198 -                regc = alloregs(p->n_left, EAX);
 199 -                if (REGNUM(regc) != EAX) {
 200 -                        p->n_left = movenode(p->n_left, EAX);
 201 -                        freeregs(regc);
 202 -                }
 203 -                MKREGC(regc, EAX, 2);
 204 -                regblk[EAX] |= 1;
 205 -                regblk[EDX] |= 1;
 206 -        } else if (q->op == MUL && (q->rtype & TCHAR)) {
 207 -                /*
 208 -                 * 8-bit mul, left in al, res in ax.
 209 -                 */
 210 -                if (regblk[EAX] & 1)
 211 -                        comperr("regalloc: needed regs inuse, node %p", p);
 212 -                if (p->n_su & DORIGHT) {
 213 -                        regc2 = alloregs(p->n_right, EDX);
 214 -                        if (REGNUM(regc2) == EAX) {
 215 -                                freeregs(regc2);
 216 -                                p->n_right = movenode(p->n_right, EDX);
 217 -                                regblk[EDX] |= 1;
 218 -                        } else
 219 -                                regblk[REGNUM(regc2)] |= 1;
 220 -                }
 221 -                regc = alloregs(p->n_left, EAX);
 222 -                if (REGNUM(regc) != EAX) {
 223 -                        p->n_left = movenode(p->n_left, EAX);
 224 -                        freeregs(regc);
 225 -                        regblk[EAX] |= 1;
 226 -                }
 227 -                if ((p->n_su & DORIGHT) == 0)
 228 -                        regc2 = alloregs(p->n_right, NOPREF);
 229 -                freeregs(regc2);
 230 -        } else if (q->op == DIV || q->op == MOD) {
 231 -                /*
 232 -                 * 32-bit div/mod.
 233 -                 */
 234 -                if (regblk[EAX] & 1 || regblk[EDX] & 1)
 235 -                        comperr("regalloc: needed regs inuse, node %p", p);
 236 -                if (p->n_su & DORIGHT) {
 237 -                        regc = alloregs(p->n_right, ECX);
 238 -                        if (REGNUM(regc) != ECX) {
 239 -                                p->n_right = movenode(p->n_right, ECX);
 240 -                                if ((p->n_su & RMASK) == ROREG) {
 241 -                                        p->n_su &= ~RMASK;
 242 -                                        p->n_su |= RREG;
 243 -                                        p->n_right->n_su &= ~LMASK;
 244 -                                        p->n_right->n_su |= LOREG;
 245 -                                }
 246 -                                freeregs(regc);
 247 -                                regblk[ECX] |= 1;
 248 -                        }
 249 -                }
 250 -                regc = alloregs(p->n_left, EAX);
 251 -                if (REGNUM(regc) != EAX) {
 252 -                        p->n_left = movenode(p->n_left, EAX);
 253 -                        freeregs(regc);
 254 -                        regblk[EAX] |= 1;
 255 -                }
 256 -                if ((p->n_su & RMASK) && !(p->n_su & DORIGHT)) {
 257 -                        regc = alloregs(p->n_right, ECX);
 258 -                        if (REGNUM(regc) != ECX) {
 259 -                                p->n_right = movenode(p->n_right, ECX);
 260 -                                if ((p->n_su & RMASK) == ROREG) {
 261 -                                        p->n_su &= ~RMASK;
 262 -                                        p->n_su |= RREG;
 263 -                                        p->n_right->n_su &= ~LMASK;
 264 -                                        p->n_right->n_su |= LOREG;
 265 -                                }
 266 -                        }
 267 -                }
 268 -                regblk[EAX] &= ~1;
 269 -                regblk[ECX] &= ~1;
 270 -                regblk[EDX] &= ~1;
 271 -                if (q->op == DIV) {
 272 -                        MKREGC(regc, EAX, 1);
 273 -                        regblk[EAX] |= 1;
 274 -                } else {
 275 -                        MKREGC(regc, EDX, 1);
 276 -                        regblk[EDX] |= 1;
 277 -                }
 278 -        } else if (q->op == LS || q->op == RS) {
 279 -                /*
 280 -                 * Shift instructions need shift count in cl.
 281 -                 */
 282 -                if (regblk[ECX] & 1)
 283 -                        comperr("regalloc: cl inuse, node %p", p);
 284 -                if (p->n_su & DORIGHT) {
 285 -                        regc = alloregs(p->n_right, ECX);
 286 -                        if (REGNUM(regc) != ECX) {
 287 -                                p->n_right = movenode(p->n_right, ECX);
 288 -                                freeregs(regc);
 289 -                                regblk[ECX] |= 1;
 290 -                        }
 291 -                }
 292 -                if ((p->n_su & LMASK) == LREG) {
 293 -                        regc = alloregs(p->n_left, NOPREF);
 294 -                        if (REGNUM(regc) == ECX) {
 295 -                                /* must move */
 296 -                                regc = getregs(NOPREF, 1, 0);
 297 -                                p->n_left = movenode(p->n_left, REGNUM(regc));
 298 -                                regblk[ECX] &= ~1;
 299 -                        }
 300 -                }
 301 -                if ((p->n_su & RMASK) == RREG && !(p->n_su & DORIGHT)) {
 302 -                        regc2 = alloregs(p->n_right, ECX);
 303 -                        if (REGNUM(regc2) != ECX) {
 304 -                                p->n_right = movenode(p->n_right, ECX);
 305 -                                freeregs(regc2);
 306 -                        }
 307 -                }
 308 -                regblk[ECX] &= ~1;
 309 -        } else
 310 -                comperr("regalloc: bad optab");
 311 -        p->n_rall = REGNUM(regc);
 312 -        return regc;
 313 -}
 314 -#endif
 315 -
316190 /*
 317191  * Splitup a function call and give away its arguments first.
 318192  */
     
 !
466340                 return tsz;
 467341         }
 468342 }
<_469 -
 470 -/*
 471 - * Tell if a register can hold a specific datatype.
 472 - */
 473 -int
 474 -mayuse(int reg, TWORD type)
 475 -{
 476 -        if (reg == EAX || reg == EBX || reg == ECX || reg == EDX)
 477 -                return 1; /* May hold any type */
 478 -        if ((reg == EDI || reg == ESI) && (type >= CHAR && type <= USHORT))
 479 -                return 0; /* May not hold char/short */
 480 -        return 1/* Everything else is OK */
 481 -}
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-21 10:56 +0100