Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
a4124cf4
Commit
a4124cf4
authored
Jan 27, 2005
by
simonpj
Browse files
[project @ 2005-01-27 15:51:11 by simonpj]
Add a rule for dataToTag (tagToEnum x)
parent
2cf37ff9
Changes
1
Hide whitespace changes
Inline
Side-by-side
ghc/compiler/prelude/PrelRules.lhs
View file @
a4124cf4
...
...
@@ -20,7 +20,7 @@ module PrelRules ( primOpRules, builtinRules ) where
#include "HsVersions.h"
import CoreSyn
import Id ( mkWildId )
import Id ( mkWildId
, isPrimOpId_maybe
)
import Literal ( Literal(..), mkMachInt, mkMachWord
, literalType
, word2IntLit, int2WordLit
...
...
@@ -381,12 +381,15 @@ For dataToTag#, we can reduce if either
(b) the argument is a variable whose unfolding is a known constructor
\begin{code}
dataToTagRule [
_, val_ar
g]
= case exprIsConApp_maybe val_arg of
Just (dc,_) -> ASSERT( not (isNewTyCon (dataConTyCon dc)) )
Just (mkIntVal (toInteger (
data
Con
Tag
dc - fIRST_TAG)))
dataToTagRule [
ty1, Var tag_to_enum `App` ty2 `App` ta
g]
| Just TagToEnumOp <- isPrimOpId_maybe tag_to_enum
, ty1 `coreEqType` ty2
= Just tag --
data
To
Tag
(tagToEnum x) ==> x
other -> Nothing
dataToTagRule [_, val_arg]
| Just (dc,_) <- exprIsConApp_maybe val_arg
= ASSERT( not (isNewTyCon (dataConTyCon dc)) )
Just (mkIntVal (toInteger (dataConTag dc - fIRST_TAG)))
dataToTagRule other = Nothing
\end{code}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment