[llvm-dev] MIR instruction size

Matthias Braun via llvm-dev llvm-dev at lists.llvm.org
Thu Apr 20 14:55:28 PDT 2017


No,
X86 instructions are variable size. Depending on which registers are allocated or what sized immediate an instruction variant takes you may need additional rex/rex.w prefixes immediate bytes etc.
There is no API today that would answer that question, and even if there were it would be a dangerous API as later passes could change the size just by swapping some registers.

- Matthias

> On Apr 20, 2017, at 11:28 AM, Ilya Skapenko via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hello,
> Is there any common way to determine a size of MIR instruction? I've tried both: MachineInstr::getDesc().getSize() and TargetInstrInfo::getInstSizeInBytes(I), and unfortunately, both interfaces can't determine instruction sizes for x86_64, though they could do it for arm architecture.
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list