language-experts
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[language-experts] SSA like notation on a simple AST


From: Paulo César Pereira de Andrade
Subject: [language-experts] SSA like notation on a simple AST
Date: Tue, 27 Mar 2012 11:39:53 -0300

  Hi,

  I am in the process of a major rewrite of a dynamically typed, "toy"
C/C++ like
language I have been working for quite some time.

  The SSA like notation should make it easy to picture what is being done, and
make it easier to figure out if in a loop, if there is a jump, e.g. goto, etc.

  A simple example could be represented as:

void t(c#0) {
    auto a#0, b#0;

    for (a#1 = b#1 = 0; a#2 < c#0; a#2++)
        b#2 += a#2;

    print("%d\n", b#3);
}

  The advantage for a simple language, besides being tied to the syntax is
that patterns are very simple to follow, e.g. it increases the counter (unique
identifier) on assignment or when the value can come from multiple places
(goto, break on switch, some try/catch construct), and in loops it auto
increments at the jump to restart of the loop, and again when leaving the
loop, if the variable is changed in the loop of course.

  Well, the language is not only dynamically typed, "auto" basically stands
for any numeric value, e.g. convert from integer to mpz on overflow, create
a rational or mpq on non exact division, complex for certain operations, etc.
But it also supports static typing, so, there will also be some type analysis
work in the ast.

  Another issue is that the SSA like notation above is only suited for copy
and constant propagation, so it is required to add some flag/notation for a
PHI like point, where it would spill/reload or register move as appropriate.

  To have an idea of what is being completely rewritten, mostly because it
does not scale well, is just a "playground" and has too much bloat:
https://code.google.com/p/exl/

  Any comments are welcome :-)

Thanks,
Paulo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]