{-# LANGUAGE CPP #-}
module RegAlloc.Graph.TrivColorable (
trivColorable,
)
where
#include "HsVersions.h"
import GhcPrelude
import RegClass
import Reg
import GraphBase
import UniqSet
import Platform
import Panic
accSqueeze
:: Int
-> Int
-> (reg -> Int)
-> UniqSet reg
-> Int
accSqueeze :: Int -> Int -> (reg -> Int) -> UniqSet reg -> Int
accSqueeze count :: Int
count maxCount :: Int
maxCount squeeze :: reg -> Int
squeeze us :: UniqSet reg
us = Int -> [reg] -> Int
acc Int
count (UniqSet reg -> [reg]
forall elt. UniqSet elt -> [elt]
nonDetEltsUniqSet UniqSet reg
us)
where acc :: Int -> [reg] -> Int
acc count :: Int
count [] = Int
count
acc count :: Int
count _ | Int
count Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
maxCount = Int
count
acc count :: Int
count (r :: reg
r:rs :: [reg]
rs) = Int -> [reg] -> Int
acc (Int
count Int -> Int -> Int
forall a. Num a => a -> a -> a
+ reg -> Int
squeeze reg
r) [reg]
rs
trivColorable
:: Platform
-> (RegClass -> VirtualReg -> Int)
-> (RegClass -> RealReg -> Int)
-> Triv VirtualReg RegClass RealReg
trivColorable :: Platform
-> (RegClass -> VirtualReg -> Int)
-> (RegClass -> RealReg -> Int)
-> Triv VirtualReg RegClass RealReg
trivColorable platform :: Platform
platform virtualRegSqueeze :: RegClass -> VirtualReg -> Int
virtualRegSqueeze realRegSqueeze :: RegClass -> RealReg -> Int
realRegSqueeze RcInteger conflicts :: UniqSet VirtualReg
conflicts exclusions :: UniqSet RealReg
exclusions
| let cALLOCATABLE_REGS_INTEGER :: Int
cALLOCATABLE_REGS_INTEGER
= (case Platform -> Arch
platformArch Platform
platform of
ArchX86 -> 3
ArchX86_64 -> 5
ArchPPC -> 16
ArchSPARC -> 14
ArchSPARC64 -> String -> Int
forall a. String -> a
panic "trivColorable ArchSPARC64"
ArchPPC_64 _ -> 15
ArchARM _ _ _ -> String -> Int
forall a. String -> a
panic "trivColorable ArchARM"
ArchARM64 -> String -> Int
forall a. String -> a
panic "trivColorable ArchARM64"
ArchAlpha -> String -> Int
forall a. String -> a
panic "trivColorable ArchAlpha"
ArchMipseb -> String -> Int
forall a. String -> a
panic "trivColorable ArchMipseb"
ArchMipsel -> String -> Int
forall a. String -> a
panic "trivColorable ArchMipsel"
ArchJavaScript-> String -> Int
forall a. String -> a
panic "trivColorable ArchJavaScript"
ArchUnknown -> String -> Int
forall a. String -> a
panic "trivColorable ArchUnknown")
, Int
count2 <- Int -> Int -> (VirtualReg -> Int) -> UniqSet VirtualReg -> Int
forall reg. Int -> Int -> (reg -> Int) -> UniqSet reg -> Int
accSqueeze 0 Int
cALLOCATABLE_REGS_INTEGER
(RegClass -> VirtualReg -> Int
virtualRegSqueeze RegClass
RcInteger)
UniqSet VirtualReg
conflicts
, Int
count3 <- Int -> Int -> (RealReg -> Int) -> UniqSet RealReg -> Int
forall reg. Int -> Int -> (reg -> Int) -> UniqSet reg -> Int
accSqueeze Int
count2 Int
cALLOCATABLE_REGS_INTEGER
(RegClass -> RealReg -> Int
realRegSqueeze RegClass
RcInteger)
UniqSet RealReg
exclusions
= Int
count3 Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
cALLOCATABLE_REGS_INTEGER
trivColorable platform :: Platform
platform virtualRegSqueeze :: RegClass -> VirtualReg -> Int
virtualRegSqueeze realRegSqueeze :: RegClass -> RealReg -> Int
realRegSqueeze RcFloat conflicts :: UniqSet VirtualReg
conflicts exclusions :: UniqSet RealReg
exclusions
| let cALLOCATABLE_REGS_FLOAT :: Int
cALLOCATABLE_REGS_FLOAT
= (case Platform -> Arch
platformArch Platform
platform of
ArchX86 -> 0
ArchX86_64 -> 0
ArchPPC -> 0
ArchSPARC -> 22
ArchSPARC64 -> String -> Int
forall a. String -> a
panic "trivColorable ArchSPARC64"
ArchPPC_64 _ -> 0
ArchARM _ _ _ -> String -> Int
forall a. String -> a
panic "trivColorable ArchARM"
ArchARM64 -> String -> Int
forall a. String -> a
panic "trivColorable ArchARM64"
ArchAlpha -> String -> Int
forall a. String -> a
panic "trivColorable ArchAlpha"
ArchMipseb -> String -> Int
forall a. String -> a
panic "trivColorable ArchMipseb"
ArchMipsel -> String -> Int
forall a. String -> a
panic "trivColorable ArchMipsel"
ArchJavaScript-> String -> Int
forall a. String -> a
panic "trivColorable ArchJavaScript"
ArchUnknown -> String -> Int
forall a. String -> a
panic "trivColorable ArchUnknown")
, Int
count2 <- Int -> Int -> (VirtualReg -> Int) -> UniqSet VirtualReg -> Int
forall reg. Int -> Int -> (reg -> Int) -> UniqSet reg -> Int
accSqueeze 0 Int
cALLOCATABLE_REGS_FLOAT
(RegClass -> VirtualReg -> Int
virtualRegSqueeze RegClass
RcFloat)
UniqSet VirtualReg
conflicts
, Int
count3 <- Int -> Int -> (RealReg -> Int) -> UniqSet RealReg -> Int
forall reg. Int -> Int -> (reg -> Int) -> UniqSet reg -> Int
accSqueeze Int
count2 Int
cALLOCATABLE_REGS_FLOAT
(RegClass -> RealReg -> Int
realRegSqueeze RegClass
RcFloat)
UniqSet RealReg
exclusions
= Int
count3 Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
cALLOCATABLE_REGS_FLOAT
trivColorable platform :: Platform
platform virtualRegSqueeze :: RegClass -> VirtualReg -> Int
virtualRegSqueeze realRegSqueeze :: RegClass -> RealReg -> Int
realRegSqueeze RcDouble conflicts :: UniqSet VirtualReg
conflicts exclusions :: UniqSet RealReg
exclusions
| let cALLOCATABLE_REGS_DOUBLE :: Int
cALLOCATABLE_REGS_DOUBLE
= (case Platform -> Arch
platformArch Platform
platform of
ArchX86 -> 6
ArchX86_64 -> 0
ArchPPC -> 26
ArchSPARC -> 11
ArchSPARC64 -> String -> Int
forall a. String -> a
panic "trivColorable ArchSPARC64"
ArchPPC_64 _ -> 20
ArchARM _ _ _ -> String -> Int
forall a. String -> a
panic "trivColorable ArchARM"
ArchARM64 -> String -> Int
forall a. String -> a
panic "trivColorable ArchARM64"
ArchAlpha -> String -> Int
forall a. String -> a
panic "trivColorable ArchAlpha"
ArchMipseb -> String -> Int
forall a. String -> a
panic "trivColorable ArchMipseb"
ArchMipsel -> String -> Int
forall a. String -> a
panic "trivColorable ArchMipsel"
ArchJavaScript-> String -> Int
forall a. String -> a
panic "trivColorable ArchJavaScript"
ArchUnknown -> String -> Int
forall a. String -> a
panic "trivColorable ArchUnknown")
, Int
count2 <- Int -> Int -> (VirtualReg -> Int) -> UniqSet VirtualReg -> Int
forall reg. Int -> Int -> (reg -> Int) -> UniqSet reg -> Int
accSqueeze 0 Int
cALLOCATABLE_REGS_DOUBLE
(RegClass -> VirtualReg -> Int
virtualRegSqueeze RegClass
RcDouble)
UniqSet VirtualReg
conflicts
, Int
count3 <- Int -> Int -> (RealReg -> Int) -> UniqSet RealReg -> Int
forall reg. Int -> Int -> (reg -> Int) -> UniqSet reg -> Int
accSqueeze Int
count2 Int
cALLOCATABLE_REGS_DOUBLE
(RegClass -> RealReg -> Int
realRegSqueeze RegClass
RcDouble)
UniqSet RealReg
exclusions
= Int
count3 Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
cALLOCATABLE_REGS_DOUBLE
trivColorable platform :: Platform
platform virtualRegSqueeze :: RegClass -> VirtualReg -> Int
virtualRegSqueeze realRegSqueeze :: RegClass -> RealReg -> Int
realRegSqueeze RcDoubleSSE conflicts :: UniqSet VirtualReg
conflicts exclusions :: UniqSet RealReg
exclusions
| let cALLOCATABLE_REGS_SSE :: Int
cALLOCATABLE_REGS_SSE
= (case Platform -> Arch
platformArch Platform
platform of
ArchX86 -> 8
ArchX86_64 -> 10
ArchPPC -> 0
ArchSPARC -> 0
ArchSPARC64 -> String -> Int
forall a. String -> a
panic "trivColorable ArchSPARC64"
ArchPPC_64 _ -> 0
ArchARM _ _ _ -> String -> Int
forall a. String -> a
panic "trivColorable ArchARM"
ArchARM64 -> String -> Int
forall a. String -> a
panic "trivColorable ArchARM64"
ArchAlpha -> String -> Int
forall a. String -> a
panic "trivColorable ArchAlpha"
ArchMipseb -> String -> Int
forall a. String -> a
panic "trivColorable ArchMipseb"
ArchMipsel -> String -> Int
forall a. String -> a
panic "trivColorable ArchMipsel"
ArchJavaScript-> String -> Int
forall a. String -> a
panic "trivColorable ArchJavaScript"
ArchUnknown -> String -> Int
forall a. String -> a
panic "trivColorable ArchUnknown")
, Int
count2 <- Int -> Int -> (VirtualReg -> Int) -> UniqSet VirtualReg -> Int
forall reg. Int -> Int -> (reg -> Int) -> UniqSet reg -> Int
accSqueeze 0 Int
cALLOCATABLE_REGS_SSE
(RegClass -> VirtualReg -> Int
virtualRegSqueeze RegClass
RcDoubleSSE)
UniqSet VirtualReg
conflicts
, Int
count3 <- Int -> Int -> (RealReg -> Int) -> UniqSet RealReg -> Int
forall reg. Int -> Int -> (reg -> Int) -> UniqSet reg -> Int
accSqueeze Int
count2 Int
cALLOCATABLE_REGS_SSE
(RegClass -> RealReg -> Int
realRegSqueeze RegClass
RcDoubleSSE)
UniqSet RealReg
exclusions
= Int
count3 Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
cALLOCATABLE_REGS_SSE