Merge in new code generator branch.
[ghc-hetmet.git] / compiler / llvmGen / LlvmCodeGen / Base.hs
index 83469c8..80d88e6 100644 (file)
@@ -25,14 +25,14 @@ module LlvmCodeGen.Base (
 import Llvm
 import LlvmCodeGen.Regs
 
-import CgUtils ( activeStgRegs )
 import CLabel
-import Cmm
-
+import CgUtils ( activeStgRegs )
+import Constants
 import FastString
+import OldCmm
 import qualified Outputable as Outp
-import Unique
 import UniqFM
+import Unique
 
 -- ----------------------------------------------------------------------------
 -- * Some Data Types
@@ -42,7 +42,7 @@ type LlvmCmmTop = GenCmmTop LlvmData [CmmStatic] (ListGraph LlvmStatement)
 type LlvmBasicBlock = GenBasicBlock LlvmStatement
 
 -- | Unresolved code.
--- Of the form: (data label, data type, unresovled data)
+-- Of the form: (data label, data type, unresolved data)
 type LlvmUnresData = (CLabel, Section, LlvmType, [UnresStatic])
 
 -- | Top level LLVM Data (globals and type aliases)
@@ -89,11 +89,15 @@ llvmFunSig :: CLabel -> LlvmLinkageType -> LlvmFunctionDecl
 llvmFunSig lbl link = llvmFunSig' (strCLabel_llvm lbl) link
 
 llvmFunSig' :: LMString -> LlvmLinkageType -> LlvmFunctionDecl
-llvmFunSig' lbl link = LlvmFunctionDecl lbl link llvmGhcCC LMVoid FixedArgs
-                        (tysToParams $ map getVarType llvmFunArgs) llvmFunAlign
+llvmFunSig' lbl link
+  = let toParams x | isPointer x = (x, [NoAlias, NoCapture])
+                   | otherwise   = (x, [])
+    in LlvmFunctionDecl lbl link llvmGhcCC LMVoid FixedArgs
+                        (map (toParams . getVarType) llvmFunArgs) llvmFunAlign
 
 -- | Create a Haskell function in LLVM.
-mkLlvmFunc :: CLabel -> LlvmLinkageType -> LMSection -> LlvmBlocks -> LlvmFunction
+mkLlvmFunc :: CLabel -> LlvmLinkageType -> LMSection -> LlvmBlocks
+           -> LlvmFunction
 mkLlvmFunc lbl link sec blks
   = let funDec = llvmFunSig lbl link
         funArgs = map (fsLit . getPlainName) llvmFunArgs
@@ -101,11 +105,11 @@ mkLlvmFunc lbl link sec blks
 
 -- | Alignment to use for functions
 llvmFunAlign :: LMAlign
-llvmFunAlign = Just 4
+llvmFunAlign = Just wORD_SIZE
 
 -- | Alignment to use for into tables
 llvmInfAlign :: LMAlign
-llvmInfAlign = Just 4
+llvmInfAlign = Just wORD_SIZE
 
 -- | A Function's arguments
 llvmFunArgs :: [LlvmVar]