typescript-llvm

APACHE-2.0 License

Stars
9

Typescript to LLVM Compiler

To get started

  1. Ensure clang is installed.
  2. Install LLVM.
  3. Install WABT.
  4. Run npm install.

To run

npm install
npm run test

Known issues

  1. I had to patch llvm-bindings in a few places. Not all of them have been released yet. E.g. see https://github.com/ApsarasX/llvm-bindings/issues/23.

Some common commands

Assembly to bitcode:

llvm-as x.ll
ls -l x.bc

To compile .ll to machine code:

llc x.ll -filetype=obj
gcc x.o
./a.out

To run optimizer:

opt -Oz -S -o x.Oz.ll x.ll
# --metarenamer - rename everything

To WASM:

llc -mtriple=wasm32-unknown-unknown -O3 -filetype=obj one.ll -o one.o
wasm-ld one.o -o one.wasm -allow-undefined --entry "main"

To see WAT (see wabt):

wasm2wat -o one.wat one.wasm