-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCodeGen.hs
More file actions
31 lines (24 loc) · 743 Bytes
/
CodeGen.hs
File metadata and controls
31 lines (24 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module CodeGen where
import qualified AST
import qualified IR
import qualified SSM
import qualified LLVM
import ASTtoIR
import IRDeadcode
import IRtoSSM
import IRtoLLVM
import TypeInference (P3)
-- Basic Steps
toIR :: P3 AST.Program -> IR.Program IR.IRStmt
toIR = translateProgram
canonicalizeIR :: IR.Program IR.IRStmt -> IR.Program [IR.BasicBlock]
canonicalizeIR = IRDeadcode.optimize . IR.linearize
toSSM :: IR.Program [IR.BasicBlock] -> SSM.Program
toSSM = irToSSM
toLLVM :: IR.Program [IR.BasicBlock] -> LLVM.Program
toLLVM = irToLLVM
-- Full steps
generateSSM :: P3 AST.Program -> SSM.Program
generateSSM = toSSM . canonicalizeIR . toIR
generateLLVM :: P3 AST.Program -> LLVM.Program
generateLLVM = toLLVM . canonicalizeIR . toIR