X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fcmm%2FCmmExpr.hs;h=d09be34b6a943ad261435ad786cfe5b67ac37c00;hp=6c38c0361dc03e4a056e3974b5c10064cbc83bd1;hb=d436c70d43fb905c63220040168295e473f4b90a;hpb=df54e4b621b1d2a8e30b01b3e93494a515d09f48 diff --git a/compiler/cmm/CmmExpr.hs b/compiler/cmm/CmmExpr.hs index 6c38c03..d09be34 100644 --- a/compiler/cmm/CmmExpr.hs +++ b/compiler/cmm/CmmExpr.hs @@ -10,6 +10,7 @@ module CmmExpr , Width(..) , widthInBits, widthInBytes, widthInLog, widthFromBytes , wordWidth, halfWordWidth, cIntWidth, cLongWidth + , narrowU, narrowS , CmmExpr(..), cmmExprType, cmmExprWidth, maybeInvertCmmExpr , CmmReg(..), cmmRegType @@ -21,7 +22,7 @@ module CmmExpr , DefinerOfSlots, UserOfSlots, foldSlotsDefd, foldSlotsUsed , RegSet, emptyRegSet, elemRegSet, extendRegSet, deleteFromRegSet, mkRegSet , plusRegSet, minusRegSet, timesRegSet - , Area(..), AreaId(..), SubArea, SubAreaSet, AreaMap, StackSlotMap, getSlot + , Area(..), AreaId(..), SubArea, SubAreaSet, AreaMap, isStackSlotOf -- MachOp , MachOp(..) @@ -48,13 +49,13 @@ import CLabel import Constants import FastString import FiniteMap -import Maybes -import Monad import Outputable -import Panic import Unique import UniqSet +import Data.Word +import Data.Int + ----------------------------------------------------------------------------- -- CmmExpr -- An expression. Expressions have no side effects. @@ -259,23 +260,14 @@ instance DefinerOfLocalRegs a => DefinerOfLocalRegs (Maybe a) where -- Stack slots ----------------------------------------------------------------------------- -mkVarSlot :: LocalReg -> CmmExpr -mkVarSlot r = CmmStackSlot (RegSlot r) 0 - --- Usually, we either want to lookup a variable's spill slot in an environment --- or else allocate it and add it to the environment. --- For a variable, we just need a single area of the appropriate size. -type StackSlotMap = FiniteMap LocalReg CmmExpr -getSlot :: StackSlotMap -> LocalReg -> (StackSlotMap, CmmExpr) -getSlot map r = case lookupFM map r of - Just s -> (map, s) - Nothing -> (addToFM map r s, s) where s = mkVarSlot r +isStackSlotOf :: CmmExpr -> LocalReg -> Bool +isStackSlotOf (CmmStackSlot (RegSlot r) _) r' = r == r' +isStackSlotOf _ _ = False ----------------------------------------------------------------------------- -- Stack slot use information for expressions and other types [_$_] ----------------------------------------------------------------------------- - -- Fold over the area, the offset into the area, and the width of the subarea. class UserOfSlots a where foldSlotsUsed :: (b -> SubArea -> b) -> b -> a -> b @@ -387,6 +379,7 @@ instance Ord GlobalReg where compare CurrentTSO CurrentTSO = EQ compare CurrentNursery CurrentNursery = EQ compare HpAlloc HpAlloc = EQ + compare EagerBlackholeInfo EagerBlackholeInfo = EQ compare GCEnter1 GCEnter1 = EQ compare GCFun GCFun = EQ compare BaseReg BaseReg = EQ @@ -635,6 +628,21 @@ widthInLog W64 = 3 widthInLog W128 = 4 widthInLog W80 = panic "widthInLog: F80" +-- widening / narrowing + +narrowU :: Width -> Integer -> Integer +narrowU W8 x = fromIntegral (fromIntegral x :: Word8) +narrowU W16 x = fromIntegral (fromIntegral x :: Word16) +narrowU W32 x = fromIntegral (fromIntegral x :: Word32) +narrowU W64 x = fromIntegral (fromIntegral x :: Word64) +narrowU _ _ = panic "narrowTo" + +narrowS :: Width -> Integer -> Integer +narrowS W8 x = fromIntegral (fromIntegral x :: Int8) +narrowS W16 x = fromIntegral (fromIntegral x :: Int16) +narrowS W32 x = fromIntegral (fromIntegral x :: Int32) +narrowS W64 x = fromIntegral (fromIntegral x :: Int64) +narrowS _ _ = panic "narrowTo" ----------------------------------------------------------------------------- -- MachOp