* except.c (expand_start_catch_block): We only need the rethrow
[official-gcc.git] / gcc / PROJECTS
blob356f477a086e4e66341d2c3e4e8d70e38fe6967f
1 Haifa scheduler (haifa-sched.c, loop.[ch], unroll.[ch], genattrtab.c):
2 (contact law@cygnus.com before starting any serious haifa work)
4   * Fix all the formatting problems.  Simple, mindless work.
6   * Fix/add comments throughout the code.  Many of the comments are from
7   the old scheduler and are out of date and misleading.  Many new hunks
8   of code don't have sufficient comments and documentation.  Those which
9   do have comments need to be rewritten to use complete sentences and
10   proper formatting.
12   * Someone needs make one (or more) passes over the scheduler as a whole to
13   just clean it up.  Try to move the machine dependent bits into the target
14   files where they belong, avoid re-creating functions where or near
15   equivalents already exist (ie is_conditional_branch and friends), etc etc.
17   * Document the new scheduling options.  Remove those options which are
18   not really useful (like reverse scheduling for example).  In general
19   the haifa scheduler adds _way_ too many options.  I'm definitely of the
20   opinion that gcc already has too many -foptions, and haifa doesn't help
21   that situation.
23   * Testing and benchmarking.  Haifa has received little testing inside
24   Cygnus -- it needs to be throughly tested on a wide variety of platforms
25   which benefit from instruction scheduling (sparc, alpha, pa, ppc, mips, x86,
26   i960, m88k, sh, etc).    It needs to be benchmarked -- my tests showed
27   haifa was very much a hit or miss in terms of performance improvements.
29   Some benchmarks ran significantly fasters, other significantly slower.
30   We need to work on making haifa generate better overall code.
32   We need to have some kind of docs for how to best describe a machine to
33   the haifa scheduler to get good performance.  Some existing ports have
34   been tuned to deal with the old scheduler -- they may need to be tuned
35   to generate good schedules with haifa.
37   
40 -------------
42 The old PROJECTS file.  Stuff I know has been done has been deleted.
43 Stuff in progress has a contact name associated with it.
44 has been 
46 1. Better optimization.
48 * Constants in unused inline functions
50 It would be nice to delay output of string constants so that string
51 constants mentioned in unused inline functions are never generated.
52 Perhaps this would also take care of string constants in dead code.
54 The difficulty is in finding a clean way for the RTL which refers
55 to the constant (currently, only by an assembler symbol name)
56 to point to the constant and cause it to be output.
58 * More cse
60 The techniques for doing full global cse are described in the red
61 dragon book, or (a different version) in Frederick Chow's thesis from
62 Stanford.  It is likely to be slow and use a lot of memory, but it
63 might be worth offering as an additional option.  Contact dje@cygnus.com
64 before doing any work on CSE.
66 * Optimize a sequence of if statements whose conditions are exclusive.
68 It is possible to optimize 
70     if (x == 1) ...;
71     if (x == 2) ...;
72     if (x == 3) ...;
74 into
76     if (x == 1) ...;
77     else if (x == 2) ...;
78     else if (x == 3) ...;
80 provided that x is not altered by the contents of the if statements.
82 It's not certain whether this is worth doing.  Perhaps programmers
83 nearly always write the else's themselves, leaving few opportunities
84 to improve anything.
86 * Un-cse.
88 Perhaps we should have an un-cse step right after cse, which tries to
89 replace a reg with its value if the value can be substituted for the
90 reg everywhere, if that looks like an improvement.  Which is if the
91 reg is used only a few times.  Use rtx_cost to determine if the
92 change is really an improvement.
94 * Clean up how cse works.
96 The scheme is that each value has just one hash entry.  The
97 first_same_value and next_same_value chains are no longer needed.
99 For arithmetic, each hash table elt has the following slots:
101 * Operation.  This is an rtx code.
102 * Mode.
103 * Operands 0, 1 and 2.  These point to other hash table elements.
105 So, if we want to enter (PLUS:SI (REG:SI 30) (CONST_INT 104)), we
106 first enter (CONST_INT 104) and find the entry that (REG:SI 30) now
107 points to.  Then we put these elts into operands 0 and 1 of a new elt.
108 We put PLUS and SI into the new elt.
110 Registers and mem refs would never be entered into the table as such.
111 However, the values they contain would be entered.  There would be a
112 table indexed by regno which points at the hash entry for the value in
113 that reg.
115 The hash entry index now plays the role of a qty number.
116 We still need qty_first_reg, reg_next_eqv, etc. to record which regs
117 share a particular qty.
119 When a reg is used whose contents are unknown, we need to create a
120 hash table entry whose contents say "unknown", as a place holder for
121 whatever the reg contains.  If that reg is added to something, then
122 the hash entry for the sum will refer to the "unknown" entry.  Use
123 UNKNOWN for the rtx code in this entry.  This replaces make_new_qty.
125 For a constant, a unique hash entry would be made based on the
126 value of the constant.
128 What about MEM?  Each time a memory address is referenced, we need a
129 qty (a hash table elt) to represent what is in it.  (Just as for a
130 register.)  If this isn't known, create one, just as for a reg whose
131 contents are unknown.
133 We need a way to find all mem refs that still contain a certain value.
134 Do this with a chain of hash elts (for memory addresses) that point to
135 locations that hold the value.  The hash elt for the value itself should
136 point to the start of the chain.  It would be good for the hash elt
137 for an address to point to the hash elt for the contents of that address
138 (but this ptr can be null if the contents have never been entered).
140 With this data structure, nothing need ever be invalidated except
141 the lists of which regs or mems hold a particular value.  It is easy
142 to see if there is a reg or mem that is equiv to a particular value.
143 If the value is constant, it is always explicitly constant.
145 * Support more general tail-recursion among different functions.
147 This might be possible under certain circumstances, such as when
148 the argument lists of the functions have the same lengths.
149 Perhaps it could be done with a special declaration.
151 You would need to verify in the calling function that it does not
152 use the addresses of any local variables and does not use setjmp.
154 * Put short statics vars at low addresses and use short addressing mode?
156 Useful on the 68000/68020 and perhaps on the 32000 series,
157 provided one has a linker that works with the feature.
158 This is said to make a 15% speedup on the 68000.
160 * Keep global variables in registers.
162 Here is a scheme for doing this.  A global variable, or a local variable
163 whose address is taken, can be kept in a register for an entire function
164 if it does not use non-constant memory addresses and (for globals only)
165 does not call other functions.  If the entire function does not meet
166 this criterion, a loop may.
168 The VAR_DECL for such a variable would have to have two RTL expressions:
169 the true home in memory, and the pseudo-register used temporarily. 
170 It is necessary to emit insns to copy the memory location into the
171 pseudo-register at the beginning of the function or loop, and perhaps
172 back out at the end.  These insns should have REG_EQUIV notes so that,
173 if the pseudo-register does not get a hard register, it is spilled into
174 the memory location which exists in any case.
176 The easiest way to set up these insns is to modify the routine
177 put_var_into_stack so that it does not apply to the entire function
178 (sparing any loops which contain nothing dangerous) and to call it at
179 the end of the function regardless of where in the function the
180 address of a local variable is taken.  It would be called
181 unconditionally at the end of the function for all relevant global
182 variables.
184 For debugger output, the thing to do is to invent a new binding level
185 around the appropriate loop and define the variable name as a register
186 variable with that scope.
188 * Live-range splitting.
190 Currently a variable is allocated a hard register either for the full
191 extent of its use or not at all.  Sometimes it would be good to
192 allocate a variable a hard register for just part of a function; for
193 example, through a particular loop where the variable is mostly used,
194 or outside of a particular loop where the variable is not used.  (The
195 latter is nice because it might let the variable be in a register most
196 of the time even though the loop needs all the registers.)
198 Contact meissner@cygnus.com before starting any work on live range
199 splitting.
201 * Detect dead stores into memory?
203 A store into memory is dead if it is followed by another store into
204 the same location; and, in between, there is no reference to anything
205 that might be that location (including no reference to a variable
206 address).
208 * Loop optimization.
210 Strength reduction and iteration variable elimination could be
211 smarter.  They should know how to decide which iteration variables are
212 not worth making explicit because they can be computed as part of an
213 address calculation.  Based on this information, they should decide
214 when it is desirable to eliminate one iteration variable and create
215 another in its place.
217 It should be possible to compute what the value of an iteration
218 variable will be at the end of the loop, and eliminate the variable
219 within the loop by computing that value at the loop end.
221 When a loop has a simple increment that adds 1,
222 instead of jumping in after the increment,
223 decrement the loop count and jump to the increment.
224 This allows aob insns to be used.
226 * Using constraints on values.
228 Many operations could be simplified based on knowledge of the
229 minimum and maximum possible values of a register at any particular time.
230 These limits could come from the data types in the tree, via rtl generation,
231 or they can be deduced from operations that are performed.  For example,
232 the result of an `and' operation one of whose operands is 7 must be in
233 the range 0 to 7.  Compare instructions also tell something about the
234 possible values of the operand, in the code beyond the test.
236 Value constraints can be used to determine the results of a further
237 comparison.  They can also indicate that certain `and' operations are
238 redundant.  Constraints might permit a decrement and branch
239 instruction that checks zeroness to be used when the user has
240 specified to exit if negative.
242 * Smarter reload pass.
244 The reload pass as currently written can reload values only into registers
245 that are reserved for reloading.  This means that in order to use a
246 register for reloading it must spill everything out of that register.
248 It would be straightforward, though complicated, for reload1.c to keep
249 track, during its scan, of which hard registers were available at each
250 point in the function, and use for reloading even registers that were
251 free only at the point they were needed.  This would avoid much spilling
252 and make better code.
254 * Change the type of a variable.
256 Sometimes a variable is declared as `int', it is assigned only once
257 from a value of type `char', and then it is used only by comparison
258 against constants.  On many machines, better code would result if
259 the variable had type `char'.  If the compiler could detect this
260 case, it could change the declaration of the variable and change
261 all the places that use it.
263 * Better handling for very sparse switches.
265 There may be cases where it would be better to compile a switch
266 statement to use a fixed hash table rather than the current
267 combination of jump tables and binary search.
269 * Order of subexpressions.
271 It might be possible to make better code by paying attention
272 to the order in which to generate code for subexpressions of an expression.
274 * More code motion.
276 Consider hoisting common code up past conditional branches or
277 tablejumps.
279 * Trace scheduling.
281 This technique is said to be able to figure out which way a jump
282 will usually go, and rearrange the code to make that path the
283 faster one.
285 * Distributive law.
287 The C expression *(X + 4 * (Y + C)) compiles better on certain
288 machines if rewritten as *(X + 4*C + 4*Y) because of known addressing
289 modes.  It may be tricky to determine when, and for which machines, to
290 use each alternative.
292 Some work has been done on this, in combine.c.
294 * Can optimize by changing if (x) y; else z; into z; if (x) y;
295 if z and x do not interfere and z has no effects not undone by y.
296 This is desirable if z is faster than jumping.
298 * For a two-insn loop on the 68020, such as
299   foo:  movb    a2@+,a3@+
300         jne     foo
301 it is better to insert dbeq d0,foo before the jne.
302 d0 can be a junk register.  The challenge is to fit this into
303 a portable framework: when can you detect this situation and
304 still be able to allocate a junk register?
306 2. Simpler porting.
308 Right now, describing the target machine's instructions is done
309 cleanly, but describing its addressing mode is done with several
310 ad-hoc macro definitions.  Porting would be much easier if there were
311 an RTL description for addressing modes like that for instructions.
312 Tools analogous to genflags and genrecog would generate macros from
313 this description.
315 There would be one pattern in the address-description file for each
316 kind of addressing, and this pattern would have:
318   * the RTL expression for the address
319   * C code to verify its validity (since that may depend on
320     the exact data).
321   * C code to print the address in assembler language.
322   * C code to convert the address into a valid one, if it is not valid.
323     (This would replace LEGITIMIZE_ADDRESS).
324   * Register constraints for all indeterminates that appear
325     in the RTL expression.
327 3. Other languages.
329 Front ends for Pascal, Fortran, Algol, Cobol, Modula-2 and Ada are
330 desirable.
332 Pascal, Modula-2 and Ada require the implementation of functions
333 within functions.  Some of the mechanisms for this already exist.
335 4. More extensions.
337 * Generated unique labels.  Have some way of generating distinct labels
338 for use in extended asm statements.  I don't know what a good syntax would
341 * A way of defining a structure containing a union, in which the choice of
342 union alternative is controlled by a previous structure component.
344 Here is a possible syntax for this.
346 struct foo {
347   enum { INT, DOUBLE } code;
348   auto union { case INT: int i; case DOUBLE: double d;} value : code;
351 * Allow constructor expressions as lvalues, like this:
353         (struct foo) {a, b, c} = foo();
355 This would call foo, which returns a structure, and then store the
356 several components of the structure into the variables a, b, and c.
358 5. Generalize the machine model.
360 * Some new compiler features may be needed to do a good job on machines
361 where static data needs to be addressed using base registers.
363 * Some machines have two stacks in different areas of memory, one used
364 for scalars and another for large objects.  The compiler does not
365 now have a way to understand this.
367 6. Useful warnings.
369 * Warn about statements that are undefined because the order of
370 evaluation of increment operators makes a big difference.  Here is an
371 example:
373     *foo++ = hack (*foo);
375 7. Better documentation of how GCC works and how to port it.
377 Here is an outline proposed by Allan Adler.
379 I.    Overview of this document
380 II.   The machines on which GCC is implemented
381     A. Prose description of those characteristics of target machines and
382        their operating systems which are pertinent to the implementation
383        of GCC.
384         i. target machine characteristics
385         ii. comparison of this system of machine characteristics with
386             other systems of machine specification currently in use
387     B. Tables of the characteristics of the target machines on which
388        GCC is implemented.
389     C. A priori restrictions on the values of characteristics of target 
390        machines, with special reference to those parts of the source code
391        which entail those restrictions
392         i. restrictions on individual characteristics 
393         ii. restrictions involving relations between various characteristics
394     D. The use of GCC as a cross-compiler 
395         i. cross-compilation to existing machines
396         ii. cross-compilation to non-existent machines
397     E. Assumptions which are made regarding the target machine
398         i.  assumptions regarding the architecture of the target machine
399         ii. assumptions regarding the operating system of the target machine
400         iii. assumptions regarding software resident on the target machine
401         iv. where in the source code these assumptions are in effect made
402 III.   A systematic approach to writing the files tm.h and xm.h
403     A. Macros which require special care or skill
404     B. Examples, with special reference to the underlying reasoning
405 IV.    A systematic approach to writing the machine description file md
406     A. Minimal viable sets of insn descriptions
407     B. Examples, with special reference to the underlying reasoning
408 V.     Uses of the file aux-output.c
409 VI.    Specification of what constitutes correct performance of an 
410        implementation of GCC
411     A. The components of GCC
412     B. The itinerary of a C program through GCC
413     C. A system of benchmark programs
414     D. What your RTL and assembler should look like with these benchmarks
415     E. Fine tuning for speed and size of compiled code
416 VII.   A systematic procedure for debugging an implementation of GCC
417     A. Use of GDB
418         i. the macros in the file .gdbinit for GCC
419         ii. obstacles to the use of GDB
420             a. functions implemented as macros can't be called in GDB
421     B. Debugging without GDB
422         i. How to turn off the normal operation of GCC and access specific
423            parts of GCC
424     C. Debugging tools
425     D. Debugging the parser
426         i. how machine macros and insn definitions affect the parser
427     E. Debugging the recognizer
428         i. how machine macros and insn definitions affect the recognizer
430 ditto for other components
432 VIII. Data types used by GCC, with special reference to restrictions not 
433       specified in the formal definition of the data type
434 IX.   References to the literature for the algorithms used in GCC