Sun, 05 Dec 2010 21:23:40 +0900

LLVM 2.8 の C API 差分をチェックしてはじめて気づいたけど、2.8 からは Union Type がなくなったみたい。

The LLVM IR 'Union' feature was removed. While this is a desirable feature for LLVM IR to support, the existing implementation was half baked and barely useful. We'd really like anyone interested to resurrect the work and finish it for a future release.

現在の実装は不完全で、また、不足分を実装しメンテする開発者がおらず優先順位も低い、ということが理由のようだ。

It's just a matter of priorities, unfortunately... :(

http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-September/034451.html

Lots of people agree it would be a useful feature, we are lacking a useful implementation :-)

http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-September/034484.html

C/C++ のコードを ActionScript に変換する Adobe Alchemy を試す

Adobe Labs の研究プロジェクト、コードネーム Alchemy を試してみた。同プロジェクトについては、すでに多くの方が書かれており、今更な感もあるが、以前に紹介記事を書いていることだし、備忘録も兼ねて残しておく。

C 言語で書かれたソフトウェアが Flash で動くようになるかもしれない

Running C and Python Code on The Web によると、Adobe の Scott Petersen 氏が大変興味深いツールを開発中のようだ。このツールを使うと、C 言語で書かれたソフトウェアを Flash Player で実行できるようになる。また、このツールはオープンソースで公開されるとのこと。

LLVM で Hello, World の puts 関数

前回のように簡単なプログラムでも、実際に書いてみると疑問が湧いてくる。

まず、文字列を出力している puts 関数。こいつの実体はどこにあるんだろう? C のプログラムなら、リンカが標準ライブラリをこっそりリンクしている、という結末になるのだが...。検索してみると、やはり、同じように疑問をもった人がいるようで、lli が実行時のライブラリとして標準 C ライブラリを利用しているらしい。

ということは printf なんかも使えるはずだよね。

@.LC0 = internal constant [14 x i8] c"Hello world!\0A\00"

declare i32 @printf(i8 *, ...)

define i32 @main() {
  %cast210 = getelementptr [14 x i8]* @.LC0, i64 0, i64 0
  call i32 (i8 *, ...)* @printf(i8 * %cast210)
  ret i32 0
}

では、コンパイル、実行。

% llvm-as -f hello-printf.ll
% lli hello-printf.bc
Hello world!

うんうん。

LLVM で Hello, World

LLVM で Hello, World プログラム。

@.LC0 = internal constant [13 x i8] c"Hello world!\00"

declare i32 @puts(i8 *)

define i32 @main() {
  %cast210 = getelementptr [13 x i8]* @.LC0, i64 0, i64 0
  call i32 @puts(i8 * %cast210)
  ret i32 0
}

バイトコードにコンパイルして実行。

% llvm-as -f hello.ll
% lli hello.bc
Hello world!

まあ、プログラム自体は LLVM Assembly Language Reference Manual からの抜粋なわけだが。

Want fries with that?

Open Source Projects