📄 projects
字号:
address calculation. Based on this information, they should decidewhen it is desirable to eliminate one iteration variable and createanother in its place.It should be possible to compute what the value of an iterationvariable will be at the end of the loop, and eliminate the variablewithin the loop by computing that value at the loop end.When a loop has a simple increment that adds 1,instead of jumping in after the increment,decrement the loop count and jump to the increment.This allows aob insns to be used.* Using constraints on values.Many operations could be simplified based on knowledge of theminimum and maximum possible values of a register at any particular time.These limits could come from the data types in the tree, via rtl generation,or they can be deduced from operations that are performed. For example,the result of an `and' operation one of whose operands is 7 must be inthe range 0 to 7. Compare instructions also tell something about thepossible values of the operand, in the code beyond the test.Value constraints can be used to determine the results of a furthercomparison. They can also indicate that certain `and' operations areredundant. Constraints might permit a decrement and branchinstruction that checks zeroness to be used when the user hasspecified to exit if negative.* Smarter reload pass.The reload pass as currently written can reload values only into registersthat are reserved for reloading. This means that in order to use aregister for reloading it must spill everything out of that register.It would be straightforward, though complicated, for reload1.c to keeptrack, during its scan, of which hard registers were available at eachpoint in the function, and use for reloading even registers that werefree only at the point they were needed. This would avoid much spillingand make better code.* Change the type of a variable.Sometimes a variable is declared as `int', it is assigned only oncefrom a value of type `char', and then it is used only by comparisonagainst constants. On many machines, better code would result ifthe variable had type `char'. If the compiler could detect thiscase, it could change the declaration of the variable and changeall the places that use it.* Better handling for very sparse switches.There may be cases where it would be better to compile a switchstatement to use a fixed hash table rather than the currentcombination of jump tables and binary search.* Order of subexpressions.It might be possible to make better code by paying attentionto the order in which to generate code for subexpressions of an expression.* More code motion.Consider hoisting common code up past conditional branches ortablejumps.* Trace scheduling.This technique is said to be able to figure out which way a jumpwill usually go, and rearrange the code to make that path thefaster one.* Distributive law.The C expression *(X + 4 * (Y + C)) compiles better on certainmachines if rewritten as *(X + 4*C + 4*Y) because of known addressingmodes. It may be tricky to determine when, and for which machines, touse each alternative.Some work has been done on this, in combine.c.* Can optimize by changing if (x) y; else z; into z; if (x) y;if z and x do not interfere and z has no effects not undone by y.This is desirable if z is faster than jumping.* For a two-insn loop on the 68020, such as foo: movb a2@+,a3@+ jne fooit is better to insert dbeq d0,foo before the jne.d0 can be a junk register. The challenge is to fit this intoa portable framework: when can you detect this situation andstill be able to allocate a junk register?2. Simpler porting.Right now, describing the target machine's instructions is donecleanly, but describing its addressing mode is done with severalad-hoc macro definitions. Porting would be much easier if there werean RTL description for addressing modes like that for instructions.Tools analogous to genflags and genrecog would generate macros fromthis description.There would be one pattern in the address-description file for eachkind of addressing, and this pattern would have: * the RTL expression for the address * C code to verify its validity (since that may depend on the exact data). * C code to print the address in assembler language. * C code to convert the address into a valid one, if it is not valid. (This would replace LEGITIMIZE_ADDRESS). * Register constraints for all indeterminates that appear in the RTL expression.3. Other languages.Front ends for Pascal, Fortran, Algol, Cobol, Modula-2 and Ada aredesirable.Pascal, Modula-2 and Ada require the implementation of functionswithin functions. Some of the mechanisms for this already exist.4. More extensions.* Generated unique labels. Have some way of generating distinct labelsfor use in extended asm statements. I don't know what a good syntax wouldbe.* A way of defining a structure containing a union, in which the choice ofunion alternative is controlled by a previous structure component.Here is a possible syntax for this.struct foo { enum { INT, DOUBLE } code; auto union { case INT: int i; case DOUBLE: double d;} value : code;};* Allow constructor expressions as lvalues, like this: (struct foo) {a, b, c} = foo();This would call foo, which returns a structure, and then store theseveral components of the structure into the variables a, b, and c.5. Generalize the machine model.* Some new compiler features may be needed to do a good job on machineswhere static data needs to be addressed using base registers.* Some machines have two stacks in different areas of memory, one usedfor scalars and another for large objects. The compiler does notnow have a way to understand this.6. Useful warnings.* Warn about statements that are undefined because the order ofevaluation of increment operators makes a big difference. Here is anexample: *foo++ = hack (*foo);7. Better documentation of how GCC works and how to port it.Here is an outline proposed by Allan Adler.I. Overview of this documentII. The machines on which GCC is implemented A. Prose description of those characteristics of target machines and their operating systems which are pertinent to the implementation of GCC. i. target machine characteristics ii. comparison of this system of machine characteristics with other systems of machine specification currently in use B. Tables of the characteristics of the target machines on which GCC is implemented. C. A priori restrictions on the values of characteristics of target machines, with special reference to those parts of the source code which entail those restrictions i. restrictions on individual characteristics ii. restrictions involving relations between various characteristics D. The use of GCC as a cross-compiler i. cross-compilation to existing machines ii. cross-compilation to non-existent machines E. Assumptions which are made regarding the target machine i. assumptions regarding the architecture of the target machine ii. assumptions regarding the operating system of the target machine iii. assumptions regarding software resident on the target machine iv. where in the source code these assumptions are in effect madeIII. A systematic approach to writing the files tm.h and xm.h A. Macros which require special care or skill B. Examples, with special reference to the underlying reasoningIV. A systematic approach to writing the machine description file md A. Minimal viable sets of insn descriptions B. Examples, with special reference to the underlying reasoningV. Uses of the file aux-output.cVI. Specification of what constitutes correct performance of an implementation of GCC A. The components of GCC B. The itinerary of a C program through GCC C. A system of benchmark programs D. What your RTL and assembler should look like with these benchmarks E. Fine tuning for speed and size of compiled codeVII. A systematic procedure for debugging an implementation of GCC A. Use of GDB i. the macros in the file .gdbinit for GCC ii. obstacles to the use of GDB a. functions implemented as macros can't be called in GDB B. Debugging without GDB i. How to turn off the normal operation of GCC and access specific parts of GCC C. Debugging tools D. Debugging the parser i. how machine macros and insn definitions affect the parser E. Debugging the recognizer i. how machine macros and insn definitions affect the recognizerditto for other componentsVIII. Data types used by GCC, with special reference to restrictions not specified in the formal definition of the data typeIX. References to the literature for the algorithms used in GCC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -