Standard libraries
POET includes many useful libraries,
such as front ends to C/C++/Fortran and AST transformations for a large number of well-known loop optimizations (e.g., loop blocking and parallelization). It has been used to
support the transformation needs of both popular programming languages such as C/C++, Java, FORTRAN, and several domain-specific languages that we have designed on the fly for various purposes.
Language features
POET borrows concepts and syntax from several languages including C, lisp, and html.
The following is a hello world program from the POET tutorial.
<parameter inputFile type=STRING default="" message="input file name" />
<parameter outputFile type=STRING default="" message="output file name" />
<input syntax="Cfront.code" from=inputFile to=inputCode />
<output syntax="Cfront.code" from=inputFile to=outputFile />
Key Language Features
A key design objective of POET is to dynamically support the parsing/unparsing of arbitrary
programming languages and to provide full programming support for defining arbitrary
transformations to the input code.
The language targets both source-to-source compiler optimizations (e.g.,
automatic parallelization and loop transformations) and domain-specific program analysis
and code generation, via the following key language features.
- Ability to dynamic parse/unparse arbitrary programming languages
POET is language neutral and uses syntax specifications defined in external files to dynamically process
different input/output languages. Transforming a different programming language simply
requires using an alternative language syntax specification file.
- Convenience of expressing arbitrary program transformations
In POET, program transformations are defined as xform routines which take a collection of input data and return
the transformed code as result. These routines can use arbitrary control-flow such as
conditionals, loops, and recursive function calls, can build compound data structures such as
lists, tuples, hash tables, and code templates, and can invoke many built-in operations (e.g.,
pattern matching, AST replacement and replication) to operate on the input code.
- Parameterization of transformation scripts
Each POET script can define a large collection of command-line parameters to dynamically
modify its behavior. A single POET script therefore can be used to dynamically produce
a wide variety of different output, effectively allowing different software implementations be
manufactured on demand based on different feature requirements.
- Composition and Tracing of Transformations
POET provides trace handles, which can be used to automatically keep track of
various code fragments as the input code goes through different transformations. The tracing
capability makes the composition of different transformations extremely flexible, where
transformation orders can be easily adjusted or even dynamically tuned.
- Flexibility and ease of use
A POET program can include an arbitrary number of different files, each of which consists of a sequence of global declarations and commands. The
declarations serve to specify attributes of special-purpose global names. The static
and local variables do not need to be declared before used, and their scopes are limited
within the files or the code template/xform routines that contain them. All variables can
dynamically hold arbitrary types of values. An extensive collection of built-in operations
are provided to easily construct, analyze, and modify internal representations of different
programming languages to satisfy the development needs of building customized program
transformations and domain-specific code generators.