08.11.2014 Views

COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX

COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX

COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

eing performed (e.g., multiplication, left solve, right solve) and the shape of a and b. They<br />

are then used to guide the allocation (or reallocation) of the array c, whenever necessary.<br />

Notice that special consideration is taken with scalars when the variable is dynamically<br />

allocated. The problem is that the Fortran 90 operation a b assumes the operands to be<br />

conformable if they are dynamically allocated. Hence, if one of the operands is scalar and<br />

if it is dynamically allocated as a 1 1 array, the operation as written above would result<br />

in an error. Therefore, dynamic rank inference is necessary. As presented in Section 6.2.1,<br />

this dynamic code can be optimized with the use of symbolic-propagation.<br />

3.2.7 Code Generator<br />

The nal phase of the <strong>MATLAB</strong> compiler generates Fortran 90. This pass is also divided<br />

into two steps: the generation of declarations, and the generation of executable code.<br />

The declarations are generated by traversing the symbol table.<br />

Variables that have<br />

unknown intrinsic type at the end of the static phase are declared twice: once for the real<br />

instance of the variable, and once for the complex instance. Variables that have unknown<br />

shape are declared as two-dimensional allocatable arrays. Shadow variables are generated<br />

only for variables that have unknown shape or intrinsic type at the end of the static phase.<br />

The generation of executable code is performed by traversing once more the AST in<br />

lexicographic order. This pass is straightforward because our output language is a high-level<br />

language and, therefore, we do not deal with most of the issues of code generation [ASU85].<br />

Moreover, at this point, all necessary attributes for the code generation have been already<br />

lled by the static and dynamic inference phases.<br />

To maintain compatibility with the <strong>MATLAB</strong> interpreter, whenever possible 7 the compiler<br />

generates function calls from the same libraries used by <strong>MATLAB</strong> (i.e., LINPACK<br />

[DMBS79], LAPACK [ABB + 92], EISPACK [SBD + 76]).<br />

7 The information on which library function is being used by theinterpreter is not always available. Also,<br />

sometimes this information is provided with a note stating that the library function was modied.<br />

31

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

Saved successfully!

Ooh no, something went wrong!