diff options
author | Norman Ramsey <nr@eecs.harvard.edu> | 2007-09-17 16:16:34 +0000 |
---|---|---|
committer | Norman Ramsey <nr@eecs.harvard.edu> | 2007-09-17 16:16:34 +0000 |
commit | bbd857519eb2960476ef67b935a632983f2d84f6 (patch) | |
tree | cdc90d851bc17e148bcc30fca155d8e6bcc12ad5 /compiler/cmm/CmmExpr.hs | |
parent | b2acf7a7179f08f7e4099799180017825154567d (diff) | |
download | haskell-bbd857519eb2960476ef67b935a632983f2d84f6.tar.gz |
added 'filterRegsUsed' to CmmExpr
Diffstat (limited to 'compiler/cmm/CmmExpr.hs')
-rw-r--r-- | compiler/cmm/CmmExpr.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/cmm/CmmExpr.hs b/compiler/cmm/CmmExpr.hs index 983a232e17..1769a01466 100644 --- a/compiler/cmm/CmmExpr.hs +++ b/compiler/cmm/CmmExpr.hs @@ -5,7 +5,7 @@ module CmmExpr , CmmLit(..), cmmLitRep , LocalReg(..), localRegRep, localRegGCFollow, GCKind(..) , GlobalReg(..), globalRegRep, spReg, hpReg, spLimReg, nodeReg, node - , UserOfLocalRegs, foldRegsUsed + , UserOfLocalRegs, foldRegsUsed, filterRegsUsed , RegSet, emptyRegSet, elemRegSet, extendRegSet, deleteFromRegSet, mkRegSet , plusRegSet, minusRegSet, timesRegSet ) @@ -112,6 +112,11 @@ timesRegSet = intersectUniqSets class UserOfLocalRegs a where foldRegsUsed :: (b -> LocalReg -> b) -> b -> a -> b +filterRegsUsed :: UserOfLocalRegs e => (LocalReg -> Bool) -> e -> RegSet +filterRegsUsed p e = + foldRegsUsed (\regs r -> if p r then extendRegSet regs r else regs) + emptyRegSet e + instance UserOfLocalRegs CmmReg where foldRegsUsed f z (CmmLocal reg) = f z reg foldRegsUsed _ z (CmmGlobal _) = z |