Converting LLVM IR to JavaScript

In this recipe, we will briefly discuss how we can convert LLVM IR to JavaScript.

Getting ready

To convert IR to JavaScript, perform the following steps:

  1. We will make use of the emscripten LLVM to JavaScript compiler. You need to download the SDK provided at https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html . You can also build it from the source code, but just for experimenting, you can use the SDK that comes with the toolchain.
  2. After downloading the SDK, extract it to a location and go to the root folder of the download.
  3. Install the default-jre, nodejs, cmake, build-essential, and git dependencies.
  4. Execute the following commands to install the SDK:
    ./emsdk update
    ./emsdk install latest

Get LLVM Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.