SlideServe
Menu
Préférences
© SlideServe · v2026

Backward Scan Code Generation with Register and Address Descriptors

nasim-howard avatar
9 diapositives · 194 Views · Oct 26, 2014

Learn how to optimize code by removing dead instructions, updating next-use information, and efficiently utilizing registers.

Backward Scan Code Generation with Register and Address Descriptors - slide 1
01 / 9Backward Scan Code Generation with Register and Address Descriptors
1 / 17

Télécharger la présentation

Backward Scan Code Generation with Register and Address Descriptors
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Rajat Sethi 04CS3022 TARGET CODE -Next Usage

  2. Topics to be covered • Next Use Information • Computation using Backward Scan • Code Generation • Register and Address Descriptor • Algorithm • getreg() function • Example

  3. Next Usage • This technique is employed in dead code optimization. The instructions with no ‘next use’ are removed from the block. • If the name in a register is no longer needed, then the register can be assigned to some other name. • We collect next-use information about names in a basic block. Note that we consider only the variables in the same block.

  4. Backward Scan: statement i : x := y op z STEP 1: Attach to statement i, attribute information of next use of x, y and z. STEP 2: In symbol table, set x to “no next use” and “not live” STEP 3: In symbol table set the next uses of y and z to I and also to “live” NOTE : The orders of Step 2 and Step 3 should not be interchanged because x may be y or z. e.g.:- x := x+1

  5. Register & Address Descriptors Register Descriptor:It keeps track of what is in each register. It is consulted whenever a new register is needed. E.g.: R0 contains t, y, z. Address Descriptor: It keeps tract of the location(s) where the current value of the name can be found at the runtime. The location might be register, stack or memory location.

  6. Code Generation Algorithm • Find space L to store value of x using function getreg(). • For Y, see whether it is stored in L. If yes, perform op Z,L • Else perform mov Y,L; op Z,L • Generate : op Z,L • Update address descriptor of X. If X stored in any other register, remove it. • If the current values of Y and Z have no next use then free the registers. STEP 1 STEP 2 STEP 3 STEP 4

  7. Function getreg(); • STEP 1: If the name y is in a register , that holds the value of no other names (in other words no other names point to the same register as y does), and y is not live and has no next use after the execution of y = x op z, then :- • return L. • Update the address descriptor of y , so that y is no longer in L. • STEP 2: Failing (1), return an empty register for L if it exists. • STEP 3: Failing (2), if x has a next use in the block, or if op requires a register then :- • find an occupied register R. • MOV(R,M) if value of R is not in proper M. If R holds value of many variables, generate a MOV for each of the variables. • STEP 4: Failing (3), select the memory location of x as L.

  8. Example: d=(a-b) + (a-c) + (a-c)

  9. THANK YOU