[llvm-dev] Allocating global variables to physical registers

Dobby HouseElf via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 29 17:34:07 PST 2021


Hello all,
Is it possible to assign specific physical register(s) to a 'special' global variable at the time of code generation phase in LLVM?
Details: I have a Mips-like target and following Cpu0 tutorial, I added my custom backend to LLVM. I have a global variable that I want to use in many places in the program. I define a global variable in the program like, 'test.cpp' - 'int special;'I want to assign / allocate a specific physical register in my backend to this special global variable.
Current status: Using 'llc -debug', I see that during the register allocation (greedy), the address of 'special' variable goes to a general purpose register and then it loads in a random general purpose register. 
I don't know if it is possible what I am trying to do? At which compilation stage should I try?I read somewhere that using 'register' keyword is not good idea.
Thank you very much.Excuse my English.Please help!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210130/5140653d/attachment.html>


More information about the llvm-dev mailing list