# US 2004/0210880 A1 · Program code conversion

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2004/0210880 A1
- Document ID: US20040210880A1
- Status: Published application
- Kind: A1
- Application number: 09/827,974
- Filed: 2001-04-06
- Published: 2004-10-21
- Earliest claimed: 1998-10-10
- Assignees: The Victoria University of Manchester
- Inventors: Jason Souloglou; Alasdair Rawsthorne
- Web page: https://patentgrep.com/patent/US20040210880A1

## CPC

- G06F 8/52: Binary to binary
- G06F 8/44: {Encoding}
- G06F 8/441: {Register allocation; Assignment of physical memory space to logical memory space}
- G06F 8/47: {Retargetable compilers}
- G06F 9/45504: {Abstract machines for program code execution, e.g. Java virtual machine [JVM], interpreters or emulators}
- G06F 9/45516: {Runtime code conversion or optimisation}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for generating an intermediate representation of computer program code written for running on a programmable machine comprises: (i) generating a plurality of register objects for holding variable values to be generated by the program code; and (ii) generating a plurality of expression objects representing fixed values and/or relationships between said fixed values and said variable values according to said program code; said objects being organized into a branched tree-like network having all register objects at the lowest basic root or tree-trunk level of the network with no register object feeding into any other register object.

## Claims

### Claim 1

A method of generating an intermediate representation of program code, the method comprising the computer implemented steps of:
on an initial translation of a given portion of program code, generating and storing only intermediate representation which is required to execute that portion of program code with a prevailing set of conditions; and
whenever subsequently the same portion of program code is entered, determining whether intermediate representation has previously been generated and stored for that portion of program code for the subsequent conditions, and if no such intermediate representation has previously been generated, generating additional intermediate representation required to execute said portion of program code with said subsequent conditions.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the conditions are entry conditions, and the method comprises the computer implemented steps of:
generating an Intermediate Representation Block (IR Block) of intermediate representation for each Basic Block of program code as it is required by the program, each IR Block representing a respective Basic Block of program code for a particular entry condition;
storing target code corresponding to each IR Block; and
when the program requires execution of a Basic Block for a given entry condition, either:
(a) if there is stored target code representing that Basic Block for that given entry condition, using said stored target code; or
(b) if there is no stored target code representing that Basic Block for that given entry condition, generating a further IR Block representative of that Basic Block for that given entry condition.

### Claim 3 (depends on 1)

The method of claim 1, wherein the intermediate representation of the program code is generated dynamically as the program code is running, the method comprising the computer implemented steps of:
at a first iteration of a particular subject code instruction having a plurality of possible effects or functions, generating and storing special-case intermediate representation representing only the specific functionality required at that iteration; and
at each subsequent iteration of the same subject code instruction, determining whether special-case intermediate representation has been generated for the required functionality required at said subsequent iteration and generating additional special-case intermediate representation specific to that functionality if no such special-case intermediate representation has previously been generated.

### Claim 4 (depends on 3)

The method according to claim 3, wherein the said special-case intermediate representation is generated and stored an associated test procedure is generated and stored to determine on subsequent iterations of the respective subject code instruction whether the required functionality is the same as that represented by the associated stored special-case intermediate representation, and where additional special-case intermediate representation is required an additional test procedure associated with that special-case intermediate representation is generated and stored with that is additional special-case intermediate representation.

### Claim 5 (depends on 4)

The method according to claim 4, wherein the additional special case intermediate representation for a particular subject code instruction and the additional associated test procedure is stored at least initially in subordinate relation to any existing special-case intermediate representation and associated test procedures stored to represent the same subject instruction, such that upon the second and subsequent iteration of a subject code instruction determination of whether or not required special-case intermediate representation has previously been generated is made by performing said test procedures in the order in which they were generated and stored until either it is determined that special-case intermediate representation of the required functionality exists or it is determined that no such required special-case intermediate representation exists in which case more additional intermediate representation and another associated test procedure is generated.

### Claim 6 (depends on 5)

The method according to claim 5, wherein the intermediate representation is optimised by adjusting the ordering of the test procedures such that test procedures associated with more frequently used special-case intermediate representation are run before test procedures associated with less frequently used special-case intermediate representation rather than ordering the test procedures in the order in which they are generated.

### Claim 7 (depends on 1)

The method of claim 1, comprising translating the program code written for execution by a processor of a first type so that the program code may be executed by a processor of a second type, using the generated intermediate representation.

### Claim 8 (depends on 7)

The method according to claim 7, wherein said translation is dynamic and performed as the program code is run.

### Claim 9 (depends on 1)

The method of claim 1, comprising optimising the program code by optimising said intermediate representation.

### Claim 10 (depends on 9)

The method according to claim 9, wherein the method is used to optimise the program code written for execution by a processor of a first type so that the program code may be executed more efficiently by that processor.

### Claim 11

A method for generating an intermediate representation of program code written for running on a programmable machine, said method comprising:
(i) generating a plurality of register objects for holding variable values to be generated by the program code; and
(ii) generating a plurality of expression objects representing fixed values and/or relationships between said fixed values and said variable values according to said program code;
said intermediate representation being generated and stored for a block of program code and subsequently re-used if the same block of program code is later re-entered, and wherein at least one block of program code can have alternative un-used entry conditions or effects or functions and said intermediate representation is only initially generated and stored as required to execute that block of program code with a then prevailing set of conditions.

### Claim 12 (depends on 11)

A method according to claim 11, wherein for a given block of program code, it is determined whether a previously stored intermediate representation therefor was for the same now currently prevailing set of conditions and, if not, then generating and storing additional intermediate representation as required to execute the block of program code for the new now currently prevailing set of conditions.

### Claim 13

A method of generating target code representation of program code, the method comprising the computer implemented steps of:
on an initial translation of a given portion of the program code, generating and storing only target code which is required to execute that portion of program code with a prevailing set of conditions; and
whenever subsequently the same portion of program code is entered, determining whether target code has previously been generated and stored for that portion of program code for the subsequent conditions, and if no such target code has previously been generated, generating additional target code required to execute said portion of program code with said subsequent conditions.

### Claim 14

A method of dynamically translating first computer program code written for compilation and/or translation and running on a first programmable machine into second computer program code for running on a different second programmable machine, said method comprising:
(a) generating an intermediate representation of a block of said first computer program code;
(b) generating a block of said second computer program code from said intermediate representation;
(c) running said block of second computer program code on said second programmable machine; and
(d) repeating steps a-c in real time for at least the blocks of first computer program code needed for a current emulated execution of the first computer program code on said second programmable machine.

### Claim 15

A system for generating an intermediate representation of program code comprising:
means for generating and storing, on an initial translation of a given portion of program code, only intermediate representation which is required to execute that portion of program code with a prevailing set of conditions; and
means for determining, whenever subsequently the same portion of program code is entered, whether intermediate representation has previously been generated and stored for that portion of program code for the subsequent conditions, and if no such intermediate representation has previously been generated, generating additional intermediate representation required to execute said portion of program code with said subsequent conditions.

### Claim 16

A system for generating an intermediate representation or program code written for running on a programmable machine, the system comprising:
means for generating a plurality of register objects for holding variable values to be generated by the program code; and
means for generating a plurality of expression objects representing fixed values and/or relationships between said fixed values and said variable values according to said program code; and
means for generating and storing intermediate representation, said intermediate representation being generated and stored for a block of program code and subsequently re-used if the same block of program code is later re-entered, and wherein at least one block of program code can have alternative un-used entry conditions or effects or functions and said intermediate representation is only initially generated and stored as required to execute that block of program code with a then prevailing set of conditions.
