[LLVMdev] how to use "new instruction()"

zhi chen zchenhn at gmail.com
Thu Apr 16 19:06:26 PDT 2015


Sorry, I mean change the scalar instructions to vector ones.

On Thu, Apr 16, 2015 at 7:05 PM, zhi chen <zchenhn at gmail.com> wrote:

> Thanks, Tim. What I want to do is to change the scalar instructions to
> scalar ones.
>
> For example, if I have to the following one:
>
> %3 = fadd double %1, double %2
>
> I want to change it into
> %6 = fadd <2 x double> %4, double %2.
>
> I understand that I can detect the operation first, and use "create" to
> create for each of them. But I don't if there is a generic way to do this
> because if might be add/sub/mul... operations. Clone is not gonna be
> helpful here because the result type (it is vectortype) should be different
> to the one being cloned (it is scalar). Any idea about how to do this?
> Thanks again.
>
> Best,
> Zhi
>
> On Thu, Apr 16, 2015 at 6:16 PM, Tim Northover <t.p.northover at gmail.com>
> wrote:
>
>> On 16 April 2015 at 17:53, zhi chen <zchenhn at gmail.com> wrote:
>> > Thanks Jonathan. I knew this document. But I didn't understand the
>> "unsigned
>> > iType, Use *Ops" fields. Could you please help how I can create a new
>> > instruction to do the example I was giving? Thanks for your time in
>> advance.
>>
>> You can't. Instruction's constructor is protected so you can't use it
>> outside implementing a new Instruction no matter how well you
>> understood its parameters.
>>
>> But, for the record:
>>   + "it" is to support LLVM's runtime type identification substitutes
>> (cast<Ty>, dyn_cast<Ty> and isa<Ty> mostly). I don't think the
>> permitted values are documented in one place, they're mostly an
>> implementation detail.
>>   + "Ops" are the operands: in "add %2, %3" they'd be "%2" and "%3"
>> (or rather, pointers to instances of Value with those names).
>>
>> What are you really trying to do  (and why)? It's entirely possible
>> Instruction::clone isn't what you want, but we can't give better
>> advice without more details.
>>
>> Cheers.
>>
>> Tim.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150416/869ee40d/attachment.html>


More information about the llvm-dev mailing list