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