Changes between Version 29 and Version 30 of PIRCDevelopment

Show
Ignore:
Timestamp:
08/09/09 12:35:40 (12 years ago)
Author:
kjs
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PIRCDevelopment

    v29 v30  
    374374The implementation can be found in [source:/trunk/compilers/pirc/src/pirregalloc.c]. Whether or not to use the register optimizer depends on how your program is used. If you have a large program that you will run many times, and memory usage is important, then you should activate it. If, on the other hand, runtime performance (compilation time included) is important, you should not activate it, as it takes additional time to perform the register optimization. In order to activate the register optimizer, use the {{{-r}}} command line option when running PIRC. 
    375375 
    376  
     376For each symbol (PIR register or declared symbol), a [source:/trunk/compilers/pirc/src/pirregalloc.h#L29 live_interval struct] instance is allocated. Most important are the {{{startpoint}}} and {{{endpoint}}} fields, which keep track of the start and end point respectively of the live interval of the variable. Consider the following example: 
     377 
     378{{{ 
     379 
     380  .sub main 
     3810   $I10 = 1 
     3821   $I11 = 2 
     3832   print $I0 
     3843   print $I1 
     385  .end 
     386 
     387}}} 
     388 
     389In this code snippet, the numbers in front of the statements indicate the sequence of instructions. As you can see, {{{$I0}}} lives from 0 to 2, whereas {{{$I1}}} lives from 1 to 3. Since these live intervals are overlapping, this means that these variables cannot share a register. On the other hand, consider the following example: 
     390 
     391{{{ 
     392 
     393   .sub main 
     3940    $I0 = 1 
     3951    print $I0 
     3962    $I1 = 2 
     3973    print $I1 
     398   .end 
     399 
     400}}} 
     401 
     402In this case, {{{$I0}}} lives from 0 to 1, whereas {{{$1}}} lives from 2 to 3. Since they do not overlap, these variables can share a register. This can be calculated by the algorithm described in the above mentioned paper. These details will not be discussed here; instead the reader is referred to the paper. 
    377403 
    378404== Bytecode Generation ==