On 02/27/2012 02:52 PM, Nico wrote:> Hi,
>
> if I want to know how switch instructions are handled in the backend, where
do I have to look first?
> I'm not familiar with the backend framework and I couldn't figure
out the interface between the LLVM instruction 'SwitchInst' and whatever
there is in the backend.
LLVM IR gets passed to the backend as a SelectionDAG, which is
constructed by peephole expansion of the IR (see
http://llvm.org/releases/3.0/docs/CodeGenerator.html#selectiondag_intro
). The relevant code for 'select' instructions in IR is the
visitSelect() function in
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp; a select gets expanded
into a ISD::SELECT (for scalar types) or ISD::VECTOR (for vector types)
for each select operand, plus a ISD::MERGE_VALUES to multiplex them all
together.
For the MIPS backend handling code, see
lib/Target/Mips/MipsISelLowering.cpp. In particular,
setOperation(ISD::SELECT, <typename>, Custom) means that the MIPS
backend lowers SELECTS in C++ rather than a simple tablegen pattern. In
LowerSELECT() in that same file, you can see that MIPS will create a
conditional move if the select condition is set by a floating point
comparison, and the "return Op;" it does otherwise means that other
cases should be handled by the default machinery rather than custom
lowering code.
The "default machinery" requires quite a bit of background knowledge
to
understand, but the Code Generator doc gives a good broad overview, and
the above is the extent of custom select-handling code in the MIPS backend.
-Matt
>
> I would be very happy about every hint where I have to look to find the
entry point of switch instructions in the backend (in particular in the MIPS
backend.
>
> Thanks a lot and kind regards,
> Nico
> _______________________________________________
> 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/20120227/88c88662/attachment.html>