From: Ben.Lippmeier@anu.edu.au Date: Sun, 15 Feb 2009 06:23:21 +0000 (+0000) Subject: NCG: Validate fixes for x86-linux X-Git-Tag: 2009-03-13~75 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=20c0e6ccf28b0961d2c5f6516b57e52fa2c13b33 NCG: Validate fixes for x86-linux --- diff --git a/compiler/nativeGen/AsmCodeGen.lhs b/compiler/nativeGen/AsmCodeGen.lhs index 8613a8e..d4fa102 100644 --- a/compiler/nativeGen/AsmCodeGen.lhs +++ b/compiler/nativeGen/AsmCodeGen.lhs @@ -401,7 +401,7 @@ cmmNativeGen dflags us cmm count #if i386_TARGET_ARCH -x86fp_kludge :: NatCmmTop -> NatCmmTop +x86fp_kludge :: NatCmmTop Instr -> NatCmmTop Instr x86fp_kludge top@(CmmData _ _) = top x86fp_kludge top@(CmmProc info lbl params (ListGraph code)) = CmmProc info lbl params (ListGraph $ i386_insert_ffrees code) diff --git a/compiler/nativeGen/PPC/CodeGen.hs b/compiler/nativeGen/PPC/CodeGen.hs index 6661a3e..e57d3ca 100644 --- a/compiler/nativeGen/PPC/CodeGen.hs +++ b/compiler/nativeGen/PPC/CodeGen.hs @@ -55,6 +55,11 @@ import Data.Bits import Data.Int import Data.Word +#if darwin_TARGET_OS || linux_TARGET_OS +import BasicTypes +import FastString +#endif + -- ----------------------------------------------------------------------------- -- Top-level of the instruction selector @@ -1053,7 +1058,7 @@ genCCall target dest_regs argsAndHints do dflags <- getDynFlagsNat mopExpr <- cmmMakeDynamicReference dflags addImportNat CallReference $ - mkForeignLabel functionName Nothing True + mkForeignLabel functionName Nothing True IsFunction let mopLabelOrExpr = case mopExpr of CmmLit (CmmLabel lbl) -> Left lbl _ -> Right mopExpr diff --git a/compiler/nativeGen/X86/Cond.hs b/compiler/nativeGen/X86/Cond.hs index 60e40b9..4907059 100644 --- a/compiler/nativeGen/X86/Cond.hs +++ b/compiler/nativeGen/X86/Cond.hs @@ -26,7 +26,7 @@ data Cond | OFLO | PARITY | NOTPARITY - + deriving Eq condUnsigned :: Cond -> Bool condUnsigned GU = True diff --git a/compiler/nativeGen/X86/Instr.hs b/compiler/nativeGen/X86/Instr.hs index b4b6fb5..26da907 100644 --- a/compiler/nativeGen/X86/Instr.hs +++ b/compiler/nativeGen/X86/Instr.hs @@ -23,6 +23,8 @@ import BlockId import Cmm import FastString import FastBool +import Outputable +import Constants (rESERVED_C_STACK_BYTES) import CLabel import Panic @@ -655,6 +657,23 @@ x86_mkLoadInstr _ _ _ = panic "X86.RegInfo.mkLoadInstr: not defined for this architecture." #endif +spillSlotSize :: Int +spillSlotSize = IF_ARCH_i386(12, 8) + +maxSpillSlots :: Int +maxSpillSlots = ((rESERVED_C_STACK_BYTES - 64) `div` spillSlotSize) - 1 + +-- convert a spill slot number to a *byte* offset, with no sign: +-- decide on a per arch basis whether you are spilling above or below +-- the C stack pointer. +spillSlotToOffset :: Int -> Int +spillSlotToOffset slot + | slot >= 0 && slot < maxSpillSlots + = 64 + spillSlotSize * slot + | otherwise + = pprPanic "spillSlotToOffset:" + ( text "invalid spill location: " <> int slot + $$ text "maxSpillSlots: " <> int maxSpillSlots) -------------------------------------------------------------------------------- diff --git a/compiler/nativeGen/X86/Ppr.hs b/compiler/nativeGen/X86/Ppr.hs index 3f181fc..ffd839a 100644 --- a/compiler/nativeGen/X86/Ppr.hs +++ b/compiler/nativeGen/X86/Ppr.hs @@ -379,7 +379,7 @@ pprSectionHeader seg RelocatableReadOnlyData -> ptext (sLit ".const_data\n.align 2") UninitialisedData -> ptext (sLit ".data\n\t.align 2") ReadOnlyData16 -> ptext (sLit ".const\n.align 4") - OtherSection sec -> panic "X86.Ppr.pprSectionHeader: unknown section" + OtherSection _ -> panic "X86.Ppr.pprSectionHeader: unknown section" # else pprSectionHeader seg @@ -390,7 +390,7 @@ pprSectionHeader seg RelocatableReadOnlyData -> ptext (sLit ".section .data\n\t.align 4") UninitialisedData -> ptext (sLit ".section .bss\n\t.align 4") ReadOnlyData16 -> ptext (sLit ".section .rodata\n\t.align 16") - OtherSection sec -> panic "X86.Ppr.pprSectionHeader: unknown section" + OtherSection _ -> panic "X86.Ppr.pprSectionHeader: unknown section" # endif @@ -404,7 +404,7 @@ pprSectionHeader seg RelocatableReadOnlyData -> ptext (sLit ".const_data\n.align 3") UninitialisedData -> ptext (sLit ".data\n\t.align 3") ReadOnlyData16 -> ptext (sLit ".const\n.align 4") - OtherSection sec -> panic "PprMach.pprSectionHeader: unknown section" + OtherSection _ -> panic "PprMach.pprSectionHeader: unknown section" # else pprSectionHeader seg @@ -415,7 +415,7 @@ pprSectionHeader seg RelocatableReadOnlyData -> ptext (sLit ".section .data\n\t.align 8") UninitialisedData -> ptext (sLit ".section .bss\n\t.align 8") ReadOnlyData16 -> ptext (sLit ".section .rodata.cst16\n\t.align 16") - OtherSection sec -> panic "PprMach.pprSectionHeader: unknown section" + OtherSection _ -> panic "PprMach.pprSectionHeader: unknown section" # endif diff --git a/compiler/nativeGen/X86/RegInfo.hs b/compiler/nativeGen/X86/RegInfo.hs index 58d063b..a3bf8e4 100644 --- a/compiler/nativeGen/X86/RegInfo.hs +++ b/compiler/nativeGen/X86/RegInfo.hs @@ -5,10 +5,6 @@ module X86.RegInfo ( JumpDest, canShortcut, shortcutJump, - - spillSlotSize, - maxSpillSlots, - spillSlotToOffset, shortcutStatic, regDotColor @@ -29,9 +25,13 @@ import Cmm import CLabel import BlockId import Outputable -import Constants ( rESERVED_C_STACK_BYTES ) import Unique +#if i386_TARGET_ARCH || x86_64_TARGET_ARCH +import UniqFM +#endif + + mkVReg :: Unique -> Size -> Reg mkVReg u size | not (isFloatSize size) = VirtualRegI u @@ -61,26 +61,6 @@ shortcutJump fn insn@(JXX cc id) = shortcutJump _ other = other - -spillSlotSize :: Int -spillSlotSize = IF_ARCH_i386(12, 8) - -maxSpillSlots :: Int -maxSpillSlots = ((rESERVED_C_STACK_BYTES - 64) `div` spillSlotSize) - 1 - --- convert a spill slot number to a *byte* offset, with no sign: --- decide on a per arch basis whether you are spilling above or below --- the C stack pointer. -spillSlotToOffset :: Int -> Int -spillSlotToOffset slot - | slot >= 0 && slot < maxSpillSlots - = 64 + spillSlotSize * slot - | otherwise - = pprPanic "spillSlotToOffset:" - ( text "invalid spill location: " <> int slot - $$ text "maxSpillSlots: " <> int maxSpillSlots) - - -- Here because it knows about JumpDest shortcutStatic :: (BlockId -> Maybe JumpDest) -> CmmStatic -> CmmStatic shortcutStatic fn (CmmStaticLit (CmmLabel lab)) @@ -116,6 +96,7 @@ regDotColor reg = let Just str = lookupUFM regColors reg in text str +regColors :: UniqFM [Char] regColors = listToUFM $ [ (eax, "#00ff00") @@ -138,6 +119,7 @@ regDotColor reg = let Just str = lookupUFM regColors reg in text str +regColors :: UniqFM [Char] regColors = listToUFM $ [ (rax, "#00ff00"), (eax, "#00ff00") diff --git a/compiler/nativeGen/X86/Regs.hs b/compiler/nativeGen/X86/Regs.hs index 87564b8..5db3ab1 100644 --- a/compiler/nativeGen/X86/Regs.hs +++ b/compiler/nativeGen/X86/Regs.hs @@ -66,6 +66,7 @@ import FastBool #if defined(i386_TARGET_ARCH) || defined(x86_64_TARGET_ARCH) import Constants +import Outputable (ppr, pprPanic) #endif