[llvm-dev] vector instruction

Anastasiya Ruzhanskaya via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 31 06:04:21 PDT 2017


Ok, seems that I simply need to check by isVectorTy()

2017-08-30 9:49 GMT+02:00 Nemanja Ivanovic <nemanja.i.ibm at gmail.com>:

> I'm also not sure what you mean by "its size is a multiple of the operands
> size". An instruction's (encoding) size has no correlation to the size of
> the registers it operates on in a general sense.
>
> So if you're looking for whether an IR instruction is a "vector
> instruction" (i.e. it operates on or produces vectors), you should keep in
> mind that every `llvm::Instruction` is an `llvm::Value` and you can get
> it's type and check if it's a vector type with something like
> `I.getType()->isVectorTy()`.
>
> For MachineInstr's, I think you'd have to ensure that the operand you're
> interested in is a register operand, get the register and check the
> `MachineRegisterInfo::getRegClass()` for whether it's a vector register.
>
> The reason I've put "vector instruction" in quotes is because that of
> course doesn't have a clear definition. For example, is `extractelt` a
> vector instruction? How about `insertelt`? What I'm getting at is if an
> instruction has scalar inputs and vector outputs or vice-versa. Or if the
> instruction has a mixture of vector and scalar operands (think of
> loads/stores - address is likely in a scalar register or perhaps some kind
> of arithmetic binary operator between a vector and a scalar).
>
> On Tue, Aug 29, 2017 at 8:28 PM, Sam Elliott via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> This depends on what you mean by "instruction". More context would have
>> been useful.
>>
>> LLVM IR is typed, and therefore you will see the operation applied to
>> vector-typed arguments. For example `%3 = add i32 %1, %2` is the scalar
>> version, `%3 = add <4 x i32> %1, %2` is the vectorised version (for a given
>> IR vector type). The language reference [] has specifics on which
>> instructions can operate on both vectors and scalars.
>>
>> I don't know anything about MIR.
>>
>> If you're looking at target-specific instructions (such as x86), you
>> should look up the instruction documentation as provided by the
>> manufacturer/ISA)
>>
>> Sam
>>
>> [] https://llvm.org/docs/LangRef.html
>>
>>
>> On 29 Aug 2017, at 2:44 am, Anastasiya Ruzhanskaya via llvm-dev <
>> llvm-dev at lists.llvm.org> wrote:
>>
>> Hello,
>> is there a good way to determine that the instruction is a vector
>> instruction? Or the only way like it's size is multiple of the operands
>> size?
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>>
>> --
>> Archibald Sam Elliott
>> ashe2 at cs.washington.edu
>> PhD Student, PLSE Group
>>
>>
>> _______________________________________________
>> 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/20170831/61b9881c/attachment.html>


More information about the llvm-dev mailing list