Register variables

Hello!

I have been considering using LLVM for my compiler project for some time now, and have been extensively researching its capabilities. However, I have come to a sticking point that I cannot solve.

My language is a multi paradigm language, but with the emphasis on “functional”. As such, it is expected that programs will allocate a lot of small, short-lived data. This means, in particular, that allocations have to be very fast - increase the heap pointer and check for heap overflow. However, I have not yet found a way to tell the LLVM compiler to keep a global variable in a register at all times (except when using some foreign calling convention, when all registers are saved on the stack). Another reason that I would like to keep the current heap pointer in processor registers is that my language will support multi-threading, with every thread having its own heap (there will be a global heap, too, but allocations will be more expensive). Therefore, I cannot use a global memory location for the heap pointer, as it has to be different for every thread on the system.

If any of you has any ideas how to solve this issue, please tell me. I have also looked at some other projects (C–, and some other implementations of compilers for functional languages), but have not yet found anything useful.

  • Tom Primožič

Wouldn't a thread-local global variable solve your problem?

Best regards,
--Edwin