[project @ 2004-08-13 13:04:50 by simonmar]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcForeign.lhs
index b5b08f3..d18fe5f 100644 (file)
@@ -17,7 +17,7 @@ module TcForeign
         , tcForeignExports
        ) where
 
-#include "config.h"
+#include "../includes/ghcconfig.h"
 #include "HsVersions.h"
 
 import HsSyn
@@ -27,7 +27,11 @@ import TcHsType              ( tcHsSigType, UserTypeCtxt(..) )
 import TcExpr          ( tcCheckSigma )                        
 
 import ErrUtils                ( Message )
-import Id              ( Id, mkLocalId, setIdLocalExported )
+import Id              ( Id, mkLocalId, mkExportedLocalId )
+#if alpha_TARGET_ARCH
+import PrimRep         ( getPrimRepSize, isFloatingRep )
+import Type            ( typePrimRep )
+#endif
 import OccName         ( mkForeignExportOcc )
 import Name            ( Name, NamedThing(..), mkExternalName )
 import TcType          ( Type, tcSplitFunTys, tcSplitTyConApp_maybe,
@@ -39,8 +43,9 @@ import TcType         ( Type, tcSplitFunTys, tcSplitTyConApp_maybe,
                          toDNType
                        )
 import ForeignCall     ( CExportSpec(..), CCallTarget(..), 
+                         CLabelString, isCLabelString,
                          isDynamicTarget, withDNTypes, DNKind(..), DNCallSpec(..) ) 
-import CStrings                ( CLabelString, isCLabelString )
+import MachOp          ( machRepByteWidth )
 import PrelNames       ( hasKey, ioTyConKey )
 import CmdLineOpts     ( dopt_HscLang, HscLang(..) )
 import Outputable
@@ -173,11 +178,11 @@ The check is needed for both via-C and native-code routes
 #include "nativeGen/NCG.h"
 #if alpha_TARGET_ARCH
 checkFEDArgs arg_tys
-  = check (integral_args <= 4) err
+  = check (integral_args <= 32) err
   where
-    integral_args = sum (map getPrimRepSize $
-                         filter (not . isFloatingRep) $
-                         map typePrimRep arg_tys)
+    integral_args = sum [ machRepByteWidth rep
+                       | (rep,hint) <- map typeMachRepRep arg_tys,
+                         hint /= FloatHint ]
     err = ptext SLIT("On Alpha, I can only handle 4 non-floating-point arguments to foreign export dynamic")
 #else
 checkFEDArgs arg_tys = returnM ()
@@ -220,7 +225,7 @@ tcFExport fo@(ForeignExport (L loc nm) hs_ty spec isDeprec) =
    let
         gnm  = mkExternalName uniq mod (mkForeignExportOcc (getOccName nm)) 
                              Nothing (srcSpanStart loc)
-       id   = setIdLocalExported (mkLocalId gnm sig_ty)
+       id   = mkExportedLocalId gnm sig_ty
        bind = L loc (VarBind id rhs)
    in
    returnM (bind, ForeignExport (L loc id) undefined spec isDeprec)