PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/compiler/nativeGen/X86/RegInfo.hs

https://bitbucket.org/carter/ghc
Haskell | 75 lines | 54 code | 15 blank | 6 comment | 0 complexity | 3ca39e1242345c5c42dda168d5d24346 MD5 | raw file
  1. {-# OPTIONS -fno-warn-tabs #-}
  2. -- The above warning supression flag is a temporary kludge.
  3. -- While working on this module you are encouraged to remove it and
  4. -- detab the module (please do the detabbing in a separate patch). See
  5. -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces
  6. -- for details
  7. module X86.RegInfo (
  8. mkVirtualReg,
  9. regDotColor
  10. )
  11. where
  12. #include "nativeGen/NCG.h"
  13. #include "HsVersions.h"
  14. import Size
  15. import Reg
  16. import Outputable
  17. import Platform
  18. import Unique
  19. import UniqFM
  20. import X86.Regs
  21. mkVirtualReg :: Unique -> Size -> VirtualReg
  22. mkVirtualReg u size
  23. = case size of
  24. FF32 -> VirtualRegSSE u
  25. FF64 -> VirtualRegSSE u
  26. FF80 -> VirtualRegD u
  27. _other -> VirtualRegI u
  28. regDotColor :: Platform -> RealReg -> SDoc
  29. regDotColor platform reg
  30. = let Just str = lookupUFM (regColors platform) reg
  31. in text str
  32. regColors :: Platform -> UniqFM [Char]
  33. regColors platform = listToUFM (normalRegColors platform ++ fpRegColors)
  34. normalRegColors :: Platform -> [(Reg,String)]
  35. normalRegColors platform
  36. | target32Bit platform = [ (eax, "#00ff00")
  37. , (ebx, "#0000ff")
  38. , (ecx, "#00ffff")
  39. , (edx, "#0080ff") ]
  40. | otherwise = [ (rax, "#00ff00"), (eax, "#00ff00")
  41. , (rbx, "#0000ff"), (ebx, "#0000ff")
  42. , (rcx, "#00ffff"), (ecx, "#00ffff")
  43. , (rdx, "#0080ff"), (edx, "#00ffff")
  44. , (r8, "#00ff80")
  45. , (r9, "#008080")
  46. , (r10, "#0040ff")
  47. , (r11, "#00ff40")
  48. , (r12, "#008040")
  49. , (r13, "#004080")
  50. , (r14, "#004040")
  51. , (r15, "#002080") ]
  52. fpRegColors :: [(Reg,String)]
  53. fpRegColors =
  54. [ (fake0, "#ff00ff")
  55. , (fake1, "#ff00aa")
  56. , (fake2, "#aa00ff")
  57. , (fake3, "#aa00aa")
  58. , (fake4, "#ff0055")
  59. , (fake5, "#5500ff") ]
  60. ++ zip (map regSingle [24..39]) (repeat "red")