Some compiler-related ideas & problems (Appel : Modern compiler implementation in Java):
- Instruction selection : Machine instructions are represented by tree pattern. The optimal code is generated by selecting tree patterns which form the minimum tree. Thus, instruction selection becomes a task of tiling the tree with minimal set of tree patterms. There is a number of approaches to this problem, most notably, the Maximal Munch algorithm and Dynamic Programming.
In pratice, tree pattern - based approach can be a problem when optimizing for cics, rather than risc machine...
- Liveness Analysis : In order to optimize the register allocation, the compiler must analyze which variables are used ("alive") during every segment of program (for example, we can observe every basic block as one segment). Variables which are not used at the same time can be allocated in the same register. We observe the control-flow-graph of the program and determine the "live" variables at every edge of the graph. Then, we can perform graph partitioning in order to divide the program into segments with a number of alive variables which correspond to number of system registers. Again, we should do this in a optimal manner (every segment should allocate all registers, but among segments there should be minimum needed transfer of data between registers and memory).
(random unfinished engineering notes)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment