QBE
言語実装
https://c9x.me/compile/
https://c9x.me/git/qbe.git
C言語で書かれたコンパイラバックエンド。LLVMのようなもの。
コンパクトに書かれているらしく、理解と改変が容易とのこと。
QBEに投げる中間言語は以下
code:il.txt
function w $add(w %a, w %b) { # Define a function add
@start
%c =w add %a, %b # Adds the 2 arguments
ret %c # Return the result
}
export function w $main() { # Main function
@start
%r =w call $add(w 1, w 1) # Call add(1, 1)
call $printf(l $fmt, w %r, ...) # Show the result
ret 0
}
data $fmt = { b "One and one make %d!\n", b 0 }
https://gitlab.com/cznic/qbe
GoでQBEを扱うパッケージとのこと。
中で ecc という Go で書かれたコンパイラでビルドしてるので、実質C並みに速い。
gcc より速い結果が出ているとのこと ↓
https://docs.google.com/spreadsheets/d/1wf7p_1WWwLiXSbfu7gI7aBNexhwWC-tuR2FqaNnOKTs/edit#gid=0
https://sr.ht/~mcf/cproc/
qbeをバックエンドに使用して書かれたC11のコンパイラ
QBEで覗き穴最適化
https://briancallahan.net/blog/20220330.html
Wiki - QbeNotes
https://wiki.alopex.li/QbeNotes
Ver1.0に達したのをきっかけに書かれたQBEに関するメモ
https://c9x.me/compile/logo.png
#言語実装