PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/ghc-7.0.4/compiler/nativeGen/X86/RegInfo.hs

http://picorec.googlecode.com/
Haskell | 88 lines | 71 code | 15 blank | 2 comment | 2 complexity | 3f18e300e812b1ff6ca752ea3587c863 MD5 | raw file
Possible License(s): BSD-3-Clause, BSD-2-Clause
  1. module X86.RegInfo (
  2. mkVirtualReg,
  3. regDotColor
  4. )
  5. where
  6. #include "nativeGen/NCG.h"
  7. #include "HsVersions.h"
  8. import Size
  9. import Reg
  10. import Outputable
  11. import Unique
  12. #if i386_TARGET_ARCH || x86_64_TARGET_ARCH
  13. import UniqFM
  14. import X86.Regs
  15. #endif
  16. mkVirtualReg :: Unique -> Size -> VirtualReg
  17. mkVirtualReg u size
  18. = case size of
  19. FF32 -> VirtualRegSSE u
  20. FF64 -> VirtualRegSSE u
  21. FF80 -> VirtualRegD u
  22. _other -> VirtualRegI u
  23. -- reg colors for x86
  24. #if i386_TARGET_ARCH
  25. regDotColor :: RealReg -> SDoc
  26. regDotColor reg
  27. = let Just str = lookupUFM regColors reg
  28. in text str
  29. regColors :: UniqFM [Char]
  30. regColors
  31. = listToUFM
  32. $ [ (eax, "#00ff00")
  33. , (ebx, "#0000ff")
  34. , (ecx, "#00ffff")
  35. , (edx, "#0080ff") ]
  36. ++ fpRegColors
  37. -- reg colors for x86_64
  38. #elif x86_64_TARGET_ARCH
  39. regDotColor :: RealReg -> SDoc
  40. regDotColor reg
  41. = let Just str = lookupUFM regColors reg
  42. in text str
  43. regColors :: UniqFM [Char]
  44. regColors
  45. = listToUFM
  46. $ [ (rax, "#00ff00"), (eax, "#00ff00")
  47. , (rbx, "#0000ff"), (ebx, "#0000ff")
  48. , (rcx, "#00ffff"), (ecx, "#00ffff")
  49. , (rdx, "#0080ff"), (edx, "#00ffff")
  50. , (r8, "#00ff80")
  51. , (r9, "#008080")
  52. , (r10, "#0040ff")
  53. , (r11, "#00ff40")
  54. , (r12, "#008040")
  55. , (r13, "#004080")
  56. , (r14, "#004040")
  57. , (r15, "#002080") ]
  58. ++ fpRegColors
  59. #else
  60. regDotColor :: Reg -> SDoc
  61. regDotColor = panic "not defined"
  62. #endif
  63. #if i386_TARGET_ARCH || x86_64_TARGET_ARCH
  64. fpRegColors :: [(Reg,String)]
  65. fpRegColors =
  66. [ (fake0, "#ff00ff")
  67. , (fake1, "#ff00aa")
  68. , (fake2, "#aa00ff")
  69. , (fake3, "#aa00aa")
  70. , (fake4, "#ff0055")
  71. , (fake5, "#5500ff") ]
  72. ++ zip (map regSingle [24..39]) (repeat "red")
  73. #endif