[llvm-dev] 回复:RE: How to change IR type?

Yafei Liu via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 18 02:31:06 PDT 2019


>From my experience, you'd better create a new one, for example:

int i[] = {1,2,3};

in my compiler I first create an array type with length is 0, then create a
new type which length is 3 after the initializer is evaluated.

I tried the API mutateType, but it doesn't work as expected. So just delete
the old one and create a new one.

That's my suggestion.

On Wed, Oct 16, 2019 at 7:19 PM Celine via llvm-dev <llvm-dev at lists.llvm.org>
wrote:

> Thank you very much for this information~
>
>
> ------------------ 原始邮件 ------------------
> *发件人:* "Krzysztof Parzyszek"<kparzysz at quicinc.com>;
> *发送时间:* 2019年10月15日(星期二) 晚上8:34
> *收件人:* "Celine"<595602881 at qq.com>; "llvm-dev"<llvm-dev at lists.llvm.org>;
> *主题:* RE: [llvm-dev] How to change IR type?
>
> In general you can use Value::mutateType to change the type of a value.
> You can’t change the types arbitrarily though, I think that the operands to
> “add” still need to have the same type.
>
>
>
> --
>
> Krzysztof Parzyszek  kparzysz at quicinc.com   AI tools development
>
>
>
> *From:* llvm-dev <llvm-dev-bounces at lists.llvm.org> *On Behalf Of *Celine
> via llvm-dev
> *Sent:* Tuesday, October 15, 2019 5:25 AM
> *To:* llvm-dev <llvm-dev at lists.llvm.org>
> *Subject:* [EXT] [llvm-dev] How to change IR type?
>
>
>
> hello,
>
>
>
> I want to change the following IR:
>
>   %2 = tail call i16 @llvm.nvvm.read.ptx.sreg.tid.x() #2
>   %add = add i16 %mul6, %2
>
> to
>
>   %2 = tail call i16v @llvm.nvvm.read.ptx.sreg.tid.x() #2
> (i16v)%add = add i16 %mul6, (i16v)%2     //Here keep %mul6 i16 as it is.
>
>
>
> I'm not familar with LLVM IR API, it's not easy to get the type and change
> it right away. Seems need to create a new IR and replace the old one?
>
> But it's also hard to CreateCall() or CreateAdd(), hard to get the
> original IR's info to fill in those CreateXXX parameter.
>
>
>
> Any ideas or reference code?
>
> How to learn LLVM IR API quickly?
>
>
>
> --
>
> Best Regards
>
> Celine
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://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/20191018/96ad65f1/attachment.html>


More information about the llvm-dev mailing list