never executed always true always false
    1 
    2 module GHC.CmmToAsm.X86.RegInfo (
    3         mkVirtualReg,
    4         regDotColor
    5 )
    6 
    7 where
    8 
    9 import GHC.Prelude
   10 
   11 import GHC.CmmToAsm.Format
   12 import GHC.Platform.Reg
   13 
   14 import GHC.Utils.Outputable
   15 import GHC.Utils.Panic
   16 import GHC.Platform
   17 import GHC.Types.Unique
   18 
   19 import GHC.Types.Unique.FM
   20 import GHC.CmmToAsm.X86.Regs
   21 
   22 
   23 mkVirtualReg :: Unique -> Format -> VirtualReg
   24 mkVirtualReg u format
   25    = case format of
   26         FF32    -> VirtualRegD u
   27         -- for scalar F32, we use the same xmm as F64!
   28         -- this is a hack that needs some improvement.
   29         -- For now we map both to being allocated as "Double" Registers
   30         -- on X86/X86_64
   31         FF64    -> VirtualRegD u
   32         _other  -> VirtualRegI u
   33 
   34 regDotColor :: Platform -> RealReg -> SDoc
   35 regDotColor platform reg
   36  = case (lookupUFM (regColors platform) reg) of
   37         Just str -> text str
   38         _        -> panic "Register not assigned a color"
   39 
   40 regColors :: Platform -> UniqFM RealReg [Char]
   41 regColors platform = listToUFM (normalRegColors platform)
   42 
   43 normalRegColors :: Platform -> [(RealReg,String)]
   44 normalRegColors platform =
   45     zip (map realRegSingle [0..lastint platform]) colors
   46         ++ zip (map realRegSingle [firstxmm..lastxmm platform]) greys
   47   where
   48     -- 16 colors - enough for amd64 gp regs
   49     colors = ["#800000","#ff0000","#808000","#ffff00","#008000"
   50              ,"#00ff00","#008080","#00ffff","#000080","#0000ff"
   51              ,"#800080","#ff00ff","#87005f","#875f00","#87af00"
   52              ,"#ff00af"]
   53 
   54     -- 16 shades of grey, enough for the currently supported
   55     -- SSE extensions.
   56     greys = ["#0e0e0e","#1c1c1c","#2a2a2a","#383838","#464646"
   57             ,"#545454","#626262","#707070","#7e7e7e","#8c8c8c"
   58             ,"#9a9a9a","#a8a8a8","#b6b6b6","#c4c4c4","#d2d2d2"
   59             ,"#e0e0e0"]
   60 
   61 
   62 
   63 --     32 shades of grey - use for avx 512 if we ever need it
   64 --     greys = ["#070707","#0e0e0e","#151515","#1c1c1c"
   65 --             ,"#232323","#2a2a2a","#313131","#383838","#3f3f3f"
   66 --             ,"#464646","#4d4d4d","#545454","#5b5b5b","#626262"
   67 --             ,"#696969","#707070","#777777","#7e7e7e","#858585"
   68 --             ,"#8c8c8c","#939393","#9a9a9a","#a1a1a1","#a8a8a8"
   69 --             ,"#afafaf","#b6b6b6","#bdbdbd","#c4c4c4","#cbcbcb"
   70 --             ,"#d2d2d2","#d9d9d9","#e0e0e0"]
   71 
   72