deep

a Cross Development Platform for Java

User Tools

Site Tools


dev:crosscompiler:backend_arm:register_allocation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:crosscompiler:backend_arm:register_allocation [2018/12/11 17:27] – [Register Usage] ursgrafdev:crosscompiler:backend_arm:register_allocation [2019/10/03 10:22] (current) – [Parameter Passing] ursgraf
Line 3: Line 3:
  
 ===== Register Usage ===== ===== Register Usage =====
-Registers can be classified as //dedicated//, //volatile// or //nonvolatile//. //Dedicated// are register with a special purpose, such as the stackpointer. //Volatile// means, that this register might be used any time. It does not have to be stored when another method is called. //Nonvolatile// registers must be saved in the prologue of a method before they can be used and after use they must be restored. The number of volatile and nonvolatile registers must be equal for all methods.  
 | Register | State | Use | | Register | State | Use |
-| R0 | volatile | 1st. parameter, return value | +| R0 | volatile | 1st. parameter, local variables, return value | 
-| R1 | volatile | 2nd. parameter, return value (if long, lower 4 bytes of long) |+| R1 | volatile | 2nd. parameter, local variables, return value (if long, lower 4 bytes of long) |
 | R2-R5 | volatile | further parameters, local variables | | R2-R5 | volatile | further parameters, local variables |
 | R6 | dedicated | scratch register | | R6 | dedicated | scratch register |
Line 14: Line 13:
 | R15 | dedicated | PC |    | R15 | dedicated | PC |   
 | D0 | dedicated| scratch register | | D0 | dedicated| scratch register |
-| D1 | volatile 1. parameter, return value | +| D1 | dedicatedscratch register, return value | 
-| D2-D6 | volatile | further parameters |+| D2-D6 | volatile | parameters, local variables |
 | D7-D10 | volatile | local variables | | D7-D10 | volatile | local variables |
 | D11-D31 | nonvolatile | local variables | | D11-D31 | nonvolatile | local variables |
 | S0,S1 | dedicated| scratch register | | S0,S1 | dedicated| scratch register |
-| S2 | volatile | 1. parameter, return value | +| S2 | volatile | 1. parameter, local variables, return value | 
-| S3-S6 | volatile | further parameters | +| S3-S13 | volatile | further parameters, local variables 
-S7-D21 | volatile | local variables |+S14-S21 | volatile | local variables |
 | S22-S31 | nonvolatile | local variables | | S22-S31 | nonvolatile | local variables |
  
Line 32: Line 31:
 For the translation of certain SSA instructions (e.g. of type long) further auxiliary registers are needed. They are assigned and reserved by the register allocator as well.  For the translation of certain SSA instructions (e.g. of type long) further auxiliary registers are needed. They are assigned and reserved by the register allocator as well. 
  
-==== Parameter Passing ==== +===== Parameter Passing ===== 
-Parameters are passed in R0..R5 and D1..D6.\\ +Parameters are passed in R0..R5 and D2..D6.\\ 
-In the interface //arm/Registers// you can find the definitions about which registers are used for volatiles and nonvolatiles and which are used for parameter passing. Important: the number of parameter registers must be smaller or equal than the number of volatiles. +In the interface //arm/Registers// you can find the definitions about which registers are used for volatiles and nonvolatiles and which are used for parameter passing. Important: the number of parameter registers must be smaller or equal than the number of volatiles. Due to the interleaving of D and S registers in the extension registers, parameters must be carefully copied into the parameter registers. D2 to D6 hold the parameters regardless of the parameter being of type single or double. To give an example. For method //m1(float a, double b, float c, double d)// the four parameters will be passed as follows: 
 +|S0|S1|S2|S3|S4|S5|S6|S7|S8|S9|S10|S11| 
 +|  D0  ||  D1  ||  D2  ||  D3  ||  D4  || D5 || 
 +| ^|  ^^a| ^  b  ^^c| ^  d  ^^
  
-==== Locals on the Stack ====+If the parameters do not fit into the parameter register, they will be passed on the stack in a special parameter block. Note that the block is filled with parameters of type integer (offset increases with parameter number) first. After this parameters of type float and double are pushed into this block. Parameters of type float and double both occupy 8 bytes.  
 + 
 +===== Locals on the Stack =====
 Most SSA instruction have 2 operands and a result. Each of them can reside on the stack. Operands must be fetched into a free register, the result must be stored onto the stack. A single SSA instruction ''sCstoreToArray'' has three operands but no result. Therefore, if stack slots are used, the following registers are reserved and cannot be used freely during register allocation. Most SSA instruction have 2 operands and a result. Each of them can reside on the stack. Operands must be fetched into a free register, the result must be stored onto the stack. A single SSA instruction ''sCstoreToArray'' has three operands but no result. Therefore, if stack slots are used, the following registers are reserved and cannot be used freely during register allocation.
  
Line 55: Line 59:
  
  
 +When dividing numbers of type long, a large number of auxiliary registers are necessary. For these cases the register allocation is run with a reduced register set with the same reserved registers as above given above.
dev/crosscompiler/backend_arm/register_allocation.1544545665.txt.gz · Last modified: 2018/12/11 17:27 by ursgraf