Skip to content

A cross-platform, cross-language platform for building compilers

License

LGPL-2.1, GPL-2.0 licenses found

Licenses found

LGPL-2.1
COPYING.LESSER
GPL-2.0
COPYING
Notifications You must be signed in to change notification settings

jayconrod/tungsten

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tungsten is a framework for building compilers. It is currently under
active development by Jay Conrod.

==Overview==

Tungsten provides a high level intermediate language, which a
compiler can use to represent code. A compiler writer can write a
front-end which translates source code into Tungsten. Tungsten files
can then be translated to lower level representations, such as LLVM or
JVM bytecode, using a backend.

Example workflow:

+---------------------+
|int f(int x, int y) {|  Source code
|  return x + y;      |
|}                    |
+---------------------+
  |
  | C front-end
  v
+--------------------------------------+
|function unit @f(int64 %x, int64 %y) {|
|  block %entry {                      |
|    int64 %sum = int64 %x + int64 %y  |
|    return int64 %sum                 |
|  }                                   |
|}                                     }
+--------------------------------------+
  |
  | LLVM back-end
  v
+-------------------------------+
|define i64 @f(i64 %x, i64 %y) {|
|  %sum = add i64 %x, i64 %y    |
|  ret i64 %sum                 |
|}                              |
+-------------------------------+

Tungsten is similar in purpose to LLVM, but it does not replace LLVM.
Tungsten is a higher level representation: it directly supports
classes, interfaces, virtual methods, type parameterization, and other
abstractions. This adds interoperability to code written in multiple
languages, as long as a Tungsten front-end exists in language. 

See the examples directory for examples of the Tungsten language.

==Building and installing==

You'll need Apache Buildr to install Tungsten. You'll also need a
working JVM. Tungsten has been tested on 32-bit and 64-bit Linux and
Mac OS X. Other platforms are unsupported. You may also want to
install LLVM 2.8 to take advantage of the LLVM backend, although
nothing depends on it directly.

To install Buildr, follow the instructions at:
http://buildr.apache.org/installing.html

Once Buildr is installed, run the following command:

 buildr install

This will download all build and runtime dependencies, compile
Tungsten and the LLVM backend, run unit tests, create .jar files, and
install them to ~/.m2/repository.

==Running==

Once Tungsten is installed, source the setenv.sh script to set your
environment variables:

 . setenv.sh

This will set PATH, and CLASSPATH to include necessary tools and
classes.

To assemble a file:
 w-as file.w

To disassemble a file:
 w-dis file.wo

To link files into a program:
 w-link -t program foo.wo bar.wo -o prog.wp

To convert to LLVM:
 w-to-llvm file.wo

About

A cross-platform, cross-language platform for building compilers

Resources

License

LGPL-2.1, GPL-2.0 licenses found

Licenses found

LGPL-2.1
COPYING.LESSER
GPL-2.0
COPYING

Stars

Watchers

Forks

Packages

No packages published