|
ACSE 2.0.3
Advanced Compiler System for Education
|
Control Flow Graph generation and related analyses. More...
Data Structures | |
| struct | t_cfgReg |
| struct | t_bbNode |
| struct | t_basicBlock |
| struct | t_cfg |
Macros | |
| #define | CFG_MAX_DEFS 1 |
| Maximum number of temporary register definitions for each node. | |
| #define | CFG_MAX_USES 2 |
| Maximum number of temporary register uses for each node. | |
Basic Blocks | |
| t_bbNode * | bbInsertInstruction (t_basicBlock *block, t_instruction *instr) |
| t_bbNode * | bbInsertInstructionBefore (t_basicBlock *block, t_instruction *instr, t_bbNode *ip) |
| t_bbNode * | bbInsertInstructionAfter (t_basicBlock *block, t_instruction *instr, t_bbNode *ip) |
Control Flow Graph construction | |
| t_cfg * | programToCFG (t_program *program) |
| int | cfgIterateNodes (t_cfg *graph, void *context, int(*callback)(t_bbNode *node, int nodeIndex, void *context)) |
| void | cfgToProgram (t_program *program, t_cfg *graph) |
| void | deleteCFG (t_cfg *graph) |
Data Flow Analysis | |
| void | cfgComputeLiveness (t_cfg *graph) |
| t_listNode * | bbGetLiveIn (t_basicBlock *bblock) |
| t_listNode * | bbGetLiveOut (t_basicBlock *bblock) |
Utilities | |
| void | cfgDump (t_cfg *graph, FILE *fout, bool verbose) |
Control Flow Graph generation and related analyses.
These functions and data structures allow to build, inspect and partially modify a Control Flow Graph (CFG) representation of a program. A program can be converted to and from a CFG, and a CFG can be analyzed to compute the liveness of each register. These facilities are used by the register allocation process.
| struct t_cfgReg |
Data structure which uniquely identifies a register used or defined by a node in a basic block.
| Data Fields | ||
|---|---|---|
| t_listNode * | mcRegWhitelist | Physical register whitelist. Used by the register allocator. |
| t_regID | tempRegID | Register identifier. |
| struct t_bbNode |
Node in a basic block. Represents an instruction, the temporary registers it uses and/or defines, and live temporary registers in/out of the node.
| Data Fields | ||
|---|---|---|
| t_cfgReg * | defs[CFG_MAX_DEFS] | Set of registers defined by this node ('def' set). NULL slots are ignored. |
| t_listNode * | in | Set of registers live at the entry of the node ('in' set). |
| t_instruction * | instr | Pointer to the instruction associated with this node. |
| t_listNode * | out | Set of registers live at the exit of the node ('out' set). |
| t_basicBlock * | parent | Pointer to the containing basic block. |
| t_cfgReg * | uses[CFG_MAX_USES] | Set of registers used by this node ('use' set). NULL slots are ignored. |
| struct t_basicBlock |
Structure representing a basic block, i.e. a segment of contiguous instructions with no branches in the middle. The use of basic blocks allows – without loss of generality – to minimize the number of edges in the Control Flow Graph, increasing the performance of code analysis.
| Data Fields | ||
|---|---|---|
| t_listNode * | nodes | List of instructions in the block. |
| t_cfg * | parent | The containing basic block. |
| t_listNode * | pred | List of predecessors to this basic block. |
| t_listNode * | succ | List of successors to this basic block. |
| struct t_cfg |
| Data Fields | ||
|---|---|---|
| t_listNode * | blocks | List of all the basic blocks, in program order. |
| t_basicBlock * | endingBlock |
Unique final basic block. The control flow must eventually reach here. This block is always empty, and is not part of the 'blocks' list. |
| t_listNode * | registers | List of all temporary registers used in the program. |
| #define CFG_MAX_DEFS 1 |
| #define CFG_MAX_USES 2 |
| t_listNode * bbGetLiveIn | ( | t_basicBlock * | bblock | ) |
Retrieve the list of live temporary registers entering the given block. Only valid after calling cfgComputeLiveness() on the graph.
| bblock | The basic block. |
| t_listNode * bbGetLiveOut | ( | t_basicBlock * | bblock | ) |
Retrieve the list of live temporary registers exiting the given block. Only valid after calling cfgComputeLiveness() on the graph.
| bblock | The basic block. |
| t_bbNode * bbInsertInstruction | ( | t_basicBlock * | block, |
| t_instruction * | instr ) |
| t_bbNode * bbInsertInstructionAfter | ( | t_basicBlock * | block, |
| t_instruction * | instr, | ||
| t_bbNode * | ip ) |
| t_bbNode * bbInsertInstructionBefore | ( | t_basicBlock * | block, |
| t_instruction * | instr, | ||
| t_bbNode * | ip ) |
| void cfgComputeLiveness | ( | t_cfg * | graph | ) |
| void cfgDump | ( | t_cfg * | graph, |
| FILE * | fout, | ||
| bool | verbose ) |
| int cfgIterateNodes | ( | t_cfg * | graph, |
| void * | context, | ||
| int(* | callback )(t_bbNode *node, int nodeIndex, void *context) ) |
Iterates through the nodes in a control flow graph.
| graph | The graph that must be iterated over. |
| context | The context pointer that will be passed to the callback function. |
| callback | The callback function that will be called at each node found. The arguments of the callback are as follows:
|
| void deleteCFG | ( | t_cfg * | graph | ) |