-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
50 lines (39 loc) · 1.54 KB
/
Main.hs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module Main where
import Analyze
import Program
import Domain
import LLVM.Module
import LLVM.Internal.Module
import LLVM.Internal.Context
import LLVM.AST
import Options.Applicative
import Data.Semigroup ((<>))
onePass :: [CFG] -> CFG -> IO ()
onePass cfgPool cfg =
let table = analyze [] cfgPool cfg in do
putStrLn $ "Analysis of " ++ (getFid cfg) ++ " begins...\n"
putStrLn ""
putStrLn $ "Analysis Results for: " ++ (getFid cfg)
putStrLn (tableToString table)
putStrLn ""
multiPass :: [CFG] -> [CFG] -> IO ()
multiPass _ [] = return ()
multiPass cfgPool (cfg:cfgs) = do
onePass cfgPool cfg >> multiPass cfgPool cfgs
data Options = Options {filePath :: String}
getFilePath :: Options -> String
getFilePath (Options filePath) = filePath
main :: IO ()
main = do
args <- execParser $ info (Options <$>
strOption (long "input" <>
short 'i' <>
help "Path to the input file.") <*
abortOption ShowHelpText (long "help" <>
short 'h' <>
help "Display this message."))
(progDesc "Interprocedural interval analyzer." <> fullDesc)
rawModule <- readFile (getFilePath args)
pureModule <- withContext $ \context -> withModuleFromLLVMAssembly context rawModule moduleAST
let myModule = Program.newModule pureModule in
multiPass (getCFGs myModule) (getCFGs myModule)