ACSE 2.0.3
Advanced Compiler System for Education
Loading...
Searching...
No Matches
cfg.h
Go to the documentation of this file.
1
3
4#ifndef CFG_H
5#define CFG_H
6
7#include <stdio.h>
8#include <stdbool.h>
9#include "program.h"
10#include "list.h"
11
23
25#define CFG_MAX_DEFS 1
27#define CFG_MAX_USES 2
28
29
38
39typedef struct t_basicBlock t_basicBlock;
40typedef struct t_cfg t_cfg;
41
58
69
80
81
84
96 t_basicBlock *block, t_instruction *instr, t_bbNode *ip);
103 t_basicBlock *block, t_instruction *instr, t_bbNode *ip);
104
106
107
110
114t_cfg *programToCFG(t_program *program);
115
129int cfgIterateNodes(t_cfg *graph, void *context,
130 int (*callback)(t_bbNode *node, int nodeIndex, void *context));
131
136void cfgToProgram(t_program *program, t_cfg *graph);
137
140void deleteCFG(t_cfg *graph);
141
143
144
147
150void cfgComputeLiveness(t_cfg *graph);
151
164
166
167
170
176void cfgDump(t_cfg *graph, FILE *fout, bool verbose);
177
179
183
184#endif
t_listNode * pred
List of predecessors to this basic block.
Definition cfg.h:65
t_regID tempRegID
Register identifier.
Definition cfg.h:34
t_listNode * registers
List of all temporary registers used in the program.
Definition cfg.h:78
t_listNode * mcRegWhitelist
Physical register whitelist. Used by the register allocator.
Definition cfg.h:36
t_listNode * in
Set of registers live at the entry of the node ('in' set).
Definition cfg.h:54
t_listNode * nodes
List of instructions in the block.
Definition cfg.h:67
t_cfg * parent
The containing basic block.
Definition cfg.h:64
t_basicBlock * parent
Pointer to the containing basic block.
Definition cfg.h:46
t_listNode * out
Set of registers live at the exit of the node ('out' set).
Definition cfg.h:56
t_listNode * succ
List of successors to this basic block.
Definition cfg.h:66
t_instruction * instr
Pointer to the instruction associated with this node.
Definition cfg.h:48
t_listNode * blocks
List of all the basic blocks, in program order.
Definition cfg.h:73
t_basicBlock * endingBlock
Definition cfg.h:76
t_cfgReg * defs[CFG_MAX_DEFS]
Set of registers defined by this node ('def' set). NULL slots are ignored.
Definition cfg.h:50
t_cfgReg * uses[CFG_MAX_USES]
Set of registers used by this node ('use' set). NULL slots are ignored.
Definition cfg.h:52
void cfgToProgram(t_program *program, t_cfg *graph)
Definition cfg.c:413
void cfgComputeLiveness(t_cfg *graph)
Definition cfg.c:639
void deleteCFG(t_cfg *graph)
Definition cfg.c:235
t_listNode * bbGetLiveOut(t_basicBlock *bblock)
Definition cfg.c:465
int cfgIterateNodes(t_cfg *graph, void *context, int(*callback)(t_bbNode *node, int nodeIndex, void *context))
Definition cfg.c:437
#define CFG_MAX_USES
Maximum number of temporary register uses for each node.
Definition cfg.h:27
t_bbNode * bbInsertInstruction(t_basicBlock *block, t_instruction *instr)
Definition cfg.c:184
#define CFG_MAX_DEFS
Maximum number of temporary register definitions for each node.
Definition cfg.h:25
t_bbNode * bbInsertInstructionBefore(t_basicBlock *block, t_instruction *instr, t_bbNode *ip)
Definition cfg.c:193
void cfgDump(t_cfg *graph, FILE *fout, bool verbose)
Definition cfg.c:775
t_listNode * bbGetLiveIn(t_basicBlock *bblock)
Definition cfg.c:477
t_cfg * programToCFG(t_program *program)
Definition cfg.c:370
t_bbNode * bbInsertInstructionAfter(t_basicBlock *block, t_instruction *instr, t_bbNode *ip)
Definition cfg.c:207
Definition cfg.h:44
Definition cfg.h:71
Definition cfg.h:32
A node belonging a list.
Definition list.h:39
int t_regID
Type for register identifiers.
Definition program.h:28
A double-linked list.
Program object definition and management.