[llvm-dev] New to LLVM. Need help getting available register

David Greene via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 18 17:22:48 PST 2019


It would help if you can describe in more detail what you are trying to do.
In which phase of the compiler is this being done?  What is your ultimate
goal?

I would not look to unit tests as good examples of how to do things.  They
are specifically designed to pinpoint small bits of functionality and often
rare corner cases.  It's possible the bit of code you're looking at is actually
testing that the assertion triggers.

                                     -David

________________________________________
From: Josh Sharp <mm92126 at hotmail.com>
Sent: Saturday, February 16, 2019 8:38:53 PM
To: David Greene
Cc: via llvm-dev
Subject: Re: [llvm-dev] New to LLVM. Need help getting available register

Is it possible to get a virtual register and then use that to create a real register? I've seen it done in unittests/CodeGen/MachineInstrTest.cpp like this:

unsigned VirtualDef1 = -42;
  VD1VU->addOperand(*MF,
                    MachineOperand::CreateReg(VirtualDef1, /*isDef*/ true));


But when I do that in my code I get an assertion so I wasn't sure if it's legal or not.
Thanks.

________________________________
From: David Greene <dag at cray.com>
Sent: Wednesday, January 2, 2019 9:23 AM
To: m m
Cc: via llvm-dev
Subject: Re: [llvm-dev] New to LLVM. Need help getting available register

m m via llvm-dev <llvm-dev at lists.llvm.org> writes:

> I'm new to LLVM. I'd like to know if there is a method I can call
> whenever I need any available CPU register.

Take a look at RegisterScavenging.  Of course, this only works after
register allocation.  Before register allocation you'd just create a new
virtual register.

                              -David


More information about the llvm-dev mailing list