On 20 February 2010 00:30, Krasimir Angelov <kr.ange...@gmail.com> wrote:
> I am just curious. What had to be changed in LLVM? Could it be useful
> for other projects using LLVM?

In the C and native code generator back-end GHC stores some variables
permanently in registers for speed reasons due to how frequently they
are accessed ('pinned registers'). The variables stored are the STG
virtual registers (so pinning them turns them into real registers)
which define a stack pointer, heap pointer.. ect for Haskells
execution model.

LLVM doesn't support reserving a register in this way for exclusive
use. Instead of changing LLVM to support this feature directly, I
added a new calling convention which passes the arguments in the same
hardware registers that GHC normally uses. This has the advantage that
it while it keeps the STG virtual registers in the correct hardware
registers across call boundaries, inside a call LLVM can allocate
registers in the most efficient manner (which may be simply leaving
them in the registers and never spilling). It's also compatible with
the other code generators.

If you want more info Chris Lattner (main LLVM guy) wrote some notes
up on it based on a brief email conversation the two of us had:

http://www.nondot.org/sabre/LLVMNotes/GlobalRegisterVariables.txt

I don't know if this would be useful for other projects, its fairly
specific so probably not although I have seen other people asking
about it on the LLVM mailing list though and referring to the approach
that I took.

_______________________________________________
Cvs-ghc mailing list
Cvs-ghc@haskell.org
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to