I mean an llvm Pass that transforms switch statements into if statements. For example, if I have code with switch statements then running the pass will convert all switches to ifs in the bytecode. George On Mon, May 6, 2013 at 4:20 PM, Hal Finkel <hfinkel at anl.gov> wrote:> ----- Original Message ----- > > From: "George Baah" <georgebaah at gmail.com> > > To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu> > > Sent: Monday, May 6, 2013 3:09:33 PM > > Subject: [LLVMdev] convert switch stmts to If statements > > > > > > > > > > Hi All, Is there a pass in llvm that converts switch statements to if > > statements? > > > > What do you mean by convert? SelectionDAGBuilder::visitSwitch in > lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp converts the switch > statements for code generation either into indirect jump tables or into > binary-search trees (which I suppose you could call if statements). > > -Hal > > > > > George > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130506/e47a8c54/attachment.html>
There is also the LowerSwitch pass that converts switch instructions to a sequence of branches. On May 6, 2013, at 1:24 PM, George Baah <georgebaah at gmail.com> wrote:> I mean an llvm Pass that transforms switch statements into if statements. For example, if I have code with switch statements then running the pass will convert all switches to ifs in the bytecode. > > George > > > On Mon, May 6, 2013 at 4:20 PM, Hal Finkel <hfinkel at anl.gov> wrote: > ----- Original Message ----- > > From: "George Baah" <georgebaah at gmail.com> > > To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu> > > Sent: Monday, May 6, 2013 3:09:33 PM > > Subject: [LLVMdev] convert switch stmts to If statements > > > > > > > > > > Hi All, Is there a pass in llvm that converts switch statements to if > > statements? > > > > What do you mean by convert? SelectionDAGBuilder::visitSwitch in lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp converts the switch statements for code generation either into indirect jump tables or into binary-search trees (which I suppose you could call if statements). > > -Hal > > > > > George > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130506/7aa37c81/attachment.html>
Thanks! George On Mon, May 6, 2013 at 4:27 PM, Nadav Rotem <nrotem at apple.com> wrote:> There is also the LowerSwitch pass that converts switch instructions to a > sequence of branches. > > On May 6, 2013, at 1:24 PM, George Baah <georgebaah at gmail.com> wrote: > > I mean an llvm Pass that transforms switch statements into if statements. > For example, if I have code with switch statements then running the pass > will convert all switches to ifs in the bytecode. > > George > > > On Mon, May 6, 2013 at 4:20 PM, Hal Finkel <hfinkel at anl.gov> wrote: > >> ----- Original Message ----- >> > From: "George Baah" <georgebaah at gmail.com> >> > To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu> >> > Sent: Monday, May 6, 2013 3:09:33 PM >> > Subject: [LLVMdev] convert switch stmts to If statements >> > >> > >> > >> > >> > Hi All, Is there a pass in llvm that converts switch statements to if >> > statements? >> > >> >> What do you mean by convert? SelectionDAGBuilder::visitSwitch in >> lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp converts the switch >> statements for code generation either into indirect jump tables or into >> binary-search trees (which I suppose you could call if statements). >> >> -Hal >> >> > >> > George >> > _______________________________________________ >> > LLVM Developers mailing list >> > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > >> > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130506/e8a6ff44/attachment.html>