Register allocation system using recursive queuing during source code compilation4435753Abstract A computing system operates upon register requests serially referenced in an instruction stream to assign quantities to registers selected from unlike subsets or classes of registers. During compilation, the register usage of quantities serially scanned in the instruction stream is determined. Upon determining during the serial scan the need for a new quantity in a register, the quantity is logged to a queue, or pending set, of load point quantities and assigned a complete set count indicative of the number of registers the quantity requires, plus the number of permanent registers, plus the number of restricted registers, plus the number of registers in register classes for which it is not a candidate. Upon determining during the serial scan the reuse of a quantity in a register (already assigned or pending assignment), the complete set counts of quantities in the pending set which are candidates for a same register class as the reuse quantity are incremented. When the complete set count for a quantity equals the total number of available registers, a complete set is detected and the quantity is assigned to the remaining register. The register assignment procedure is recursively executed to generate load instructions for addressability register manipulations conditionally for base address constants not already in a register. Claims What is claimed is: Description BACKGROUND OF THE INVENTION
TABLE 1
__________________________________________________________________________
Pass 1 Procedure
__________________________________________________________________________
100
PASS 1 PROCEDURE 00003
102
INITIALIZE elements-being-managed list to the number and
00005
of registers being managed 00006
* note that this is where decisions are made on assignment
*f
00008
* permanent registers. * 00009
* * 00010
* for convenience the registers are arranged as even
*ollowed
00011
* by odd of register pairs. * 00012
103
INITIALIZE pointers and counters 00014
104
READ the intermediate text 00016
105
DO WHILE not end of file 00018
106
CASE (text type) 00020
111
WHEN (text is a non-branch instruction)
00022
112
CALL Process-Instruction 00023
113
WHEN (text is a branch instruction)
00025
114
CALL Process-Branch 00026
115
WHEN (text is an Assembler command)
00028
116
CALL Assembler-Commands 00029
117
WHEN (text is a label) 00031
118
CALL Process-Label 00032
119
WHEN OTHER 00034
ABORT * invalid instruction type *
00035
120
END CASE 00037
104
READ the intermediate text 00039
105
END 00041
107
SET complete-set-point to past end of queue
00043
108
CALL Register-Assigner (complete-set-point)
00044
__________________________________________________________________________
In FIG. 9 and Table 2 is set forth in greater detail the operation of the pass 1 process instruction step 112 of FIG. 8.
TABLE 2
__________________________________________________________________________
Process Instruction Procedure
__________________________________________________________________________
121
Process-Instruction PROCEDURE 00046
122
SAVE the instruction in storage 00048
SET the instruction-counter up by 1
00049
123
DO for each operand 00051
124
IF the operand is a register 00053
THEN 00054
125
CALL Register-Manager (Register Operand)
00055
OTHERWISE 00056
126
COMPUTE its basing-register-value 00057
MARK the request "READ ONLY" and "ADDRESSING"
00058
CALL Register-Manager (basing-register-value)
00059
FI 00060
127
IF the Request was "NEW" 00062
THEN 00063
128
DO for all prior requests in this instruction
00064
CALL Register-Manager (prior request)
00065
* this causes prior requests to be in the complete set
* 00066
* of the new reference and assures concurrency
* 00067
END 00068
FI 00069
129
END 00071
130
END Process-Instruction 00073
__________________________________________________________________________
In step 122, the instruction (FIG. 5) from input stream 60 is added to temporary storage 80, and instruction counter 26 incremented to point to it, at location 82. Each operand 454, 455, etc. of the instruction is then processed (step 123) through steps 124-129. If the operand request is a register, in step 125 register manager 65 is called via a register request 50, with the operand as the request argument. If the input stream 60 instruction operand is a storage (not register) operand, then the basing register value is computed and register manager 65 is called in step 126 with the basing register name as the argument of request 50. When an instruction includes a plurality of register assignment requests, and this request is for a new register, then in steps 127, 128 register manager 65 is called to force prior requests within the same instruction to be included within the complete set of this request. Assume, by way of example, an instruction requiring that first A and then B be in registers. In step 127, if B is a request for a new quantity, then step 128 follows. If B is not new, then B is a reuse, and B is in A's complete set. A, then, was either a new or reuse request. If A was new, it is pending and B is a member of its complete set. If A was reused, then A is either pending or in a register. If A is pending, then B is a member of its complete set. If A is in a register, then both A and B are members of the complete set of some pending element. For an element in a register, there is no complete set--also, an element will not be displaced from a register until the current load point 25 is beyond the latest use 46. Thus, by steps 127, 128, it is assured that all register requests in a single instruction will either be in registers or members of each others complete sets. In FIG. 10 and Table 3 is set forth the process branch of step 114. In step 132 it is determined that the target of the branch instruction is to a favorable label.
TABLE 3
______________________________________
Process Branch
______________________________________
131 Process-Branch PROCEDURE 00075
132 IF the target of the branch is favorable
00077
133 THEN 00078
ENQUEUE a request to save the register state
00079
FI 00080
134 CALL Process-Instruction (with branch instruction)
00082
135 END Process-Branch 00084
______________________________________
A favorable label is one which is branched to only from instructions appearing earlier in the code stream (which is determined from an earlier pass through the stream). If a label is favorable ("well behaved") then the ordered intersection of the totality of all possible register states can be calculated, and "inherited" at that label to extend the algorithm beyond basic blocks. The request is enqueued so that it will be processed after currently pending assignments have been processed (only then is the register state at the branch known). On the other hand, if the label is not "well behaved" then certain possible states have not been seen and recorded and the ordered intersection of the totality of register states cannot be calculated, therefore the state of all registers must be made free and inheritance cannot occur. In step 134, process instruction (FIG. 9) is called. In FIG. 11 and Table 4 is set forth the process assembler command of step 115, FIG. 8.
TABLE 4
__________________________________________________________________________
Assembler Command
__________________________________________________________________________
136 Assembler-Command PROCEDURE 00086
CASE (type of command) 00088
137 WHEN (command is to reserve an actual register)
00090
138 CALL Register-Manager (Register to reserve)
00091
139 WHEN (command is to release an actual register)
00093
140 CALL Register-Manager 00094
(Register to be released marked "LAST USE")
00095
141 SAVE command in storage 00096
SET Instruction-counter up by 1
00097
142 WHEN (command marks last use of a symbolic register)
00099
143 CALL Register-Manager 00100
(Symbolic Register marked "LAST USE")
00101
144 SAVE command in storage 00102
SET Instruction-counter up by 1
00103
145 WHEN (command equates symbolic register to
00105
one of a register pair symbolic register)
00106
146 ENQUEUE a request to release the other of the pair
00107
147 ENQUEUE a request for the new symbolic register
00108
148 WHEN (command equates an optimization register to
00110
a symbolic register) 00111
149 ENQUEUE a request to equate the symbolic register
00112
150 ENQUEUE a request for the new optimization register
00113
END CASE 00115
END Assembler-Command 00117
__________________________________________________________________________
In steps 137, 138, if the assembler command is to reserve an actual register, register manager 65 is called to increase by one the number of restricted registers. In steps 139-141, register manager 65 is called to release an actual register, decrementing by one the count of restricted registers and marking field 46 with latest use. The command is stored in storage 80, and instruction counter 26 incremented to point to the new location 82, for subsequent use by pass 2 process 69--which must know when to remove the usage of the register from elements being managed list 40 by setting field 44 to free status, and field 42 to null. Steps 142-144 process a command marking the last use of a symbolic register, steps 145-147 process a command equating a symbolic register to one of a register pair symbolic register, and steps 148-150 a command equating an optimization register to a symbolic register. Enqueuing steps 146, 147, 149, 150 add elements to queue 92, which is processed first-in-first-out (FIFO). Steps 139-144 handle the special situation where the code generator (input to input stream 60) could not mark the last use in the instruction. In FIGS. 12 and 13 and Table 5 is set forth the process label procedure of step 118 (FIG. 8).
TABLE 5
__________________________________________________________________________
Process Label
__________________________________________________________________________
151 Process-Label PROCEDURE 00119
152 ENQUEUE a request to backstore optimization registers
00121
153 SET complete-set-point to past the end of the queue
00122
154 CALL Register-Assigner (complete-set-point)
00123
155 IF the label is referenced 00124
158 THEN 00125
IF the label has a saved register state
00126
THEN 00127
159 DC for each register 00128
160 IF the register does not have a counterpart in the
00129
saved state 00130
163 THEN 00131
FREE the register 00132
OTHERWISE 00133
161 IF Dropin is possible 00134
THEN 00135
164 IF the current and saved quantity are not the same
00136
165 THEN 00137
FREE the register 00138
162 FI 00139
OTHERWISE 00140
SET the value of the register to the saved state
00141
FI 00142
FI 00143
167 END 00144
FI 00145
FI 00146
168 END Process-Label 00147
109 END PASS1 00149
__________________________________________________________________________
When a favorable label is encountered in input stream 60, a request is enqueued in queue 92 by step 152 to backstore optimization registers (which will be done during register assigner 66 processing) to assure that, regardless of the path by which the label is reached, copies of optimization registers exist in backstore. In order to resolve all pending requests, complete set pointer 24 is set to the end of pending queue 92 in step 153, and register assigner 66 called in step 154. When the label is referenced, steps 155, 156 (FIG. 12) and FIG. 13 reset the register state. Each register which has no counterpart in the saved state (in backstore 93), as a result of the processing of enqueued requests to save the register by register assigner 66, has its register state field 44 set to the free state. However, if a counterpart register exists in the saved state (in backstore 93) and if drop in is possible (that is, the label can be reached without a prior branch; that is, from the previous instruction in the instruction stream), steps 164, 165 set free registers where the saved contents are not the same as the current register. If drop in is not possible, the register is set to the saved state value in step 162. Step 109 (Table 5) ends the pass 1 procedure, which begins at step 100 (Table 1). Register Manager In FIGS. 14-21 is set forth the steps executed by register manager 65, with Tables 6-8 containing the corresponding psuedo code description.
TABLE 6
__________________________________________________________________________
Register Manager - Part 1
__________________________________________________________________________
A.2.2 REGISTER-MANAGER SMEZSH3
Register-Manager Procedure with argument (register-request)
00002
170
SFT complete-set-point to queue-elements-start
00004
SET found-register to "NO" 00005
HASH the name of the register request
00007
171
SEARCH elements-being-managed 00008
beginning with names-search-vector of hash
00009
along the hash chain 00010
172
WHEN name of element-being-managed is equal to
00011
name of register-request 00012
173
SET basing pointer for element to current element-being-managed
00013
174
IF the quantity is an absolute register AND
00014
its prior occurence is marked "LAST USE"
00015
THEN * this is a new restriction of the register *
00016
* and it will be put in the queue *
00017
OTHERWISE 00018
175
IF register quantity is in the backstore
00019
176
THEN 00020
SET found-register to "IN BACKSTORE"
00021
178
OTHERWISE 00022
SET found-register to "IN REGISTER OR PENDING ASSIGNMENT"
00023
FI 00024
FI 00025
179
IF this request causes the quantity to become active
00027
THEN 00028
SET its status to "ACTIVE" 00029
FI 00030
IF this request is marked as the last use of the quantity
00032
THEN 00033
SET its status to "LAST USE" 00034
FI 00035
177
END SEARCH 00036
__________________________________________________________________________
Referring to FIGS. 14-21 in connection with Tables 6-8, register manager 65, inter alia, enqueues new requests in queue 92, together with instructions on the action to be taken upon dequeue. It also tests for complete sets, and when found, calls register assigner 66. When called, such as from pass 1 processor 64 or by recursion from itself, register manager 65 initializes complete set printer 24 in step 170 to point to the beginning of the pending register requests queue 92, and computes the hash value of the symbolic register name. With that hash value, in steps 171, 172, 177, the names-search-vector 30 is searched to find the pointer in vector 30 to the matching element in elements-being-managed list 40. In steps 174-179, the location of the found register is identified and logged.
TABLE 7
__________________________________________________________________________
Register Manager - Part 2
__________________________________________________________________________
181
IF found-register is "IN REGISTER OR PENDING ASSIGNMENT"
00038
182
THEN 00039
188
IF the register is not permanently assigned
00040
THEN 00041
189
IF this request is for an absolute register
00042
THEN 00043
190
IF it is marked last use 00044
191
SET the number of restricted registers down by 1
00045
FI 00046
193
IF the register is 0 00047
THEN 00048
195
SET register-0-restricted to 0 00049
FI 00050
192
OTHERWISE 00051
* this is a reuse of the register and the complete set
00052
* count of all quantities pending must be updated *
00053
197
IF the element is on the queue 00054
THEN 00055
198
SET start-point to the next element in the queue
00056
OTHERWISE * It is in a register * 00057
199
SET start-point to the queue-elements-start
00058
200
IF the register is register 0 00059
THEN 00060
201
SET register-0-flag to "YES" 00061
FI 00062
FI 00063
202
IF the current request is for a register pair
00065
THEN 00066
203
SET register-size to 2 00067
OTHERWISE 00068
204
SET register-size to 1 00069
FI 00070
213
DC from start-point to queue-elements-end using pointer
00072
214
IF pointer .fwdarw. first-use-point of element is greater than
00074
last-used-point of the element being reused
00075
THEN * this reuse may be a member of the pending *
00076
* element's complete SET * 00077
215
IF pointer .fwdarw. complete-set-count + register-size
00078
is greater than the number of registers
00079
THEN 00080
216
SET complete-set-point to the successor of this element
00081
CALL Register-Assigner 00082
* restart register management * 00083
217
CALL Register-Manager (Register Request)
00084
218
RETURN 00085
FI 00086
219
IF pointer .fwdarw. element cannot use register 0 AND
00087
the quantity being reused is register 0
00088
THEN 00089
220
SET the pointer .fwdarw. complete-set-count of the element
00090
up by register-size - 1 00091
OTHERWISE 00092
221
SET the pointer .fwdarw. complete-set-count of the element
00093
up by register-size 00094
FI 00095
222
IF the complete-set-count of this element is equal to
00097
number of registers 00098
THEN * we have discovered a resolution point *
00099
223
SET complete-set-point to the successor of this element
00100
FI 00101
FI 00103
224
END 00104
208
IF the complete-set-point is not queue-elements-start
00106
THEN 00107
209
CALL Registet-Assigner (complete-set-point)
00108
FI 00109
FI 00111
194
SET the last-used-point of the quantity being reused
00113
to the instruction-counter 00114
FI 00115
__________________________________________________________________________
Referring to FIG. 15, in connection with Tables 7 and 8, in steps 181, 182, if the quantity is in a register or pending assignment to a register, as determined from its elements-being-managed record (FIG. 2), then it is processed as a reused quantity (see FIGS. 16-18). In steps 183, 184, if the quantity is new, it is processed as a new quantity (see FIG. 19). In step 185, as the quantity is neither in a register, pending, or new, it must be in the backstore--consequently, it is retrieved from backstore. In step 186, new elements and backstored elements ae enqueued into 92 for register assignment--as is described in FIGS. 20 and 21. In steps 188-195, if the reused quantity in a register (found in step 181) is permanently assigned, then register manager 65 ends. Otherwise, and if the register is not an absolute register, then in steps 192 and 194 the complete set of the reused register is computed (see FIGS. 17 and 18), and the latest use field 46 set to the instruction counter 26 value. In steps 189-190, 191, 193, 195, if the register is an absolute register (a quantity assigned to an actual register), the request is processed, as appropriate, according to its last use status and register .0. usage. In FIG. 17 is set forth in greater detail the compute complete sets step 192 of FIG. 16--with FIG. 18 further describing step 205 of FIG. 17. When the quantity of register request 50 is found to be neither permanently assigned, (step 188) nor assigned an absolute register (step 189), then this is a reuse of the register, and the complete set count of certain quantities pending in queue 92 must be updated. If the register request 50 is for an element pending on queue 92, then in step 198 start pointer 21 is set to the next element in queue 92, and processing branches to step 202. Otherwise, in steps 199-201, start pointer 21 is set to the first element in queue 92, and register .0. flag set if required. In steps 202-204, the request size (also referred to as width) is set to the number of registers in (or consumed by) the request, and in step 205 the complete sets are computed (see FIG. 18, below). In step 207, latest use field 46 of the reused quantity is set to the value in instruction counter 26. If a complete set has been found, then register assigner 66 is called in step 209, which will process queue 92 to assign registers to quantities up through the element pointed to by pointer 24. In FIG. 18 is set forth the steps for computing complete sets (step 205, FIG. 17). For each pending element in queue 92, from start pointer 21 through end pointer 22, it is determined if the reused quantity has been counted in the pending quantities complete set. The reused quantity has been counted if its latest use prior to this reuse (field 46 of the reused element being managed) is after (greater than) the first use of the pending element (field 45 of the pending element being managed). If not, in steps 215, 219-221 the complete set count in field 49 is increased and in step 222 the existence of a complete set is tested. If there is a complete set, in step 223 complete set pointer 24 is set to the next element in queue 92. If in step 215 it is determined that this reuse quantity would cause the complete set for the element to be exceeded, in step 216, register assigner 66 is called to assign this pending element in queue 92 to a register, and in step 217 processing returns to register manager 65. In FIG. 19, the register manager 65 process steps for processing a new element (step 184 of FIG. 15) are set forth. If the quantity of register request 50 is of a type that requires a register load instruction, then register manager 65 must be recursively called to force a basing register for the quantity being loaded to be assigned. In step 228 the quantity's base address is computed. If the base address is not yet directly addressable by register 12 or 13, then in step 230 register manager 65 is recursively called, with the computed (still symbolic) base address from step 228 as the argument of register request 50. In step 232 the LOAD command (see step 268) is entered into queue 92 and the instruction counter 26 incremented; and in step 231 the request is added to names search vector 30. In step 229, ASSIGN queue commands (see step 266) are given quantities which need not be loaded. In FIGS. 20-21, enqueue step 186 of FIG. 15 is described in greater detail. In step 186, request for a new quantity in a register is enqueued for register assignment. This is done by, in steps 235-242, setting register status 44 to "in queue", setting first use point 45 to the value of instruction counter 27, and complete set count in field 49. The register request element 40 is then added to queue 92 in step 245. If the element is a LOAD or BACKSTORE load command, instruction counter 26 is incremented by one in step 247. In step 248, latest-use-point field 46 is set equal to instruction counter 26. If the request is for an absolute register that is not marked for last use, then the count of restricted registers is incremented by one, and one is added to the complete set count field 49 as a safety precaution--so that an address quantity in this absolute register will not be moved into register .0.. In step 253, if the request is for absolute register .0., and it is not marked for last use, then register .0. is marked restricted. REGISTER ASSIGNER The operational steps executed by the computing system under control of register assigner 66 are set forth in FIGS. 22-35 , and in Tables 9-12. Referring first to FIG. 22 in connection with Table 9, the register assigner, when called, services pending elements 40 in queue 92 beginning (at step 256) with that element anchored to start pointer 21 (referred to as "queue-elements-start") and ending with that element anchored to complete set pointer 24 (referred to as "resolve-until-we-get-to-here"). In step 257, the request element in queue 92 pointed to by start pointer 21 is dequeued, and the current load pointer counter set to point in storage 83 to the first use of the element as determined from field 45. If pass 2 counter 27 has not caught up to current load point counter 25, then in step 259 pass 2 processor 69 is called to process instructions prior to the current instruction. In step 260, the dequeued request is processed (FIG. 23) to assign symbolic registers to actual registers. This is repeated until the complete set point 24 is reached in queue 92. If at that point, queue 92 is empty, in step 263 pass 2 is called to process the remaining instructions in storage 80. In FIG. 23, detail with respect to step 260 is provided. In steps 266, 268, 270, 272, 274 and 276 the queue command 47 is tested to determine the action to be taken, with steps 267, 269, 271, 273, 275, 277 carrying out the required action--as is more fully explained in connection with FIGS. 24-35.
TABLE 9
__________________________________________________________________________
Register Assigner
__________________________________________________________________________
186 Register-Assigner Procedure 00001
with argument (resolve-until-we-get-to-here)
00002
256 DO current-pointer begins with queue-elements-start
00004
process successive requests in the pending request queue
00005
while current-pointer is not resolve-until-we-get-to-here
00006
257 SET current-load-point to first-use-point of the pending
00008nt
DEQUEUE the pending element 00010
258 If pass2-instruction-counter is less than current-load-point
00012
THEN 00013
259 CALL Pass2 (current-load-point)
00014
FI 00015
CASE (Queue-command) 00017
266 WHEN ("ASSIGN") 00019
267 CALL Get-a-Register 00020
268 WHEN ("ICAD", "BACKSTORE LOAD")
00022
280 COMPUTE its basing-register-value
00023
281 IF the basing-register-value is not an absolute register
00024
THEN 00025
282 CALL Register-Resolver (basing-register-value)
00026
FI 00027
283 CONSTRUCT a load instruction 00028
284 CALL Get-a-Register 00029
285 INSERT the register in the instruction
00030
286 WRITE the instruction 00031
270 WHEN (backstore optimization registers)
00033
289 DO for each reister 00034
290-1
IF the register contains an optimization register AND
00035
the register has not been backstored
00036
THEN 00037
292 CALL Backstore 00038
FI 00039
293 END 00040
272 WHEN (save register state) 00042
296 DO for each register 00043
297-8
IF the register contains an optimization register AND
00044
the register has not been backstored
00045
THEN 00046
299 CALL Backstore 00047
FI 00048
300 END 00049
301 IF there is already a saved pending state
00050
THEN 00051
302 DO for each register in the saved state
00052
304 IF the saved register contents are not
00053
the same as the current contents
00054
THEN 00055
305 REMOVE the register from the saved set
00056
FI 00057
END 00058
ELSF 00059
303 SAVE the current register state for this label
00060
307 FI 00061
274 WHEN (release other of pair) 00063
309 FIND the register pair 00064
310 FREE the other of the pair 00065
311 DEQUEUE pending request to assign the new symbolic register
00066
312 ASSIGN the symbolic register to the former pair half
00067
276 WHEN (equate symbolic register)
00069
315 FIND the symbolic register 00070
316 DEQUEUE the request for the optimization register
00071
317 ASSIGN the optimization register to the symbolic register
00072
278 END CASE 00074
261 END 00075
262 IF the queue is empty 00077
THEN 00078
SET current-load-point to instruction counter + 1
00079
263 CALL PASS2 (current-load-point)
00080
FI 00081
__________________________________________________________________________
Process load request 269 is explained in FIG. 24. In step 280, the load instruction base register value is computed. If the computed base value is not an actual (i.e., register 12 or 13), but rather a symbolic register--then in step 282 register resolver 68 is called for the base. In step 283 the load instruction is constructed, in steps 284 and 285 the register number is obtained and put in the instruction, which will then be written to output stream 71 in step 286. Process backstore request 271 is explained in FIG. 25. If the queue command is to backstore an optimization register that has not been previously backstored, then backstore (FIG. 35) is called in step 292. Process save request 273 is explained in FIG. 26. A save request pertains to the saving of registers at a label (see step 118). In steps 296-300, all optimization registers not previously backstored have instructions generated and written out to output stream 71 to backstore to save their contents. In steps 301-306, register assigner 66 assures that the current state of all registers for the label are saved. Process request to release other of a pair 275 is explained in FIG. 27. In step 309, the register pair is found in register list 91, and the other of the pair released in step 310. Release requires modification of fields 42, inter alia, in the element record in list 91. In steps 311 and 312 the pending request is dequeued, and assigned to the other (unreleased) register setting field 42 to the new symbolic register name and adjusting field 43 to reflect the new (single) type. Process request 277 is explained in FIG. 28, steps 315-317 of which search vector 30 to find the symbolic register, dequeue from queue 92 the optimization register, and assign the former symbolic register number to the optimization register. In FIGS. 29-31, and Table 10, are set forth the process steps for get-a-register, a procedure which is internal to register resolver 68 and is called from at least steps 267 and 284.
TABLE 10
__________________________________________________________________________
Get-A-Register
__________________________________________________________________________
A.2.4 GET-A-REGISTER SMEZSH3
Get-a-Register: Procedure * this procedure is internal
00084
to the Register-Resolver procedure *
00085
320 IF the request is for a register pair
00087
THEN 00088
321 CALL Process-Register-Pair 00089
ELSE 00090
Find-Register: DC 00091
322 IF the request is for an absolute register
00092
THEN 00093
323 FIND the absolute register 00094
324 IF the absolute register does not contain
00095
part of a register pair 00096
325 IF the absolute register is free or discardable
00097
THEN 00098
LEAVE Find-Register 00099
FI 00100
328 IF the quantity in the absolute register cannot
00101
use register 0 00102
327 THEN 00103
SET an indicator to prevent a Load Register 0
00104
FI 00105
FI 00106
FI 00107
* look for a free register * 00108
326 DO for the registers available 00109
329 IF the register is free 00110
THEN 00111
LEAVE Find-Register 00112
FI 00113
330 END 00114
* look for the register not in the complete set *
00115
331 DO for the available registers 00116
IF the last use of the register is prior to the
00117
current load point 00118
THEN 00119
IF the register is backstored OR read only
00120
THEN 00121
LEAVE Find-Register 00122
OTHERWISE 00123
CALL Backstore 00124
LEAVE Find-Register 00125
FI 00126
FI 00127
END 00128
ABORT 00129
END Find-Register 00130
FI 00131
334 IF the request is for an absolute register AND
00133
the register found is not that register
00134
THEN 00135
335 IF the value in the absolute register is part
00136
of a register pair 00137
THEN 00138
336 GENERATE Load Register instructions to
00140
reallocate the registers 00141
* For Example * 00142
* Free In-Use Pair Pair
* 00143
* becomes * 00144
* Pair Pair Absolute In-use
* 00145
ELSEDO 00147
337 GENERATE a Load Register instruction to move the quantity
00148
in the Absolute register to the free register
00149
FI 00150
FI 00151
338 IF the quantity being displaced has been backstored
00153
THEN 00154
339 MOVE it to the Backstore 00155
FI 00156
340 ASSIGN the register to the pending element
00158
341
345 IF the register just assigned was register 0 AND
00160
the register is not an absolute register AND
00161
346 there is at least one complete set in the queue
00162
342 THEN * recompute the complete sets *
00163
349 DO for all elements in the queue
00164
350 IF the enqueued element cannot be put into register 0
00165
the just assigned register was counted in its complete
00166
THEN 00167
351 SET the complete set count for the enqueued element
00168
down by 1 00169
OTHERWISE 00170
352 IF the enqueued element still contains a complete set
00171
THEN 00172
353 SET complete-set-point to point to the next element
00173
FI 00174
FI 00175
END 00176
354 FI 00177
END Get-a-Register 00179
__________________________________________________________________________
In FIG. 29, steps 320, 321, process register pair (FIGS. 32-34) is called if the assignment for the dequeued element is for a pair of registers. If not, in steps 322-325, 327-328, for requests for an absolute (also refered to as an actual) register, it is determined if the request is for part of a pair, whether it is free or discardable, and/or if it is unable to use register zero. In steps 326-331 a search is made of available registers in register list 91 for a free register or, failing that, a register not of the complete set of the current register--and, if necessary to displace a register, that register is, if required, backstored. For the purpose of step 326, a register is available if it is not restricted and not permanently assigned and, if the pending quantity cannot use register .0., it is not register .0.. In FIG. 30, steps 334-337, if the register request is for an absolute register, but the register found is not that register, then the load register instructions are generated to reallocate register values. In steps 338, 339, registers that were previously backstored are moved to the backstore list 93. In step 340 the pending request is assigned to the found register, and in steps 341, 342 the complete sets are recomputed if necessary. (See FIG. 31.) In FIG. 31, the complete sets are recomputed when required by steps 341, 342. In steps 345-354, the complete set count and complete set pointers are managed for this request. In FIGS. 32-34 and Table 11, the procedure for processing a process pair request is set forth. This procedure is internal to register assigner 66, and is called from step 321 of get-a-register (FIG. 29) when a register pair is to be assigned in response to either of queue commands ASSIGN or LOAD/BACKSTORE LOAD (steps 267, 284).
TABLE 11
__________________________________________________________________________
Process Pair
__________________________________________________________________________
Process-Pair PROCEDURE 00181
356 DO for the available registers * looking for a free pair
00183
357 IF the even of the pair is free
00184
THEN 00185
IF the odd of the pair is free
00186
THEN 00187
358 SET found-register to the even of the pair
00188
RETURN 00189
FI 00190
FI 00191
360 END 00192
361 DO for the available registers * looking for two free
00194
383 IF a register is free 00195
THEN 00196
384 SET r2pointer to the other of the pair
00197
385 IF r2pointer is not pointing to a permanent or
00198
to an absolute register 00199
386 THEN 00200
DO for the remaining registers
00201
387 IF a remaining register is free
00202
THEN 00203
388 GENERATE a Load Register instruction to
00204
move r2pointer register to this register
00205
RETURN 00206
FI 00207
END 00208
FI 00209
FI 00210
390 END 00211
368 DO for the available registers * looking for a register
00213
* not in the complete set *
00214
369 IF the last use of the register is prior to the
00215
current load point 00216
THEN 00217
373 IF it was backstored 00218
THEN 00219
374 MOVE it to the backstore 00220
376 SET the register free 00221
378 CALL Process-Pair 00222
380 RETURN 00223
FI 00224
375 IF it is read-only 00226
THEN 00227
376 SET the register free 00228
378 CALL Process-Pair 00229
RETURN 00230
FI 00231
377 CALL Backstore 00232
379 IF the register just stored was a pair
00233
THEN 00234
372 RETURN 00235
FI 00236
378 CALL Process-Pair 00237
380 RETURN 00238
FI 00239
END 00240
ABORT 00241
END Process-Pair 00242
__________________________________________________________________________
FIG. 35 and Table 12 set forth the backstore procedure, which is internal to register assigner 66, and called from steps 292, 299, etc. In steps 393, 399, optimization registers are directed to the optimization cell in the backstore. In steps 394-398, one or more backstore cells are addressed, and in steps 400-402 the write instructions generated for inclusion in output stream 71 as required to preserve the contents of the one or more registers displaced because not included in the complete set of the current load point instruction.
TABLE 12
__________________________________________________________________________
Backstore
__________________________________________________________________________
Backstore PROCEDURE 00244
393 IF it is a symbolic register
00246
THEN 00247
394 IF backstore space has not been assigned to it
00248
THEN 00249
396 IF it is a register pair 00250
THEN 00251
398 FIND two adjacent free backstore slots
00252
OTHERWISE 00253
397 FIND a free backstore slot 00254
FI 00255
397-8 SET the backstore location in the element
00256
FI 00257
395 SET the store address to the backstore cell
00258
OTHERWISE 00259
399 SET the store address to the optimized backstore cell
00260
FI 00261
400 IF register is a pair 00263
THEN 00264
401 WRITE a STORE MULTIPLE instruction
00265
OTHERWISE 00266
402 WRITE a STORE instruction 00267
FI 00268
403 END Backstore 00270
END Register-Assigner 00272
__________________________________________________________________________
Pass 2 Processor The procedure steps executed by pass 2 processor 69 are set forth in Table 13 and FIGS. 36-38. Pass 2 processor 69, when called, processes the instructions and commands in storage 80 from pass 2 counter 27 location 81 to current load point 25 location 83, with steps 408 (FIG. 37) and 410 (FIG. 38) processing instructions and commands, respectively.
TABLE 13
__________________________________________________________________________
Pass2 Processor
__________________________________________________________________________
PASS2 Procedure 00002
405 DO WHILE pass2-instruction-counter
00003
is less than current-load-point
00004
406 GET the first instruction in storage
00006
SET pass2-instruction-counter up by 1
00007
CASE (text type) 00009
407 WHEN (text is an instruction) 00011
408 CALL Process-Instruction 00012
409 WHEN (text is an Assembler command)
00014
410 CALL Assembler-Commands 00015
WHEN OTHER 00017
411 ABORT * invalid instruction type *
00018
412 END CASE 00020
END 00022
414 Process-Instruction PROCEDURE 00024
415 DO for each operand 00026
416 IF the operand is a register 00028
THEN 00029
417 CALL Register-Resolver (Register Operand)
00030
419 INSERT the register number in the instruction
00031
OTHERWISE 00032
418 COMPUTE its basing-register-value
00033
420 CALL Register-Resolver (basing-register-value)
00034
421 INSERT the storage address in the instruction
00035
FI 00036
423 WRITE the instruction 00038
422 END 00040
424 END Process-Instruction 00042
Assembler-Command PROCEDURE 00044
CASE (type of command) 00046
426 WHEN (command is to release an actual register)
00048
CALL Register-Resolver 00049
427-8
(Register to be released marked "LAST USE")
00050
429 WHEN (command indicates last use of a symbolic register)
00052
430-32
CALL Register-Resolver 00053
Symbolic Register marked "LAST USE")
00054
END CASE 00056
433 END Assembler-Command 00058
END PASS2 00060
__________________________________________________________________________
In FIG. 37, each operand of the current instruction is processed to insert the storage address or register number in the instruction to be written out to stream 70. In FIG. 37, register references marked "last use" are created for absolute and symbolic registers, and a call made to register resolver 68. Register Resolver Register resolver 68 operates the computing system according to the method steps set forth in Table 14 and FIG. 39. Its function is to mark registers free (register list 91, field 44 and the backstore cell if required) when the current resistance is a "last use".
TABLE 14
______________________________________
Register Resolver
______________________________________
Register-Resolver Procedure 00002
435 SEARCH elements-being-managed
00004
beginning with names-search-vector
00005
of hash along the hash chain
00006
WHEN name of element-being-managed is equal to
00007
name of register-request 00008
SET found-register to its register number
00009
436 IF the request is for the even of a pair
00010
THEN 00011
* the register number is correct *
00012
OTHERWISE 00013
IF the request is for the odd of a pair
00014
THEN 00015
437 SET found-register up by 1 00016
FI 00017
FI 00018
438 IF it is marked "LAST USE" 00020
THEN 00021
439 IF it had been backstored 00022
THEN 00023
440 IF it is a register pair 00024
THEN 00025
441 FREE the two backstore cells
00026
OTHERWISE 00027
442 FREE the backstore cell 00028
FI 00029
FI 00030
443 FREE the register 00031
FI 00032
END SEARCH 00034
444 END Register-Resolver 00036
______________________________________
EXAMPLES The following examples assume the availability of three registers which are initially free. The instruction stream is expressed as a string of letters which represent references in input stream 61 to quantities that need to be a register. To avoid undue complexity, only straight line code (no labels) and a uniform register set (any quantity may enter any of the three registers) are illustrated: Example 1: abcdab . . . In the hypothetical three register machine the quantities a, b, and c are assigned to the free registers during load points 1, 2, and 3, respectively. When d is encountered, a pending load point 4 exists, a decision delay starts and a collection of data on reuses begins. The reuse of a and b at load points 5 and 6 yield the complete set abd and the quantity c will be displaced. The above case assumes that the delayed displacement can be made before a second displacement is necessary. In general, however, not enough reuses occur between two such pending load points to make the decision that early. The load point is that point in the instruction stream at which the instruction must be inserted into a register. A load point quantity enters its register at its load point. During the decision delay following a pending load point, which register that is had not been determined. Therefore, while one or more decision delays exist, the scan of references to discover the complete set of N-1 reuses (where N is, for the present, the number of registers--here, 3) must consider the reuse of pending load point quantities as well as the quantities in the latest register state. The composition of the complete set may be any permutation of register and pending register quantities. Example 2: abcdeab Here the reuse of a and b cause d to displace c. Their reuse after load point 5 make them a complete set for load point 3, and e displaces d. Both reused quantities were in the latest register state prior to the decision delay, abc. The final register state is abe. Example 3: abcdeab Example 4: abcdead In these two examples the complete set for the load point 4 is discovered with the last reference in the string. In example 3, d displaces c when its complete set abd is discovered. The final register state is abd. Note that while b is a member of the complete set for load point 3 a complete set does not yet exist for e. In example 4, the reuse of d triggers the complete set for load point 5. Load point 4 does not have a complete set. The intermediate state may be adc or abd, in the transition to the complete set register state ade or aed. In this example the complete set contains both a pending load point quantity and a register resident quantity. Example 5: abcdefde This example shows that the complete set may be composed of pending quantities only. The reuse of d and e form a complete set with f, at pending load point 6. Load points 4(d) and 5(e) are resolved in the transition to the final register state, which can be in the registers in any permutation of d, e, and f. The above examples are greatly simplified for clarity merely to illustrate the concepts of complete set count and load point, without the introduction of an essential aspect to the invention, in particular the handling of unlike subsets of registers by manipulation of the complete set count (to provide for registers for which the quantity is not a candidate) as is described in connection with FIGS. 17-18 and 20, and certain other aspects of the invention, such as the processng of a queued LABEL command, FIGS. 12 and 13, and the recursive processing of addressability calculations, FIG. 19. While the invention has been particularly shown and described with reference to preferred embodiments thereof, it will be understood by those skilled in the art that changes in form and detail may be made therein without departing from the spirit and scope of the invention.
|
Same subclass | ||||||||||
