-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
121 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
module Juvix.Compiler.Reg.Transformation.Base | ||
( module Juvix.Compiler.Tree.Transformation.Generic.Base, | ||
module Juvix.Compiler.Tree.Options, | ||
module Juvix.Compiler.Reg.Data.InfoTable, | ||
module Juvix.Compiler.Reg.Language, | ||
) | ||
where | ||
|
||
import Juvix.Compiler.Reg.Data.InfoTable | ||
import Juvix.Compiler.Reg.Language | ||
import Juvix.Compiler.Tree.Options | ||
import Juvix.Compiler.Tree.Transformation.Generic.Base |
2 changes: 1 addition & 1 deletion
2
...Reg/Transformation/ConstantPropagation.hs → ...formation/Optimize/ConstantPropagation.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ler/Reg/Transformation/CopyPropagation.hs → ...ransformation/Optimize/CopyPropagation.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Reg/Transformation/DeadCodeElimination.hs → ...formation/Optimize/DeadCodeElimination.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/Juvix/Compiler/Reg/Transformation/Optimize/Phase/Cairo.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Juvix.Compiler.Reg.Transformation.Optimize.Phase.Cairo where | ||
|
||
import Juvix.Compiler.Reg.Transformation.Base | ||
import Juvix.Compiler.Reg.Transformation.Optimize.Phase.Main qualified as Main | ||
|
||
optimize :: (Member (Reader Options) r) => InfoTable -> Sem r InfoTable | ||
optimize = withOptimizationLevel 1 Main.optimize |
20 changes: 20 additions & 0 deletions
20
src/Juvix/Compiler/Reg/Transformation/Optimize/Phase/Main.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Juvix.Compiler.Reg.Transformation.Optimize.Phase.Main where | ||
|
||
import Juvix.Compiler.Reg.Transformation.Base | ||
import Juvix.Compiler.Reg.Transformation.Optimize.ConstantPropagation | ||
import Juvix.Compiler.Reg.Transformation.Optimize.CopyPropagation | ||
import Juvix.Compiler.Reg.Transformation.Optimize.DeadCodeElimination | ||
|
||
optimize' :: Options -> InfoTable -> InfoTable | ||
optimize' Options {..} = | ||
compose | ||
(2 * _optOptimizationLevel) | ||
( copyPropagate | ||
. constantPropagate | ||
. removeDeadAssignments | ||
) | ||
|
||
optimize :: (Member (Reader Options) r) => InfoTable -> Sem r InfoTable | ||
optimize tab = do | ||
opts <- ask | ||
return $ optimize' opts tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Juvix.Compiler.Tree.Options where | ||
|
||
import Juvix.Compiler.Pipeline.EntryPoint | ||
import Juvix.Data.Field | ||
import Juvix.Prelude | ||
|
||
data Options = Options | ||
{ _optOptimizationLevel :: Int, | ||
_optFieldSize :: Natural | ||
} | ||
|
||
makeLenses ''Options | ||
|
||
defaultOptions :: Options | ||
defaultOptions = | ||
Options | ||
{ _optOptimizationLevel = defaultOptimizationLevel, | ||
_optFieldSize = defaultFieldSize | ||
} | ||
|
||
fromEntryPoint :: EntryPoint -> Options | ||
fromEntryPoint EntryPoint {..} = | ||
Options | ||
{ _optOptimizationLevel = _entryPointOptimizationLevel, | ||
_optFieldSize = _entryPointFieldSize | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters