diff options
author | Simon Marlow <marlowsd@gmail.com> | 2014-01-16 15:14:49 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2014-01-16 15:14:49 +0000 |
commit | 58e5843a4118ca19fd1c93f52f2365d90bb1b9b6 (patch) | |
tree | 252ec4f6c29852ea9ef9d37fa8da91b4e96eb7cb /compiler/cmm/CmmOpt.hs | |
parent | eaa37a0f69df28f051e7511d62dc104eb50a2a6b (diff) | |
download | haskell-58e5843a4118ca19fd1c93f52f2365d90bb1b9b6.tar.gz |
Allow the argument to 'reserve' to be a compile-time expression
By using the constant-folder to reduce it to an integer.
Diffstat (limited to 'compiler/cmm/CmmOpt.hs')
-rw-r--r-- | compiler/cmm/CmmOpt.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/cmm/CmmOpt.hs b/compiler/cmm/CmmOpt.hs index acaed28acf..54dbbebae6 100644 --- a/compiler/cmm/CmmOpt.hs +++ b/compiler/cmm/CmmOpt.hs @@ -7,6 +7,8 @@ ----------------------------------------------------------------------------- module CmmOpt ( + constantFoldNode, + constantFoldExpr, cmmMachOpFold, cmmMachOpFoldM ) where @@ -24,6 +26,16 @@ import Platform import Data.Bits import Data.Maybe + +constantFoldNode :: DynFlags -> CmmNode e x -> CmmNode e x +constantFoldNode dflags = mapExp (constantFoldExpr dflags) + +constantFoldExpr :: DynFlags -> CmmExpr -> CmmExpr +constantFoldExpr dflags = wrapRecExp f + where f (CmmMachOp op args) = cmmMachOpFold dflags op args + f (CmmRegOff r 0) = CmmReg r + f e = e + -- ----------------------------------------------------------------------------- -- MachOp constant folder |