Przemyslaw Ossowski via llvm-dev
2021-Jun-01 17:16 UTC
[llvm-dev] Adding instructions in pass directly from string containing IR
Hello, I would like to add a pass which modifies IR by insertion set of IR instructions somewhere in the middle of the basicblock, like example below: %address = call i32* @llvm.target_intrinsic.getaddress() %value = load i32, i32* %address %addvalue = add nsw i32 %value, 10 store i32 %addvalue, i32* %address Is there any function available which would allow for parsing the string (containing set of instructions) and generating instructions automatically instead of manually calling functions creating instructions from IRBuilder? ...at least for simple set of basic instructions Regards, Przemek -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210601/9ec43742/attachment.html>
pawel k. via llvm-dev
2021-Jun-02 02:08 UTC
[llvm-dev] Adding instructions in pass directly from string containing IR
What arch btw? wt., 1.06.2021, 19:16 użytkownik Przemyslaw Ossowski via llvm-dev < llvm-dev at lists.llvm.org> napisał:> Hello, > > > > I would like to add a pass which modifies IR by insertion set of IR > instructions somewhere in the middle of the basicblock, > > like example below: > > > > %address = call i32* @llvm.target_intrinsic.getaddress() > > %value = load i32, i32* %address > > %addvalue = add nsw i32 %value, 10 > > store i32 %addvalue, i32* %address > > > > Is there any function available which would allow for parsing the string > (containing set of instructions) and generating instructions automatically > instead of manually calling functions creating instructions from IRBuilder? > > ...at least for simple set of basic instructions > > > Regards, > > Przemek > > _______________________________________________ > 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/20210602/8c9019a6/attachment.html>
Johannes Doerfert via llvm-dev
2021-Jun-02 02:13 UTC
[llvm-dev] Adding instructions in pass directly from string containing IR
Hi Przemek, I doubt that such functionality exists right now. The main problem I see is the name matching to embed it with other code. If the new code is not connected, I'd recommend the pass to read in an IR file with a function in it, link it into the module, and insert a call wherever you want to "paste" the instructions. Much cleaner than dealing with strings, IMHO. ~ Johannes On 6/1/21 12:16 PM, Przemyslaw Ossowski via llvm-dev wrote:> Hello, > > > > I would like to add a pass which modifies IR by insertion set of IR > instructions somewhere in the middle of the basicblock, > > like example below: > > > > %address = call i32* @llvm.target_intrinsic.getaddress() > > %value = load i32, i32* %address > > %addvalue = add nsw i32 %value, 10 > > store i32 %addvalue, i32* %address > > > > Is there any function available which would allow for parsing the string > (containing set of instructions) and generating instructions automatically > instead of manually calling functions creating instructions from IRBuilder? > > ...at least for simple set of basic instructions > > > Regards, > > Przemek > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev