File List

Files of check-in [60af66d773] in the top-level directory


TclQuadcode

This is a project to develop a compiler for Tcl that produces native code. It does this by translating Tcl code into bytecode, then into quadcode (hence the project's name). That quadcode is analysed and optimized, then translated into LLVM Intermediate Representation, from which native code is issued.

Dependencies

This requires Tcl 8.6, and llvmtcl.

Usage

Write some procedures. Load the code in quadcode.tcl and codegen.tcl in this directory (note that this is not yet a proper package). Now you have the LLVM command:

  • LLVM configure options...

    Configures LLVM. Useful options are -debug, -opt and -time.

    • -debug boolean -- Whether to print debugging information. Off by default.
    • -opt int -- Number of optimization rounds to run.
    • -time int -- The level to perform timing analysis at. Level 0 turns it off. Level 1 is coarse-grained. Level 2 is detailed.
  • LLVM optimise procs...

    Compiles each of the listed procedures (each name is a separate argument). This is the core of this project. The collection of procedures will become a single package (in a Tcl load sense) that is compiled. Note that you can use command globs as well; internally, everything is passed through info commands.

  • LLVM pre

    Returns the LLVM IR generated from the most recent compilation, taken at the point where the IR was about to be fed into the optimizer.

  • LLVM post

    Returns the LLVM IR generated from the most recent compilation, taken after the code was optimized. This is the code that is actually used to drive native code issuing.

If you want to just test-drive the code, check out the demo.tcl script in this directory. It's our current driver and exercises most of the currently-implemented features. There's also a smalldemo.tcl that is a cut-down version.