1. Field of the Invention
This invention relates to the field of data processing systems. More particularly, this invention relates to the decoding of conditional instructions within data processing systems.
2. Description of the Prior Art
It is known to provide data processing systems which support conditional program instructions. The program instructions may be conditional by virtue of their own encoding and parameters or they may be rendered conditional by a predication instruction. It is known to speculatively process conditional program instructions before it is known whether the condition associated with that conditional instruction will be passed or failed. In order to preserve the state of the system should the conditional program instruction not pass its condition codes, it is known to provide as an additional source operand to such conditional program instructions the original value stored within the destination to be written to by that conditional program instruction. Thus, if the conditional program instruction does not pass its condition, then the original state will be available to be reinstated. A problem with this approach is that it requires extra operand routing within a processor increasing cost and circuit overhead. This is particularly the case for conditional program instructions which already have a large number of associated operands, such as, for example, single instruction multiple data (SIMD) instructions.
Another approach to dealing with conditional program instructions is to decompose them into micro-operation instructions which include within the micro-operation instructions sequence steps which store the original value of the destination into temporary storage and then restore this original destination should the conditional program instruction fail its condition. A disadvantage with this approach is that the extra micro-operation instructions slow execution of the conditional program instruction and the temporary storage is an additional resource to be provided. Furthermore, decoding a conditional program instruction in this way produces a sequence of micro-operation instructions which differ significantly from those of a non-conditional version of the same program instruction. This tends to increase the complexity and overhead associated with the instruction decoder.
Viewed from one aspect the present invention provides an apparatus for processing data comprising:
instruction decoding circuitry configured to decode a program instruction to generate one or more micro-operation instructions;
processing circuitry configured to process said one or more micro-operation instructions, said processing circuitry including condition resolution circuitry configured to respond to a condition resolution micro-operation instruction to determine if a condition associated with said condition resolution micro-operation instruction is passed or failed; wherein
at least one conditional program instruction specifying a processing action to be performed by said processing circuitry if a condition associated with said conditional program instruction is passed is decoded by said instruction decoding circuitry in accordance with a condition prediction as one of:
(i) in accordance with said condition prediction being a condition pass prediction, one or more micro-operation instructions that control said processing circuitry to perform said processing action together with a condition resolution micro-operation instruction; and
(ii) in accordance with said condition prediction being a condition fail, at least said condition resolution micro-operation instruction; and
said condition resolution circuitry is configured to respond to said condition resolution micro-operation instruction to determine if said condition prediction is incorrect and if said condition prediction is determined to be incorrect then:
(a) to flush any micro-operation instructions for said conditional program instruction from said processing circuitry;
(b) to change said condition prediction for said conditional program instruction to a new condition prediction; and
(c) to trigger said instruction decoding circuitry to decode said conditional program instruction again using said new condition prediction.
The present technique decodes conditional program instructions into one or more micro-operation instructions in accordance with a condition prediction and includes a conditional resolution micro-operation instruction within the sequence of micro-operation instructions. Condition resolution circuitry responds to this condition resolution micro-operation to determine if the condition prediction is incorrect and should the condition prediction be incorrect serves to trigger flushing of any other micro-operations for that conditional program instruction from the processing circuitry, changing of the condition prediction for that conditional program instruction to a new condition prediction and triggering of the re-decoding of that conditional program instruction using the new condition prediction.
This approach provides a mechanism for handling condition misprediction with relatively little additional circuitry overhead although at the cost of having to replay the conditional program instructions should the condition prediction be incorrect.
It will be appreciated that the decoding of the conditional program instruction in accordance with the condition prediction being a condition fail could take a variety of different forms providing these do not inappropriately change the state of the system. However, one form of this decoding which consumes advantageously little power to execute whilst conveniently matching the number of micro-operations of the other decoding is when the conditional program instruction is decoded as a number of no-operation micro-operation instructions equal in number to the one or more micro-operation instructions that control the processing circuitry to perform the desired processing action in the condition pass decoding.
It will be appreciated that the condition resolution micro-operation instruction could be located at various positions within the sequence of micro-operation instructions into which the conditional program instructions is decoded. However, in some embodiments it is convenient that the condition resolution micro-operation instruction is the last micro-operation instruction in the sequence of micro-operations to which the conditional program instruction is decoded.
While the condition resolution micro-operation instruction could have a variety of different forms, it is convenient if it is a conditional branch micro-operation instruction. Circuitry for processing conditional branch micro-operation instructions and resolving their conditions is typically already present within a processor and accordingly support may be provided for the condition resolution micro-operation instruction with reduced overhead.
While the conditional program instruction may have a variety of different forms, one form where this technique is useful is when the conditional program instruction is a single instruction multiple data instruction as the mechanisms of forwarding the old destination value as a source operand are difficult to support with such operand dense program instructions.
As mentioned above, the conditional program instruction may itself be encoded with condition parameters, but it may also be conditional by virtue of being predicated by a predication program instruction decoded by the instruction decoding circuitry so as to predicate one or more other program instructions. In this case, the prediction instruction can render conditional a program instruction which would otherwise be non-conditional. Keeping a decoding similar to that which produces the desired processing action for the non-conditional version of the program instruction whilst supporting the conditional version of the program instruction reduces the complexity and overhead associated with the instruction decoder.
The condition resolution circuitry may conveniently be one of a plurality of processing pipelines provided within the processing apparatus concerned.
Commonality of the decoding hardware may be improved in some embodiments where the instruction decoding circuitry first decodes the conditional program instruction in accordance with the condition fail condition prediction by generating the one or more micro-operation instructions that control the processing circuitry to perform the processing action and then suppressing the sending of these one or more micro-operations to the processing circuitry.
In some embodiments the one or more micro-operation instructions corresponding to the processing action may be replaced by a corresponding number of no-operation micro-operation instructions.
Viewed from another aspect the present invention provides an apparatus for processing data comprising:
instruction decoding means for decoding a program instruction to generate one or more micro-operation instructions;
processing means for processing said one or more micro-operation instructions, said processing means including condition resolution means for responding to a condition resolution micro-operation instruction to determine if a condition associated with said condition resolution micro-operation instruction is passed or failed; wherein
at least one conditional program instruction specifying a processing action to be performed by said processing means if a condition associated with said conditional program instruction is passed is decoded by said instruction decoding means in accordance with a condition prediction as one of:
(i) in accordance with said condition prediction being a condition pass prediction, one or more micro-operation instructions that control said processing means to perform said processing action together with a condition resolution micro-operation instruction; and
(ii) in accordance with said condition prediction being a condition fail, at least said condition resolution micro-operation instruction; and
said condition resolution means responds to said condition resolution micro-operation instruction to determine if said condition prediction is incorrect and if said condition prediction is determined to be incorrect then:
(a) to flush any micro-operation instructions for said conditional program instruction from said processing means;
(b) to change said condition prediction for said conditional program instruction to a new condition prediction; and
(c) to trigger said instruction decoding means to decode said conditional program instruction again using said new condition prediction.
Viewed from a further aspect the present invention provides a method of processing data comprising the steps of:
decoding a program instruction to generate one or more micro-operation instructions;
processing said one or more micro-operation instructions, said processing including condition resolution for responding to a condition resolution micro-operation instruction to determine if a condition associated with said condition resolution micro-operation instruction is passed or failed; wherein
at least one conditional program instruction specifying a processing action to be performed if a condition associated with said conditional program instruction is passed is decoded in accordance with a condition prediction as one of:
(i) in accordance with said condition prediction being a condition pass prediction, one or more micro-operation instructions that control said processing action together with a condition resolution micro-operation instruction; and
(ii) in accordance with said condition prediction being a condition fail, at least said condition resolution micro-operation instruction; and
in response to said condition resolution micro-operation instruction, determining if said condition prediction is incorrect and if said condition prediction is determined to be incorrect then:
(a) to flush any micro-operation instructions for said conditional program instruction;
(b) to change said condition prediction for said conditional program instruction to a new condition prediction; and
(c) to trigger decoding said conditional program instruction again using said new condition prediction.
The above, and other objects, features and advantages of this invention will be apparent from the following detailed description of illustrative embodiments which is to be read in connection with the accompanying drawings.
The destination operands produced by the processing pipeline 16, 18, 20 and 22 are passed to result queue circuitry where commit queue circuitry 28 serves to monitor the commit status of groups of micro-operation instructions and accordingly gate the update of an architectural register file 30 with the result values stored within the result queue circuitry 27.
The general arrangement of the processing stages and processing pipelines within the processor 2 of
If the condition was incorrectly predicted, then step 34 triggers the flushing of the micro-ops associated with the conditional program instruction from the pipeline 16. Step 36 then specifies a new condition prediction and stores this within the prediction status store 26 where it will be used to control the next decoding of the replayed conditional program instruction. Step 38 then triggers the instruction decoding circuitry 8 to re-decode the conditional program instruction with the new condition prediction using a flush/refetch signal.
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.