bee8c98c617bd24535e593aa26895759c8415ac8
[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 )
10
11 #include "HsVersions.h"
12
13 where
14
15 -- -----------------------------------------------------------------------------
16 -- The free register set
17 -- This needs to be *efficient*
18 -- Here's an inefficient 'executable specification' of the FreeRegs data type:
19 --
20 --      type FreeRegs = [RegNo]
21 --      noFreeRegs = 0
22 --      releaseReg n f = if n `elem` f then f else (n : f)
23 --      initFreeRegs = allocatableRegs
24 --      getFreeRegs cls f = filter ( (==cls) . regClass . RealReg ) f
25 --      allocateReg f r = filter (/= r) f
26
27
28 #if   defined(powerpc_TARGET_ARCH) 
29 import RegAlloc.Linear.PPC.FreeRegs
30
31 #elif defined(sparc_TARGET_ARCH)
32 import RegAlloc.Linear.SPARC.FreeRegs
33
34 #elif defined(i386_TARGET_ARCH) || defined(x86_64_TARGET_ARCH)
35 import RegAlloc.Linear.X86.FreeRegs
36
37 #else
38 #error "RegAlloc.Linear.FreeRegs not defined for this architecture."
39
40 #endif
41