I have got an address by mmap. And I want to build a MachineInstr of MOV64mr to move a value to the address. But it seems that the MachinePointerInfo needs a pointer to a Value.
So can I create a MachineMemOperand directly with the address (is a long*) ? Or I need to try some other methods?
Thanks for your advice. But I have searched X86 and find no more information than I have known.
The problem is not to create a MachineMemOperand, but to create a MachineMemOperand with certain address. This scene does not exist in the original code.
Since I have to do this in the process of register allocating, inserting IR instruction seems to be infeasible. I have thought of storing the address in a global variable in the IR, and loading it afterwards. But it seems to be improper as mentioned before.
May I do not create a MachineMemOperand, just store the address in a register, and use some MachineInstr to store the value to the address?
MachineMemOperands are used to tell compiler optimizations where a
memory instruction will access. It's not the actual representation
used to tell the CPU where to load or store. So you can conservatively
create a dummy one that essentially tells LLVM "this may write
anywhere" and your program will compile correctly.
To do that you'd write something like
"MF->getMachineMemOperand(MachinePointerInfo(),
MachineMemOperand::MOStore, 0, 1)". I've not tested this in code, so
you may have to tweak it.