home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / PROJECTS < prev    next >
Text File  |  1991-05-20  |  17KB  |  404 lines

  1. 0. Improved efficiency.
  2.  
  3. * Parse and output array initializers an element at a time, freeing
  4. storage after each, instead of parsing the whole initializer first and
  5. then outputting.  This would reduce memory usage for large
  6. initializers.
  7.  
  8. 1. Better optimization.
  9.  
  10. * Constants in unused inline functions
  11.  
  12. It would be nice to delay output of string constants so that string
  13. constants mentioned in unused inline functions are never generated.
  14. Perhaps this would also take care of string constants in dead code.
  15.  
  16. The difficulty is in finding a clean way for the RTL which refers
  17. to the constant (currently, only by an assembler symbol name)
  18. to point to the constant and cause it to be output.
  19.  
  20. * More cse
  21.  
  22. The techniques for doing full global cse are described in the red
  23. dragon book, or (a different version) in Frederick Chow's thesis from
  24. Stanford.  It is likely to be slow and use a lot of memory, but it
  25. might be worth offering as an additional option.
  26.  
  27. It is probably possible to extend cse to a few very frequent cases
  28. without so much expense.
  29.  
  30. For example, it is not very hard to handle cse through if-then
  31. statements with no else clauses.  Here's how to do it.  On reaching a
  32. label, notice that the label's use-count is 1 and that the last
  33. preceding jump jumps conditionally to this label.  Now you know it
  34. is a simple if-then statement.  Remove from the hash table
  35. all the expressions that were entered since that jump insn
  36. and you can continue with cse.
  37.  
  38. It is probably not hard to handle cse from the end of a loop
  39. around to the beginning, and a few loops would be greatly sped
  40. up by this.
  41.  
  42. * Optimize a sequence of if statements whose conditions are exclusive.
  43.  
  44. It is possible to optimize 
  45.  
  46.     if (x == 1) ...;
  47.     if (x == 2) ...;
  48.     if (x == 3) ...;
  49.  
  50. into
  51.  
  52.     if (x == 1) ...;
  53.     else if (x == 2) ...;
  54.     else if (x == 3) ...;
  55.  
  56. provided that x is not altered by the contents of the if statements.
  57.  
  58. It's not certain whether this is worth doing.  Perhaps programmers
  59. nearly always write the else's themselves, leaving few opportunities
  60. to improve anything.
  61.  
  62. * Support more general tail-recursion among different functions.
  63.  
  64. This might be possible under certain circumstances, such as when
  65. the argument lists of the functions have the same lengths.
  66. Perhaps it could be done with a special declaration.
  67.  
  68. You would need to verify in the calling function that it does not
  69. use the addresses of any local variables and does not use setjmp.
  70.  
  71. * Put short statics vars at low addresses and use short addressing mode?
  72.  
  73. Useful on the 68000/68020 and perhaps on the 32000 series,
  74. provided one has a linker that works with the feature.
  75. This is said to make a 15% speedup on the 68000.
  76.  
  77. * Keep global variables in registers.
  78.  
  79. Here is a scheme for doing this.  A global variable, or a local variable
  80. whose address is taken, can be kept in a register for an entire function
  81. if it does not use non-constant memory addresses and (for globals only)
  82. does not call other functions.  If the entire function does not meet
  83. this criterion, a loop may.
  84.  
  85. The VAR_DECL for such a variable would have to have two RTL expressions:
  86. the true home in memory, and the pseudo-register used temporarily. 
  87. It is necessary to emit insns to copy the memory location into the
  88. pseudo-register at the beginning of the function or loop, and perhaps
  89. back out at the end.  These insns should have REG_EQUIV notes so that,
  90. if the pseudo-register does not get a hard register, it is spilled into
  91. the memory location which exists in any case.
  92.  
  93. The easiest way to set up these insns is to modify the routine
  94. put_var_into_stack so that it does not apply to the entire function
  95. (sparing any loops which contain nothing dangerous) and to call it at
  96. the end of the function regardless of where in the function the
  97. address of a local variable is taken.  It would be called
  98. unconditionally at the end of the function for all relevant global
  99. variables.
  100.  
  101. For debugger output, the thing to do is to invent a new binding level
  102. around the appropriate loop and define the variable name as a register
  103. variable with that scope.
  104.  
  105. * Live-range splitting.
  106.  
  107. Currently a variable is allocated a hard register either for the full
  108. extent of its use or not at all.  Sometimes it would be good to
  109. allocate a variable a hard register for just part of a function; for
  110. example, through a particular loop where the variable is mostly used,
  111. or outside of a particular loop where the variable is not used.  (The
  112. latter is nice because it might let the variable be in a register most
  113. of the time even though the loop needs all the registers.)
  114.  
  115. It might not be very hard to do this in global-alloc.c when a variable
  116. fails to get a hard register for its entire life span.
  117.  
  118. The first step is to find a loop in which the variable is live, but
  119. which is not the whole life span or nearly so.  It's probably best to
  120. use a loop in which the variable is heavily used.
  121.  
  122. Then create a new pseudo-register to represent the variable in that loop.
  123. Substitute this for the old pseudo-register there, and insert move insns
  124. to copy between the two at the loop entry and all exits.  (When several
  125. such moves are inserted at the same place, some new feature should be
  126. added to say that none of those registers conflict merely because of
  127. overlap between the new moves.  And the reload pass should reorder them
  128. so that a store precedes a load, for any given hard register.)
  129.  
  130. After doing this for all the reasonable candidates, run global-alloc
  131. over again.  With luck, one of the two pseudo-registers will be fit
  132. somewhere.  It may even have a much higher priority due to its reduced
  133. life span.
  134.  
  135. There will be no room in general for the new pseudo-registers in
  136. basic_block_live_at_start, so there will need to be a second such
  137. matrix exclusively for the new ones.  Various other vectors indexed by
  138. register number will have to be made bigger, or there will have to be
  139. secondary extender vectors just for global-alloc.
  140.  
  141. A simple new feature could arrange that both pseudo-registers get the
  142. same stack slot if they both fail to get hard registers.
  143.  
  144. Other compilers split live ranges when they are not connected, or
  145. try to split off pieces `at the edge'.  I think splitting around loops
  146. will provide more speedup.
  147.  
  148. Creating a fake binding block and a new like-named variable with
  149. shorter life span and different address might succeed in describing
  150. this technique for the debugger.
  151.  
  152. * Detect dead stores into memory?
  153.  
  154. A store into memory is dead if it is followed by another store into
  155. the same location; and, in between, there is no reference to anything
  156. that might be that location (including no reference to a variable
  157. address).
  158.  
  159. * Loop optimization.
  160.  
  161. Strength reduction and iteration variable elimination could be
  162. smarter.  They should know how to decide which iteration variables are
  163. not worth making explicit because they can be computed as part of an
  164. address calculation.  Based on this information, they should decide
  165. when it is desirable to eliminate one iteration variable and create
  166. another in its place.
  167.  
  168. It should be possible to compute what the value of an iteration
  169. variable will be at the end of the loop, and eliminate the variable
  170. within the loop by computing that value at the loop end.
  171.  
  172. When a loop has a simple increment that adds 1,
  173. instead of jumping in after the increment,
  174. decrement the loop count and jump to the increment.
  175. This allows aob insns to be used.
  176.  
  177. * Using constraints on values.
  178.  
  179. Many operations could be simplified based on knowledge of the
  180. minimum and maximum possible values of a register at any particular time.
  181. These limits could come from the data types in the tree, via rtl generation,
  182. or they can be deduced from operations that are performed.  For example,
  183. the result of an `and' operation one of whose operands is 7 must be in
  184. the range 0 to 7.  Compare instructions also tell something about the
  185. possible values of the operand, in the code beyond the test.
  186.  
  187. Value constraints can be used to determine the results of a further
  188. comparison.  They can also indicate that certain `and' operations are
  189. redundant.  Constraints might permit a decrement and branch
  190. instruction that checks zeroness to be used when the user has
  191. specified to exit if negative.
  192.  
  193. * Smarter reload pass.
  194.  
  195. The reload pass as currently written can reload values only into registers
  196. that are reserved for reloading.  This means that in order to use a
  197. register for reloading it must spill everything out of that register.
  198.  
  199. It would be straightforward, though complicated, for reload1.c to keep
  200. track, during its scan, of which hard registers were available at each
  201. point in the function, and use for reloading even registers that were
  202. free only at the point they were needed.  This would avoid much spilling
  203. and make better code.
  204.  
  205. * Change the type of a variable.
  206.  
  207. Sometimes a variable is declared as `int', it is assigned only once
  208. from a value of type `char', and then it is used only by comparison
  209. against constants.  On many machines, better code would result if
  210. the variable had type `char'.  If the compiler could detect this
  211. case, it could change the declaration of the variable and change
  212. all the places that use it.
  213.  
  214. * Order of subexpressions.
  215.  
  216. It might be possible to make better code by paying attention
  217. to the order in which to generate code for subexpressions of an expression.
  218.  
  219. * More code motion.
  220.  
  221. Consider hoisting common code up past conditional branches or
  222. tablejumps.
  223.  
  224. * Trace scheduling.
  225.  
  226. This technique is said to be able to figure out which way a jump
  227. will usually go, and rearrange the code to make that path the
  228. faster one.
  229.  
  230. * Distributive law.
  231.  
  232. The C expression *(X + 4 * (Y + C)) compiles better on certain
  233. machines if rewritten as *(X + 4*C + 4*Y) because of known addressing
  234. modes.  It may be tricky to determine when, and for which machines, to
  235. use each alternative.
  236.  
  237. Some work has been done on this, in combine.c.
  238.  
  239. * Jump-execute-next.
  240.  
  241. Many recent machines have jumps which optionally execute the following
  242. instruction before the instruction jumped to, either conditionally or
  243. unconditionally.  To take advantage of this capability requires a new
  244. compiler pass that would reorder instructions when possible.  After
  245. reload may be a good place for it.
  246.  
  247. On some machines, the result of a load from memory is not available
  248. until after the following instruction.  The easiest way to support
  249. these machines is to output each RTL load instruction as two assembler
  250. instructions, the second being a no-op.  Putting useful instructions
  251. after the load instructions may be a similar task to putting them
  252. after jump instructions.
  253.  
  254. * Pipeline scheduling.
  255.  
  256. On many machines, code gets faster if instructions are reordered
  257. so that pipelines are kept full.  Doing the best possible job of this
  258. requires knowing which functional units each kind of instruction executes
  259. in and how long the functional unit stays busy with it.  Then the
  260. goal is to reorder the instructions to keep many functional units
  261. busy but never feed them so fast they must wait.
  262.  
  263. * Can optimize by changing if (x) y; else z; into z; if (x) y;
  264. if z and x do not interfere and z has no effects not undone by y.
  265. This is desirable if z is faster than jumping.
  266.  
  267. * For a two-insn loop on the 68020, such as
  268.   foo:    movb    a2@+,a3@+
  269.     jne    foo
  270. it is better to insert dbeq d0,foo before the jne.
  271. d0 can be a junk register.  The challenge is to fit this into
  272. a portable framework: when can you detect this situation and
  273. still be able to allocate a junk register?
  274.  
  275. * For the 80387 floating point, perhaps it would be possible to use 3
  276. or 4 registers in the stack to hold register variables.  (It would be
  277. necessary to keep track of how those slots move in the stack as other
  278. pushes and pops are done.)  This is probably very tricky, but if
  279. you are a GCC wizard and you care about the speed of floating point on
  280. an 80386, you might want to work on it.
  281.  
  282. 2. Simpler porting.
  283.  
  284. Right now, describing the target machine's instructions is done
  285. cleanly, but describing its addressing mode is done with several
  286. ad-hoc macro definitions.  Porting would be much easier if there were
  287. an RTL description for addressing modes like that for instructions.
  288. Tools analogous to genflags and genrecog would generate macros from
  289. this description.
  290.  
  291. There would be one pattern in the address-description file for each
  292. kind of addressing, and this pattern would have:
  293.  
  294.   * the RTL expression for the address
  295.   * C code to verify its validity (since that may depend on
  296.     the exact data).
  297.   * C code to print the address in assembler language.
  298.   * C code to convert the address into a valid one, if it is not valid.
  299.     (This would replace LEGITIMIZE_ADDRESS).
  300.   * Register constraints for all indeterminates that appear
  301.     in the RTL expression.
  302.  
  303. 3. Other languages.
  304.  
  305. Front ends for Pascal, Fortran, Algol, Cobol, Modula-2 and Ada are
  306. desirable.
  307.  
  308. Pascal, Modula-2 and Ada require the implementation of functions
  309. within functions.  Some of the mechanisms for this already exist.
  310.  
  311. 4. More extensions.
  312.  
  313. * Block structure for labels.
  314.  
  315. The ({...}) construct should serve as a lexical block for label names,
  316. so that the same label may be defined both inside and outside of it.
  317. Then macro definitions could use labels internally safely, by enclosing
  318. the label and the goto in one of these constructs.
  319.  
  320. * Generated unique labels.  Have some way of generating distinct labels
  321. for use in extended asm statements.  I don't know what a good syntax would
  322. be.
  323.  
  324. * A way of defining a structure containing a union, in which the choice of
  325. union alternative is controlled by a previous structure component.
  326.  
  327. Here is a possible syntax for this.
  328.  
  329. struct foo {
  330.   enum { INT, DOUBLE } code;
  331.   auto union { case INT: int i; case DOUBLE: double d;} value : code;
  332. };
  333.  
  334. 5. Generalize the machine model.
  335.  
  336. * Some new compiler features may be needed to do a good job on machines
  337. where static data needs to be addressed using base registers.
  338.  
  339. * Some machines have two stacks in different areas of memory, one used
  340. for scalars and another for large objects.  The compiler does not
  341. now have a way to understand this.
  342.  
  343. 6. Better documentation of how GCC works and how to port it.
  344.  
  345. Here is an outline proposed by Allan Adler.
  346.  
  347. I.    Overview of this document
  348. II.   The machines on which GCC is implemented
  349.     A. Prose description of those characteristics of target machines and
  350.        their operating systems which are pertinent to the implementation
  351.        of GCC.
  352.     i. target machine characteristics
  353.     ii. comparison of this system of machine characteristics with
  354.         other systems of machine specification currently in use
  355.     B. Tables of the characteristics of the target machines on which
  356.        GCC is implemented.
  357.     C. A priori restrictions on the values of characteristics of target 
  358.        machines, with special reference to those parts of the source code
  359.        which entail those restrictions
  360.     i. restrictions on individual characteristics 
  361.         ii. restrictions involving relations between various characteristics
  362.     D. The use of GCC as a cross-compiler 
  363.     i. cross-compilation to existing machines
  364.     ii. cross-compilation to non-existent machines
  365.     E. Assumptions which are made regarding the target machine
  366.     i.  assumptions regarding the architecture of the target machine
  367.     ii. assumptions regarding the operating system of the target machine
  368.     iii. assumptions regarding software resident on the target machine
  369.     iv. where in the source code these assumptions are in effect made
  370. III.   A systematic approach to writing the files tm.h and xm.h
  371.     A. Macros which require special care or skill
  372.     B. Examples, with special reference to the underlying reasoning
  373. IV.    A systematic approach to writing the machine description file md
  374.     A. Minimal viable sets of insn descriptions
  375.     B. Examples, with special reference to the underlying reasoning
  376. V.     Uses of the file aux-output.c
  377. VI.    Specification of what constitutes correct performance of an 
  378.        implementation of GCC
  379.     A. The components of GCC
  380.     B. The itinerary of a C program through GCC
  381.     C. A system of benchmark programs
  382.     D. What your RTL and assembler should look like with these benchmarks
  383.     E. Fine tuning for speed and size of compiled code
  384. VII.   A systematic procedure for debugging an implementation of GCC
  385.     A. Use of GDB
  386.     i. the macros in the file .gdbinit for GCC
  387.     ii. obstacles to the use of GDB
  388.         a. functions implemented as macros can't be called in GDB
  389.     B. Debugging without GDB
  390.     i. How to turn off the normal operation of GCC and access specific
  391.        parts of GCC
  392.     C. Debugging tools
  393.     D. Debugging the parser
  394.     i. how machine macros and insn definitions affect the parser
  395.     E. Debugging the recognizer
  396.     i. how machine macros and insn definitions affect the recognizer
  397.  
  398. ditto for other components
  399.  
  400. VIII. Data types used by GCC, with special reference to restrictions not 
  401.       specified in the formal definition of the data type
  402. IX.   References to the literature for the algorithms used in GCC
  403.  
  404.