b357160c9628c54d13bf89078b998217edeffc76
[ghc-hetmet.git] / compiler / nativeGen / RegAlloc / Linear / FreeRegs.hs
1
2 module RegAlloc.Linear.FreeRegs (
3         FreeRegs(),
4         noFreeRegs,
5         releaseReg,
6         initFreeRegs,
7         getFreeRegs,
8         allocateReg,
9         maxSpillSlots
10 )
11
12 #include "HsVersions.h"
13
14 where
15
16 -- -----------------------------------------------------------------------------
17 -- The free register set
18 -- This needs to be *efficient*
19 -- Here's an inefficient 'executable specification' of the FreeRegs data type:
20 --
21 --      type FreeRegs = [RegNo]
22 --      noFreeRegs = 0
23 --      releaseReg n f = if n `elem` f then f else (n : f)
24 --      initFreeRegs = allocatableRegs
25 --      getFreeRegs cls f = filter ( (==cls) . regClass . RealReg ) f
26 --      allocateReg f r = filter (/= r) f
27
28
29 #if   defined(powerpc_TARGET_ARCH) 
30 import RegAlloc.Linear.PPC.FreeRegs
31 import PPC.Instr        (maxSpillSlots)
32
33 #elif defined(sparc_TARGET_ARCH)
34 import RegAlloc.Linear.SPARC.FreeRegs
35 import SPARC.Instr      (maxSpillSlots)
36
37 #elif defined(i386_TARGET_ARCH) || defined(x86_64_TARGET_ARCH)
38 import RegAlloc.Linear.X86.FreeRegs
39 import X86.Instr        (maxSpillSlots)
40
41 #else
42 #error "RegAlloc.Linear.FreeRegs not defined for this architecture."
43
44 #endif
45