1 (* M2BasicBlock.def converts a scope block into a list of basic blocks.
3 Copyright (C) 2001-2025 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. *)
22 DEFINITION MODULE M2BasicBlock ;
29 Description: Converts a scope block into a list of basic blocks.
30 The basic blocks are either converted back into quadruples
31 or alternatively translated into GCC trees.
34 FROM M2Scope IMPORT ScopeBlock ;
39 BasicBlockProc = PROCEDURE (BasicBlock) ;
43 InitBasicBlocks - converts a list of quadruples as defined by
44 scope blocks into a set of basic blocks.
45 All quadruples within this list which are not
46 reachable are removed.
49 PROCEDURE InitBasicBlocks (sb: ScopeBlock) : BasicBlock ;
53 InitBasicBlocksFromRange - converts a list of quadruples as defined by
55 All quadruples within this list which are not
56 reachable are removed.
59 PROCEDURE InitBasicBlocksFromRange (ScopeSym: CARDINAL;
60 start, end: CARDINAL) : BasicBlock ;
64 KillBasicBlocks - destroys the list of Basic Blocks and assigns bb to NIL.
67 PROCEDURE KillBasicBlocks (VAR bb: BasicBlock) ;
71 FreeBasicBlocks - destroys the list of Basic Blocks.
74 PROCEDURE FreeBasicBlocks (bb: BasicBlock) ;
78 ForeachBasicBlockDo - for each basic block call procedure, p.
81 PROCEDURE ForeachBasicBlockDo (bb: BasicBlock; p: BasicBlockProc) ;
85 GetBasicBlockScope - return the scope associated with the basic block.
88 PROCEDURE GetBasicBlockScope (bb: BasicBlock) : CARDINAL ;
92 GetBasicBlockStart - return the quad associated with the start of the basic block.
95 PROCEDURE GetBasicBlockStart (bb: BasicBlock) : CARDINAL ;
99 GetBasicBlockEnd - return the quad associated with the end of the basic block.
102 PROCEDURE GetBasicBlockEnd (bb: BasicBlock) : CARDINAL ;
106 IsBasicBlockFirst - return TRUE if this basic block is the first in the sequence.
109 PROCEDURE IsBasicBlockFirst (bb: BasicBlock) : BOOLEAN ;