Asm inline and integer

Hi,

I’m working on my own llvm backend.
I’m trying to generate an instruction that takes a integer as an operand by using llvm asm inline.
I have something like that:

asm (“add %%r0, %%r1, %0” : : “i” (3));

And I expect llvm to generate:

add %r0, %r1, 3

But instead, llvm generates:

mov %r2, 3
add %r0, %r1, %r2

Did someone already have the same kind of issue?
What should I do in my backend to get to the expected format?

Thanks,
Romaric

Hi Romaric,

Did someone already have the same kind of issue?
What should I do in my backend to get to the expected format?

The main function involved in this mapping is
LowerAsmOperandForConstraint. It looks like the generic code in
lib/CodeGen/SelectionDAG/TargetLowering.cpp handles 'i', so maybe
you've implemented that function in your backend for some constraints
but don't delegate to the original implementation at the end?

Cheers.

Tim.