X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FnativeGen%2FPprMach.hs;h=5016726cefa23d54398c3d667d68d8888f67cddd;hb=84923cc7de2a93c22a2f72daf9ac863959efae13;hp=afa5bcd872f62c0bd58f3320ffe940ef6c0588a7;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/compiler/nativeGen/PprMach.hs b/compiler/nativeGen/PprMach.hs index afa5bcd..5016726 100644 --- a/compiler/nativeGen/PprMach.hs +++ b/compiler/nativeGen/PprMach.hs @@ -37,22 +37,15 @@ import Pretty import FastString import qualified Outputable -import StaticFlags ( opt_PIC, opt_Static ) - -#if __GLASGOW_HASKELL__ >= 504 import Data.Array.ST import Data.Word ( Word8 ) -#else -import MutableArray -#endif - -import MONAD_ST -import Char ( chr, ord ) -import Maybe ( isJust ) +import Control.Monad.ST +import Data.Char ( chr, ord ) +import Data.Maybe ( isJust ) #if powerpc_TARGET_ARCH || darwin_TARGET_OS -import DATA_WORD(Word32) -import DATA_BITS +import Data.Word(Word32) +import Data.Bits #endif -- ----------------------------------------------------------------------------- @@ -623,7 +616,8 @@ pprSectionHeader Text ,IF_ARCH_i386(IF_OS_darwin(SLIT(".text\n\t.align 2"), SLIT(".text\n\t.align 4,0x90")) {-needs per-OS variation!-} - ,IF_ARCH_x86_64(SLIT(".text\n\t.align 8") {-needs per-OS variation!-} + ,IF_ARCH_x86_64(IF_OS_darwin(SLIT(".text\n.align 3"), + SLIT(".text\n\t.align 8")) ,IF_ARCH_powerpc(SLIT(".text\n.align 2") ,))))) pprSectionHeader Data @@ -632,7 +626,8 @@ pprSectionHeader Data ,IF_ARCH_sparc(SLIT(".data\n\t.align 8") {-<8 will break double constants -} ,IF_ARCH_i386(IF_OS_darwin(SLIT(".data\n\t.align 2"), SLIT(".data\n\t.align 4")) - ,IF_ARCH_x86_64(SLIT(".data\n\t.align 8") + ,IF_ARCH_x86_64(IF_OS_darwin(SLIT(".data\n.align 3"), + SLIT(".data\n\t.align 8")) ,IF_ARCH_powerpc(SLIT(".data\n.align 2") ,))))) pprSectionHeader ReadOnlyData @@ -641,7 +636,8 @@ pprSectionHeader ReadOnlyData ,IF_ARCH_sparc(SLIT(".data\n\t.align 8") {-<8 will break double constants -} ,IF_ARCH_i386(IF_OS_darwin(SLIT(".const\n.align 2"), SLIT(".section .rodata\n\t.align 4")) - ,IF_ARCH_x86_64(SLIT(".section .rodata\n\t.align 8") + ,IF_ARCH_x86_64(IF_OS_darwin(SLIT(".const\n.align 3"), + SLIT(".section .rodata\n\t.align 8")) ,IF_ARCH_powerpc(IF_OS_darwin(SLIT(".const\n.align 2"), SLIT(".section .rodata\n\t.align 2")) ,))))) @@ -651,7 +647,8 @@ pprSectionHeader RelocatableReadOnlyData ,IF_ARCH_sparc(SLIT(".data\n\t.align 8") {-<8 will break double constants -} ,IF_ARCH_i386(IF_OS_darwin(SLIT(".const_data\n.align 2"), SLIT(".section .rodata\n\t.align 4")) - ,IF_ARCH_x86_64(SLIT(".section .rodata\n\t.align 8") + ,IF_ARCH_x86_64(IF_OS_darwin(SLIT(".const_data\n.align 3"), + SLIT(".section .rodata\n\t.align 8")) ,IF_ARCH_powerpc(IF_OS_darwin(SLIT(".const_data\n.align 2"), SLIT(".data\n\t.align 2")) ,))))) @@ -659,9 +656,10 @@ pprSectionHeader UninitialisedData = ptext IF_ARCH_alpha(SLIT("\t.bss\n\t.align 3") ,IF_ARCH_sparc(SLIT(".bss\n\t.align 8") {-<8 will break double constants -} - ,IF_ARCH_i386(IF_OS_darwin(SLIT(".const_data\n\t.align 2"), + ,IF_ARCH_i386(IF_OS_darwin(SLIT(".data\n\t.align 2"), SLIT(".section .bss\n\t.align 4")) - ,IF_ARCH_x86_64(SLIT(".section .bss\n\t.align 8") + ,IF_ARCH_x86_64(IF_OS_darwin(SLIT(".data\n\t.align 3"), + SLIT(".section .bss\n\t.align 8")) ,IF_ARCH_powerpc(IF_OS_darwin(SLIT(".const_data\n.align 2"), SLIT(".section .bss\n\t.align 2")) ,))))) @@ -671,7 +669,8 @@ pprSectionHeader ReadOnlyData16 ,IF_ARCH_sparc(SLIT(".data\n\t.align 16") ,IF_ARCH_i386(IF_OS_darwin(SLIT(".const\n.align 4"), SLIT(".section .rodata\n\t.align 16")) - ,IF_ARCH_x86_64(SLIT(".section .rodata.cst16\n\t.align 16") + ,IF_ARCH_x86_64(IF_OS_darwin(SLIT(".const\n.align 4"), + SLIT(".section .rodata.cst16\n\t.align 16")) ,IF_ARCH_powerpc(IF_OS_darwin(SLIT(".const\n.align 4"), SLIT(".section .rodata\n\t.align 4")) ,))))) @@ -706,7 +705,7 @@ pprASCII str pprAlign bytes = IF_ARCH_alpha(ptextSLIT(".align ") <> int pow2, IF_ARCH_i386(ptext SLIT(".align ") <> int IF_OS_darwin(pow2,bytes), - IF_ARCH_x86_64(ptext SLIT(".align ") <> int bytes, + IF_ARCH_x86_64(ptext SLIT(".align ") <> int IF_OS_darwin(pow2,bytes), IF_ARCH_sparc(ptext SLIT(".align ") <> int bytes, IF_ARCH_powerpc(ptext SLIT(".align ") <> int pow2,))))) where @@ -752,10 +751,10 @@ pprDataItem lit <> int (fromIntegral (fromIntegral (x `shiftR` 32) :: Word32))] #endif -#if i386_TARGET_ARCH +#if i386_TARGET_ARCH || (darwin_TARGET_OS && x86_64_TARGET_ARCH) ppr_item I64 x = [ptext SLIT("\t.quad\t") <> pprImm imm] #endif -#if x86_64_TARGET_ARCH +#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 @@ -1309,10 +1308,10 @@ pprInstr (FDIV size op1 op2) = pprSizeOpOp SLIT("div") size op1 op2 pprInstr (CVTSS2SD from to) = pprRegReg SLIT("cvtss2sd") from to pprInstr (CVTSD2SS from to) = pprRegReg SLIT("cvtsd2ss") from to -pprInstr (CVTSS2SI from to) = pprOpReg SLIT("cvtss2si") from to -pprInstr (CVTSD2SI from to) = pprOpReg SLIT("cvtsd2si") from to -pprInstr (CVTSI2SS from to) = pprOpReg SLIT("cvtsi2ss") from to -pprInstr (CVTSI2SD from to) = pprOpReg SLIT("cvtsi2sd") from to +pprInstr (CVTSS2SI from to) = pprOpReg SLIT("cvtss2siq") from to +pprInstr (CVTSD2SI from to) = pprOpReg SLIT("cvtsd2siq") from to +pprInstr (CVTSI2SS from to) = pprOpReg SLIT("cvtsi2ssq") from to +pprInstr (CVTSI2SD from to) = pprOpReg SLIT("cvtsi2sdq") from to #endif -- FETCHGOT for PIC on ELF platforms @@ -2163,6 +2162,19 @@ pprInstr (BCC cond (BlockId id)) = hcat [ ] where lbl = mkAsmTempLabel id +pprInstr (BCCFAR cond (BlockId id)) = vcat [ + hcat [ + ptext SLIT("\tb"), + pprCond (condNegate cond), + ptext SLIT("\t$+8") + ], + hcat [ + ptext SLIT("\tb\t"), + pprCLabel_asm lbl + ] + ] + where lbl = mkAsmTempLabel id + pprInstr (JMP lbl) = hcat [ -- an alias for b that takes a CLabel char '\t', ptext SLIT("b"), @@ -2323,6 +2335,8 @@ pprInstr (FETCHPC reg) = vcat [ hcat [ ptext SLIT("1:\tmflr\t"), pprReg reg ] ] +pprInstr LWSYNC = ptext SLIT("\tlwsync") + pprInstr _ = panic "pprInstr (ppc)" pprLogic op reg1 reg2 ri = hcat [