Alberto Barbaro via llvm-dev
2019-Jun-27 18:07 UTC
[llvm-dev] How to the get the PHI Nodes in a basic block?
Hi all, I have an Instruction object I from where I can correctly obtain the parent doing I.getParent(). Now I would like to understand how to obtain the PHI Nodes in that block. Do you suggest to iterate all over the instructions since the PHI nodes are always at the beginning or should I use another approach? What the best way to iterate over the instructions in a block? Thanks Alberto -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190627/82c3e9e6/attachment.html>
Quentin Colombet via llvm-dev
2019-Jun-27 18:17 UTC
[llvm-dev] How to the get the PHI Nodes in a basic block?
Hi Alberto, You’ll have to indeed iterate over the instructions, but you don’t have to go through all of them. You can use MachineBasicBlock::getFirstNonPHI and then iterate backward. Cheers, -Quentin> On Jun 27, 2019, at 11:07 AM, Alberto Barbaro via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi all, > I have an Instruction object I from where I can correctly obtain the parent doing I.getParent(). Now I would like to understand how to obtain the PHI Nodes in that block. Do you suggest to iterate all over the instructions since the PHI nodes are always at the beginning or should I use another approach? What the best way to iterate over the instructions in a block? > > Thanks > Alberto > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Krzysztof Parzyszek via llvm-dev
2019-Jun-27 20:13 UTC
[llvm-dev] How to the get the PHI Nodes in a basic block?
BasicBlock::phis() gives you the range of PHI instructions in that block. -- Krzysztof Parzyszek kparzysz at quicinc.com<mailto:kparzysz at quicinc.com> LLVM compiler development From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Alberto Barbaro via llvm-dev Sent: Thursday, June 27, 2019 1:07 PM To: llvm-dev <llvm-dev at lists.llvm.org> Subject: [EXT] [llvm-dev] How to the get the PHI Nodes in a basic block? Hi all, I have an Instruction object I from where I can correctly obtain the parent doing I.getParent(). Now I would like to understand how to obtain the PHI Nodes in that block. Do you suggest to iterate all over the instructions since the PHI nodes are always at the beginning or should I use another approach? What the best way to iterate over the instructions in a block? Thanks Alberto -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190627/8148a0d0/attachment.html>
Alberto Barbaro via llvm-dev
2019-Jun-27 21:30 UTC
[llvm-dev] How to the get the PHI Nodes in a basic block?
Thanks for the answers. I'll try it tomorrow. Alberto On Thu, Jun 27, 2019, 21:13 Krzysztof Parzyszek <kparzysz at quicinc.com> wrote:> BasicBlock::phis() gives you the range of PHI instructions in that block. > > > > -- > > Krzysztof Parzyszek kparzysz at quicinc.com LLVM compiler development > > > > *From:* llvm-dev <llvm-dev-bounces at lists.llvm.org> *On Behalf Of *Alberto > Barbaro via llvm-dev > *Sent:* Thursday, June 27, 2019 1:07 PM > *To:* llvm-dev <llvm-dev at lists.llvm.org> > *Subject:* [EXT] [llvm-dev] How to the get the PHI Nodes in a basic block? > > > > Hi all, > > I have an Instruction object I from where I can correctly obtain the > parent doing I.getParent(). Now I would like to understand how to obtain > the PHI Nodes in that block. Do you suggest to iterate all over the > instructions since the PHI nodes are always at the beginning or should I > use another approach? What the best way to iterate over the instructions in > a block? > > > > Thanks > > Alberto >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190627/a9fa3c6b/attachment.html>