1999-12-04 Mark Mitchell <mark@codesourcery.com>
+ * function.h (insert_block_after_note): Declare.
+ * function.c (insert_block_after_note): Split out from ...
+ (retrofit_block): ... here.
+
* stmt.c (expand_fixup): Fix typo in comment.
Sat Dec 4 14:13:38 MET 1999 Jan Hubicka <hubicka@freesoft.cz>
return tramp;
}
\f
+/* Insert the BLOCK in the block-tree, knowing that the previous
+ block-note is for OLD_BLOCK. BEGIN_P is non-zero if the previous
+ block-note was the for the beginning of a BLOCK. FN is the
+ FUNCTION_DECL into which the BLOCK is being inserted. */
+
+void
+insert_block_after_note (block, old_block, begin_p, fn)
+ tree block;
+ tree old_block;
+ int begin_p;
+ tree fn;
+{
+ if (begin_p)
+ {
+ /* If there was no previous block, use the top-level block for
+ the function. */
+ if (!old_block)
+ old_block = DECL_INITIAL (fn);
+
+ BLOCK_SUPERCONTEXT (block) = old_block;
+ BLOCK_CHAIN (block) = BLOCK_SUBBLOCKS (old_block);
+ BLOCK_SUBBLOCKS (old_block) = block;
+ }
+ else
+ {
+ BLOCK_SUPERCONTEXT (block) = BLOCK_SUPERCONTEXT (old_block);
+ BLOCK_CHAIN (block) = BLOCK_CHAIN (old_block);
+ BLOCK_CHAIN (old_block) = block;
+ }
+}
+
/* Insert the BLOCK in the block-tree before LAST_INSN. */
void
&& (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG
|| NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_END))
break;
- if (!insn || NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG)
- {
- tree superblock;
- if (insn)
- superblock = NOTE_BLOCK (insn);
- else
- superblock = DECL_INITIAL (current_function_decl);
-
- BLOCK_SUPERCONTEXT (block) = superblock;
- BLOCK_CHAIN (block) = BLOCK_SUBBLOCKS (superblock);
- BLOCK_SUBBLOCKS (superblock) = block;
- }
- else
- {
- tree prevblock = NOTE_BLOCK (insn);
-
- BLOCK_SUPERCONTEXT (block) = BLOCK_SUPERCONTEXT (prevblock);
- BLOCK_CHAIN (block) = BLOCK_CHAIN (prevblock);
- BLOCK_CHAIN (prevblock) = block;
- }
+ insert_block_after_note (block,
+ insn ? NOTE_BLOCK (insn) : NULL_TREE,
+ insn
+ ? (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG)
+ : 1,
+ current_function_decl);
}
/* The functions identify_blocks and reorder_blocks provide a way to
Also store in each NOTE for the beginning or end of a block
the index of that block in the vector. */
extern void identify_blocks PROTO((tree, rtx));
+/* Insert the BLOCK in the block-tree, knowing that the previous
+ block-note is for OLD_BLOCK. BEGIN_P is non-zero if the previous
+ block-note was the for the beginning of a BLOCK. FN is the
+ FUNCTION_DECL into which the BLOCK is being inserted. */
+extern void insert_block_after_note PROTO((tree, tree, int, tree));
/* Insert a new BLOCK at an appropriate place in the block tree. */
extern void retrofit_block PROTO((tree, rtx));