[LLVMdev] RFC: ErLLVM - An LLVM backend for Erlang

Yiannis Tsiouris gtsiour at softlab.ntua.gr
Sat Apr 14 15:49:41 CDT 2012


Hi,

We 've been working on an LLVM backend for High Performance Erlang (HiPE) [1],
the native code compiler of Erlang/OTP [2]. ErLLVM [3] targets the X86 and AMD64
architectures for now but there is some ongoing work from a team on the Uppsala
University to also support ARM.  In our implementation, we have paid special
attention on retaining ABI-compatibility with the Erlang Runtime System in order
to support loading both HiPE- and ErLLVM-generated code at the same time.

Currently, our work is supported by the Erlang/OTP team and it has reached a
complete and robust state. Thus, we would like to submit some patches to the
LLVM project to support our work on ErLLVM.

Our patches (applied on current Git ToT as of: "5e5c5f8 Rename 'fpaccuracy'
metadata to the more generic 'fpmath'...") involve:

1) A new calling convention (& register pinning as explained in [4]).

Touches:
- include/llvm/CallingConv.h
- lib/Target/X86/X86CallingConv.td
- lib/Target/X86/X86ISelLowering.cpp
- lib/Target/X86/X86RegisterInfo.cpp
&&
- lib/Target/X86/X86RegisterInfo.td

2) A pass to add custom prologue when needed (that performs a stack check and
inserts a call to a BIF, named "inc_stack_0", from the HiPE Runtime to increase
the available stack of a function frame).

Touches/Adds:
- include/llvm/Target/TargetOptions.h
- tools/llc/llc.cpp
&&
- include/llvm/Erlang.h
- include/llvm/Target/TargetFrameLowering.h
- lib/CodeGen/PrologEpilogInserter.cpp
- lib/Target/X86/X86FrameLowering.cpp
- lib/Target/X86/X86FrameLowering.h

3) A GC plugin to support precise Garbage Collection (with the problems
explained in a previous mail [5]).

Touches/Adds:
- include/llvm/ErlangGC/ErlangGCPrinter.h
- lib/ErlangGC/ErlangGC.cpp
- lib/ErlangGC/ErlangGCPrinter.cpp
- lib/ErlangGC/Makefile
- lib/Makefile

The commit messages and the comments in the code should explain a lot; however,
feel free to ask anything that doesn't make any sense for you! :-)

We 're looking forward to any feedback for the above patches as we would love to
get this included in LLVM so that we don't need to carry around our own version
of LLVM. We are aware that some of the patches might not adhere to the "LLVM
way" of handling things or even include some coding style violations. As Tom
Stellard indicated in his R600 mail too, we didn't want to spend a lot of time
on coding style changes prior to the initial review in case big changes to the
code are needed.

Best regards,
The ErLLVM team

[1]: http://www.it.uu.se/research/group/hipe
[2]: http://www.erlang.org
[3]: http://erllvm.softlab.ntua.gr
[4]: http://nondot.org/sabre/LLVMNotes/GlobalRegisterVariables.txt
[5]: http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-April/048685.html

--
Yiannis Tsiouris
Ph.D. student,
Software Engineering Laboratory,
National Technical University of Athens
WWW: http://www.softlab.ntua.gr/~gtsiour
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Implemented-HiPE-Calling-Convention-1-2.patch
Type: text/x-diff
Size: 9439 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20120414/8f74d2b5/attachment-0005.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Implemented-HiPE-Calling-Convention-2-2.patch
Type: text/x-diff
Size: 1255 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20120414/8f74d2b5/attachment-0006.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-HiPE-prologue-code-emission-for-X86-as-a-pass-1-2.patch
Type: text/x-diff
Size: 2363 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20120414/8f74d2b5/attachment-0007.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-HiPE-prologue-code-emission-for-X86-as-a-pass-2-2.patch
Type: text/x-diff
Size: 7838 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20120414/8f74d2b5/attachment-0008.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-A-Garbage-Colleciton-plugin-for-HiPE-s-gc-scheme.patch
Type: text/x-diff
Size: 13158 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvmdev/attachments/20120414/8f74d2b5/attachment-0009.bin 


More information about the LLVMdev mailing list