[LLVMdev] Problem in X86 backend (original) (raw)
Tim Northover t.p.northover at gmail.com
Mon Oct 27 07:42:13 PDT 2014
- Previous message: [LLVMdev] Problem in X86 backend
- Next message: [LLVMdev] Problem in X86 backend
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
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 :(
I find the best way to do this when I'm unsure is to get the llvm-mc tool to assemble my instruction and copy what it produces. Your instruction is actually ambiguous though: you need to say what size you want the store to be. I'll assume 32-bit:
$ echo "mov dword ptr [rdi], 0" | llvm-mc -x86-asm-syntax=intel -output-asm-variant=1 -show-inst mov dword ptr [rdi], 0 ## <MCInst #1611 MOV32mi ## ## ## ## ## ## >
Now, that looks complicated, but x86 has uniform memory addressing-modes: those first 5 operands are just specifying that address and you only have to learn about them once; and the last operand is the "0" you've written (try playing around a bit with the input).
As for the addressing, the meaning of each operand is given at the top of lib/Target/X86/X86BaseInfo.h: 0 == Base, 1 == Scale, 2 == Index, 3 == Disp, 4 == Segment.
Cheers.
Tim.
- Previous message: [LLVMdev] Problem in X86 backend
- Next message: [LLVMdev] Problem in X86 backend
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]