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