-
Notifications
You must be signed in to change notification settings - Fork 82
Compiler Design
calvis edited this page Apr 28, 2012
·
2 revisions
Our compiler is divided into three parts, a front-end, a middle, and a back-end.
The front-end of the Harlan compiler is comprised of our parser, typechecker, and several passes that are responsible for making the code more uniform and simple.
-
parse-harlan
verifies the input program, and inserts tags around all scalar expressions (for example, the integer0
becomes(int 0)
). This reduces ambiguity in the typechecker. -
returnify
will insert a return around the last expression in each function body, if one does not exist already. This pass must run before typechecking, so that the typechecker can enforce that all returns are returning expressions of the same type. -
typecheck
does exactly what it sounds like. Every expression is tagged with its type, assuming that the program is statically well-typed. If not, the typechecker will error. -
expand-primitives
rewrites front-end primitives, such aswrite-pgm
(primitives that are too complex to deal with in passes later), orprint
andassert
that are called on complex data-types. -
remove-danger
adds safety-checks before vector-refs, to ensure safe memory access.
make-kernel-dimensions-explicit
optimize-fuse-kernels
lift-complex
remove-nested-kernels
optimize-lift-lets
returnify-kernels
make-vector-refs-explicit
annotate-free-vars
insert-let-regions
infer-regions
uglify-vectors
remove-let-regions
flatten-lets
hoist-kernels
generate-kernel-calls
compile-module
convert-types
Currently, harlan-format-c
is the only pass in the back-end of the compiler, and it is responsible for turning s-expressions into a string of C++ with OpenCL.