Commit 20c0e6cc authored by Ben.Lippmeier@anu.edu.au's avatar Ben.Lippmeier@anu.edu.au
Browse files

NCG: Validate fixes for x86-linux

parent 17839aa3
......@@ -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)
......
......@@ -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
......
......@@ -26,7 +26,7 @@ data Cond
| OFLO
| PARITY
| NOTPARITY
deriving Eq
condUnsigned :: Cond -> Bool
condUnsigned GU = True
......
......@@ -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)
--------------------------------------------------------------------------------
......
......@@ -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
......
......@@ -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")
......
......@@ -66,6 +66,7 @@ import FastBool
#if defined(i386_TARGET_ARCH) || defined(x86_64_TARGET_ARCH)
import Constants
import Outputable (ppr, pprPanic)
#endif
......
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