Commit 3c765019 authored by wolfgang's avatar wolfgang
Browse files

[project @ 2005-09-24 02:15:32 by wolfgang]

PowerPC: track changes in the rest of the register allocator
parent 4d5a0088
...@@ -157,7 +157,10 @@ allocateReg f r = filter (/= r) f ...@@ -157,7 +157,10 @@ allocateReg f r = filter (/= r) f
data FreeRegs = FreeRegs !Word32 !Word32 data FreeRegs = FreeRegs !Word32 !Word32
noFreeRegs :: FreeRegs
noFreeRegs = FreeRegs 0 0 noFreeRegs = FreeRegs 0 0
releaseReg :: RegNo -> FreeRegs -> FreeRegs
releaseReg r (FreeRegs g f) releaseReg r (FreeRegs g f)
| r > 31 = FreeRegs g (f .|. (1 `shiftL` (fromIntegral r - 32))) | r > 31 = FreeRegs g (f .|. (1 `shiftL` (fromIntegral r - 32)))
| otherwise = FreeRegs (g .|. (1 `shiftL` fromIntegral r)) f | otherwise = FreeRegs (g .|. (1 `shiftL` fromIntegral r)) f
...@@ -165,6 +168,7 @@ releaseReg r (FreeRegs g f) ...@@ -165,6 +168,7 @@ releaseReg r (FreeRegs g f)
initFreeRegs :: FreeRegs initFreeRegs :: FreeRegs
initFreeRegs = foldr releaseReg noFreeRegs allocatableRegs initFreeRegs = foldr releaseReg noFreeRegs allocatableRegs
getFreeRegs :: RegClass -> FreeRegs -> [RegNo] -- lazilly
getFreeRegs cls (FreeRegs g f) getFreeRegs cls (FreeRegs g f)
| RcDouble <- cls = go f (0x80000000) 63 | RcDouble <- cls = go f (0x80000000) 63
| RcInteger <- cls = go g (0x80000000) 31 | RcInteger <- cls = go g (0x80000000) 31
...@@ -173,7 +177,8 @@ getFreeRegs cls (FreeRegs g f) ...@@ -173,7 +177,8 @@ getFreeRegs cls (FreeRegs g f)
go x m i | x .&. m /= 0 = i : (go x (m `shiftR` 1) $! i-1) go x m i | x .&. m /= 0 = i : (go x (m `shiftR` 1) $! i-1)
| otherwise = go x (m `shiftR` 1) $! i-1 | otherwise = go x (m `shiftR` 1) $! i-1
allocateReg (FreeRegs g f) r allocateReg :: RegNo -> FreeRegs -> FreeRegs
allocateReg r (FreeRegs g f)
| r > 31 = FreeRegs g (f .&. complement (1 `shiftL` (fromIntegral r - 32))) | r > 31 = FreeRegs g (f .&. complement (1 `shiftL` (fromIntegral r - 32)))
| otherwise = FreeRegs (g .&. complement (1 `shiftL` fromIntegral r)) f | otherwise = FreeRegs (g .&. complement (1 `shiftL` fromIntegral r)) f
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment