PageRenderTime 54ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/compiler/nativeGen/X86/RegInfo.hs

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