Compiler Module
This module implements the core of a simple compiler for translating MiniC programs to CmdType programs and control dataflow graphs.
Types
Type | Description |
BasicBlock is a record to hold the data of a basic block of the CDFG of a cmd program. rdVars and wrVars hold the sets of variables that were read and written by that basic block, cmdProg is the program of that basic block, and actDepGraph is its action dependency graph. nextBBs is the set of successor basic blocks (either one or two). Finally, lineBegin and lineEnd are the first and last lines of the cmd program that belong to this basic block. |
Functions and values
Function or value | Description |
|
CompileStmtC compiles a given MiniC statement to a CmdType program where the given declarations decl are used. The result is a mapping that maps program lines to CmdType instructions plus the list of used temporary variables.
|
|
ComputeCmdDependencyGraph computes the action dependency graph of a cmd program without branch/jump instructions, i.e., of a basic block. This is a graph whose nodes are integers denoting program lines of the cmd program, and where there is an edge l->l' if l must be executed before l' (since there is a data dependency between l and l'). Data dependencies considered are read-after-write, write-after-write and write-after-read. Besides the Cmd program, also the first and last line of it is needed as argument. The result is a mapping that maps l to the set of its dependent nodes l', meaning that l has to be executed before l'. |
|
ComputeControlDataFlowGraph computes the control-dataflow graph (CDFG) of a cmd program where the generated CDFG is represented as a map from some of the program lines to BasicBlocks where the
|
Full Usage:
ControlDataFlowGraph2DotFile ostr cdfg
Parameters:
TextWriter
cdfg : Map<int, BasicBlock>
|
Writes CDFG of a cmd program as computed by ComputeControlDataFlowGraph and ComputeCmdDependencyGraph to a dot-file for visualization.
|
Full Usage:
ControlFlowGraph2DotFile ostr cdfg
Parameters:
TextWriter
cdfg : Map<int, BasicBlock>
|
Writes CFG of a cmd program as computed by ComputeControlDataFlowGraph to a dot-file for visualization.
|
Full Usage:
ForceDirectedScheduling bb delay
Parameters:
BasicBlock
delay : int
Returns: Set<int> array * Map<Ops2, float array>
|
ForceDirectedScheduling is a time-constrained scheduling heuristic: Given the commands of a basic block, the function first computes the ASAP and ALAP schedules. To determine the mobility intervals of the cmds, the ALAP schedule is then shifted by "delay" time steps, to stretch the mobility intervals to a schedule with Length(ASAP)+delay many steps. The function then determines a schedule that requires that many time steps where the resources are distributed as equal as possible to maximize the reuse of allocated function units. The result is the generated schedule with its resource usage matrix (mapping each step and operation to the number of operation units requires in that step).
|
Full Usage:
ListScheduling bb fuMap
Parameters:
BasicBlock
fuMap : Map<Ops2, int>
Returns: Set<int> array
|
List based scheduling is a resource directed scheduling method, i.e., available resources are given, and a schedule is generated that only makes use of the given resources, thus taking possibly more time than a ASAP/ALAP schedule.
|
Given an acyclic graph represented by its set of nodes nodesG, and its edges given as adjacency map (mapping a node to its successors), this function computes the mobility intervals, i.e., a map which maps a node i to a pair (lv1,lv2) where lv1 and lv2 are the steps where node i will be scheduled to in an ASAP and ALAP schedule, respectively. |
|
|
Prints the CDFG as a program listing with separation lines between bbs.
|
Full Usage:
ResetTempVarIndex ()
Parameters:
unit
|
|
Full Usage:
VarIndex
Returns: int ref
|
|
Full Usage:
printSchedule ostr bb schedule
Parameters:
'a
bb : BasicBlock
schedule : Set<int>[]
|
print a schedule
|
|