BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 schematically shows a buffer for storing data relating to said unresolved exception instructions and an example instruction stream;
FIG. 2 schematically shows a data processing apparatus according to an embodiment of the present invention;
FIG. 3 schematically shows a portion of the data processing apparatus of FIG. 2;
FIG. 4 shows a flow diagram illustrating steps in a method according to and embodiment of the present invention; and
FIG. 5 a portion of the data processing apparatus of an embodiment of the present invention.
DESCRIPTION OF THE PREFERRED EMBODIMENTS
FIG. 1 shows a buffer 10 operable to store register renaming data that is needed to be able to restore a register renaming table if an exception occurs. FIG. 1 also shows an example stream of instructions 20, this stream of instructions was decoded in the direction of the arrow (that is the instruction at the top of the list LDR P4 was before MOV P6 in the instruction stream) and was then forwarded to register renaming logic, where the mapping between architectural registers and physical registers is performed, sequentially for each decoded instruction in the decoded instruction stream. The decoded instruction stream is shown as instructions with their remapped registers. Thus, P4, P6 etc. refer to physical registers present in the silicon, that the instruction shown write data values to. The portion of the instruction stream illustrated are the instructions that lie between the decoded instruction most recently remapped by the register remapping or renaming table and the decoded instruction whose remapping values are stored in the recover or restore table. The restore table is the table holding the values of the remapping table at the last resolved exception point. The last resolved exception point being an instruction in the instruction stream that can generate an exception but that a handling unit within the processing apparatus has determined will not do so. The instructions shown whose remapped registers are stored in buffer 10.
Thus, data relating to decoded instructions not yet remapped are not stored in buffer 10 and neither is data relating to decoded exception instructions that have been resolved.
FIG. 2 shows a data processing apparatus 30 operable to process instructions such as the instruction stream 20 shown in FIG. 1. Data processing apparatus 30 comprises a renaming table 40 which is operable to store the mapping values which remap or rename registers from the architecture set which is how the registers are referred to in the instruction set to the physical set of registers 50 which are present in the silicon on data processing apparatus 30. An instruction stream is decoded by decoder 60 and the decoded instructions are sent to the renaming stage of the processor which is not shown in detail but which includes renaming table 40. Logic present on the data processing apparatus populates renaming table 40 with remapping values for the appropriate decoded instruction being received. Thus, if in the instruction being received register Ro in the architecture set is id be remapped to register P4 on the physical register set then the initial line of remapping table 40 contains the information P4. As the decoded instruction has not yet been executed by execution stage 70 this table is sometimes called a future table.
Control logic 80 is associated with renaming table 40 and is operable to control the storing of sufficient data to enable the renaming table 40 to be restored in the event of an exception occurring.
Thus, control logic 80 comprises buffer 10 and restore table 100. Restore table 100 contains tie values stored in the renaming table at the previous resolved exception. Thus, if an exception occurs the state of the processor can always be restored to the previous resolved exception instruction.
FIG. 1 shows how information from a decoded instruction that has been processed by renaming logic and had the renaming table populated for it is then stored in buffer 10. Control logic 80 of FIG. 2 detects decoded exception instructions, that is instructions that can generate an exception (these are marked by # in the instruction stream 20 of the figure) and groups these instructions with any subsequent decoded instruction that is not an exception instruction. Thus, looking at the instruction stream 20 in FIG. 1, from the oldest instruction shown, an exception instruction LDR is detected and the subsequent move instructions which are not exception instructions are grouped together with it. This group of instruction modifies the stored values in physical registers P4, P6, P7, P8, P10, P11 and P12 and thus information relating to these registers is stored in buffer 10. Although this is just shown in the figure as being the physical register itself, it is in effect the renaming or remapping that is stored in other words the architectural register and the physical register that it is remapped to is stored. Alongside these values are values marked as B or L in the figure. These provide an indication of the exception instruction that is being considered and this will be described in more detail later.
Looking again at FIG. 2, when a decoded exception instruction is detected by control logic 80, the type of exception that it might generate, is identified and the relevant counter 90 or 92 is incremented. In the embodiment shown there are two counters and these correspond to branch exceptions and memory access exceptions. Branch instructions can provide exceptions by being mispredicted, whereas memory access instructions can provide exceptions by the memory to be accessed not being accessible by the processor, for example it is secure memory for which that operation does not have sufficient privilege. There are of course other sorts of exception instructions that could be considered and more or fewer counters could be used.
In addition to the counters being incremented on detection of an exception instruction, the value identifying the instruction within buffer table 10 is also incremented. Thus, if a branch instruction is detected bit B is incremented, whereas if a memory access instruction is detected such as a load or store, bit denoted L is incremented.
Non-exception decoded instructions following an exception instruction are grouped together with the decoded exception instruction by the control logic 80 and all registers which store values that are modified are recorded in buffer 10 along with the instruction identifying information from the counter. Thus, if there are lots of registers that are renamed as is shown in FIG. 1 at the bottom of buffer 10 several lines are used with the same instruction identifier values.
In addition to receiving information about the decoded instruction stream being processed by the register renaming logic, control logic 80 also receives information from the execute unit 70 executing the decoded instruction stream and in particular from branch handling unit 72 or load store unit 74. These units can assess when a decoded exception instruction is resolved, i.e. when it is sure that it will execute. It may not at this point have actually executed, it is just that the unit has assessed that, for example the memory will be accessible or the condition code is correct. When this information is received by control logic 80, the appropriate counter 90, 92 is decremented as is the corresponding value in buffer table 10. This enables the buffer 10 to identify the next unresolved instruction by the numbers relating to it.
Furthermore, when the numbers B, L in buffer reach 00, this is an indication to the control logic that the exception instruction this data relates to has been resolved and that the restore table 100 can now be updated using the information stored in buffer 10. The advantage of this technique, is that information is stored relating to the registers rather than relating to individual instructions and it is only this information that is needed to update restore table 10Q. This is because the instructions that have been processed have only remapped the registers that are stored in this table and thus, the restore table only needs updating with this information. Furthermore, when an exception occurs the restore table is ready to be written to the remapping table to update it to the correct value in one clock cycle.
If an exception instruction does not write to a register, such that no remapping of a register is involved and if none of any immediately subsequent non-exception instructions write to a register, see for example the STR instruction above LDR P4 in the instruction stream 20, then the corresponding counter is incremented, in this case counter L, but no data is stored. This is because there is no information associated with this instruction that might be required to restore the remapping table following an exception. The counter needs to be incremented so that the logic can identify which instruction is resolved.
It should be noted, that although two counters are shown in this particular embodiment it is clear that only one counter could be used or that more counters could be used if there were more different types of exceptions. The advantage of using different counter values in this embodiment is that there are two exception instruction handling units 72 and 74 and these operate independently of each other. Thus, it may be that the condition of a branch instruction is found out to be correct before the memory accessibility of a load instruction which was received previous to the branch instruction. If these were not separate counters relating to these units then the counter would be decremented in response to the information, and it would be the load instruction that would appear at the bottom of the table when it had not yet been resolved.
It should also be noted that although the counters are shown as being incremented when an instruction is detected and decremented when it is resolved, this could clearly be done in the reverse sense, with the attainment of a predetermined value indicating that the buffer 10 should be flushed of the corresponding values.
FIG. 3 shows schematically a portion of the data processing apparatus 30 shown in FIG. 2. In this figure, signals received at the buffer 10 from the execute unit 70 shown in FIG. I are shown in more detail. Thus, these signals include a signal indicating that a load/store instruction has been resolved, a signal indicating that a branch instruction has been resolved and an abort signal indicating that an exception has occurred.
In response to the abort signal, the contents of restore table 100 are copied to register renaming table 40. This restores the table to the value held at the previously resolved exception instruction. The PC is then forced to indicate the instruction to be processed following the abort.
FIG. 4 shows a flow diagram showing a method according to an embodiment of the invention. In this embodiment the control logic receives an instruction from the decoded instruction stream and looks to see if the received instruction is an exception instruction. If it is not it looks at subsequent instructions until it detects an exception instruction. Once having detected an exception instruction it updates a counter (generally incremented) counting that type of exception instructions and then looks to see if the subsequent instructions are exception instruction.
When the subsequent instruction is not an exception instruction, control logic looks again until it finds an exception instruction. It then groups the first exception instruction together with any subsequently received non-exception instructions and then looks to see if any of this group of instructions modify a register. If any of them do it stores the renaming information relating to the modified registers in a buffer along with the value of the updated counter that acts to identify the exception instruction. If no registers are modified then no data is stored in the buffer.
The control logic also looks to see if information regarding decoded exception instructions previously remapped and being processed has been received. If there is no information then it returns to the top of the table to look at the next instruction from the decoded instruction stream to see if it is an exception instruction. If however information regarding exception instructions has been received it looks to see if this information indicates whether the exception is resolved or not. If it has been resolved it updates the relevant counter (generally by decrementing it) and the instruction identifier information within the buffer. It then looks to see if any of the instruction identifier information indicates that it is itself the exception instruction that has been resolved (generally the identifier value(s) are zero). If one of the instruction identifiers indicates that it has been resolved then the restore table is updated with the stored values from the buffer stored with that instruction identifier and then this information is flushed from the buffer. We then return to the top of the flow diagram and the next instruction from the instruction stream is examined to see if it is an exception instruction which of course it will be in this case.
If the information regarding an exception instruction received indicates that the exception has not been resolved and in fact an exception has occurred register renaming table is updated with the values from the restore table and the PC is forced to a value of the next instruction that is to be performed after the exception.
FIG. 5 schematically shows a portion of the data processing apparatus of an embodiment of the present invention. In this embodiment register remapping logic 42 is shown. This receives information signals from restore table 100. This can be following an exception in which case it updates table 40 with the information it receives. Alternatively, it may be following the resolution of an exception instruction when the restore table has been updated. In this case the physical register information from the stored remapping values that are to be overwritten are sent to register remapping logic 42, where they are entered into a ““free list” indicating which physical registers are free to be used in any remapping. One of the problems associated with renaming registers is to work out which physical registers will be free and therefore available for renaming once they have been allocated. A big advantage of the present technique is that this information is available “free” owing to the way the information is stored and treated. In effect, when a value is pushed out of the restore table then the physical register that has been pushed out is no longer used and can no longer be affected by an exception and as such can be allocated. There may be circumstances where condition codes are such that in fact this register is not actually available, however the renaming logic can work this out add not enter the physical register into the free list if this is the case. Thus, the information that this register is free from any exception circumstances is highly valuable and is a major advantage of the present technique.
Although illustrative embodiments of the invention have been described in detail herein with reference to the accompanying drawings, it is to be understood that the invention is not limited to those precise embodiments, and that various changes and modifications can be effected therein by one skilled in the art without departing from the scope and spirit of the invention as defined by the appended claims.