/lib/c2 optimizes calls instructions
Chris Torek
chris at umcp-cs.UUCP
Thu Aug 22 15:58:56 AEST 1985
>Index: /lib/c2, BRL-Unix release 3, likely appears in other 4.?BSD.
>Problem: Calls instructions have a format "calls <const-#-of-args>,<addr>".
> The <const-#-of-args> argument will sometimes be "optimized" into
> a register reference. This isn't necessary, and breaks the
> massager which helps create the code in the kernel.
It saves a little teensy bit of time. Anyway, here's how to work
around it. I added a new flag to /lib/c2 (-c) but it should be
obvious how to make it always do what -c does.
First, change /usr/src/lib/c2/c20.c to handle "-c". (Beware, these
are to what amounts to the 4.3BSD c2; your code may vary slightly.)
RCS file: RCS/c20.c,v
retrieving revision 1.1
diff -c2 -r1.1 c20.c
*** /tmp/,RCSt1015521 Thu Aug 22 01:45:07 1985
--- c20.c Thu Aug 22 01:44:13 1985
***************
*** 15,18
caddr_t sbrk();
int ioflag;
int fflag;
long isn = 2000000;
--- 15,19 -----
caddr_t sbrk();
int ioflag;
+ int cflag;
int fflag;
long isn = 2000000;
***************
*** 57,60
if ((*argv)[1]=='i') ioflag++;
else if ((*argv)[1]=='f') fflag++;
else nflag++;
} else if (infound==0) {
--- 58,62 -----
if ((*argv)[1]=='i') ioflag++;
else if ((*argv)[1]=='f') fflag++;
+ else if ((*argv)[1]=='c') cflag++;
else nflag++;
} else if (infound==0) {
Second, modify the optimizer code in /usr/src/lib/c2/c21.c to check
cflag before optimizing "calls" constants. This also includes a
fix from Donn Seeley for a longstanding fencepost error:
RCS file: RCS/c21.c,v
retrieving revision 1.1
diff -c2 -r1.1 c21.c
*** /tmp/,RCSt1015526 Thu Aug 22 01:45:24 1985
--- c21.c Thu Aug 22 01:44:49 1985
***************
*** 14,17
#define NUSE 6
int ioflag;
int biti[NUSE] = {1,2,4,8,16,32};
int bitsize[] = { /* index by type codes */
--- 14,18 -----
#define NUSE 6
int ioflag;
+ int cflag;
int biti[NUSE] = {1,2,4,8,16,32};
int bitsize[] = { /* index by type codes */
***************
*** 509,512
break;
/* .rx,.rx,.rx */
case PROBER:
--- 510,521 -----
break;
+ /* .rx,.rx */
+ case CALLS:
+ if (cflag) /* don't optimize constants in calls */
+ break;
+ /* fall through */
+ case MTPR:
+ case CMP:
+ case BIT:
/* .rx,.rx,.rx */
case PROBER:
***************
*** 514,522
case CASE:
case MOVC3:
- /* .rx,.rx */
- case MTPR:
- case CALLS:
- case CMP:
- case BIT:
splitrand(p);
/* fool repladdr into doing right number of operands */
--- 523,526 -----
case CASE:
case MOVC3:
splitrand(p);
/* fool repladdr into doing right number of operands */
***************
*** 724,728
if (!equstr(regs[RT3],"-(sp)")) p->combop=T(MOVA,BYTE);
else {p->combop=T(PUSHA,BYTE); *cp2=0;}
! if (uses[r]==0) {uses[r]=p; regs[r][0]=OPX<<4;}
p->pop=0;
}
--- 728,735 -----
if (!equstr(regs[RT3],"-(sp)")) p->combop=T(MOVA,BYTE);
else {p->combop=T(PUSHA,BYTE); *cp2=0;}
! if (r < NUSE && uses[r] == 0) {
! uses[r]=p;
! regs[r][0]=OPX<<4;
! }
p->pop=0;
}
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP: seismo!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris at maryland
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list