X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FnativeGen%2FX86%2FPpr.hs;h=4c3454d43b9dcda4ab69b059e1081091585a9b2e;hp=5182f7c0b65ec4f8c8580dcd0e212ec90a05a433;hb=32f24ddfd9549010dd345733c6f46f67196cacf6;hpb=b1f453e16f0ce11a2ab18cc4c350bdcbd36299a6 diff --git a/compiler/nativeGen/X86/Ppr.hs b/compiler/nativeGen/X86/Ppr.hs index 5182f7c..4c3454d 100644 --- a/compiler/nativeGen/X86/Ppr.hs +++ b/compiler/nativeGen/X86/Ppr.hs @@ -56,19 +56,19 @@ pprNatCmmTop (CmmData section dats) = pprSectionHeader section $$ vcat (map pprData dats) -- special case for split markers: -pprNatCmmTop (CmmProc [] lbl (ListGraph [])) = pprLabel True lbl +pprNatCmmTop (CmmProc [] lbl (ListGraph [])) = pprLabel lbl pprNatCmmTop (CmmProc info lbl (ListGraph blocks)) = pprSectionHeader Text $$ (if null info then -- blocks guaranteed not null, so label needed - pprLabel True lbl + pprLabel lbl else #if HAVE_SUBSECTIONS_VIA_SYMBOLS pprCLabel_asm (mkDeadStripPreventer $ entryLblToInfoLbl lbl) <> char ':' $$ #endif vcat (map pprData info) $$ - pprLabel True (entryLblToInfoLbl lbl) + pprLabel (entryLblToInfoLbl lbl) ) $$ vcat (map pprBasicBlock blocks) -- above: Even the first block gets a label, because with branch-chain @@ -87,18 +87,27 @@ pprNatCmmTop (CmmProc info lbl (ListGraph blocks)) = <+> pprCLabel_asm (mkDeadStripPreventer $ entryLblToInfoLbl lbl) else empty #endif - $$ pprSizeDecl (if null info then lbl else entryLblToInfoLbl lbl) + $$ pprSizeDecl (if null info then lbl else entryLblToInfoLbl lbl) +-- | Output the ELF .size directive. +pprSizeDecl :: CLabel -> Doc +#if elf_OBJ_FORMAT +pprSizeDecl lbl = + ptext (sLit "\t.size") <+> pprCLabel_asm lbl + <> ptext (sLit ", .-") <> pprCLabel_asm lbl +#else +pprSizeDecl _ = empty +#endif pprBasicBlock :: NatBasicBlock Instr -> Doc pprBasicBlock (BasicBlock blockid instrs) = - pprCLabel_asm (mkAsmTempLabel (getUnique blockid)) <> char ':' $$ + pprLabel (mkAsmTempLabel (getUnique blockid)) $$ vcat (map pprInstr instrs) pprData :: CmmStatic -> Doc pprData (CmmAlign bytes) = pprAlign bytes -pprData (CmmDataLabel lbl) = pprLabel False lbl +pprData (CmmDataLabel lbl) = pprLabel lbl pprData (CmmString str) = pprASCII str #if darwin_TARGET_OS @@ -116,29 +125,19 @@ pprGloblDecl lbl (sLit ".globl ")) <> pprCLabel_asm lbl -pprTypeDecl :: Bool -> CLabel -> Doc +pprTypeAndSizeDecl :: CLabel -> Doc #if elf_OBJ_FORMAT -pprTypeDecl isCode lbl = - ptext (sLit "\t.type ") <> pprCLabel_asm lbl - <> ptext (sLit (if isCode then ", @function" else ", @object")) +pprTypeAndSizeDecl lbl + | not (externallyVisibleCLabel lbl) = empty + | otherwise = ptext (sLit ".type ") <> + pprCLabel_asm lbl <> ptext (sLit ", @object") #else -pprTypeDecl _ _ +pprTypeAndSizeDecl _ = empty #endif --- | Output the ELF .size directive. -pprSizeDecl :: CLabel -> Doc -#if elf_OBJ_FORMAT -pprSizeDecl lbl = - ptext (sLit "\t.size") <+> pprCLabel_asm lbl - <> ptext (sLit ", .-") <> pprCLabel_asm lbl -#else -pprSizeDecl _ = empty -#endif - -pprLabel :: Bool -> CLabel -> Doc -pprLabel isCode lbl = pprGloblDecl lbl $$ pprTypeDecl isCode lbl - $$ (pprCLabel_asm lbl <> char ':') +pprLabel :: CLabel -> Doc +pprLabel lbl = pprGloblDecl lbl $$ pprTypeAndSizeDecl lbl $$ (pprCLabel_asm lbl <> char ':') pprASCII :: [Word8] -> Doc @@ -637,7 +636,7 @@ pprInstr (JXX_GBL cond imm) = pprCondInstr (sLit "j") cond (pprImm imm) pprInstr (JMP (OpImm imm)) = (<>) (ptext (sLit "\tjmp ")) (pprImm imm) pprInstr (JMP op) = (<>) (ptext (sLit "\tjmp *")) (pprOperand archWordSize op) -pprInstr (JMP_TBL op _) = pprInstr (JMP op) +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)