Reshaped doc's
[fw/sdcc] / doc / sdccman.html / node48.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2
3 <!--Converted with LaTeX2HTML 99.1 release (March 30, 1999)
4 original version by:  Nikos Drakos, CBLU, University of Leeds
5 * revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
6 * with significant contributions from:
7   Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
8 <HTML>
9 <HEAD>
10 <TITLE>6. Retargetting for other MCUs.</TITLE>
11 <META NAME="description" CONTENT="6. Retargetting for other MCUs.">
12 <META NAME="keywords" CONTENT="sdccman">
13 <META NAME="resource-type" CONTENT="document">
14 <META NAME="distribution" CONTENT="global">
15
16 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
17 <META NAME="Generator" CONTENT="LaTeX2HTML v99.1 release">
18 <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
19
20 <LINK REL="STYLESHEET" HREF="sdccman.css">
21
22 <LINK REL="next" HREF="node49.html">
23 <LINK REL="previous" HREF="node46.html">
24 <LINK REL="up" HREF="sdccman.html">
25 <LINK REL="next" HREF="node49.html">
26 </HEAD>
27
28 <BODY >
29 <!--Navigation Panel-->
30 <A NAME="tex2html978"
31  HREF="node49.html">
32 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
33 <A NAME="tex2html972"
34  HREF="sdccman.html">
35 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
36 <A NAME="tex2html966"
37  HREF="node47.html">
38 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
39 <A NAME="tex2html974"
40  HREF="node1.html">
41 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
42 <A NAME="tex2html976"
43  HREF="node61.html">
44 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A> 
45 <BR>
46 <B> Next:</B> <A NAME="tex2html979"
47  HREF="node49.html">7. SDCDB - Source</A>
48 <B> Up:</B> <A NAME="tex2html973"
49  HREF="sdccman.html">SDCC Compiler User Guide</A>
50 <B> Previous:</B> <A NAME="tex2html967"
51  HREF="node47.html">5.1 Notes on MCS51</A>
52  &nbsp <B>  <A NAME="tex2html975"
53  HREF="node1.html">Contents</A></B> 
54  &nbsp <B>  <A NAME="tex2html977"
55  HREF="node61.html">Index</A></B> 
56 <BR>
57 <BR>
58 <!--End of Navigation Panel-->
59
60 <H1><A NAME="SECTION00070000000000000000">
61 6. Retargetting for other MCUs.</A>
62 </H1>
63
64 <P>
65 The issues for retargetting the compiler are far too numerous to be
66 covered by this document. What follows is a brief description of each
67 of the seven phases of the compiler and its MCU dependency.
68
69 <P>
70
71 <UL>
72 <LI>Parsing the source and building the annotated parse tree. This phase
73 is largely MCU independent (except for the language extensions). Syntax
74 &amp; semantic checks are also done in this phase, along with some initial
75 optimizations like back patching labels and the pattern matching optimizations
76 like bit-rotation etc.</LI>
77 <LI>The second phase involves generating an intermediate code which can
78 be easy manipulated during the later phases. This phase is entirely
79 MCU independent. The intermediate code generation assumes the target
80 machine has unlimited number of registers, and designates them with
81 the name iTemp. The compiler can be made to dump a human readable
82 form of the code generated by using the -dumpraw option.</LI>
83 <LI>This phase does the bulk of the standard optimizations and is also
84 MCU independent. This phase can be broken down into several sub-phases:
85 <BR>
86
87 <BR>
88 Break down intermediate code (iCode) into basic blocks.
89 <BR>
90 Do control flow &amp; data flow analysis on the basic blocks.
91 <BR>
92 Do local common subexpression elimination, then global subexpression
93 elimination
94 <BR>
95 Dead code elimination
96 <BR>
97 Loop optimizations
98 <BR>
99 If loop optimizations caused any changes then do 'global subexpression
100 elimination' and 'dead code elimination' again.</LI>
101 <LI>This phase determines the live-ranges; by live range I mean those
102 iTemp variables defined by the compiler that still survive after all
103 the optimizations. Live range analysis is essential for register allocation,
104 since these computation determines which of these iTemps will be assigned
105 to registers, and for how long.</LI>
106 <LI>Phase five is register allocation. There are two parts to this process.
107 <BR>
108
109 <BR>
110 The first part I call 'register packing' (for lack of a better term).
111 In this case several MCU specific expression folding is done to reduce
112 register pressure.
113 <BR>
114
115 <BR>
116 The second part is more MCU independent and deals with allocating
117 registers to the remaining live ranges. A lot of MCU specific code
118 does creep into this phase because of the limited number of index
119 registers available in the 8051.</LI>
120 <LI>The Code generation phase is (unhappily), entirely MCU dependent and
121 very little (if any at all) of this code can be reused for other MCU.
122 However the scheme for allocating a homogenized assembler operand
123 for each iCode operand may be reused.</LI>
124 <LI>As mentioned in the optimization section the peep-hole optimizer is
125 rule based system, which can reprogrammed for other MCUs.</LI>
126 </UL>
127
128 <P>
129 <HR>
130 <!--Navigation Panel-->
131 <A NAME="tex2html978"
132  HREF="node49.html">
133 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
134 <A NAME="tex2html972"
135  HREF="sdccman.html">
136 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
137 <A NAME="tex2html966"
138  HREF="node47.html">
139 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
140 <A NAME="tex2html974"
141  HREF="node1.html">
142 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
143 <A NAME="tex2html976"
144  HREF="node61.html">
145 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A> 
146 <BR>
147 <B> Next:</B> <A NAME="tex2html979"
148  HREF="node49.html">7. SDCDB - Source</A>
149 <B> Up:</B> <A NAME="tex2html973"
150  HREF="sdccman.html">SDCC Compiler User Guide</A>
151 <B> Previous:</B> <A NAME="tex2html967"
152  HREF="node47.html">5.1 Notes on MCS51</A>
153  &nbsp <B>  <A NAME="tex2html975"
154  HREF="node1.html">Contents</A></B> 
155  &nbsp <B>  <A NAME="tex2html977"
156  HREF="node61.html">Index</A></B> 
157 <!--End of Navigation Panel-->
158 <ADDRESS>
159 <I>Johan Knol</I>
160 <BR><I>2001-07-13</I>
161 </ADDRESS>
162 </BODY>
163 </HTML>