LLVM 導入覚書
LLVM (Low Level Virtual Machine) を導入するための覚書です。
Windows の Visual Studio でビルドする方法
CMake のサイトからインストーラ cmake-2.8.4-win32-x86.exe をダウンロードし、インストールします。C:\Program Files\Cmake 2.8\bin にパスを通しておきます。
LLVM のサイトからソースパッケージ llvm-2.8.tgz をダウンロードして展開します。
Visual Studio のコマンドラインプロンプトを開き、LLVM のソースパッケージを展開したディレクトリに入って以下のコマンドを実行します。
> mkdir build-msc
> cd build-msc
> cmake ..
> nmake
これで、build-msc\bin にツールの実行ファイル、build-msc\lib にライブラリファイルが生成されます。
テストをします (http://d.hatena.ne.jp/propella/20110224/p1 から拝借)。
; hello.ll
@hello = internal constant [13 x i8] c"hello, world\00"
declare i32 @puts(i8*)
define i32 @main() {
start:
%0 = call i32 @puts(i8* getelementptr inbounds ([13 x i8]* @hello, i32 0, i32 0))
ret i32 0
}
> llvm-as hello.ll
> lli hello.bc
最近のコメント