Trailing-Edge
-
PDP-10 Archives
-
decuslib10-05
-
43,50337/12/cgiw.mac
There are 2 other files named cgiw.mac in the archive. Click here to see a list.
COMMENT;
AUTHOR: I WENNERSTR@M
VERSION:3A [14]
PURPOSE(S):THIS MODULE IS PART OF THE CODE GENERATION IN PASS 2
IT ADMINISTRATES THE USE OF THE RUN TIME ACCUMULATORS
XWAC1 TO XWACL.
TWO SUBROUTINES GET ACCUMULATORS CGG AND RELEASE ACCUMULATORS CGR
WITH MULTIPLE ENTRY POINTS ARE DEFINED.
CODE TO STORE AND RESTORE THE ACCUMULATORS IN THE PSEUDOREGISTER
STACK ARE GENERATED WHEN THE REAL ACCUMULATORS ARE OCCUPIED
ONE COMPLICATION IS THAT THE RESERVED ACCUMULATORS MUST BE
CONSECUTIVE AND IF AT RESERVATION TIME SOME ACCUMULATORS WERE
SKIPPED IN ORDER TO GET CONSECUTIVE ACCUMULATORS
,THEN AT RELEASE TIME CODE MUST BE GENERATED
TO MOVE THE RESULT TO THE FIRST UNUSED ACCUMULATOR.
CONTENTS:
ROUTINE CGG WITH ENTRY POINTS CGG1,CGG2,......,CGG10
ROUTINE CGR WITH ENTRY POINTS CGR,CGR1,CGR2,......,CGR7
;
TWOSEG
SALL
SEARCH SIMMAC,SIMMC2,SIMMCR
CTITLE CGIW
CGINIT
MACINIT
RELOC 400K
EXTERN CGAD,CGCA,CGCC,CGCO,CGIM,CGIM1,CGMO,CGMO1,CGPU,CGVA,O2AD,O2GI,O2GWD
EXTERN CADS,O2CF,O2DF,O2GA,O2GF,O2GR,O2GW,O2IV,CGLO,CGLO1,M2CO
EXTERN YTAC,YACTAB,YCGXAC,YCGNAC,YCGSK,YCGACT ;EXTERNAL VARIABLES
EXTERN YDCSTO,YDCSTP
INTERN CGG1,CGG2,CGG3,CGG4,CGG5,CGG6,CGG7,CGG8,CGG9,CGG10 ;GET AC's
INTERN CGR,CGR1,CGR2,CGR3,CGR4,CGR5,CGR6,CGR7 ;RELEASE ACCUMULATORS
INTERN CGPD,CGRA
INTERN CGIACT ;[14]
SUBTTL LOCAL DECLARATIONS
QNXAC=QNAC+QNAC
YACTAP=YACTAB+QNAC ;FIRST PSEUDOREGISTER ENTRY IN YACTAB
YACTAE=YACTAP+QNAC
;YACTAB IS USED TO CONTROL THE RTS ACCUMULATORS XWAC1,...XWACL
;FIRST PART OF TABLE HAS ONE ENTRY PER REAL ACCUMULATOR
;AND LAST PART HAS ONE ENTRY PER PSEUDOACCUMULATOR
;WHICH CAN ONLY BE ONE PER REAL ACCUMULATOR
DF (YACTPF,0,18,17) ;POINTER FIELD IN YACTAB
;CONTENTS:
;AT EXIT FROM RESERVATION /GET ROUTINE
;0 IF RESERVATION PERFORMED AND
; XCUR VALUE IN FIRST ENTRY
;OR
; POINTER POINTS AT ITSELF WHEN THE ENTRY WAS
;SKIPPED IN ORDER TO GET CONSECUTIVE
; ACCUMULATORS
;
;AT EXIT FROM RELEASE ROUTINE
;SKIPPED ENTRIES REMOVED AND
;POINTER FIELD IS COPIED FROM XWAC1 (AND XWAC2)
;ENTRIES
;NORMAL CASE UNCHANGED
DF (YACTAF,0,18,35) ;ADDRESS FIELD IN YACTAB
;CONTAINS:
;ACCUMULATOR NUMBER IF RESERVED OR REAL NOT
;USED ACCUMULATOR
;OR
;PSEUDOREGISTER FIXUP INDEX IF
; SAVED ACCUMULATOR (ONLY TEST VERSION)
;OR
;777777 IF NOT USED PSEUDOREGISTER ENTRY
;LOCAL REGISTER ASSIGNMENTS
XCG1=X2
XCG2=X3
SUBTTL CGG,GET (OR RESERVE) ACCUMULATORS
COMMENT;
PURPOSE:TO RESERVE ACCUMULATORS AND GENERATE CODE IF PSEUDOREGISTER
STACK INVOLVED
ENTRIES:CGG1,CGG2,...,CGG7
INPUT ARGUMENTS:ENTRY POINT ESTABLISH NUMBER OF ACCUMULATORS NEEDED
YTAC POINTS AT FIRST ACCUMULATOR
TO BE USED TO SATISFY THE REQUEST
NORMAL EXIT: RETURN
OUTPUT ARGUMENTS:YTAC POINTS AT FIRST OF THE RESERVED ENTRIES
CALL FORMAT:EXEC CGG1,....,EXEC CGG7
ERRORS GENERATED:RFAIL MESSAGES CG YACTAB ERR0R1 ,ENTRY NEITHER 777777 NOR ACC.NUMBER
CG YACTAB ERR0R2 ,ENTRY YTAC<YACTAB
CG YACTAB ERR0R9 ,SKIPPED ACCUM IS<= XWAC1+YCGNAC-1
USED SUBROUTINES:GENFIX
;
PROC
CGG10: LI X1,^D10
GOTO CGG
CGG9: LI X1,9
GOTO CGG
CGG8: LI X1,8
GOTO CGG
CGG7: LI X1,7
GOTO CGG
CGG6: LI X1,6
GOTO CGG
CGG5: LI X1,5
GOTO CGG
CGG4: LI X1,4
GOTO CGG
CGG3: LI X1,3
GOTO CGG
CGG2: LI X1,2
GOTO CGG
CGG1: LI X1,1
CGG: ;COMMON ENTRY X1 CONTAINS NUMBER OF ACCUMULATORS
; TO BE RESERVED
ADD X1,YTAC
ASSERT <
IF L X0,YTAC
STACK X1
SUBI X1,YACTAB
PUSHJ XPDP,GATAB(X1)
UNSTK X1
CAIL X0,YACTAB
GOTO FALSE
THEN
RFAIL (CG YACTAB ERR0R2)
GATAB: REPEAT 30,<POPJ XPDP,0
>
FI
>
IF CAILE X1,YACTAP
GOTO FALSE
THEN WHILE
CAMN X1,YTAC
GOTO FALSE
DO
HRRZS ,-1(X1) ;ZERO TO POINTER FIELD
SOJ X1,
OD
HRLM XCUR,@YTAC ;SET POINTER IN FIRST RESERVED ENTRY
RETURN ;RETURN IF NO PSEUDOREGISTERS INVOLVED
FI
;REAL ACCUMULATORS ARE NOT AVAILABLE
SUB X1,YTAC
ST X1,YCGNAC ;SAVE NUMBER OF ACCUMULATORS TO BE RESERVED
STACK XCG1
STACK XCG2 ;SAVE REGISTERS
L X1,YTAC
IF CAILE X1,YACTAP ;[14] CAILE INSTEAD OF CAIL TO GET THE
; WARNING ALSO WHEN CGG1 IS CALLED TO
; GET THE FIRST PSEUDO AC.
GOTO FALSE
THEN
WARNING 1,INTERMEDIATE QUANTITIES SAVED
FI
LF (XCG2) YACTAF(X1,-1) ;FETCH LAST RESERVED ACCUMULATOR
;SKIP UNTIL OUT IF SKIP NECESSARY
WHILE AOJ XCG2, ;FIND FIRST TO BE RESERVED
CAIN XCG2,XWACL+1
LI XCG2,XWAC1 ;FIRST AFTER LAST
ADD XCG2,YCGNAC ;FIND LAST+1 ACCUMULATOR TO BE RESERVED
CAIG XCG2,XWACL+1
GOTO FALSE ;CONSECUTIVE ACCUMULATORS POSSIBLE WITHOUT SKIP
DO
;FIND NEXT XWAC1
SETON SCGSKP
SF (X1) YACTPF(X1) ;MARK THAT THIS ENTRY HAS BEEN SKIPPED
;POINTER FIELD POINTS AT ITSELF
CAIL X1,YACTAE-QNAC
GOTO L1 ;YACTAB OVERFLOW
LF (X0) YACTAF(X1)
SF (X0) YACTAF(X1,QNAC) ;INDICATE THAT REGISTER IS FREE AND SKIPPED
ASSERT <
IF SUB X0,YCGNAC
CAILE X0,XWAC1-1
GOTO FALSE
THEN ;FIRST SKIPPED IS LESS THAN OR EQUAL XWAC1+YCGNAC-1
RFAIL (CG YACTAB ERR0R9)
FI
>
AOJ X1, ;NEXT ENTRY
SUB XCG2,YCGNAC ;RESTORE ACCUMULATOR NUMBER AND HANDLE
;NEXT ENTRY
; LOOP STOP WHEN LAST+1 ACCUMULATOR IS REACHED
OD
SUB XCG2,YCGNAC ;FIND FIRST ACCUMULATOR TO BE RESERVED
ST X1,YTAC ;RETURN VALUE OF YTAC FOUND
;???/SA CAIN X1,YACTAP
L XCG1,YCGXAC ;FETCH PSEUDOREGISTER STACK POINTER
; WITH FIXUP INDEX IN RIGHT HALF
;GENERATE CODE TO STORE RESERVED ACCUMULATORS IN PSEUDOREGISTER STACK
;AND UPDATE YACTAB ENTRIES
LOOP CAIL X1,YACTAE
GOTO L1 ;FATAL ERROR IF YACTAB OVERFLOW
LF (X0) YACTAF(X1)
IF CAMN X0,XCG2
GOTO FALSE ;REGISTER ALREADY FREE
THEN ;ACCUMULATOR MUST BE SAVED
STACK X1
ASSERT < IF CAIN X0,777777
GOTO FALSE
THEN RFAIL (CG YACTAB ERROR 1)
FI
>
ASSERT <
SF (XCG1) YACTAF(X1,-QNAC) ;STORE PSEUDOREGISTER
; FIXUP INDEX
>
;GENERATE SAVE ACCUMULATOR IN PSEUDOREGISTER STACK
KA10WARNING
OP (DMOVEM) ;ASSUME DMOVEM INSTRUCTION
LF (X1) YACTAF(X1,+1)
CAIE X1,777777
OP (MOVEM) ;ASSUME MOVEM IF NEXT ENTRY IS ALREADY FREE
IF L X1,YCGNAC
TRNN X1,1
GOTO FALSE ;YCGNAC IS EVEN
THEN
CAME XCG1,YCGXAC
GOTO L3 ;NO GENERATION OF CODE IF
;YCGNAC IS ODD AND NOT FIRST,
;DMOVEM IS USED
KA10WARNING
OP (MOVEM) ;GENERATE MOVEM
FI
DPB XCG2,[POINT 4,X0,12]
;STORE ACCUMULATOR IN INSTRUCTION
HRR X0,XCG1 ;STORE PSEUDOREGISTER
; FIXUP INDEX IN INSTRUCTION
GENFIX
L3(): UNSTK X1 ;RESTORE TO CURRENT ENTRY IN YACTAB
AOBJP XCG1,L1 ;FATAL ERROR IF PSEUDOREGISTER OVERFLOW
FI
AS
ST XCG2,(X1) ;0,ACCUMULATOR NUMBER TO ENTRY
AOJ XCG2, ;NEXT ACCUMULATOR
SOSE ,YCGNAC ;SKIP IF ALL ACCUMULATORS RESERVED
AOJA X1,TRUE ;HANDLE NEXT ENTRY
ST XCG1,YCGXAC
;SAVE NEW PSEUDOREGISTER POINTER
UNSTK XCG2
UNSTK XCG1
HRLZ @YTAC
LSH 5 ; UPDATE TOP AC IN ACFIELD
ST YCGACT
HRLM XCUR,@YTAC ;SET POINTER IN FIRST RESERVED ENTRY
RETURN ;RETURN IF PSEUDOREGISTERS INVOLVED
SA
L1(): ERROR2 35,EXPRESSION TOO COMPLICATED
UNSTK XCG2
UNSTK XCG1
BRANCH CGPU ; PURGE CURRENT EXPRESSION AND CONTINUE
EPROC
SUBTTL CGR,RELEASE ACCUMULATORS ROUTINE
COMMENT;
PURPOSE:TO RELEASE ACCUMULATORS THAT IS TO GENERATE CODE IF RESERVED
ACCUMULATORS ARE STORED IN PSEUDOREGISTER STACK
ENTRIES:CGR,CGR1,....,CG7
ALL ENTRY POINTS ARE THE SAME,THE DIFFERENT NAMES ARE KEPT TO
FACILITATE MATCHING WITH THE GET ACCUMULATORS ROUTINE
INPUT ARGUMENTS:YTAC POINTS AT LAST OR LAST-1 YACTAB ENTRY THAT SHOULD
STILL BE RESERVED.
WHETHER THE RESULT OCCUPIES ONE OR TWO ACCUMULATORS IS
ESTABLISHED VIA THE ZNO-RECORD POINTER IN YACTPF.
NORMAL EXIT: RETURN
ERROR EXIT: NONE
OUTPUT ARGUMENTS:YTAC UNCHANGED UNLESS SOME ENTRIES WERE SKIPPED AT
RESERVATION TIME.
IF SO YTAC POINTS TO FIRST OF THESE AND THE POINTER FIELDS
ARE UPDATED.CODE IS GENERATED TO MOVE XWAC1 (AND XWAC2) TO THE
NEW ACCUMULATORS.
CALL FORMAT: EXEC CGR,EXEC CGR1,....EXEC CGR7
ERRORS GENERATED:RFAIL MESSAGES CG YACTAB ERR0R2 ,YTAC<YACTAB
CG YACTAB ERR0R4 ,TOO MANY ACCUMULATORS RELEASED
CG YACTAB ERR0R5 ,PSEUDOREGISTER ERROR IN ADDRESS
CG YACTAB ERR0R6 ,SKIPPED WAS NOT PERFORMED
CG YACTAB ERR0R7 ,YTAC POINTER OUT OF TABLE
CG YACTAB ERR0R8 ,LONG ARGUMENT NEEDS TWO ACCUMULATORS
USED SUBROUTINES:GENFIX,GENABS
;
PROC
CGR7:
CGR6:
CGR5:
CGR4:
CGR3:
CGR2:
CGR1:
CGR: ; COMMON ENTRY
; RELEASE ALL ENTRIES FOLLOWING YTAC ENTRY OR
; YTAC ENTRY +1 IF LONG ARGUMENT
L X1,YTAC
ASSERT <
IF CAIL X1,YACTAB
GOTO FALSE
THEN RFAIL (CG YACTAB ERR0R2)
FI
>
CAIGE X1,YACTAP
RETURN ;RETURN WHEN NO PSEUDOREGISTERS INVOLVED
;RESTORE OF ACCUMULATORS NECESSARY
; RESET YTAC TO VALUE AFTER CORRESPONDING GETAC
HRRZ X1,YLINK
IFOFF SCGSKP
SKIPA X1,2(X1) ; YTAC STACK LOCATION
LI X1,YACTAP
ST X1,YTAC ; RESET YTAC
STACK XCG1
STACK XCG2
L XCG1,YCGXAC ;FETCH PSEUDOREGISTER STACK POINTER
; WITH FIXUP INDEX IN RIGHT HALF
L XCG2,X1 ;CURRENT ENTRY IN YACTAB
SETZM ,YCGNAC ;0 INDICATES ONE ACCUMULATOR LEFT AFTER RELEASE
L X1,XCUR
IFLONG
AOS ,YCGNAC ;1 INDICATES TWO ACCUMULATORS LEFT AFTER RELEASE
;FIND OUT IF SKIP WAS PERFORMED AT RESERVATION TIME
IF LF (X0) YACTAF(XCG2) ;FETCH ACCUMULATOR NUMBER
CAIE X0,XWAC1
GOTO FALSE ;NOT FIRST AND SKIP NOT INVOLVED
IFOFF SCGSKP
;WITH SKIP THAT HAS BEEN DONE
GOTO FALSE ;NOT LAST RELEASE
ASSERT <
IF LF (X0) YACTPF(XCG2,-1)
AOJ X0,
CAMN X0,XCG2
GOTO FALSE
THEN RFAIL (CG YACTAB ERR0R6)
FI
>
THEN ; PERFORM
LOOP SOJ XCG2, ;PREVIOUS ENTRY
SETZ X0,
SF (X0) YACTPF(XCG2) ;REMOVE POINTER
LI X0,777777
SF (X0) YACTAF(XCG2,QNAC) ;INDICATE THAT THIS
;ACCUMULATOR IS NO LONGER SKIPPED
LF (X0) YACTPF(XCG2,-1)
AOJ X0,
AS CAMN X0,XCG2
GOTO TRUE ;CONTINUE IF NOT FIRST OF SKIPPED ENTRIES
SA
;FIRST ENTRY FOUND
EXCH XCG2,YTAC ;AT EXIT YTAC MUST POINT TO FIRST OF SKIPPED ENTRIES
LF (X0) YACTPF(XCG2) ;FETCH POINTER FIELD OF XWAC1 ENTRY
HRLM X0,@YTAC ;TO NEW RESULT ENTRY
L X0,@YTAC ;FETCH ACCUMULATOR NUMBER
OP (MOVEM XWAC1,)
IF SKIPN ,YCGNAC
GOTO FALSE ;ONLY ONE ACCUMULATOR LEFT IN RESULT
THEN L X1,YTAC
ASSERT <
IF LF (X0) YACTAF(X1)
CAIE X0,XWACL
GOTO FALSE
THEN RFAIL (CG YACTAB ERR0R8)
FI
>
LF (X0) YACTPF(XCG2,1) ;FETCH POINTER FIELD OF XWAC2 ENTRY
SF (X0) YACTPF(X1,1) ;TO NEW RESULT ENTRY
L X0,@YTAC
KA10WARNING
OP (DMOVEM XWAC1,) ;GENERATE DMOVEM XWAC1,
SOJ XCG2,
FI
GENABS ;GENERATE MOVEM XWAC1,CURRENT ACCUMULATOR
;OR DMOVEM XWAC1,CURRENT ACCUMULATOR
SOJ XCG2, ;XWACL ENTRY
FI ;RESTORE ALL ACCUMULATORS STARTING TO TEST ENTRY XCG2+1
ADD XCG2,YCGNAC ;SKIP ONE MORE ACCUMULATOR IF LONG
SETZM ,YCGNAC
WHILE CAIL XCG2,YACTAE-1
GOTO FALSE ;END OF TABLE REACHED
LF (X0) YACTAF(XCG2,1)
CAIN X0,777777
GOTO FALSE ;ACCUMULATOR NOT RESERVED
LF (X0) YACTPF(XCG2,1-QNAC)
ADDI X0,QNAC-1
CAMN X0,XCG2
GOTO FALSE ;ENTRY SKIPPED,
; DO NOT RELEASE ACCUMULATOR
DO
AOS ,YCGNAC ;UPDATE COUNTER
AOJ XCG2, ;NEXT ENTRY
OD
ASSERT <
IF CAIGE XCG2,YACTAE
GOTO FALSE
THEN ;POINTER OUTOF TABLE
RFAIL (CG YACTAB ERR0R7)
FI
>
;YCGNAC =NUMBER OF ENTRIES TO RELEASE
;XCG2 POINTS AT LAST ENTRY TO RELEASE
WHILE
SKIPG ,YCGNAC
GOTO FALSE ;EXIT IF LAST ACCUMULATOR RESTORED
DO
IF L X0,YCGNAC
TRNN X0,1
GOTO FALSE ;YCGNAC EVEN ,DO NOT GENERATE
THEN ;YCGNAC ODD ,ALWAYS GENERATE
KA10WARNING
OP (DMOVE) ;ASSUME DMOVE
CAMN XCG1,YCGXAC ;
OP (MOVE) ;GENERATE MOVE IF FIRST RESTORE
;INSTRUCTION
HRR X0,XCG1 ;INSERT PSEUDOREGISTER FIXUP INDEX
SOJ X0, ;CORRECT FIXUP INDEX
LF (X1) YACTAF(XCG2) ;FETCH ACCUMULATOR NUMBER
DPB X1,[POINT 4,X0,12] ;AND MOVE TO INSTRUCTION
GENFIX ;GENERATE RESTORE INSTRUCTION
FI
SUB XCG1,[XWD 1,1] ;UPDATE STACK POINTER
LF (X1) YACTAF(XCG2) ;SAVE REGISTER NUMBER
LI X0,777777
SF (X0) YACTAF(XCG2) ;SET ENTRY TO 777777
LF (X0) YACTAF(XCG2,-QNAC)
SF (X1) YACTAF(XCG2,-QNAC) ;RESTORE ENTRY
ASSERT <
IF HRRZ X1,XCG1
CAMN X0,X1
GOTO FALSE
THEN ;ACCUMULATORS ARE NOT OK
RFAIL (CG YACTAB ERR0R5)
FI
>
;CONTINUE WITH PREVIOUS ENTRY
SOS ,YCGNAC
SOJ XCG2,
OD
UNSTK XCG2
ST XCG1,YCGXAC ;UPDATE PSEUDOREGISTER POINTER
ASSERT <
IF HLRZ X0,XCG1
CAIL X0,-QNXAC-1
GOTO FALSE
;TOO MANY ACCUMULATORS RELEASED
THEN RFAIL (CG YACTAB ERROR 4)
FI
>
UNSTK XCG1
RETURN ;RETURN WHEN PSEUDOREGISTERS INVOLVED
EPROC
SUBTTL CGPD-PUSH DOWN YACTAB IN DECLARATION STACK
COMMENT;
PURPOSE: PUSH DOWN AC DESCRIPTION AND INITIALIZE A NEW ONE
ENTRY: CGPD
;
SSIZE=QNXAC
TSIZE=SSIZE+6
CGPD: PROC
SAVE<X2,X3>
L X2,YDCSTP
LI X3,TSIZE(X2)
CAML X3,YDCSTO
EXEC M2CO
ST X3,YDCSTP
MOVSI YACTAB
ADD X2
BLT SSIZE(X2)
L YTAC
ST SSIZE+1(X2)
L YCGXAC
ST SSIZE+2(X2)
L YCGACT
ST SSIZE+5(X2)
EXEC CGIACT ;[14]
RETURN
EPROC
SUBTTL CGIACT INITIATE YACTAB AND YTAC
COMMENT;
PURPOSE: TO INITIATE THE DESCRIPTION IN YACTAB
AND TO SET YTAC TO POINT TO YACTAB
SET YCGXAC TO [-QNAC-1,,YXA1]
ENTRY: CGIACT
CALL FORMAT: EXEC CGIACT
;
CGIACT: PROC
LI X2,YACTAB
ST X2,YTAC
LI XWAC1
LI X1,-1
WHILE CAME (X2)
CAIL X2,YACTAB+QNAC
GOTO FALSE
DO
ST (X2)
ST X1,QNAC(X2)
ADDI 1
ADDI X2,1
OD
L X0,[-QNAC-1,,YXA1]
ST X0,YCGXAC
RETURN
EPROC
SUBTTL CGRA-RESTORE YACTAB DESCRIPTION
CGRA: PROC
SAVE <X2,X3>
L X2,YDCSTP
SUBI X2,TSIZE
ST X2,YDCSTP
LI YACTAB
HRLI (X2)
BLT YACTAE-1
L SSIZE+1(X2)
ST YTAC
L SSIZE+2(X2)
ST YCGXAC
L SSIZE+3(X2)
ST YCGNAC
L SSIZE+4(X2)
ST YCGSK
L SSIZE+5(X2)
ST YCGACT
RETURN
EPROC
END