21.01.2013 Views

Lecture Notes in Computer Science 4917

Lecture Notes in Computer Science 4917

Lecture Notes in Computer Science 4917

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

134 M. Cornero et al.<br />

Fig. 2. Structure of the GCC compiler<br />

This is a very clean way to describe the target, but when the compiler needs<br />

<strong>in</strong>formation that is difficult to express <strong>in</strong> this fashion, GCC developers have not<br />

hesitated to def<strong>in</strong>e an ad-hoc parameter to the mach<strong>in</strong>e description. The mach<strong>in</strong>e<br />

description is used throughout RTL passes.<br />

RTL is the lowest level GCC <strong>in</strong>termediate representation; <strong>in</strong> RTL<br />

– each <strong>in</strong>struction is target-specific and it describes its overall effects <strong>in</strong> terms<br />

of register and memory usage;<br />

– registers may be physical as well as virtual registers, freely <strong>in</strong>ter-mixed (until<br />

register allocation pass is run, which leaves no virtual registers);<br />

– memory is represented through an address expression and the size of the<br />

accessed memory cell;<br />

– f<strong>in</strong>ally, RTL has a very low-level representation of types, which are called<br />

mach<strong>in</strong>e modes. They correspond to the typical mach<strong>in</strong>e language representation<br />

of types, which only <strong>in</strong>cludes the size of the data object and the<br />

representation used for it.<br />

CIL bytecode is much more high-level than a processor mach<strong>in</strong>e code. CIL is<br />

guaranteed by design to be <strong>in</strong>dependent from the target mach<strong>in</strong>e and to allow<br />

effective just-<strong>in</strong>-time compilation through the execution environment provided<br />

by the Common Language Runtime. It is a stack-based mach<strong>in</strong>e, it is strongly<br />

typed and there is no such a concept as registers or frame stack; <strong>in</strong>structions<br />

operate on an unbound set of locals (which closely match the concept of local<br />

variables) and on elements on top of an evaluation stack.<br />

We <strong>in</strong>itially considered writ<strong>in</strong>g a standard GCC back-end. However. much of<br />

the high-level <strong>in</strong>formation needed to dump CLI is lost at RTL level, whereas<br />

there is a good semantic fit between GIMPLE and CLI . It seemed awkward to<br />

augment a lowered representation with high-level <strong>in</strong>formation.<br />

Thus, we decided to stop the compilation flow at the end of the middle-end<br />

passes without go<strong>in</strong>g through any RTL pass, and to emit CIL bytecode from<br />

GIMPLE representation (see Figure 2).<br />

We wrote three specific CLI passes:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!