Google
 

Trailing-Edge - PDP-10 Archives - BB-4157D-BM - sources/goptim.bli
There are 12 other files named goptim.bli in the archive. Click here to see a list.


!THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
!  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.

!COPYRIGHT (C) 1972,1977 BY DIGITAL EQUIPMENT CORPORATION
MODULE GOPTIM(RESERVE(0,1,2,3),SREG=#17,VREG=#15,FREG=#16,DREGS=4,GLOROUTINES)=
BEGIN

SWITCHES NOLIST;
REQUIRE FIRST.BLI;
REQUIRE TABLES.BLI;
REQUIRE OPTMAC.BLI;
SWITCHES LIST;

GLOBAL BIND GOPTV = 4^24 + 2^18 + 53;		!VERSION DATE: 21-MAY-76
%(
REVISION HISTORY
52	-----	-----	REMOVE REFERENCES TO THISLEVL

*************** BEGIN VERSION 4B *****************

53	18869	404	FIX UP THE CREATION OF ASSOCIATE VARIABLE LIST
)%

!
!************************************
!
!
!********************************************
!
GLOBAL ROUTINE LOOKUP(VAR)=
BEGIN
EXTERNAL CHOSEN;
MAP PEXPRNODE VAR;
!LOOKUP IS CALLED BY THE DEFINITION ALGORITHM AND GLOBAL REGISTER
!ALLOCATION TO SEARCH A LINEAR LIST (CHOSEN) TO DETERMINE IF
!VAR IS IN THAT LIST
!
	IF .VAR[IDATTRIBUT(INCOM)] THEN VAR_.VAR[IDCOMMON];
	INCR I FROM 0 TO 31 DO
		IF .CHOSEN[.I]<RIGHT> EQL .VAR THEN RETURN(.I);
RETURN(64);
END;
!
!***********************************************
!
ROUTINE CHKUA(CPTR)=
BEGIN
	!THIS ROUITNE HELPS THE GLOBAL ALLOCATOR DETERMINE USED BEFORE
	!ASSIGNED AND ASSIGNED BEFORE FIRST USE INFO. UNFORTUNATELY, 
	!WE DO NOT HAVE THE INDEX INTO GLOBREG AT THIS TIME SO WE
	!WILL LOOK THE POINTER UP (USING LOOKUP) AND THEN CHECK

	EXTERNAL GLOBREG,CHOSEN,SPECCASE;
	REGISTER INX;

	IF .SPECCASE NEQ 1 THEN RETURN;
	!GET OUT FAST IF THIS IS NOT THE GLOBAL ALLOCATION CASE
	INX_LOOKUP(.CPTR);

	IF .INX GEQ 64 THEN RETURN;

	IF NOT .GLOBREG[.INX]<ASGND4USED> THEN
		GLOBREG[.INX]<USED4ASGND>_1;
END;

GLOBAL ROUTINE LOKCALST(PTR,NUMB,COMPR,SUBSTITUTE)=
BEGIN

	LOCAL BASE ARGG;
	MAP ARGUMENTLIST PTR;
	EXTERNAL LEAFSUBSTITUTE,SPECCASE;
	EXTERNAL TOP;
	MAP BASE TOP:SUBSTITUTE;
!LOOK AT A LIST OF ARGUMENTS POINTED TO BY PTR
!LOOK AT NUMB ELEMENTS OF THE LIST.
!COMPARE ELEMENTS OF THE LIST WITH COMPR.
!WHEN COMPR IS FOUND REPLACE IT WITH SUBSTITUTE
!
	INCR K FROM 1 TO .NUMB DO
	BEGIN
		ARGG_.PTR[.K,ARGNPTR];
		IF .ARGG[OPRCLS] EQL DATAOPR THEN
		BEGIN
			IF .ARGG EQL .COMPR THEN
			BEGIN
				!DONT DO IT IF THIS
				!IS A HALF WORD INDUCTION VARIABLE
				IF .TOP NEQ 0 THEN
				IF .TOP[DOSYM] EQL .COMPR THEN
					IF .TOP[FLCWD] AND .SPECCASE EQL 1 THEN
						TOP[NEDSMATRLZ]_1;
				!NOW SUBSTITUTE ANYWAY.
				PTR[.K,ARGNPTR]_.SUBSTITUTE;
				PTR[.K,AVALFLG]_1;
				CHKUA(.SUBSTITUTE);
			END;
		END ELSE
		!IT COULD  BE THIS EXPRESSION ITSELF
		IF .ARGG EQL .COMPR THEN
		BEGIN
			PTR[.K,ARGNPTR]_.SUBSTITUTE;
			CHKUA(.SUBSTITUTE);
			!SET VAL FLAG IF IT SHOULD BE SET
			!IT SHOULD BE SET FOR A COMMON SUB OR DATA ITEM
			IF .SUBSTITUTE[OPRCLS] EQL DATAOPR OR
			   .SUBSTITUTE[OPRCLS] EQL CMNSUB THEN
				PTR[.K,AVALFLG]_1;
		END
		ELSE
		!MUST WALK EXPRESSION TREE LOOKING FOR IT
			LEAFSUBSTITUTE(.ARGG);
	END;	!INCR LOOP
END;
!******************************************************
!ROUTINE
!
GLOBAL ROUTINE REPLACARG(STMT,OLDARG,NEWARG)=
BEGIN
REGISTER INX;
EXTERNAL TOP,GLOBREG,CELMNT;
MAP BASE TOP;
EXTERNAL OPTERR;
MAP BASE STMT:NEWARG;
EXTERNAL SPECCASE;
!A PARENT THAT POINTS TO A STATEMENT HAS BEEN FOUND
!LIKE UP ARG TO THE CORRECT STAEMENT TYPE
!
	SELECT .STMT[SRCID] OF NSET
ASGNID:			!ASSIGNMENT STATEMENT
	BEGIN
		!IT COULD BE BOTH RIGHT AND LEFT HAND SIDES
		IF .STMT[RHEXP] EQL .OLDARG THEN
		BEGIN
			STMT[RHEXP]_.NEWARG;
			IF .NEWARG[OPRCLS] EQL DATAOPR THEN
				STMT[A2VALFLG]_1;
			IF .NEWARG[OPRCLS] EQL REGCONTENTS THEN
			BEGIN
				STMT[A2VALFLG]_1;
				IF .SPECCASE EQL 2 THEN
				STMT[A2IMMEDFLG]_1
				ELSE
				IF .SPECCASE EQL 1 THEN
				BEGIN
					IF .TOP[DOSYM] EQL .OLDARG
					AND .TOP[FLCWD] THEN
						STMT[A2IMMEDFLG]_1;
					!ONCE AGAIN GET THE USED/ASSIGNED INFO
					CHKUA(.NEWARG);
				END;
			END;
		END;
		IF .STMT[LHEXP] EQL .OLDARG THEN
		BEGIN
			 STMT[LHEXP]_.NEWARG;
			IF .NEWARG[OPRCLS] EQL DATAOPR THEN
				STMT[A1VALFLG]_1;
			IF .NEWARG[OPRCLS] EQL REGCONTENTS THEN
			BEGIN
				STMT[A1VALFLG]_1;
				IF .SPECCASE EQL 2 THEN
				STMT[A1IMMEDFLG]_1
				ELSE
				IF .SPECCASE EQL 1 THEN
				BEGIN
					IF .TOP[DOSYM] EQL .OLDARG 
					AND .TOP[FLCWD] THEN
						STMT[A1IMMEDFLG]_1;
					!HER WE ALSO WANT TO SET ASGND4USED BIT
					INX_LOOKUP(.NEWARG);
					IF .INX LSS 64 THEN
						IF NOT .GLOBREG[.INX]<USED4ASGND> THEN
							GLOBREG[.INX]<ASGND4USED>_1;
				END;
			END;
		END;
	END;
!
!
CALLID:			!SUBROUTINE CALL
	BEGIN
		LOCAL ARGUMENTLIST AG;
		AG_.STMT[CALLIST];
		IF .AG NEQ 0 THEN
		LOKCALST(.AG,.AG[ARGCOUNT],.OLDARG,.NEWARG);
	END;
!
!
DOID:
	BEGIN
		IF .STMT[DOLPCTL] EQL .OLDARG THEN
			STMT[DOLPCTL]_.NEWARG;
	END;
!
!
IFAID:
	BEGIN
		IF .STMT[AIFEXPR] EQL .OLDARG THEN
		BEGIN
			STMT[AIFEXPR]_.NEWARG;
			IF .NEWARG[OPRCLS] EQL REGCONTENTS THEN
			BEGIN
				IF .SPECCASE EQL 2 THEN
				STMT[A1IMMEDFLG]_1
				ELSE
				IF .SPECCASE EQL 1 THEN
				BEGIN
					IF .TOP[DOSYM] EQL .OLDARG 
					AND .TOP[FLCWD] THEN
						STMT[A1IMMEDFLG]_1;
					CHKUA(.NEWARG);
				END;
			END;
		END;
	END;
!
!
IFLID:
	BEGIN
		IF .STMT[LIFEXPR] EQL .OLDARG THEN
		BEGIN
			STMT[LIFEXPR]_.NEWARG;
			IF .NEWARG[OPRCLS] EQL REGCONTENTS THEN
			BEGIN
				IF .SPECCASE EQL 2 THEN
				!P2S, AOBJN WORD. VALUE IS +
				!CUZ WE DONT DO AOBJNS THRU ZERO
				!IT IS FALSE SO THE STATEMENT GOES AWAY
					STMT[SRCID]_CONTID
				ELSE
				IF .SPECCASE EQL 1 THEN
				BEGIN
				!GLOBAL CASE, IF AOBJN, INDUCTION VARABLE
				!DO THE SAME THING
					IF .TOP[DOSYM] EQL .OLDARG
						AND .TOP[FLCWD] THEN
						STMT[SRCID]_CONTID
					ELSE
						CHKUA(.NEWARG);
				END;
			END;
		END;
	END;
!

AGOID:
	BEGIN
		IF .STMT[AIFEXPR] EQL .OLDARG THEN
			STMT[AIFEXPR]_.NEWARG;
	END;
!
!
CGOID:
	BEGIN
	!WE SHOULD BE TRYING THIS ONLY FOR GLOBAL REGISTER ALLOCATION
	IF .STMT[CGOTOLBL] EQL .OLDARG THEN
	BEGIN
		STMT[CGOTOLBL]_.NEWARG;
		IF .SPECCASE EQL 1 THEN	!GLOBAL REG ALLOC.
		BEGIN
			IF .TOP[SRCID] EQL DOID AND
			  .TOP[FLCWD] THEN
				STMT[A1IMMEDFLG]_1;
			CHKUA(.NEWARG);
		END;
	END;
	END;
!
!
READID:	REPLACARG(.CELMNT,.OLDARG,.NEWARG);
WRITID:	REPLACARG(.CELMNT,.OLDARG,.NEWARG);
ENCOID:	REPLACARG(.CELMNT,.OLDARG,.NEWARG);
DECOID:	REPLACARG(.CELMNT,.OLDARG,.NEWARG);
REREDID:	REPLACARG(.CELMNT,.OLDARG,.NEWARG);
	TESN;
END;
!MORE WILL BE INCLUDED IN THIS WHEN THE FORMAT OF I/O STATEMENTS IS
!EXPLICIT


GLOBAL ROUTINE DOPARMS(CNODE)=
!ROUTINE CALLED TO COLLECT GLOBAL PARAMETERS USED BY THE