1 / 14

Supposons que l’on dispose de 4 registres ARM

Supposons que l’on dispose de 4 registres ARM. Considérons le code C suivant w = a + b; x = c + w; y = c + d;. Allocation Naïve. début fin de vie. Durée de vie. Une variable est assignée à un registre : il nous faudrait 7 registres Comment améliorer ce résultat ?

Download Presentation

Supposons que l’on dispose de 4 registres ARM

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Supposons que l’on dispose de 4 registres ARM • Considérons le code C suivant w = a + b; x = c + w; y = c + d;

  2. Allocation Naïve début fin de vie Durée de vie • Une variable est assignée à un registre : il nous faudrait 7 registres • Comment améliorer ce résultat ? • Construction du graphe de durée de vie des variables w = a + b; blabla … … x = c + w;

  3. Durée de vie des variables : 2 w = a + b; /*1*/ x = c + w; /*2*/ y = c + d; /*3*/ MAX = 3 MAX

  4. Résoudre le problème d’allocation b a w x y c d

  5. Résoudre le problème d’allocation b a w x y c d b a w x y c d • Coloriage de graphe - NP Problem

  6. Durée de vie des variables w = a + b; /*1*/ x = c + w; /*2*/ y = c + d; /*3*/ LDR R0,[p-a] ;load a into R0 using pointer to a (p-a) LDR R1,[p-b] ;load a into R1 ADD R3,R0,R1 ;compute a+b STR R3,[p-w] ;w=a+b LDR R1,[p-c] ;load c into R1 ADD R0,R1,R3 ;compute c+w, reusing R0 for x STR R0,[p-d] ;x=c+w LDR R0,[p-d] ;load d into R0 ADD R3,R1,R0 ;compute c+d, reusing R3 for y STR R3,[p-y] ;y=c+d

  7. Problèmes interdépendants Allocation des registres Ordonnancement

  8. Interdépendance avec l’ordonnancement MAX MAX = 5 w = a + b; /*1*/ x = c + d; /*2*/ y = x + e; /*3*/ Z = a – b; /*4*/

  9. interdépendance • On dispose que de 3 registres • Recharger des variables

  10. Comparaison w = a + b; /*1*/ x = c + d; /*2*/ y = x + e; /*3*/ Z = a – b; /*4*/ LDR R0,a LDR R1,b ADD R2,R0,R1 STR R2,w LDR R0,c LDR R1,d ADD R2,R0,R1 STR R2,x LDR R1,e ADD R0,R1,R2 STR R0,y LDR R0,a LDR R1,b SUB R2,R1,R0 STR R2,z

  11. Modification de l’ordonnancement w = a + b; /*1*/ x = c + d; /*2*/ y = x + e; /*3*/ Z = a – b; /*4*/ w = a + b; /*1*/ Z = a – b; /*2*/ x = c + d; /*3*/ y = x + e; /*4*/

  12. Interdépendance avec l’ordonnancement MAX MAX = 3 w = a + b; /*1*/ Z = a – b; /*2*/ x = c + d; /*3*/ y = x + e; /*4*/ Modification de l’ordonnancement

  13. Comparaison w = a + b; /*1*/ Z = a – b; /*2*/ x = c + d; /*3*/ y = x + e; /*4*/ LDR R0,a LDR R1,b ADD R2,R0,R1 STR R2,w SUB R2,R0,R1 STR R2,z LDR R0,c LDR R1,d ADD R2,R1,R0 STR R2,x LDR R1,e ADD R0,R1,R2 STR R0,y

  14. Comparaison w = a + b; /*1*/ x = c + d; /*2*/ y = x + e; /*3*/ Z = a – b; /*4*/ LDR R0,a LDR R1,b ADD R2,R0,R1 STR R2,w LDR R0,c LDR R1,d ADD R2,R0,R1 STR R2,x LDR R1,e ADD R0,R1,R2 STR R0,y LDR R0,a LDR R1,b SUB R2,R1,R0 STR R2,z w = a + b; /*1*/ Z = a – b; /*2*/ x = c + d; /*3*/ y = x + e; /*4*/ LDR R0,a LDR R1,b ADD R2,R0,R1 STR R2,w SUB R2,R0,R1 STR R2,z LDR R0,c LDR R1,d ADD R2,R1,R0 STR R2,x LDR R1,e ADD R0,R1,R2 STR R0,y

More Related