Author: leo
Date: Sun Sep 25 02:42:06 2005
New Revision: 9241
Modified:
branches/leo-ctx5/docs/dev/optimizer.pod
branches/leo-ctx5/docs/memory_internals.pod
Log:
merge -r9238:9239 from trunk
Modified: branches/leo-ctx5/docs/dev/optimizer.pod
==============================================================================
--- branches/leo-ctx5/docs/dev/optimizer.pod (original)
+++ branches/leo-ctx5/docs/dev/optimizer.pod Sun Sep 25 02:42:06 2005
@@ -26,28 +26,28 @@ The IMC_Unit structure contains all the
Each instruction line has an Instruction structure. Pointers to the first and
last Instruction are stored in IMC_Unit. Instructions are stored as a linked
list. To iterate through all Instructions, use:
-Instruction *ins;
-for (ins = unit->instructions; ins; ins = ins->next) {
- ...
-}
+ Instruction *ins;
+ for (ins = unit->instructions; ins; ins = ins->next) {
+ ...
+ }
=item Basic_block
Basic blocks are the most important structure for optimization. A basic block
identifies a block of instructions that will all execute in sequence without
jumps into or out of that block. All labels will appear at the beginning of a
block, and all conditional or unconditional jumps will appear at the end.
Basic_block structures are stored as an array of pointers, each with an index
that denotes their position in the array. Block 0 is implicitly the top block.
To iterate through all Basic_blocks, use:
-int i;
-for (i = 0; i < unit->n_basic_blocks; i++) {
- ...
-}
+ int i;
+ for (i = 0; i < unit->n_basic_blocks; i++) {
+ ...
+ }
=item Edge
Edges denote the flow of control between Basic_blocks. Edges and Basic_blocks
together make up the basic CFG. Each Basic_block has *pred_list and *succ_list
pointer to the first predecessor edge and successor edge, respectively. Each
edge has a *to and *from pointer to the Basic_blocks it joins. To iterate
through all predecessor Edges, use:
-Edge *pred;
-for (pred = to->pred_list; pred; pred=pred->pred_next) {
- ...
-}
+ Edge *pred;
+ for (pred = to->pred_list; pred; pred=pred->pred_next) {
+ ...
+ }
=item Loop_info
@@ -68,9 +68,13 @@ The optimizer loop works as follows:
=over 4
=item 1. Run all pre_optimize() optimizations until none make a change.
+
=item 2. Build basic block info.
+
=item 3. Run all cfg_optimize() optimizations. If one makes a change, go to
step 1.
+
=item 4. Build all other CFG info (dominators, loops, life analysis).
+
=item 5. Run all optimize() optimizations. If one makes a change, go to step
1.
=back
Modified: branches/leo-ctx5/docs/memory_internals.pod
==============================================================================
--- branches/leo-ctx5/docs/memory_internals.pod (original)
+++ branches/leo-ctx5/docs/memory_internals.pod Sun Sep 25 02:42:06 2005
@@ -160,31 +160,39 @@ both the word containing the object's fl
The flag word for object o is found as follows:
- Get the C<dod_flags[]> array for the object's arena
+
[GET_ARENA(o)->dod_flags]
- Get the index of the object in its arena
+
[n=GET_OBJ_N(arena,o)]
- Determine which word in dod_flags contains the needed flag nibble
+
[(obj index)/(obj flag sets per word) = n>>ARENA_FLAG_SHIFT]
The composite expression to reference the flag word is then
- GET_ARENA(o)->dod_flags[ GET_OBJ_N(GET_ARENA(o), o) >> ARENA_FLAG_SHIFT ]
+
+ GET_ARENA(o)->dod_flags[ GET_OBJ_N(GET_ARENA(o), o) >> ARENA_FLAG_SHIFT ]
The bitmask for the desired flag is constructed as follows:
- Determine the index into the flag word of the object's nibble
+
[(obj index)%(nibbles per word) = n & ARENA_FLAG_MASK]
- Convert nibble index into bit index
+
[(nibble index)*(bits per nibble) = (n & ARENA_FLAG_MASK) << 2]
- Create bitmask for desired flag by shifting base flag by bit index
+
[d_PObj_whatever_FLAG << (nibble index)]
The composite expression to form the bitmask is then
- (d_PObj_ ## flag ## _FLAG << (( GET_OBJ_N(GET_ARENA(o), o) &
- ARENA_FLAG_MASK ) << 2))
+
+ (d_PObj_ ## flag ## _FLAG << (( GET_OBJ_N(GET_ARENA(o), o) &
+ ARENA_FLAG_MASK ) << 2))
The DOD_flag_* macros combine these constructions to access the flags.