[LLVMdev] Problem in X86 backend

Tim Northover t.p.northover at gmail.com
Mon Oct 27 07:54:14 PDT 2014


>> I want to add this instruction in one of my machine basic block: mov [rdi], 0
>> How can I achieve that with the LLVM api? I tried several stuff, but none works :(

Just realised I didn't actually answer your question after that
explanation. Something like this should work:

BuildMI(MBB, MBBI, dl, TII.get(X86::MOV32mi))
    .addReg(X86::RDI).addImm(1).addReg(0).addImm(0).addReg(0)
    .addImm(0);

All the operands are outside the BuildMI because the register operand
you often put inside is actually one the function defines, but this
store doesn't actually change RDI itself.

(You may want to add a RegState::Kill if that's the last use of RDI).

Cheers.

Tim.



More information about the llvm-dev mailing list