Commit f6694264 authored by Ian Lynagh's avatar Ian Lynagh

Use a derived Ord instance for Discr

Our hand-written leAlt behaved differently when given a micture of
constructors, but I think that either it won't make a difference or
that this will be an improvement.
parent f1c81a73
...@@ -66,6 +66,7 @@ import Module ...@@ -66,6 +66,7 @@ import Module
import Data.Map (Map) import Data.Map (Map)
import qualified Data.Map as Map import qualified Data.Map as Map
import qualified FiniteMap as Map import qualified FiniteMap as Map
import Data.Ord
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- Generating byte code for a complete module -- Generating byte code for a complete module
...@@ -1349,9 +1350,7 @@ mkMultiBranch maybe_ncons raw_ways = do ...@@ -1349,9 +1350,7 @@ mkMultiBranch maybe_ncons raw_ways = do
return (instrs `appOL` the_default) return (instrs `appOL` the_default)
where where
(defaults, not_defaults) = partition (isNoDiscr.fst) raw_ways (defaults, not_defaults) = partition (isNoDiscr.fst) raw_ways
notd_ways = sortLe notd_ways = sortBy (comparing fst) not_defaults
(\w1 w2 -> leAlt (fst w1) (fst w2))
not_defaults
testLT (DiscrI i) fail_label = TESTLT_I i fail_label testLT (DiscrI i) fail_label = TESTLT_I i fail_label
testLT (DiscrW i) fail_label = TESTLT_W i fail_label testLT (DiscrW i) fail_label = TESTLT_W i fail_label
...@@ -1386,14 +1385,6 @@ mkMultiBranch maybe_ncons raw_ways = do ...@@ -1386,14 +1385,6 @@ mkMultiBranch maybe_ncons raw_ways = do
Just n -> (0, fromIntegral n - 1) Just n -> (0, fromIntegral n - 1)
Nothing -> (minBound, maxBound) Nothing -> (minBound, maxBound)
(DiscrI i1) `leAlt` (DiscrI i2) = i1 <= i2
(DiscrW w1) `leAlt` (DiscrW w2) = w1 <= w2
(DiscrF f1) `leAlt` (DiscrF f2) = f1 <= f2
(DiscrD d1) `leAlt` (DiscrD d2) = d1 <= d2
(DiscrP i1) `leAlt` (DiscrP i2) = i1 <= i2
NoDiscr `leAlt` NoDiscr = True
_ `leAlt` _ = False
isNoDiscr NoDiscr = True isNoDiscr NoDiscr = True
isNoDiscr _ = False isNoDiscr _ = False
...@@ -1423,7 +1414,7 @@ data Discr ...@@ -1423,7 +1414,7 @@ data Discr
| DiscrD Double | DiscrD Double
| DiscrP Word16 | DiscrP Word16
| NoDiscr | NoDiscr
deriving Eq deriving (Eq, Ord)
instance Outputable Discr where instance Outputable Discr where
ppr (DiscrI i) = int i ppr (DiscrI i) = int i
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment