[LLVMdev] Operand constraints

Chris Lattner sabre at nondot.org
Thu Jul 1 12:44:01 PDT 2004

On Thu, 1 Jul 2004, Vladimir Prus wrote:
> On my target, the multiplication can involve all general purpose registers,
> but there's are still some restrictions: the first and the second operand as
> well as the result must be in different registers, and neither register can
> be gr7. How can I enforce this restriction on the register allocator?

This is a good question, one that I don't have a great answer for.  In
order to just get things working for you in the short term, you can just
force the operands into specific physical registers, by outputting a
template like this:

gr5 = reg1024
gr6 = reg1025
gr4 = mul gr5, gr6
reg1026 = gr4

This is obviously not going to generate wonderful code over the long term,
but should work.

In the longer term, we need to increase the expressivity of the register
classes a bit.  In particular we need to be able to support nested
register classes (important on the X86), be able to specify aliasing more
precisely, and be able to handle other strange constraints like you ran
into here.

I imagine that you are more interested in getting things working than
tuning the generated code at this point, but if you get interested in
working on this, please bring it back up :)



More information about the llvm-dev mailing list