module GHC.CmmToAsm.X86.RegInfo (
mkVirtualReg,
regDotColor
)
where
#include "HsVersions.h"
import GHC.Prelude
import GHC.CmmToAsm.Format
import GHC.Platform.Reg
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Platform
import GHC.Types.Unique
import GHC.Types.Unique.FM
import GHC.CmmToAsm.X86.Regs
mkVirtualReg :: Unique -> Format -> VirtualReg
mkVirtualReg u format
= case format of
FF32 -> VirtualRegD u
FF64 -> VirtualRegD u
_other -> VirtualRegI u
regDotColor :: Platform -> RealReg -> SDoc
regDotColor platform reg
= case (lookupUFM (regColors platform) reg) of
Just str -> text str
_ -> panic "Register not assigned a color"
regColors :: Platform -> UniqFM RealReg [Char]
regColors platform = listToUFM (normalRegColors platform)
normalRegColors :: Platform -> [(RealReg,String)]
normalRegColors platform =
zip (map realRegSingle [0..lastint platform]) colors
++ zip (map realRegSingle [firstxmm..lastxmm platform]) greys
where
colors = ["#800000","#ff0000","#808000","#ffff00","#008000"
,"#00ff00","#008080","#00ffff","#000080","#0000ff"
,"#800080","#ff00ff","#87005f","#875f00","#87af00"
,"#ff00af"]
greys = ["#0e0e0e","#1c1c1c","#2a2a2a","#383838","#464646"
,"#545454","#626262","#707070","#7e7e7e","#8c8c8c"
,"#9a9a9a","#a8a8a8","#b6b6b6","#c4c4c4","#d2d2d2"
,"#e0e0e0"]