[llvm-dev] [X86] How to query for Opcode type?

Nivas Valli via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 20 22:09:36 PDT 2017


I did look at the suggested functions. I am calling those functions on a
MachineInstr that I created by hand in my tool.

For example, I created an MachineInstr (whose dump is as follows)

(lldb) call mi.dump()

  MOV32mr %RBP, 1, %noreg, -12, %noreg, %EDI

corresponding to

mov dword ptr [rbp - 12], edi

I thought a call  subTargetInstrInfo->isStoreToStackSlot(mi, 0); would
return true

but X86InstrInfo::isFrameOperand() fails because MI.getOperand(Op + X86::
AddrBaseReg).isFI() fails.

May be my construction of the mi (as well as my understanding) is
incomplete.

Any additional nudges are very much appreciated.

Thanks!

On Fri, Oct 20, 2017 at 8:41 PM, Craig Topper <craig.topper at gmail.com>
wrote:

> Isn't X86InstrInfo::isLoadFromStackSlot and X86InstrInfo::isStoreToStackSlot
> what's you're looking for?
>
> ~Craig
>
> On Fri, Oct 20, 2017 at 8:30 PM, Nivas Valli via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> Hi,
>>
>> I would like to query the X86InstrInfo tables to determine if a given
>> opcode is a load or store from stack. I see functions isFrameLoadOpcode and isFrameStoreOpcode
>> in lib/Target/X86/X86InstrInfo.cpp that would provide the functionality
>> I am looking for.
>>
>> However, these functions are static.
>>
>> What is the recommended way to perform such queries for a MachineInstr -
>> short of replicating the logic from X86InstrInfo.cpp in my tool that links
>> to llvm libraries?
>>
>> Thanks,
>>
>> Bharadwaj
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171020/e4d85818/attachment.html>


More information about the llvm-dev mailing list