Hong Hu via llvm-dev
2019-Apr-22 20:21 UTC
[llvm-dev] How to reliably get memory operand size
Hi All, I'm working on a MIR pass that tries to duplicate memory operation instructions. For example, if there is a move instruction "movq (%rax), %rbx", I will insert another MIR instruction before it. For other instructions, like add, sub, I also insert a mov instruction. Now my question is, is there any way to obtain the size of the memory operation? in the given example, the size should be 8, while for "movslq (%rax), %tbx)", the size should be 4. I have tried memoperand size, but apparently the memoperand is optional and is not necessarily always there. So other than parsing the opcode, do we have any reliably way to get the memory operation size? Thanks in advance. Regards, Hong Hu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190422/b23e67e5/attachment.html>
Francis Visoiu Mistrih via llvm-dev
2019-Jul-24 20:32 UTC
[llvm-dev] How to reliably get memory operand size
Hi,> On Apr 22, 2019, at 1:21 PM, Hong Hu via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi All, > > I'm working on a MIR pass that tries to duplicate memory operation instructions. For example, if there is a move instruction "movq (%rax), %rbx", I will insert another MIR instruction before it. For other instructions, like add, sub, I also insert a mov instruction. > > Now my question is, is there any way to obtain the size of the memory operation? in the given example, the size should be 8, while for "movslq (%rax), %tbx)", the size should be 4.As far as I know, every target has its own way of doing this. For AArch64, we have AArch64InstrInfo::getMemOpInfo which can give you the width. Maybe on X86 you can use things from llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h for this. +Craig for X86.> > I have tried memoperand size, but apparently the memoperand is optional and is not necessarily always there. So other than parsing the opcode, do we have any reliably way to get the memory operation size?Right, the memoperands are not always there. Sorry for the very late answer, — Francis> > Thanks in advance. > > Regards, > Hong Hu > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev