Averest


CodeTransformations Module

This module implements the core of a simple compiler for translating MiniC programs to CmdType programs and control dataflow graphs.

Functions and values

Function or value Description

ExpandFunCallsInMiniC mcp

Full Usage: ExpandFunCallsInMiniC mcp

Parameters:
Returns: MiniCProgram

ExpandFunCallsInStmtC expands all function calls in a statement. The function definitions have to be provided in the array of MiniC functions.

mcp : MiniCProgram
Returns: MiniCProgram

ExpandFunCallsInStmtC funcArr stmt

Full Usage: ExpandFunCallsInStmtC funcArr stmt

Parameters:
Returns: StmtC

ExpandFunCallsInStmtC expands all function calls in a statement. The function definitions have to be provided in the array of MiniC functions.

funcArr : MiniCFunction[]
stmt : StmtC
Returns: StmtC

Expr2C e

Full Usage: Expr2C e

Parameters:
Returns: string

translate an expression to C code

e : ExprC
Returns: string

Expr2FSharp e

Full Usage: Expr2FSharp e

Parameters:
Returns: string

translate an expression to F# code

e : ExprC
Returns: string

ExprDouble2C e

Full Usage: ExprDouble2C e

Parameters:
Returns: string * bool

translate an double expression to C code

e : ExprC
Returns: string * bool

LhsExpr2C lhs

Full Usage: LhsExpr2C lhs

Parameters:
Returns: string

translate a left-hand side expression to C code

lhs : LhsExprC
Returns: string

LhsExpr2FSharp lhs

Full Usage: LhsExpr2FSharp lhs

Parameters:
Returns: string

translate a lhs expression to F# code

lhs : LhsExprC
Returns: string

PredicateMiniCProgram mcp

Full Usage: PredicateMiniCProgram mcp

Parameters:
Returns: MiniCProgram

predicate the threads of a MiniC program

mcp : MiniCProgram
Returns: MiniCProgram

PredicateStmt stmt

Full Usage: PredicateStmt stmt

Parameters:
Returns: StmtC

if-conversion: predicate a statement, i.e., convert control-flow into dataflow in that if-statements are converted to conditional expressions

stmt : StmtC
Returns: StmtC

PrintStmtC2C indent ostr stmt

Full Usage: PrintStmtC2C indent ostr stmt

Parameters:

print a statement as C code; it is called with the initial indentation, the stream to print and the MiniC statement

indent : string
ostr : TextWriter
stmt : StmtC

PrintThread2C ostr mcp thrdName

Full Usage: PrintThread2C ostr mcp thrdName

Parameters:

print a single threads of a MiniC program as C code after expanding the function and procedure calls

ostr : TextWriter
mcp : MiniCProgram
thrdName : string

PrintThreads2C ostr mcp

Full Usage: PrintThreads2C ostr mcp

Parameters:

print all threads of a MiniC program as C code after expanding the function and procedure calls

ostr : TextWriter
mcp : MiniCProgram

SSAofMiniCProgram mcp

Full Usage: SSAofMiniCProgram mcp

Parameters:
Returns: MiniCProgram

compute SSA form of a MiniC program (it only transforms the threads, and not the functions which are expected to be inlined before this trafa)

mcp : MiniCProgram
Returns: MiniCProgram

SSAofStmt decL stmt

Full Usage: SSAofStmt decL stmt

Parameters:
Returns: (string * TypeC)[] * StmtC

Compute static single assignment (SSA) form for a given MiniC statement. The function requires also the declarations of the variables that occur in the statement, and will generate a pair (decL,stmtSSA) where the declarations decL contain the declarations of the generated variables, and stmtSSA is the statement in SSA form.

decL : (string * TypeC)[]
stmt : StmtC
Returns: (string * TypeC)[] * StmtC

StmtC2FSharp indent stmt

Full Usage: StmtC2FSharp indent stmt

Parameters:
    indent : string
    stmt : StmtC

Returns: string list

translate a statement to F# code

indent : string
stmt : StmtC
Returns: string list

Type2C ty

Full Usage: Type2C ty

Parameters:
Returns: string * string

Translate a MiniC type to a type in C. The function returns a tuple (tyS,dimS) where tyS is the type in C syntax and dimS is a further string for dimensions in case of arrays (otherwise it is the empty string).

ty : TypeC
Returns: string * string