Browse Prior Art Database

A Method to Convert Physical Registers in Assembly Methods into Local Variables

IP.com Disclosure Number: IPCOM000012693D
Original Publication Date: 2003-May-21
Included in the Prior Art Database: 2003-May-21
Document File: 4 page(s) / 91K

Publishing Venue

IBM

Abstract

Disclosed is a mechanism to convert physical registers in assembly "methods" into local variables, which is independent of variables in other methods.

This text was extracted from a PDF file.
At least one non-text object (such as an image or picture) has been suppressed.
This is the abbreviated version, containing approximately 46% of the total text.

Page 1 of 4

A Method to Convert Physical Registers in Assembly Methods into Local Variables

  Disclosed is a mechanism to convert physical registers in assembly "methods" into local variables, which is independent of variables in other methods. An assembly program is given, and is already separated into multiple "methods" which contains one or more "entries" that can be invoked through an INVOKE instruction. For this separation, a mechanism disclosed in JP8-2002-1078 can be used. However, at this point, physical registers are still used in each method. To apply optimizations, it is better to convert these global physical registers into local variables. The mechanism disclosed here enables this by detecting registers used to pass arguments among methods.

The disclosed mechanism calculates the following five register sets by dataflow analysis.

ENT_reg_is_defined[entry-ID]

A set of registers that is ALWAYS DEFINED from the specified entry to the end of the method.

ENT_reg_maybe_defined[entry-ID]

A set of registers that MAY BE DEFINED from the specified entry to the end of the method.

ENT_reg_maybe_used[entry-ID]

A set of registers whose value at the specified entry may be used until the end of the method.

INV_reg_maybe_used_untilE[invoke-ID]

A set of registers whose value just after the specified INVOKE instruction (i.e. just returned from the invocation) may be used UNTIL THE END OF THE PROGRAM.

MTD_reg_is_returned[method-ID]

A set of registers whose value should be returned to the specified method's caller. In other words, the registers' value at the method's return point may be used somewhere.

Initialize the five register sets as empty, and perform the following dataflow analysis for each method.

STEP 1

Scan each BB (basic block) from bottom to top, and calculate the following register sets. If the BB contains an INVOKE instruction, information of the target method is also reflected.

perBB_reg_is_defined[BB-ID]

  A set of registers that is ALWAYS DEFINED by executing the BB perBB_reg_maybe_defined[BB-ID]

  A set of registers that MAY BE DEFINED by executing the BB perBB_reg_maybe_used[BB-ID]

A set of registers whose value at the entry of the BB MAY BE USED by executing the BB

Concretely, start with empty sets and check instructions in the BB from bottom to top as follows.

If register rX is defined in the instruction (e.g. MOV rX=...)

1

Page 2 of 4

perBB_reg_is_defined[BB-ID] += { rX } perBB_reg_maybe_defined[BB-ID] += { rX } perBB_reg_maybe_used[BB-ID] -= { rX }

If the instruction is INVOKE perBB_reg_is_defined[BB-ID] += ENT_reg_is_defined[target entry of the INVOKE] perBB_reg_maybe_defined[BB-ID] += ENT_reg_maybe_defined[target entry of the INVOKE] perBB_reg_maybe_used[BB-ID] = perBB_reg_maybe_used[BB-ID] - ENT_reg_is_defined[target entry of the INVOKE] + ENT_reg_maybe_used[target entry of the INVOKE]

If register rX is used in the instruction (e.g. MOV ...=rX) perBB_reg_maybe_used[BB-ID] += { rX }

STEP 2

Using the register sets calculated in STEP...