{-# OPTIONS -fno-warn-tabs #-}-- The above warning supression flag is a temporary kludge.-- While working on this module you are encouraged to remove it and-- detab the module (please do the detabbing in a separate patch). See-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces-- for details-- | A description of the register set of the X86.-- This isn't used directly in GHC proper.---- See RegArchBase.hs for the reference.-- See MachRegs.hs for the actual trivColorable function used in GHC.--moduleRegAlloc.Graph.ArchX86(classOfReg,regsOfClass,regName,regAlias,worst,squeese,)whereimportRegAlloc.Graph.ArchBase(Reg(..),RegSub(..),RegClass(..))importUniqSet-- | Determine the class of a registerclassOfReg::Reg->RegClassclassOfRegreg=caseregofRegc_->cRegSubSubL16_->ClassG16RegSubSubL8_->ClassG8RegSubSubL8H_->ClassG8-- | Determine all the regs that make up a certain class.regsOfClass::RegClass->UniqSetRegregsOfClassc=casecofClassG32->mkUniqSet[RegClassG32i|i<-[0..7]]ClassG16->mkUniqSet[RegSubSubL16(RegClassG32i)|i<-[0..7]]ClassG8->unionUniqSets(mkUniqSet[RegSubSubL8(RegClassG32i)|i<-[0..3]])(mkUniqSet[RegSubSubL8H(RegClassG32i)|i<-[0..3]])ClassF64->mkUniqSet[RegClassF64i|i<-[0..5]]-- | Determine the common name of a reg-- returns Nothing if this reg is not part of the machine.regName::Reg->MaybeStringregNamereg=caseregofRegClassG32i|i<=7->Just(["eax","ebx","ecx","edx","ebp","esi","edi","esp"]!!i)RegSubSubL16(RegClassG32i)|i<=7->Just(["ax","bx","cx","dx","bp","si","di","sp"]!!i)RegSubSubL8(RegClassG32i)|i<=3->Just(["al","bl","cl","dl"]!!i)RegSubSubL8H(RegClassG32i)|i<=3->Just(["ah","bh","ch","dh"]!!i)_->Nothing-- | Which regs alias what other regsregAlias::Reg->UniqSetRegregAliasreg=caseregof-- 32 bit regs alias all of the subregsRegClassG32i-- for eax, ebx, ecx, eds|i<=3->mkUniqSet$[RegClassG32i,RegSubSubL16reg,RegSubSubL8reg,RegSubSubL8Hreg]-- for esi, edi, esp, ebp|4<=i&&i<=7->mkUniqSet$[RegClassG32i,RegSubSubL16reg]-- 16 bit subregs alias the whole regRegSubSubL16r@(RegClassG32_)->regAliasr-- 8 bit subregs alias the 32 and 16, but not the other 8 bit subregRegSubSubL8r@(RegClassG32_)->mkUniqSet$[r,RegSubSubL16r,RegSubSubL8r]RegSubSubL8Hr@(RegClassG32_)->mkUniqSet$[r,RegSubSubL16r,RegSubSubL8Hr]-- fpRegClassF64_->unitUniqSetreg_->error"regAlias: invalid register"-- | Optimised versions of RegColorBase.{worst, squeese} specific to x86worst::Int->RegClass->RegClass->IntworstnclassNclassC=caseclassNofClassG32->caseclassCofClassG32->minn8ClassG16->minn8ClassG8->minn4ClassF64->0ClassG16->caseclassCofClassG32->minn8ClassG16->minn8ClassG8->minn4ClassF64->0ClassG8->caseclassCofClassG32->min(n*2)8ClassG16->min(n*2)8ClassG8->minn8ClassF64->0ClassF64->caseclassCofClassF64->minn6_->0squeese::RegClass->[(Int,RegClass)]->IntsqueeseclassNcountCs=sum(map(\(i,classC)->worsticlassNclassC)countCs)