<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 02/27/2012 02:52 PM, Nico wrote:
<blockquote cite="mid:85ACC129-49DC-4D97-B41F-ABC90D4A0AF5@arcor.de"
type="cite">
<pre wrap="">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.</pre>
</blockquote>
LLVM IR gets passed to the backend as a SelectionDAG, which is
constructed by peephole expansion of the IR (see
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<a
href="http://llvm.org/releases/3.0/docs/CodeGenerator.html#selectiondag_intro">http://llvm.org/releases/3.0/docs/CodeGenerator.html#selectiondag_intro</a>
). 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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
-Matt<br>
<br>
<blockquote cite="mid:85ACC129-49DC-4D97-B41F-ABC90D4A0AF5@arcor.de"
type="cite">
<pre wrap="">
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
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
</body>
</html>