From d9e0cfba383d8bbff5f5b7428a683cfdfb7b95b9 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Wed, 5 Jan 2011 17:11:24 +0000 Subject: [PATCH] Whitespace only in X86.Ppr --- compiler/nativeGen/X86/Ppr.hs | 588 ++++++++++++++++++++--------------------- 1 file changed, 294 insertions(+), 294 deletions(-) diff --git a/compiler/nativeGen/X86/Ppr.hs b/compiler/nativeGen/X86/Ppr.hs index baf853c..0ca230b 100644 --- a/compiler/nativeGen/X86/Ppr.hs +++ b/compiler/nativeGen/X86/Ppr.hs @@ -7,15 +7,15 @@ ----------------------------------------------------------------------------- module X86.Ppr ( - pprNatCmmTop, - pprBasicBlock, - pprSectionHeader, - pprData, - pprInstr, - pprUserReg, - pprSize, - pprImm, - pprDataItem, + pprNatCmmTop, + pprBasicBlock, + pprSectionHeader, + pprData, + pprInstr, + pprUserReg, + pprSize, + pprImm, + pprDataItem, ) where @@ -35,11 +35,11 @@ import PprBase import BlockId import Cmm import CLabel -import Unique ( pprUnique ) +import Unique ( pprUnique ) import Pretty import FastString import qualified Outputable -import Outputable (panic, Outputable) +import Outputable (panic, Outputable) import Data.Word @@ -51,13 +51,13 @@ import Data.Bits -- Printing this stuff out pprNatCmmTop :: NatCmmTop Instr -> Doc -pprNatCmmTop (CmmData section dats) = +pprNatCmmTop (CmmData section dats) = pprSectionHeader section $$ vcat (map pprData dats) -- special case for split markers: pprNatCmmTop (CmmProc [] lbl _ (ListGraph [])) = pprLabel lbl -pprNatCmmTop (CmmProc info lbl _ (ListGraph blocks)) = +pprNatCmmTop (CmmProc info lbl _ (ListGraph blocks)) = pprSectionHeader Text $$ (if null info then -- blocks guaranteed not null, so label needed pprLabel lbl @@ -80,11 +80,11 @@ pprNatCmmTop (CmmProc info lbl _ (ListGraph blocks)) = -- so that the linker will not think it is unreferenced and dead-strip -- it. That's why the label is called a DeadStripPreventer (_dsp). $$ if not (null info) - then text "\t.long " - <+> pprCLabel_asm (entryLblToInfoLbl lbl) - <+> char '-' - <+> pprCLabel_asm (mkDeadStripPreventer $ entryLblToInfoLbl lbl) - else empty + then text "\t.long " + <+> pprCLabel_asm (entryLblToInfoLbl lbl) + <+> char '-' + <+> pprCLabel_asm (mkDeadStripPreventer $ entryLblToInfoLbl lbl) + else empty #endif @@ -110,16 +110,16 @@ pprData (CmmStaticLit lit) = pprDataItem lit pprGloblDecl :: CLabel -> Doc pprGloblDecl lbl | not (externallyVisibleCLabel lbl) = empty - | otherwise = ptext IF_ARCH_sparc((sLit ".global "), - (sLit ".globl ")) <> - pprCLabel_asm lbl + | otherwise = ptext IF_ARCH_sparc((sLit ".global "), + (sLit ".globl ")) <> + pprCLabel_asm lbl pprTypeAndSizeDecl :: CLabel -> Doc #if elf_OBJ_FORMAT pprTypeAndSizeDecl lbl | not (externallyVisibleCLabel lbl) = empty | otherwise = ptext (sLit ".type ") <> - pprCLabel_asm lbl <> ptext (sLit ", @object") + pprCLabel_asm lbl <> ptext (sLit ", @object") #else pprTypeAndSizeDecl _ = empty @@ -140,25 +140,25 @@ pprAlign :: Int -> Doc pprAlign bytes - = ptext (sLit ".align ") <> int IF_OS_darwin(pow2, bytes) + = ptext (sLit ".align ") <> int IF_OS_darwin(pow2, bytes) where #if darwin_TARGET_OS - pow2 = log2 bytes - - log2 :: Int -> Int -- cache the common ones - log2 1 = 0 - log2 2 = 1 - log2 4 = 2 - log2 8 = 3 - log2 n = 1 + log2 (n `quot` 2) + pow2 = log2 bytes + + log2 :: Int -> Int -- cache the common ones + log2 1 = 0 + log2 2 = 1 + log2 4 = 2 + log2 8 = 3 + log2 n = 1 + log2 (n `quot` 2) #endif -- ----------------------------------------------------------------------------- -- pprInstr: print an 'Instr' instance Outputable Instr where - ppr instr = Outputable.docToSDoc $ pprInstr instr + ppr instr = Outputable.docToSDoc $ pprInstr instr #if i386_TARGET_ARCH || x86_64_TARGET_ARCH @@ -191,26 +191,26 @@ pprReg s r ppr_reg_byte i = ptext (case i of { - 0 -> sLit "%al"; 1 -> sLit "%bl"; - 2 -> sLit "%cl"; 3 -> sLit "%dl"; - _ -> sLit "very naughty I386 byte register" + 0 -> sLit "%al"; 1 -> sLit "%bl"; + 2 -> sLit "%cl"; 3 -> sLit "%dl"; + _ -> sLit "very naughty I386 byte register" }) ppr_reg_word i = ptext (case i of { - 0 -> sLit "%ax"; 1 -> sLit "%bx"; - 2 -> sLit "%cx"; 3 -> sLit "%dx"; - 4 -> sLit "%si"; 5 -> sLit "%di"; - 6 -> sLit "%bp"; 7 -> sLit "%sp"; - _ -> sLit "very naughty I386 word register" + 0 -> sLit "%ax"; 1 -> sLit "%bx"; + 2 -> sLit "%cx"; 3 -> sLit "%dx"; + 4 -> sLit "%si"; 5 -> sLit "%di"; + 6 -> sLit "%bp"; 7 -> sLit "%sp"; + _ -> sLit "very naughty I386 word register" }) ppr_reg_long i = ptext (case i of { - 0 -> sLit "%eax"; 1 -> sLit "%ebx"; - 2 -> sLit "%ecx"; 3 -> sLit "%edx"; - 4 -> sLit "%esi"; 5 -> sLit "%edi"; - 6 -> sLit "%ebp"; 7 -> sLit "%esp"; + 0 -> sLit "%eax"; 1 -> sLit "%ebx"; + 2 -> sLit "%ecx"; 3 -> sLit "%edx"; + 4 -> sLit "%esi"; 5 -> sLit "%edi"; + 6 -> sLit "%ebp"; 7 -> sLit "%esp"; _ -> ppr_reg_float i }) #elif x86_64_TARGET_ARCH @@ -222,53 +222,53 @@ pprReg s r ppr_reg_byte i = ptext (case i of { - 0 -> sLit "%al"; 1 -> sLit "%bl"; - 2 -> sLit "%cl"; 3 -> sLit "%dl"; - 4 -> sLit "%sil"; 5 -> sLit "%dil"; -- new 8-bit regs! - 6 -> sLit "%bpl"; 7 -> sLit "%spl"; - 8 -> sLit "%r8b"; 9 -> sLit "%r9b"; - 10 -> sLit "%r10b"; 11 -> sLit "%r11b"; - 12 -> sLit "%r12b"; 13 -> sLit "%r13b"; - 14 -> sLit "%r14b"; 15 -> sLit "%r15b"; - _ -> sLit "very naughty x86_64 byte register" + 0 -> sLit "%al"; 1 -> sLit "%bl"; + 2 -> sLit "%cl"; 3 -> sLit "%dl"; + 4 -> sLit "%sil"; 5 -> sLit "%dil"; -- new 8-bit regs! + 6 -> sLit "%bpl"; 7 -> sLit "%spl"; + 8 -> sLit "%r8b"; 9 -> sLit "%r9b"; + 10 -> sLit "%r10b"; 11 -> sLit "%r11b"; + 12 -> sLit "%r12b"; 13 -> sLit "%r13b"; + 14 -> sLit "%r14b"; 15 -> sLit "%r15b"; + _ -> sLit "very naughty x86_64 byte register" }) ppr_reg_word i = ptext (case i of { - 0 -> sLit "%ax"; 1 -> sLit "%bx"; - 2 -> sLit "%cx"; 3 -> sLit "%dx"; - 4 -> sLit "%si"; 5 -> sLit "%di"; - 6 -> sLit "%bp"; 7 -> sLit "%sp"; - 8 -> sLit "%r8w"; 9 -> sLit "%r9w"; - 10 -> sLit "%r10w"; 11 -> sLit "%r11w"; - 12 -> sLit "%r12w"; 13 -> sLit "%r13w"; - 14 -> sLit "%r14w"; 15 -> sLit "%r15w"; - _ -> sLit "very naughty x86_64 word register" + 0 -> sLit "%ax"; 1 -> sLit "%bx"; + 2 -> sLit "%cx"; 3 -> sLit "%dx"; + 4 -> sLit "%si"; 5 -> sLit "%di"; + 6 -> sLit "%bp"; 7 -> sLit "%sp"; + 8 -> sLit "%r8w"; 9 -> sLit "%r9w"; + 10 -> sLit "%r10w"; 11 -> sLit "%r11w"; + 12 -> sLit "%r12w"; 13 -> sLit "%r13w"; + 14 -> sLit "%r14w"; 15 -> sLit "%r15w"; + _ -> sLit "very naughty x86_64 word register" }) ppr_reg_long i = ptext (case i of { - 0 -> sLit "%eax"; 1 -> sLit "%ebx"; - 2 -> sLit "%ecx"; 3 -> sLit "%edx"; - 4 -> sLit "%esi"; 5 -> sLit "%edi"; - 6 -> sLit "%ebp"; 7 -> sLit "%esp"; - 8 -> sLit "%r8d"; 9 -> sLit "%r9d"; - 10 -> sLit "%r10d"; 11 -> sLit "%r11d"; - 12 -> sLit "%r12d"; 13 -> sLit "%r13d"; - 14 -> sLit "%r14d"; 15 -> sLit "%r15d"; - _ -> sLit "very naughty x86_64 register" + 0 -> sLit "%eax"; 1 -> sLit "%ebx"; + 2 -> sLit "%ecx"; 3 -> sLit "%edx"; + 4 -> sLit "%esi"; 5 -> sLit "%edi"; + 6 -> sLit "%ebp"; 7 -> sLit "%esp"; + 8 -> sLit "%r8d"; 9 -> sLit "%r9d"; + 10 -> sLit "%r10d"; 11 -> sLit "%r11d"; + 12 -> sLit "%r12d"; 13 -> sLit "%r13d"; + 14 -> sLit "%r14d"; 15 -> sLit "%r15d"; + _ -> sLit "very naughty x86_64 register" }) ppr_reg_quad i = ptext (case i of { - 0 -> sLit "%rax"; 1 -> sLit "%rbx"; - 2 -> sLit "%rcx"; 3 -> sLit "%rdx"; - 4 -> sLit "%rsi"; 5 -> sLit "%rdi"; - 6 -> sLit "%rbp"; 7 -> sLit "%rsp"; - 8 -> sLit "%r8"; 9 -> sLit "%r9"; - 10 -> sLit "%r10"; 11 -> sLit "%r11"; - 12 -> sLit "%r12"; 13 -> sLit "%r13"; - 14 -> sLit "%r14"; 15 -> sLit "%r15"; + 0 -> sLit "%rax"; 1 -> sLit "%rbx"; + 2 -> sLit "%rcx"; 3 -> sLit "%rdx"; + 4 -> sLit "%rsi"; 5 -> sLit "%rdi"; + 6 -> sLit "%rbp"; 7 -> sLit "%rsp"; + 8 -> sLit "%r8"; 9 -> sLit "%r9"; + 10 -> sLit "%r10"; 11 -> sLit "%r11"; + 12 -> sLit "%r12"; 13 -> sLit "%r13"; + 14 -> sLit "%r14"; 15 -> sLit "%r15"; _ -> ppr_reg_float i }) #else @@ -278,52 +278,52 @@ pprReg s r #if defined(i386_TARGET_ARCH) || defined(x86_64_TARGET_ARCH) ppr_reg_float :: Int -> LitString ppr_reg_float i = case i of - 16 -> sLit "%fake0"; 17 -> sLit "%fake1" - 18 -> sLit "%fake2"; 19 -> sLit "%fake3" - 20 -> sLit "%fake4"; 21 -> sLit "%fake5" - 24 -> sLit "%xmm0"; 25 -> sLit "%xmm1" - 26 -> sLit "%xmm2"; 27 -> sLit "%xmm3" - 28 -> sLit "%xmm4"; 29 -> sLit "%xmm5" - 30 -> sLit "%xmm6"; 31 -> sLit "%xmm7" - 32 -> sLit "%xmm8"; 33 -> sLit "%xmm9" - 34 -> sLit "%xmm10"; 35 -> sLit "%xmm11" - 36 -> sLit "%xmm12"; 37 -> sLit "%xmm13" - 38 -> sLit "%xmm14"; 39 -> sLit "%xmm15" - _ -> sLit "very naughty x86 register" + 16 -> sLit "%fake0"; 17 -> sLit "%fake1" + 18 -> sLit "%fake2"; 19 -> sLit "%fake3" + 20 -> sLit "%fake4"; 21 -> sLit "%fake5" + 24 -> sLit "%xmm0"; 25 -> sLit "%xmm1" + 26 -> sLit "%xmm2"; 27 -> sLit "%xmm3" + 28 -> sLit "%xmm4"; 29 -> sLit "%xmm5" + 30 -> sLit "%xmm6"; 31 -> sLit "%xmm7" + 32 -> sLit "%xmm8"; 33 -> sLit "%xmm9" + 34 -> sLit "%xmm10"; 35 -> sLit "%xmm11" + 36 -> sLit "%xmm12"; 37 -> sLit "%xmm13" + 38 -> sLit "%xmm14"; 39 -> sLit "%xmm15" + _ -> sLit "very naughty x86 register" #endif pprSize :: Size -> Doc -pprSize x +pprSize x = ptext (case x of - II8 -> sLit "b" - II16 -> sLit "w" - II32 -> sLit "l" - II64 -> sLit "q" - FF32 -> sLit "ss" -- "scalar single-precision float" (SSE2) - FF64 -> sLit "sd" -- "scalar double-precision float" (SSE2) - FF80 -> sLit "t" - ) + II8 -> sLit "b" + II16 -> sLit "w" + II32 -> sLit "l" + II64 -> sLit "q" + FF32 -> sLit "ss" -- "scalar single-precision float" (SSE2) + FF64 -> sLit "sd" -- "scalar double-precision float" (SSE2) + FF80 -> sLit "t" + ) pprSize_x87 :: Size -> Doc pprSize_x87 x = ptext $ case x of - FF32 -> sLit "s" - FF64 -> sLit "l" - FF80 -> sLit "t" + FF32 -> sLit "s" + FF64 -> sLit "l" + FF80 -> sLit "t" _ -> panic "X86.Ppr.pprSize_x87" pprCond :: Cond -> Doc pprCond c = ptext (case c of { - GEU -> sLit "ae"; LU -> sLit "b"; - EQQ -> sLit "e"; GTT -> sLit "g"; - GE -> sLit "ge"; GU -> sLit "a"; - LTT -> sLit "l"; LE -> sLit "le"; - LEU -> sLit "be"; NE -> sLit "ne"; - NEG -> sLit "s"; POS -> sLit "ns"; - CARRY -> sLit "c"; OFLO -> sLit "o"; - PARITY -> sLit "p"; NOTPARITY -> sLit "np"; - ALWAYS -> sLit "mp"}) + GEU -> sLit "ae"; LU -> sLit "b"; + EQQ -> sLit "e"; GTT -> sLit "g"; + GE -> sLit "ge"; GU -> sLit "a"; + LTT -> sLit "l"; LE -> sLit "le"; + LEU -> sLit "be"; NE -> sLit "ne"; + NEG -> sLit "s"; POS -> sLit "ns"; + CARRY -> sLit "c"; OFLO -> sLit "o"; + PARITY -> sLit "p"; NOTPARITY -> sLit "np"; + ALWAYS -> sLit "mp"}) pprImm :: Imm -> Doc @@ -344,30 +344,30 @@ pprImm (ImmConstantDiff a b) = pprImm a <> char '-' pprAddr :: AddrMode -> Doc pprAddr (ImmAddr imm off) - = let pp_imm = pprImm imm + = let pp_imm = pprImm imm in if (off == 0) then - pp_imm + pp_imm else if (off < 0) then - pp_imm <> int off + pp_imm <> int off else - pp_imm <> char '+' <> int off + pp_imm <> char '+' <> int off pprAddr (AddrBaseIndex base index displacement) = let - pp_disp = ppr_disp displacement - pp_off p = pp_disp <> char '(' <> p <> char ')' - pp_reg r = pprReg archWordSize r + pp_disp = ppr_disp displacement + pp_off p = pp_disp <> char '(' <> p <> char ')' + pp_reg r = pprReg archWordSize r in case (base, index) of (EABaseNone, EAIndexNone) -> pp_disp (EABaseReg b, EAIndexNone) -> pp_off (pp_reg b) (EABaseRip, EAIndexNone) -> pp_off (ptext (sLit "%rip")) (EABaseNone, EAIndex r i) -> pp_off (comma <> pp_reg r <> comma <> int i) - (EABaseReg b, EAIndex r i) -> pp_off (pp_reg b <> comma <> pp_reg r + (EABaseReg b, EAIndex r i) -> pp_off (pp_reg b <> comma <> pp_reg r <> comma <> int i) - _ -> panic "X86.Ppr.pprAddr: no match" - + _ -> panic "X86.Ppr.pprAddr: no match" + where ppr_disp (ImmInt 0) = empty ppr_disp imm = pprImm imm @@ -376,57 +376,57 @@ pprAddr (AddrBaseIndex base index displacement) pprSectionHeader :: Section -> Doc #if i386_TARGET_ARCH -# if darwin_TARGET_OS +# if darwin_TARGET_OS pprSectionHeader seg = case seg of - Text -> ptext (sLit ".text\n\t.align 2") - Data -> ptext (sLit ".data\n\t.align 2") - ReadOnlyData -> ptext (sLit ".const\n.align 2") - RelocatableReadOnlyData -> ptext (sLit ".const_data\n.align 2") - UninitialisedData -> ptext (sLit ".data\n\t.align 2") - ReadOnlyData16 -> ptext (sLit ".const\n.align 4") - OtherSection _ -> panic "X86.Ppr.pprSectionHeader: unknown section" + Text -> ptext (sLit ".text\n\t.align 2") + Data -> ptext (sLit ".data\n\t.align 2") + ReadOnlyData -> ptext (sLit ".const\n.align 2") + RelocatableReadOnlyData -> ptext (sLit ".const_data\n.align 2") + UninitialisedData -> ptext (sLit ".data\n\t.align 2") + ReadOnlyData16 -> ptext (sLit ".const\n.align 4") + OtherSection _ -> panic "X86.Ppr.pprSectionHeader: unknown section" # else pprSectionHeader seg = case seg of - Text -> ptext (sLit ".text\n\t.align 4,0x90") - Data -> ptext (sLit ".data\n\t.align 4") - ReadOnlyData -> ptext (sLit ".section .rodata\n\t.align 4") - 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 _ -> panic "X86.Ppr.pprSectionHeader: unknown section" + Text -> ptext (sLit ".text\n\t.align 4,0x90") + Data -> ptext (sLit ".data\n\t.align 4") + ReadOnlyData -> ptext (sLit ".section .rodata\n\t.align 4") + 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 _ -> panic "X86.Ppr.pprSectionHeader: unknown section" # endif #elif x86_64_TARGET_ARCH -# if darwin_TARGET_OS +# if darwin_TARGET_OS pprSectionHeader seg = case seg of - Text -> ptext (sLit ".text\n.align 3") - Data -> ptext (sLit ".data\n.align 3") - ReadOnlyData -> ptext (sLit ".const\n.align 3") - RelocatableReadOnlyData -> ptext (sLit ".const_data\n.align 3") - UninitialisedData -> ptext (sLit ".data\n\t.align 3") - ReadOnlyData16 -> ptext (sLit ".const\n.align 4") - OtherSection _ -> panic "PprMach.pprSectionHeader: unknown section" + Text -> ptext (sLit ".text\n.align 3") + Data -> ptext (sLit ".data\n.align 3") + ReadOnlyData -> ptext (sLit ".const\n.align 3") + RelocatableReadOnlyData -> ptext (sLit ".const_data\n.align 3") + UninitialisedData -> ptext (sLit ".data\n\t.align 3") + ReadOnlyData16 -> ptext (sLit ".const\n.align 4") + OtherSection _ -> panic "PprMach.pprSectionHeader: unknown section" # else pprSectionHeader seg = case seg of - Text -> ptext (sLit ".text\n\t.align 8") - Data -> ptext (sLit ".data\n\t.align 8") - ReadOnlyData -> ptext (sLit ".section .rodata\n\t.align 8") - 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 _ -> panic "PprMach.pprSectionHeader: unknown section" + Text -> ptext (sLit ".text\n\t.align 8") + Data -> ptext (sLit ".data\n\t.align 8") + ReadOnlyData -> ptext (sLit ".section .rodata\n\t.align 8") + 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 _ -> panic "PprMach.pprSectionHeader: unknown section" # endif #else -pprSectionHeader _ = panic "X86.Ppr.pprSectionHeader: not defined for this architecture" +pprSectionHeader _ = panic "X86.Ppr.pprSectionHeader: not defined for this architecture" #endif @@ -437,22 +437,22 @@ pprDataItem :: CmmLit -> Doc pprDataItem lit = vcat (ppr_item (cmmTypeSize $ cmmLitType lit) lit) where - imm = litToImm lit + imm = litToImm lit - -- These seem to be common: - ppr_item II8 _ = [ptext (sLit "\t.byte\t") <> pprImm imm] - ppr_item II32 _ = [ptext (sLit "\t.long\t") <> pprImm imm] + -- These seem to be common: + ppr_item II8 _ = [ptext (sLit "\t.byte\t") <> pprImm imm] + ppr_item II32 _ = [ptext (sLit "\t.long\t") <> pprImm imm] - ppr_item FF32 (CmmFloat r _) + ppr_item FF32 (CmmFloat r _) = let bs = floatToBytes (fromRational r) in map (\b -> ptext (sLit "\t.byte\t") <> pprImm (ImmInt b)) bs - ppr_item FF64 (CmmFloat r _) + ppr_item FF64 (CmmFloat r _) = let bs = doubleToBytes (fromRational r) in map (\b -> ptext (sLit "\t.byte\t") <> pprImm (ImmInt b)) bs #if i386_TARGET_ARCH || x86_64_TARGET_ARCH - ppr_item II16 _ = [ptext (sLit "\t.word\t") <> pprImm imm] + ppr_item II16 _ = [ptext (sLit "\t.word\t") <> pprImm imm] #endif #if i386_TARGET_ARCH && darwin_TARGET_OS ppr_item II64 (CmmInt x _) = @@ -463,30 +463,30 @@ pprDataItem lit (fromIntegral (x `shiftR` 32) :: Word32))] #endif #if i386_TARGET_ARCH || (darwin_TARGET_OS && x86_64_TARGET_ARCH) - ppr_item II64 _ = [ptext (sLit "\t.quad\t") <> pprImm imm] + ppr_item II64 _ = [ptext (sLit "\t.quad\t") <> pprImm imm] #endif #if x86_64_TARGET_ARCH && !darwin_TARGET_OS - -- x86_64: binutils can't handle the R_X86_64_PC64 relocation - -- type, which means we can't do pc-relative 64-bit addresses. - -- Fortunately we're assuming the small memory model, in which - -- all such offsets will fit into 32 bits, so we have to stick - -- to 32-bit offset fields and modify the RTS appropriately + -- x86_64: binutils can't handle the R_X86_64_PC64 relocation + -- type, which means we can't do pc-relative 64-bit addresses. + -- Fortunately we're assuming the small memory model, in which + -- all such offsets will fit into 32 bits, so we have to stick + -- to 32-bit offset fields and modify the RTS appropriately -- -- See Note [x86-64-relative] in includes/rts/storage/InfoTables.h - -- - ppr_item II64 x - | isRelativeReloc x = - [ptext (sLit "\t.long\t") <> pprImm imm, - ptext (sLit "\t.long\t0")] - | otherwise = - [ptext (sLit "\t.quad\t") <> pprImm imm] - where - isRelativeReloc (CmmLabelDiffOff _ _ _) = True - isRelativeReloc _ = False + -- + ppr_item II64 x + | isRelativeReloc x = + [ptext (sLit "\t.long\t") <> pprImm imm, + ptext (sLit "\t.long\t0")] + | otherwise = + [ptext (sLit "\t.quad\t") <> pprImm imm] + where + isRelativeReloc (CmmLabelDiffOff _ _ _) = True + isRelativeReloc _ = False #endif - ppr_item _ _ - = panic "X86.Ppr.ppr_item: no match" + ppr_item _ _ + = panic "X86.Ppr.ppr_item: no match" @@ -516,34 +516,34 @@ pprInstr (LDATA _ _) {- pprInstr (SPILL reg slot) = hcat [ - ptext (sLit "\tSPILL"), - char ' ', - pprUserReg reg, - comma, - ptext (sLit "SLOT") <> parens (int slot)] + ptext (sLit "\tSPILL"), + char ' ', + pprUserReg reg, + comma, + ptext (sLit "SLOT") <> parens (int slot)] pprInstr (RELOAD slot reg) = hcat [ - ptext (sLit "\tRELOAD"), - char ' ', - ptext (sLit "SLOT") <> parens (int slot), - comma, - pprUserReg reg] + ptext (sLit "\tRELOAD"), + char ' ', + ptext (sLit "SLOT") <> parens (int slot), + comma, + pprUserReg reg] -} pprInstr (MOV size src dst) = pprSizeOpOp (sLit "mov") size src dst pprInstr (MOVZxL II32 src dst) = pprSizeOpOp (sLit "mov") II32 src dst - -- 32-to-64 bit zero extension on x86_64 is accomplished by a simple - -- movl. But we represent it as a MOVZxL instruction, because - -- the reg alloc would tend to throw away a plain reg-to-reg - -- move, and we still want it to do that. + -- 32-to-64 bit zero extension on x86_64 is accomplished by a simple + -- movl. But we represent it as a MOVZxL instruction, because + -- the reg alloc would tend to throw away a plain reg-to-reg + -- move, and we still want it to do that. pprInstr (MOVZxL sizes src dst) = pprSizeOpOpCoerce (sLit "movz") sizes II32 src dst - -- zero-extension only needs to extend to 32 bits: on x86_64, - -- the remaining zero-extension to 64 bits is automatic, and the 32-bit - -- instruction is shorter. + -- zero-extension only needs to extend to 32 bits: on x86_64, + -- the remaining zero-extension to 64 bits is automatic, and the 32-bit + -- instruction is shorter. pprInstr (MOVSxL sizes src dst) = pprSizeOpOpCoerce (sLit "movs") sizes archWordSize src dst @@ -579,8 +579,8 @@ pprInstr (IMUL size op1 op2) = pprSizeOpOp (sLit "imul") size op1 op2 because the lower half of the product is the same regardless if (sic) the operands are signed or unsigned. The CF and OF flags, however, cannot be used to determine if the upper half of the - result is non-zero." So there. --} + result is non-zero." So there. +-} pprInstr (AND size src dst) = pprSizeOpOp (sLit "and") size src dst pprInstr (OR size src dst) = pprSizeOpOp (sLit "or") size src dst @@ -597,15 +597,15 @@ pprInstr (SHR size src dst) = pprShift (sLit "shr") size src dst pprInstr (BT size imm src) = pprSizeImmOp (sLit "bt") size imm src -pprInstr (CMP size src dst) +pprInstr (CMP size src dst) | is_float size = pprSizeOpOp (sLit "ucomi") size src dst -- SSE2 | otherwise = pprSizeOpOp (sLit "cmp") size src dst where - -- This predicate is needed here and nowhere else - is_float FF32 = True - is_float FF64 = True - is_float FF80 = True - is_float _ = False + -- This predicate is needed here and nowhere else + is_float FF32 = True + is_float FF64 = True + is_float FF80 = True + is_float _ = False pprInstr (TEST size src dst) = pprSizeOpOp (sLit "test") size src dst pprInstr (PUSH size op) = pprSizeOp (sLit "push") size op @@ -621,7 +621,7 @@ pprInstr (CLTD II64) = ptext (sLit "\tcqto") pprInstr (SETCC cond op) = pprCondInstr (sLit "set") cond (pprOperand II8 op) -pprInstr (JXX cond (BlockId id)) +pprInstr (JXX cond (BlockId id)) = pprCondInstr (sLit "j") cond (pprCLabel_asm lab) where lab = mkAsmTempLabel id @@ -633,7 +633,7 @@ pprInstr (JMP_TBL op _) = pprInstr (JMP op) pprInstr (CALL (Left imm) _) = (<>) (ptext (sLit "\tcall ")) (pprImm imm) pprInstr (CALL (Right reg) _) = (<>) (ptext (sLit "\tcall *")) (pprReg archWordSize reg) -pprInstr (IDIV sz op) = pprSizeOp (sLit "idiv") sz op +pprInstr (IDIV sz op) = pprSizeOp (sLit "idiv") sz op pprInstr (DIV sz op) = pprSizeOp (sLit "div") sz op pprInstr (IMUL2 sz op) = pprSizeOp (sLit "imul") sz op @@ -676,21 +676,21 @@ pprInstr (FETCHPC reg) pprInstr g@(GMOV src dst) | src == dst = empty - | otherwise + | otherwise = pprG g (hcat [gtab, gpush src 0, gsemi, gpop dst 1]) -- GLD sz addr dst ==> FLDsz addr ; FSTP (dst+1) pprInstr g@(GLD sz addr dst) - = pprG g (hcat [gtab, text "fld", pprSize_x87 sz, gsp, + = pprG g (hcat [gtab, text "fld", pprSize_x87 sz, gsp, pprAddr addr, gsemi, gpop dst 1]) -- GST sz src addr ==> FLD dst ; FSTPsz addr pprInstr g@(GST sz src addr) | src == fake0 && sz /= FF80 -- fstt instruction doesn't exist - = pprG g (hcat [gtab, + = pprG g (hcat [gtab, text "fst", pprSize_x87 sz, gsp, pprAddr addr]) | otherwise - = pprG g (hcat [gtab, gpush src 0, gsemi, + = pprG g (hcat [gtab, gpush src 0, gsemi, text "fstp", pprSize_x87 sz, gsp, pprAddr addr]) pprInstr g@(GLDZ dst) @@ -698,10 +698,10 @@ pprInstr g@(GLDZ dst) pprInstr g@(GLD1 dst) = pprG g (hcat [gtab, text "fld1 ; ", gpop dst 1]) -pprInstr (GFTOI src dst) +pprInstr (GFTOI src dst) = pprInstr (GDTOI src dst) -pprInstr g@(GDTOI src dst) +pprInstr g@(GDTOI src dst) = pprG g (vcat [ hcat [gtab, text "subl $8, %esp ; fnstcw 4(%esp)"], hcat [gtab, gpush src 0], @@ -715,11 +715,11 @@ pprInstr g@(GDTOI src dst) where reg = pprReg II32 dst -pprInstr (GITOF src dst) +pprInstr (GITOF src dst) = pprInstr (GITOD src dst) -pprInstr g@(GITOD src dst) - = pprG g (hcat [gtab, text "pushl ", pprReg II32 src, +pprInstr g@(GITOD src dst) + = pprG g (hcat [gtab, text "pushl ", pprReg II32 src, text " ; fildl (%esp) ; ", gpop dst 1, text " ; addl $4,%esp"]) @@ -736,19 +736,19 @@ pprInstr g@(GITOD src dst) Here's how the general (non-inequality) case works. As an example, consider generating the an equality test: - pushl %eax -- we need to mess with this + pushl %eax -- we need to mess with this fcomp and pop pushed src1 - -- Result of comparison is in FPU Status Register bits - -- C3 C2 and C0 - fstsw %ax -- Move FPU Status Reg to %ax - sahf -- move C3 C2 C0 from %ax to integer flag reg + -- Result of comparison is in FPU Status Register bits + -- C3 C2 and C0 + fstsw %ax -- Move FPU Status Reg to %ax + sahf -- move C3 C2 C0 from %ax to integer flag reg -- now the serious magic begins - setpo %ah -- %ah = if comparable(neither arg was NaN) then 1 else 0 + setpo %ah -- %ah = if comparable(neither arg was NaN) then 1 else 0 sete %al -- %al = if arg1 == arg2 then 1 else 0 andb %ah,%al -- %al &= %ah -- so %al == 1 iff (comparable && same); else it holds 0 - decb %al -- %al == 0, ZeroFlag=1 iff (comparable && same); + decb %al -- %al == 0, ZeroFlag=1 iff (comparable && same); else %al == 0xFF, ZeroFlag=0 -- the zero flag is now set as we desire. popl %eax @@ -761,11 +761,11 @@ pprInstr g@(GITOD src dst) decb %al -- if (incomparable || different) then (%al == 0, ZF=1) else (%al == 0xFF, ZF=0) -} -pprInstr g@(GCMP cond src1 src2) +pprInstr g@(GCMP cond src1 src2) | case cond of { NE -> True; _ -> False } = pprG g (vcat [ hcat [gtab, text "pushl %eax ; ",gpush src1 0], - hcat [gtab, text "fcomp ", greg src2 1, + hcat [gtab, text "fcomp ", greg src2 1, text "; fstsw %ax ; sahf ; setpe %ah"], hcat [gtab, text "setne %al ; ", text "orb %ah,%al ; decb %al ; popl %eax"] @@ -773,7 +773,7 @@ pprInstr g@(GCMP cond src1 src2) | otherwise = pprG g (vcat [ hcat [gtab, text "pushl %eax ; ",gpush src1 0], - hcat [gtab, text "fcomp ", greg src2 1, + hcat [gtab, text "fcomp ", greg src2 1, text "; fstsw %ax ; sahf ; setpo %ah"], hcat [gtab, text "set", pprCond (fix_FP_cond cond), text " %al ; ", text "andb %ah,%al ; decb %al ; popl %eax"] @@ -789,7 +789,7 @@ pprInstr g@(GCMP cond src1 src2) fix_FP_cond LE = LEU fix_FP_cond EQQ = EQQ fix_FP_cond NE = NE - fix_FP_cond _ = panic "X86.Ppr.fix_FP_cond: no match" + fix_FP_cond _ = panic "X86.Ppr.fix_FP_cond: no match" -- there should be no others @@ -800,7 +800,7 @@ pprInstr g@(GNEG _ src dst) = pprG g (hcat [gtab, gpush src 0, text " ; fchs ; ", gpop dst 1]) pprInstr g@(GSQRT sz src dst) - = pprG g (hcat [gtab, gpush src 0, text " ; fsqrt"] $$ + = pprG g (hcat [gtab, gpush src 0, text " ; fsqrt"] $$ hcat [gtab, gcoerceto sz, gpop dst 1]) pprInstr g@(GSIN sz l1 l2 src dst) @@ -818,71 +818,71 @@ pprInstr g@(GTAN sz l1 l2 src dst) pprInstr g@(GADD _ src1 src2 dst) | src1 == dst - = pprG g (text "\t#GADD-xxxcase1" $$ + = pprG g (text "\t#GADD-xxxcase1" $$ hcat [gtab, gpush src2 0, text " ; faddp %st(0),", greg src1 1]) | src2 == dst - = pprG g (text "\t#GADD-xxxcase2" $$ + = pprG g (text "\t#GADD-xxxcase2" $$ hcat [gtab, gpush src1 0, text " ; faddp %st(0),", greg src2 1]) | otherwise - = pprG g (hcat [gtab, gpush src1 0, + = pprG g (hcat [gtab, gpush src1 0, text " ; fadd ", greg src2 1, text ",%st(0)", gsemi, gpop dst 1]) pprInstr g@(GMUL _ src1 src2 dst) | src1 == dst - = pprG g (text "\t#GMUL-xxxcase1" $$ + = pprG g (text "\t#GMUL-xxxcase1" $$ hcat [gtab, gpush src2 0, text " ; fmulp %st(0),", greg src1 1]) | src2 == dst - = pprG g (text "\t#GMUL-xxxcase2" $$ + = pprG g (text "\t#GMUL-xxxcase2" $$ hcat [gtab, gpush src1 0, text " ; fmulp %st(0),", greg src2 1]) | otherwise - = pprG g (hcat [gtab, gpush src1 0, + = pprG g (hcat [gtab, gpush src1 0, text " ; fmul ", greg src2 1, text ",%st(0)", gsemi, gpop dst 1]) pprInstr g@(GSUB _ src1 src2 dst) | src1 == dst - = pprG g (text "\t#GSUB-xxxcase1" $$ + = pprG g (text "\t#GSUB-xxxcase1" $$ hcat [gtab, gpush src2 0, text " ; fsubrp %st(0),", greg src1 1]) | src2 == dst - = pprG g (text "\t#GSUB-xxxcase2" $$ + = pprG g (text "\t#GSUB-xxxcase2" $$ hcat [gtab, gpush src1 0, text " ; fsubp %st(0),", greg src2 1]) | otherwise - = pprG g (hcat [gtab, gpush src1 0, + = pprG g (hcat [gtab, gpush src1 0, text " ; fsub ", greg src2 1, text ",%st(0)", gsemi, gpop dst 1]) pprInstr g@(GDIV _ src1 src2 dst) | src1 == dst - = pprG g (text "\t#GDIV-xxxcase1" $$ + = pprG g (text "\t#GDIV-xxxcase1" $$ hcat [gtab, gpush src2 0, text " ; fdivrp %st(0),", greg src1 1]) | src2 == dst - = pprG g (text "\t#GDIV-xxxcase2" $$ + = pprG g (text "\t#GDIV-xxxcase2" $$ hcat [gtab, gpush src1 0, text " ; fdivp %st(0),", greg src2 1]) | otherwise - = pprG g (hcat [gtab, gpush src1 0, + = pprG g (hcat [gtab, gpush src1 0, text " ; fdiv ", greg src2 1, text ",%st(0)", gsemi, gpop dst 1]) -pprInstr GFREE +pprInstr GFREE = vcat [ ptext (sLit "\tffree %st(0) ;ffree %st(1) ;ffree %st(2) ;ffree %st(3)"), - ptext (sLit "\tffree %st(4) ;ffree %st(5)") + ptext (sLit "\tffree %st(4) ;ffree %st(5)") ] pprInstr _ - = panic "X86.Ppr.pprInstr: no match" + = panic "X86.Ppr.pprInstr: no match" pprTrigOp :: String -> Bool -> CLabel -> CLabel -> Reg -> Reg -> Size -> Doc @@ -1005,67 +1005,67 @@ pprOperand _ (OpAddr ea) = pprAddr ea pprMnemonic_ :: LitString -> Doc -pprMnemonic_ name = +pprMnemonic_ name = char '\t' <> ptext name <> space pprMnemonic :: LitString -> Size -> Doc -pprMnemonic name size = +pprMnemonic name size = char '\t' <> ptext name <> pprSize size <> space pprSizeImmOp :: LitString -> Size -> Imm -> Operand -> Doc pprSizeImmOp name size imm op1 = hcat [ - pprMnemonic name size, - char '$', - pprImm imm, - comma, - pprOperand size op1 + pprMnemonic name size, + char '$', + pprImm imm, + comma, + pprOperand size op1 ] - + pprSizeOp :: LitString -> Size -> Operand -> Doc pprSizeOp name size op1 = hcat [ - pprMnemonic name size, - pprOperand size op1 + pprMnemonic name size, + pprOperand size op1 ] pprSizeOpOp :: LitString -> Size -> Operand -> Operand -> Doc pprSizeOpOp name size op1 op2 = hcat [ - pprMnemonic name size, - pprOperand size op1, - comma, - pprOperand size op2 + pprMnemonic name size, + pprOperand size op1, + comma, + pprOperand size op2 ] pprOpOp :: LitString -> Size -> Operand -> Operand -> Doc pprOpOp name size op1 op2 = hcat [ - pprMnemonic_ name, - pprOperand size op1, - comma, - pprOperand size op2 + pprMnemonic_ name, + pprOperand size op1, + comma, + pprOperand size op2 ] pprSizeReg :: LitString -> Size -> Reg -> Doc pprSizeReg name size reg1 = hcat [ - pprMnemonic name size, - pprReg size reg1 + pprMnemonic name size, + pprReg size reg1 ] pprSizeRegReg :: LitString -> Size -> Reg -> Reg -> Doc pprSizeRegReg name size reg1 reg2 = hcat [ - pprMnemonic name size, - pprReg size reg1, + pprMnemonic name size, + pprReg size reg1, comma, pprReg size reg2 ] @@ -1074,8 +1074,8 @@ pprSizeRegReg name size reg1 reg2 pprRegReg :: LitString -> Reg -> Reg -> Doc pprRegReg name reg1 reg2 = hcat [ - pprMnemonic_ name, - pprReg archWordSize reg1, + pprMnemonic_ name, + pprReg archWordSize reg1, comma, pprReg archWordSize reg2 ] @@ -1084,8 +1084,8 @@ pprRegReg name reg1 reg2 pprSizeOpReg :: LitString -> Size -> Operand -> Reg -> Doc pprSizeOpReg name size op1 reg2 = hcat [ - pprMnemonic name size, - pprOperand size op1, + pprMnemonic name size, + pprOperand size op1, comma, pprReg archWordSize reg2 ] @@ -1094,11 +1094,11 @@ pprSizeOpReg name size op1 reg2 pprCondRegReg :: LitString -> Size -> Cond -> Reg -> Reg -> Doc pprCondRegReg name size cond reg1 reg2 = hcat [ - char '\t', - ptext name, - pprCond cond, - space, - pprReg size reg1, + char '\t', + ptext name, + pprCond cond, + space, + pprReg size reg1, comma, pprReg size reg2 ] @@ -1106,12 +1106,12 @@ pprCondRegReg name size cond reg1 reg2 pprSizeSizeRegReg :: LitString -> Size -> Size -> Reg -> Reg -> Doc pprSizeSizeRegReg name size1 size2 reg1 reg2 = hcat [ - char '\t', - ptext name, - pprSize size1, + char '\t', + ptext name, + pprSize size1, pprSize size2, - space, - pprReg size1 reg1, + space, + pprReg size1 reg1, comma, pprReg size2 reg2 @@ -1121,8 +1121,8 @@ pprSizeSizeRegReg name size1 size2 reg1 reg2 pprSizeRegRegReg :: LitString -> Size -> Reg -> Reg -> Reg -> Doc pprSizeRegRegReg name size reg1 reg2 reg3 = hcat [ - pprMnemonic name size, - pprReg size reg1, + pprMnemonic name size, + pprReg size reg1, comma, pprReg size reg2, comma, @@ -1133,39 +1133,39 @@ pprSizeRegRegReg name size reg1 reg2 reg3 pprSizeAddrReg :: LitString -> Size -> AddrMode -> Reg -> Doc pprSizeAddrReg name size op dst = hcat [ - pprMnemonic name size, - pprAddr op, - comma, - pprReg size dst + pprMnemonic name size, + pprAddr op, + comma, + pprReg size dst ] pprSizeRegAddr :: LitString -> Size -> Reg -> AddrMode -> Doc pprSizeRegAddr name size src op = hcat [ - pprMnemonic name size, - pprReg size src, - comma, - pprAddr op + pprMnemonic name size, + pprReg size src, + comma, + pprAddr op ] pprShift :: LitString -> Size -> Operand -> Operand -> Doc pprShift name size src dest = hcat [ - pprMnemonic name size, - pprOperand II8 src, -- src is 8-bit sized - comma, - pprOperand size dest + pprMnemonic name size, + pprOperand II8 src, -- src is 8-bit sized + comma, + pprOperand size dest ] pprSizeOpOpCoerce :: LitString -> Size -> Size -> Operand -> Operand -> Doc pprSizeOpOpCoerce name size1 size2 op1 op2 = hcat [ char '\t', ptext name, pprSize size1, pprSize size2, space, - pprOperand size1 op1, - comma, - pprOperand size2 op2 + pprOperand size1 op1, + comma, + pprOperand size2 op2 ] -- 1.7.10.4