Hack genconv() so that downward scalar conversions for conversion codes
authorDonn Seeley <donn@ucbvax.Berkeley.EDU>
Thu, 14 Jan 1988 16:30:31 +0000 (08:30 -0800)
committerDonn Seeley <donn@ucbvax.Berkeley.EDU>
Thu, 14 Jan 1988 16:30:31 +0000 (08:30 -0800)
force a test to be emitted if the source is a register; more tahoe
architecture grot...

SCCS-vsn: old/pcc/ccom.tahoe/local2.c 1.29

usr/src/old/pcc/ccom.tahoe/local2.c

index 813b348..1d92e2a 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)local2.c   1.28 (Berkeley) %G%";
+static char sccsid[] = "@(#)local2.c   1.29 (Berkeley) %G%";
 #endif
 
 # include "pass2.h"
 #endif
 
 # include "pass2.h"
@@ -747,6 +747,8 @@ static char convtab[SZINT/SZCHAR + 1] = {
  *     ignored and the high bits of the source are copied.  (Note
  *     that zero-extension is not a problem for immediate
  *     constants.)
  *     ignored and the high bits of the source are copied.  (Note
  *     that zero-extension is not a problem for immediate
  *     constants.)
+ * Another problem -- condition codes for a conversion with a
+ *     register source reflect the source rather than the destination.
  */
 sconv(p, forcc)
        NODE *p;
  */
 sconv(p, forcc)
        NODE *p;
@@ -838,7 +840,7 @@ sconv(p, forcc)
                }
                genconv(ISUNSIGNED(srctype),
                        srclen, dst->in.op == REG ? SZINT/SZCHAR : dstlen,
                }
                genconv(ISUNSIGNED(srctype),
                        srclen, dst->in.op == REG ? SZINT/SZCHAR : dstlen,
-                       src, dst);
+                       src, dst, forcc);
                return;
        }
 
                return;
        }
 
@@ -898,20 +900,21 @@ sconv(p, forcc)
                        tmp->tn.op = OREG;
                        tmp->tn.lval = srclen - dstlen;
                }
                        tmp->tn.op = OREG;
                        tmp->tn.lval = srclen - dstlen;
                }
-               genconv(ISUNSIGNED(dsttype), dstlen, SZINT/SZCHAR, tmp, dst);
+               genconv(ISUNSIGNED(dsttype), dstlen, SZINT/SZCHAR, tmp, dst, forcc);
                tmp->in.op = FREE;
                return;
        }
 
        genconv(neg ? -1 : ISUNSIGNED(dsttype),
                srclen, dst->in.op == REG ? SZINT/SZCHAR : dstlen,
                tmp->in.op = FREE;
                return;
        }
 
        genconv(neg ? -1 : ISUNSIGNED(dsttype),
                srclen, dst->in.op == REG ? SZINT/SZCHAR : dstlen,
-               src, dst);
+               src, dst, forcc);
 }
 
 }
 
-genconv(srcflag, srclen, dstlen, src, dst)
+genconv(srcflag, srclen, dstlen, src, dst, forcc)
        int srcflag;
        register int srclen, dstlen;
        NODE *src, *dst;
        int srcflag;
        register int srclen, dstlen;
        NODE *src, *dst;
+       int forcc;
 {
        if (srclen != dstlen) {
                if (srcflag > 0 && srclen < dstlen)
 {
        if (srclen != dstlen) {
                if (srcflag > 0 && srclen < dstlen)
@@ -928,6 +931,17 @@ genconv(srcflag, srclen, dstlen, src, dst)
        adrput(src);
        putchar(',');
        adrput(dst);
        adrput(src);
        putchar(',');
        adrput(dst);
+
+       /*
+        * This hack is made necessary by architecture problems
+        *      described above
+        */
+       if (forcc && src->in.op == REG && srclen > dstlen) {
+               putstr("\n\ttst");
+               prlen(dstlen);
+               putchar('\t');
+               adrput(dst);
+       }
 }
 
 rmove( rt, rs, t ) TWORD t; {
 }
 
 rmove( rt, rs, t ) TWORD t; {