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:
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.After downloading the SDK, extract it to a location and go to the root folder of the download.
Install the
default-jre
,nodejs
,cmake
,build-essential
, andgit
dependencies.Execute the following commands to install the SDK:
./emsdk update ./emsdk install latest ./emsdk activate latest
See the
~/emscripten
script to check whether it has the correct values, and if not, update it accordingly.
How to do it…
Perform the following steps:
Write the test code for the conversion:
$ cat test.c #include<stdio.h> int...