{-# LINE 1 "./Data/BitUtil.hs" #-}
# LINE 1 " dist / dist - sandbox-235ea54e / build / autogen / cabal_macros.h " #
                                                                

                           






                          






                             






                     






                       






                  






                    






                        






                         






                       






                   






                      






                          







{-# LINE 2 "./Data/BitUtil.hs" #-}
{-# LINE 1 "./Data/BitUtil.hs" #-}
# LANGUAGE CPP #

# LANGUAGE MagicHash #


# LANGUAGE Trustworthy #

-----------------------------------------------------------------------------
-- |
-- Module      :  Data.BitUtil
  Copyright    :   ( c )   2012
                 ( c )   2012
-- License     :  BSD-style
-- Maintainer  :  
-- Stability   :  provisional
-- Portability :  portable
-----------------------------------------------------------------------------

module Data.BitUtil
    ( highestBitMask
    , shiftLL
    , shiftRL
    ) where

  On GHC , include MachDeps.h to get WORD_SIZE_IN_BITS macro .

# LINE 1 " /usr / lib / ghc / include / MachDeps.h " #
                                                                                
  
                                     
   
                                                                     
                       
  
                                                
                                               
  
                                                                
                                                                            
  
                                                                                




                                        
# LINE 1 " /usr / lib / ghc / include / ghcautoconf.h " #


                                                             
                                                                  

                                                          
                                     

                                


                                  


                                 


                               


                                


                                     


                                 


                                         


                                        


                                         


                                              


                                          


                                  


                                                                         
                                                                              
     
                              

                                      
                     

                                                                     
                            
                                  

                           


                                                               


                                                                            
     


                                                      
                       

                                      


                                                           


                                                     


                                                        


                                                                        
            


                                                         


                                                        


                                                        


                                                     


                                                        


                                                  


                                                      
                          

                                                               
                                   

                                                       


                                                          


                                                      


                                                           


                                                        
                        

                                                   


                                                              
                           

                                               


                                                      


                                                         


                                                         


                                                         


                                                         


                                                  
                         

                                                        
                         

                                                                         


                                                          


                                                      


                                                        


                                                               


                                                       


                                                              


                                                       


                                                          


                                                         


                                                         


                                                         


                                                          


                                                         


                                                             
                                         

                                                     


                                                             
                              

                                                              


                                                           


                                                               


                                                             


                                                           


                                                            


                                                             
                              

                                                            


                                                           


                                                            


                                                              


                                                           


                                                          


                                                          


                                                           


                                                   


                                                       


                                                         


                                                        


                                                   


                                                        
                         

                                                          
                           

                                                     
                         

                                                          
                           

                                  


                                   


                                                              
                                  

                                                                            
     
                               

                                                                              
                              

                                              
                         

                                                          
                           

                                                          
                            

                                               
                        

                                            
                            

                                                                     


                                                


                                                  


                                                 


                                               


                                                


                                                     


                                                 


                                                         


                                                        


                                                         


                                                              


                                                          


                                                  


                                                                  
                                                                  
                                    
                                                     
                                                    
                                                      
                            

                                                      


                                                                           


                                                                          


                                                                             
                                         


                                                                           
                                                                     






                              



                                                   




                                                                       
                              

                                                 
                         

                
                                    

                
                                    

                                                            
                  

                                                       
                  

                                                                
                   

                                                
                  




# LINE 21 " /usr / lib / ghc / include / MachDeps.h " #

                                                             
                                                           
                                                                     
                                                
  
                                                                      
                                                            
   

                                     
























































































{-# LINE 28 "./Data/BitUtil.hs" #-}


import Data.Bits ((.|.), xor)


import GHC.Exts (Word(..), Int(..))
import GHC.Prim (uncheckedShiftL#, uncheckedShiftRL#)




  The highestBitMask implementation is based on
-- /~seander/bithacks.html#RoundUpPowerOf2
-- which has been put in the public domain.

-- | Return a word where only the highest bit is set.
highestBitMask :: Word -> Word
highestBitMask x1 = let x2 = x1 .|. x1 `shiftRL` 1
                        x3 = x2 .|. x2 `shiftRL` 2
                        x4 = x3 .|. x3 `shiftRL` 4
                        x5 = x4 .|. x4 `shiftRL` 8
                        x6 = x5 .|. x5 `shiftRL` 16

                        x7 = x6 .|. x6 `shiftRL` 32
                     in x7 `xor` (x7 `shiftRL` 1)



# INLINE highestBitMask #

-- Right and left logical shifts.
shiftRL, shiftLL :: Word -> Int -> Word

------------------------------------------------------------------- 
   GHC : use unboxing to get @shiftRL@ inlined . 
 -------------------------------------------------------------------
  GHC: use unboxing to get @shiftRL@ inlined.
--------------------------------------------------------------------}
shiftRL (W# x) (I# i) = W# (uncheckedShiftRL# x i)
shiftLL (W# x) (I# i) = W# (uncheckedShiftL#  x i)




# INLINE shiftRL #
# INLINE shiftLL #

# LINE 1 "./Data/BitUtil.hs" #
# LINE 2 "./Data/BitUtil.hs" #
# LINE 1 "./Data/BitUtil.hs" #
---------------------------------------------------------------------------
 |
 Module      :  Data.BitUtil
 License     :  BSD-style
 Maintainer  :  
 Stability   :  provisional
 Portability :  portable
---------------------------------------------------------------------------
# LINE 28 "./Data/BitUtil.hs" #
 /~seander/bithacks.html#RoundUpPowerOf2
 which has been put in the public domain.
 | Return a word where only the highest bit is set.
 Right and left logical shifts.
----------------------------------------------------------------- 
-----------------------------------------------------------------
------------------------------------------------------------------}
# LINE 1 " dist / dist - sandbox-235ea54e / build / autogen / cabal_macros.h " #
                                                                

                           






                          






                             






                     






                       






                  






                    






                        






                         






                       






                   






                      






                          







# LANGUAGE CPP #

# LANGUAGE MagicHash #


# LANGUAGE Trustworthy #

  Copyright    :   ( c )   2012
                 ( c )   2012

module Data.BitUtil
    ( highestBitMask
    , shiftLL
    , shiftRL
    ) where

  On GHC , include MachDeps.h to get WORD_SIZE_IN_BITS macro .

# LINE 1 " /usr / lib / ghc / include / MachDeps.h " #
                                                                                
  
                                     
   
                                                                     
                       
  
                                                
                                               
  
                                                                
                                                                            
  
                                                                                




                                        
# LINE 1 " /usr / lib / ghc / include / ghcautoconf.h " #


                                                             
                                                                  

                                                          
                                     

                                


                                  


                                 


                               


                                


                                     


                                 


                                         


                                        


                                         


                                              


                                          


                                  


                                                                         
                                                                              
     
                              

                                      
                     

                                                                     
                            
                                  

                           


                                                               


                                                                            
     


                                                      
                       

                                      


                                                           


                                                     


                                                        


                                                                        
            


                                                         


                                                        


                                                        


                                                     


                                                        


                                                  


                                                      
                          

                                                               
                                   

                                                       


                                                          


                                                      


                                                           


                                                        
                        

                                                   


                                                              
                           

                                               


                                                      


                                                         


                                                         


                                                         


                                                         


                                                  
                         

                                                        
                         

                                                                         


                                                          


                                                      


                                                        


                                                               


                                                       


                                                              


                                                       


                                                          


                                                         


                                                         


                                                         


                                                          


                                                         


                                                             
                                         

                                                     


                                                             
                              

                                                              


                                                           


                                                               


                                                             


                                                           


                                                            


                                                             
                              

                                                            


                                                           


                                                            


                                                              


                                                           


                                                          


                                                          


                                                           


                                                   


                                                       


                                                         


                                                        


                                                   


                                                        
                         

                                                          
                           

                                                     
                         

                                                          
                           

                                  


                                   


                                                              
                                  

                                                                            
     
                               

                                                                              
                              

                                              
                         

                                                          
                           

                                                          
                            

                                               
                        

                                            
                            

                                                                     


                                                


                                                  


                                                 


                                               


                                                


                                                     


                                                 


                                                         


                                                        


                                                         


                                                              


                                                          


                                                  


                                                                  
                                                                  
                                    
                                                     
                                                    
                                                      
                            

                                                      


                                                                           


                                                                          


                                                                             
                                         


                                                                           
                                                                     






                              



                                                   




                                                                       
                              

                                                 
                         

                
                                    

                
                                    

                                                            
                  

                                                       
                  

                                                                
                   

                                                
                  




# LINE 21 " /usr / lib / ghc / include / MachDeps.h " #

                                                             
                                                           
                                                                     
                                                
  
                                                                      
                                                            
   

                                     


























































































import Data.Bits ((.|.), xor)


import GHC.Exts (Word(..), Int(..))
import GHC.Prim (uncheckedShiftL#, uncheckedShiftRL#)




  The highestBitMask implementation is based on

highestBitMask :: Word -> Word
highestBitMask x1 = let x2 = x1 .|. x1 `shiftRL` 1
                        x3 = x2 .|. x2 `shiftRL` 2
                        x4 = x3 .|. x3 `shiftRL` 4
                        x5 = x4 .|. x4 `shiftRL` 8
                        x6 = x5 .|. x5 `shiftRL` 16

                        x7 = x6 .|. x6 `shiftRL` 32
                     in x7 `xor` (x7 `shiftRL` 1)



# INLINE highestBitMask #

shiftRL, shiftLL :: Word -> Int -> Word

   GHC : use unboxing to get @shiftRL@ inlined . 
  GHC: use unboxing to get @shiftRL@ inlined.
shiftRL (W# x) (I# i) = W# (uncheckedShiftRL# x i)
shiftLL (W# x) (I# i) = W# (uncheckedShiftL#  x i)




# INLINE shiftRL #
# INLINE shiftLL #
