NCG: Validate fixes for x86-linux
authorBen.Lippmeier@anu.edu.au <unknown>
Sun, 15 Feb 2009 06:23:21 +0000 (06:23 +0000)
committerBen.Lippmeier@anu.edu.au <unknown>
Sun, 15 Feb 2009 06:23:21 +0000 (06:23 +0000)
compiler/nativeGen/AsmCodeGen.lhs
compiler/nativeGen/PPC/CodeGen.hs
compiler/nativeGen/X86/Cond.hs
compiler/nativeGen/X86/Instr.hs
compiler/nativeGen/X86/Ppr.hs
compiler/nativeGen/X86/RegInfo.hs
compiler/nativeGen/X86/Regs.hs

index 8613a8e..d4fa102 100644 (file)
@@ -401,7 +401,7 @@ cmmNativeGen dflags us cmm count
 
 
 #if i386_TARGET_ARCH
 
 
 #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)
 x86fp_kludge top@(CmmData _ _) = top
 x86fp_kludge top@(CmmProc info lbl params (ListGraph code)) = 
        CmmProc info lbl params (ListGraph $ i386_insert_ffrees code)
index 6661a3e..e57d3ca 100644 (file)
@@ -55,6 +55,11 @@ import Data.Bits
 import Data.Int
 import Data.Word
 
 import Data.Int
 import Data.Word
 
+#if darwin_TARGET_OS || linux_TARGET_OS
+import BasicTypes
+import FastString
+#endif
+
 -- -----------------------------------------------------------------------------
 -- Top-level of the instruction selector
 
 -- -----------------------------------------------------------------------------
 -- Top-level of the instruction selector
 
@@ -1053,7 +1058,7 @@ genCCall target dest_regs argsAndHints
             do
                 dflags <- getDynFlagsNat
                 mopExpr <- cmmMakeDynamicReference dflags addImportNat CallReference $
             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
                 let mopLabelOrExpr = case mopExpr of
                         CmmLit (CmmLabel lbl) -> Left lbl
                         _ -> Right mopExpr
index 60e40b9..4907059 100644 (file)
@@ -26,7 +26,7 @@ data Cond
        | OFLO
        | PARITY
        | NOTPARITY
        | OFLO
        | PARITY
        | NOTPARITY
-
+       deriving Eq
 
 condUnsigned :: Cond -> Bool
 condUnsigned GU  = True
 
 condUnsigned :: Cond -> Bool
 condUnsigned GU  = True
index b4b6fb5..26da907 100644 (file)
@@ -23,6 +23,8 @@ import BlockId
 import Cmm
 import FastString
 import FastBool
 import Cmm
 import FastString
 import FastBool
+import Outputable
+import Constants       (rESERVED_C_STACK_BYTES)
 
 import CLabel
 import Panic
 
 import CLabel
 import Panic
@@ -655,6 +657,23 @@ x86_mkLoadInstr _ _ _
        = panic "X86.RegInfo.mkLoadInstr: not defined for this architecture."
 #endif
 
        = 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)
 
 --------------------------------------------------------------------------------
 
 
 --------------------------------------------------------------------------------
 
index 3f181fc..ffd839a 100644 (file)
@@ -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")
        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
 
 #    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")
        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
 
 
 #    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")
        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
 
 #    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")
        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
 
 
 #    endif
 
index 58d063b..a3bf8e4 100644 (file)
@@ -5,10 +5,6 @@ module X86.RegInfo (
         JumpDest, 
        canShortcut, 
        shortcutJump, 
         JumpDest, 
        canShortcut, 
        shortcutJump, 
-
-       spillSlotSize,
-       maxSpillSlots,
-       spillSlotToOffset,
        
        shortcutStatic,
        regDotColor
        
        shortcutStatic,
        regDotColor
@@ -29,9 +25,13 @@ import Cmm
 import CLabel
 import BlockId
 import Outputable
 import CLabel
 import BlockId
 import Outputable
-import Constants       ( rESERVED_C_STACK_BYTES )
 import Unique
 
 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
 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
 
 
 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))
 -- 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
 
  = let Just    str     = lookupUFM regColors reg
    in  text str
 
+regColors :: UniqFM [Char]
 regColors
  = listToUFM
  $     [ (eax, "#00ff00")
 regColors
  = listToUFM
  $     [ (eax, "#00ff00")
@@ -138,6 +119,7 @@ regDotColor reg
  = let Just    str     = lookupUFM regColors reg
    in  text str
 
  = let Just    str     = lookupUFM regColors reg
    in  text str
 
+regColors :: UniqFM [Char]
 regColors
  = listToUFM
  $     [ (rax, "#00ff00"), (eax, "#00ff00")
 regColors
  = listToUFM
  $     [ (rax, "#00ff00"), (eax, "#00ff00")
index 87564b8..5db3ab1 100644 (file)
@@ -66,6 +66,7 @@ import FastBool
 
 #if  defined(i386_TARGET_ARCH) || defined(x86_64_TARGET_ARCH)
 import Constants
 
 #if  defined(i386_TARGET_ARCH) || defined(x86_64_TARGET_ARCH)
 import Constants
+import Outputable      (ppr, pprPanic)
 #endif
 
 
 #endif