module AsmCodeGen ( nativeCodeGen ) where
#include "HsVersions.h"
-#include "NCG.h"
+#include "nativeGen/NCG.h"
import MachInstrs
import MachRegs
import ErrUtils ( dumpIfSet_dyn )
import DynFlags ( DynFlags, DynFlag(..), dopt )
import StaticFlags ( opt_Static, opt_PIC )
+import Config ( cProjectVersion )
import Digraph
import qualified Pretty
import List ( intersperse )
#endif
-import DATA_INT
-import DATA_WORD
-import DATA_BITS
-import GLAEXTS
+import Data.Int
+import Data.Word
+import Data.Bits
+import GHC.Exts
{-
The native-code generator has machine-independent and
-- stack so add the note in:
Pretty.$$ Pretty.text ".section .note.GNU-stack,\"\",@progbits"
#endif
+#if !defined(darwin_TARGET_OS)
+ -- And just because every other compiler does, lets stick in
+ -- an identifier directive: .ident "GHC x.y.z"
+ Pretty.$$ let compilerIdent = Pretty.text "GHC" Pretty.<+>
+ Pretty.text cProjectVersion
+ in Pretty.text ".ident" Pretty.<+>
+ Pretty.doubleQuotes compilerIdent
+#endif
)
}
genMachCode :: CmmTop -> UniqSM ([NatCmmTop], [CLabel])
-genMachCode cmm_top initial_us
- = let initial_st = mkNatM_State initial_us 0
- (new_tops, final_st) = initNat initial_st (cmmTopCodeGen cmm_top)
- final_us = natm_us final_st
- final_delta = natm_delta final_st
- final_imports = natm_imports final_st
- in
- if final_delta == 0
- then ((new_tops, final_imports), final_us)
- else pprPanic "genMachCode: nonzero final delta"
- (int final_delta)
+genMachCode cmm_top
+ = do { initial_us <- getUs
+ ; let initial_st = mkNatM_State initial_us 0
+ (new_tops, final_st) = initNat initial_st (cmmTopCodeGen cmm_top)
+ final_us = natm_us final_st
+ final_delta = natm_delta final_st
+ final_imports = natm_imports final_st
+ ; if final_delta == 0
+ then return (new_tops, final_imports)
+ else pprPanic "genMachCode: nonzero final delta" (int final_delta)
+ }
-- -----------------------------------------------------------------------------
-- Fixup assignments to global registers so that they assign to