Claims
- 1. A method for emulating condition code flags during program code conversion, comprising the steps of:
(a) identifying a flag-affecting instruction in a sequence of subject code instructions; (b) recording parameters of the identified flag-affecting instruction; (c) detecting a flag-usage instruction in the sequence of subject code instructions; and (d) resolving a flag status with respect to the recorded parameters.
- 2. The method of claim 1, wherein the step (d) comprises explicitly calculating a flag status by emulating effects of the identified flag-affecting instruction on one or more subject condition code flags.
- 3. The method of claim 2, wherein the step (b) comprises setting a flag status indicator to a pending state to indicate that parameters have been recorded, and the step (d) comprises setting the flag status indicator to a normalised state to indicate that a flag status has been explicitly calculated.
- 4. The method of claim 1, wherein the step (d) comprises implicitly determining flag status with reference to the recorded parameters.
- 5. The method of claim 1, wherein the step (c) comprises determining a flag usage type with reference to a type of the detected flag-usage instruction, and the step (d) comprises resolving flag status either by explicitly calculating a flag status or by implicitly determining a flag status, according to the determined flag usage type.
- 6. The method of claim 1, wherein the step (a) comprises identifying a second flag-identifying instruction in the sequence of subject code instructions, and the step (b) comprises replacing the recorded parameters with parameters of the second flag-affecting instruction.
- 7. The method of claim 1, wherein the step (a) comprises identifying a type of flag-affecting instruction as one of a plurality of predetermined types, and the step (b) comprises recording parameters for each type of flag-affecting instruction.
- 8. The method of claim 7, wherein the predetermined types include a first type instruction affecting a fill set of condition code flags, and a second type instruction affecting a subset of the full set of condition code flags.
- 9. The method of claim 8, wherein the step (d) comprises resolving flag status for a full set of condition code flags with respect to the recorded first-type parameters, and resolving flag status with respect to the subset of the condition code flags with respect to the recorded second-type parameters.
- 10. The method of claim 9, wherein the step (d) comprises explicitly determining flag status from the recorded first-type parameters, and modifying the explicitly determined flag status from the recorded second-type parameters.
- 11. The method of claim 7, wherein the predetermined types include instruction types each affecting a condition code flag set amongst a plurality of condition code flag sets.
- 12. The method of claim 1, wherein the recorded parameters include an instruction type parameter and one or more instruction operand parameters.
- 13. The method of claim 12, wherein recording an instruction operand parameter comprises storing a reference to a location containing an operand.
- 14. The method of claim 12, wherein recording an instruction operand parameter comprises determining that an operand remains available unmodified at an original location and storing a reference to the original location as the instruction operand parameter, or else copying the operand from the original location to a dedicated operand parameter storage location.
- 15. The method of claim 12, comprising providing a plurality of abstract registers representing registers of a subject processor, and supplementing the abstract registers with one or more additional abstract registers each for storing an operand as an instruction operand parameter.
- 16. A method for emulating condition code flags during program code conversion, comprising:
selecting a sequence of subject code instructions; identifying a flag-affecting instruction in the sequence of subject code instructions, the flag-affecting instruction specifying an operation that affects subject condition code flags of a subject processor; recording parameters of the identified flag-affecting instruction including an instruction type parameter and one or more operand parameters; detecting a flag-usage instruction in the sequence of subject code instructions, the flag-usage instruction specifying an operation with reference to a flag status of one or more of the subject condition code flags; and in response to detecting a flag-usage instruction, resolving a flag status of one or more of the subject condition code flags with respect to the recorded parameters.
- 17. The method of claim 16, comprising updating the recorded parameters when a new flag-affecting instruction is encountered in the sequence of subject code instructions.
- 18. The method of claim 16, comprising recording parameters for a plurality of flag-affecting instructions.
- 19. The method of claim 18, wherein the plurality of flag-affecting instructions are each associated with differing sets of subject condition code flags.
- 20. The method of claim 16, comprising resolving flag status by at least one of (a) explicitly calculating a status for one or more subject condition code flags by emulating an effect of the recorded flag-affecting instruction, or (b) implicitly representing the flag-usage instruction using the recorded parameters, or (c) selecting between options (a) and (b) according to a type of the flag-usage instruction.
- 21. The method of claim 16, wherein the recorded parameters include at least one instruction operand parameter, and wherein recording the instruction operand parameter comprises at least one of (a) copying an operand to a predetermined storage location, or (b) storing a reference to an original location containing the operand, or (c) selectively performing (a) or (b).
- 22. An emulator apparatus for use in a target computing environment for emulating a subject processor of a subject computing environment when translating subject code appropriate to the subject computing environment to produce target code appropriate to the target computing environment, the emulator apparatus comprising:
means for identifying a flag-affecting instruction in a sequence of subject code instructions; an instruction parameter store f or recording parameters of the identified flag-affecting instruction; means for detecting a flag-usage instruction in the sequence of subject code instructions; and means for resolving a flag status with respect to the instruction parameters recorded in the instruction parameter store.
- 23. A computing platform comprising the emulator apparatus of claim 22.
- 24. A computer-readable recording medium containing program code constructions for performing the method of claim 1.
- 25. A computer-readable recording medium containing program code constructions for performing the method of claim 16.
- 26. Computer software resident on a tangible medium and operable when executed by a computer to perform the steps of:
detecting a flag affecting instruction in a sequence of subject code instructions; and emulating a flag using subject instruction based on the type and at least one operand value of said flag affecting instruction, thereby avoiding generation of target code to explicitly calculate the value of a flag normally used by the flag using subject instruction.
- 27. Computer software resident on a tangible medium and operable when executed by a computer to perform the steps of:
establishing one or more second abstract registers, each corresponding to a unique flag parameter (operand); generating an intermediate representation (IR) tree for a selected instruction sequence, said tree depending from one or more of said abstract registers; and responding to a first flag affecting instruction in said sequence to cause a flag parameter abstract register to refer to said IR.
- 28. The software of claim 2 further operable to perform the step of recording the first flag affecting instruction as the most recent flag affecting instruction.
- 29. Computer software resident on a tangible medium and operable when executed by a computer to perform the steps of:
generating intermediate representation for a sequence of instructions, said sequence including a plurality of flag affecting instructions followed by a flag using instruction; and deferring generation of intermediate representation for condition code flag emulation until said flag using instruction is encountered.
- 30. Computer software resident on a tangible medium and operable when executed by a computer to perform the steps of:
translating a sequence of instructions, said sequence including a plurality of flag affecting instructions followed by a flag using instruction; and deferring condition code flag translation until said flag using instruction is encountered.
- 31. The software of claim 30 wherein said computer performs the further steps of recording the type and each operand of a said flag affecting instruction.
- 32. The software of claim 31 wherein said computer further resolves a flag value based on type and operand.
- 33. The software of claim 29 further operable to generate said IR in a basic block mode and to save the flag parameter(s) and flag affecting instruction type across a basic block boundary.
- 34. The software of claim 33 wherein the flag affecting instruction type is saved within the translator.
- 35. The software of claim 34 wherein the flag parameters are saved in flag parameter abstract registers.
- 36. The software of claim 35 wherein said flag parameter abstract registers reside in a global register store.
- 37. The software of claim 36 further including the steps of responding to the case where a flag parameter is still alive in a subject register at the end of a basic block by recording the identity of said subject register rather than saving a duplicate value.
- 38. The software of claim 30 further including the step of using a stack of flag affecting instructions in emulation of sticky flags.
Priority Claims (1)
Number |
Date |
Country |
Kind |
0202728.2 |
Feb 2002 |
GB |
|
Parent Case Info
[0001] This application is a continuation-in-part of U.S. application Ser. No. 10/314,179 filed Dec. 5, 2002 and incorporated by reference herein.
Continuation in Parts (1)
|
Number |
Date |
Country |
Parent |
10314179 |
Dec 2002 |
US |
Child |
10361000 |
Feb 2003 |
US |