Add a couple more mkDerivedConstants modes
authorIan Lynagh <ian@well-typed.com>
Thu, 13 Sep 2012 17:00:39 +0000 (18:00 +0100)
committerIan Lynagh <ian@well-typed.com>
Thu, 13 Sep 2012 17:17:23 +0000 (18:17 +0100)
We now also generate nice wrappers for the platformConstants
methods. For now it's all commented out as the definitions
conflict with those in Constants.

compiler/ghc.mk
compiler/main/DynFlags.hs
includes/ghc.mk
includes/mkDerivedConstants.c

index fee9d38..f65813d 100644 (file)
@@ -465,6 +465,8 @@ COMPILER_INCLUDES_DEPS += $(includes_H_CONFIG)
 COMPILER_INCLUDES_DEPS += $(includes_H_PLATFORM)
 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS)
 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_TYPE)
+COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
+COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
 COMPILER_INCLUDES_DEPS += $(includes_DERIVEDCONSTANTS)
 COMPILER_INCLUDES_DEPS += $(PRIMOP_BITS)
 
index 3d94cd7..15ef065 100644 (file)
@@ -116,6 +116,8 @@ module DynFlags (
 #endif
         -- ** Only for use in the tracing functions in Outputable
         tracingDynFlags,
+
+#include "../includes/dist-derivedconstants/header/GHCConstantsHaskellExports.hs"
   ) where
 
 #include "HsVersions.h"
@@ -3141,4 +3143,5 @@ compilerInfo dflags
       ]
 
 #include "../includes/dist-derivedconstants/header/GHCConstantsHaskellType.hs"
+#include "../includes/dist-derivedconstants/header/GHCConstantsHaskellWrappers.hs"
 
index ac11ee3..c34fd47 100644 (file)
@@ -134,6 +134,8 @@ includes_DERIVEDCONSTANTS = includes/dist-derivedconstants/header/DerivedConstan
 includes_GHCCONSTANTS = includes/dist-derivedconstants/header/GHCConstants.h
 includes_GHCCONSTANTS_HASKELL_TYPE = includes/dist-derivedconstants/header/GHCConstantsHaskellType.hs
 includes_GHCCONSTANTS_HASKELL_VALUE = includes/dist-derivedconstants/header/platformConstants
+includes_GHCCONSTANTS_HASKELL_WRAPPERS = includes/dist-derivedconstants/header/GHCConstantsHaskellWrappers.hs
+includes_GHCCONSTANTS_HASKELL_EXPORTS = includes/dist-derivedconstants/header/GHCConstantsHaskellExports.hs
 
 INSTALL_LIBS += includes/dist-derivedconstants/header/platformConstants
 
@@ -190,6 +192,20 @@ ifeq "$(AlienScript)" ""
 else
        $(AlienScript) run ./$< --gen-haskell-value >$@
 endif
+
+$(includes_GHCCONSTANTS_HASKELL_WRAPPERS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
+ifeq "$(AlienScript)" ""
+       ./$< --gen-haskell-wrappers >$@
+else
+       $(AlienScript) run ./$< --gen-haskell-wrappers >$@
+endif
+
+$(includes_GHCCONSTANTS_HASKELL_EXPORTS) : $(INPLACE_BIN)/mkDerivedConstants$(exeext) | $$(dir $$@)/.
+ifeq "$(AlienScript)" ""
+       ./$< --gen-haskell-exports >$@
+else
+       $(AlienScript) run ./$< --gen-haskell-exports >$@
+endif
 endif
 
 endif
index b9f4147..6bfd87a 100644 (file)
@@ -29,7 +29,7 @@
 #include <stdio.h>
 #include <string.h>
 
-enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
+enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappers, Gen_Haskell_Exports, Gen_Header } mode;
 
 #define str(a,b) #a "_" #b
 
@@ -51,6 +51,13 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell_Value:                                                 \
         printf("    , pc_OFFSET_" str " = %" FMT_SizeT "\n", (size_t)offset); \
         break;                                                              \
+    case Gen_Haskell_Wrappers:                                              \
+        printf("-- oFFSET_" str " :: DynFlags -> Int\n");                      \
+        printf("-- oFFSET_" str " dflags = pc_OFFSET_" str " (sPlatformConstants (settings dflags))\n"); \
+        break;                                                              \
+    case Gen_Haskell_Exports:                                               \
+        printf("--     oFFSET_" str ",\n");                                    \
+        break;                                                              \
     case Gen_Header:                                                        \
         printf("#define OFFSET_" str " %" FMT_SizeT "\n", (size_t)offset);  \
         break;                                                              \
@@ -61,6 +68,8 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell:                                                       \
     case Gen_Haskell_Type:                                                  \
     case Gen_Haskell_Value:                                                 \
+    case Gen_Haskell_Wrappers:                                              \
+    case Gen_Haskell_Exports:                                               \
         break;                                                              \
     case Gen_Header:                                                        \
         printf("#define SIZEOF_" #type " %" FMT_SizeT "\n",                 \
@@ -79,6 +88,8 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell:                                                       \
     case Gen_Haskell_Type:                                                  \
     case Gen_Haskell_Value:                                                 \
+    case Gen_Haskell_Wrappers:                                              \
+    case Gen_Haskell_Exports:                                               \
         break;                                                              \
     case Gen_Header:                                                        \
         printf("#define REP_" str " b");                                    \
@@ -91,6 +102,8 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell:                                                       \
     case Gen_Haskell_Type:                                                  \
     case Gen_Haskell_Value:                                                 \
+    case Gen_Haskell_Wrappers:                                              \
+    case Gen_Haskell_Exports:                                               \
         break;                                                              \
     case Gen_Header:                                                        \
         printf("#define REP_" str " gcptr\n");                              \
@@ -112,6 +125,8 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell:                                                       \
     case Gen_Haskell_Type:                                                  \
     case Gen_Haskell_Value:                                                 \
+    case Gen_Haskell_Wrappers:                                              \
+    case Gen_Haskell_Exports:                                               \
         break;                                                              \
     case Gen_Header:                                                        \
         printf("#define " str "(__ptr__)  REP_" str "[__ptr__+OFFSET_" str "]\n"); \
@@ -141,6 +156,13 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell_Value:                                                 \
         printf("    , pc_SIZEOF_" str " = %" FMT_SizeT "\n", (size_t)size); \
         break;                                                              \
+    case Gen_Haskell_Wrappers:                                              \
+        printf("-- sIZEOF_" str " :: DynFlags -> Int\n");                      \
+        printf("-- sIZEOF_" str " dflags = pc_SIZEOF_" str " (sPlatformConstants (settings dflags))\n"); \
+        break;                                                              \
+    case Gen_Haskell_Exports:                                               \
+        printf("--     sIZEOF_" str ",\n");                                    \
+        break;                                                              \
     case Gen_Header:                                                        \
         printf("#define SIZEOF_" str " %" FMT_SizeT "\n", (size_t)size);    \
         break;                                                              \
@@ -151,6 +173,8 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell:                                                       \
     case Gen_Haskell_Type:                                                  \
     case Gen_Haskell_Value:                                                 \
+    case Gen_Haskell_Wrappers:                                              \
+    case Gen_Haskell_Exports:                                               \
         break;                                                              \
     case Gen_Header:                                                        \
         printf("#define SIZEOF_" str " (SIZEOF_StgHeader+%" FMT_SizeT ")\n", (size_t)size); \
@@ -178,6 +202,8 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell:                                                       \
     case Gen_Haskell_Type:                                                  \
     case Gen_Haskell_Value:                                                 \
+    case Gen_Haskell_Wrappers:                                              \
+    case Gen_Haskell_Exports:                                               \
         break;                                                              \
     case Gen_Header:                                                        \
         printf("#define " str "(__ptr__)  REP_" str "[__ptr__+SIZEOF_StgHeader+OFFSET_" str "]\n"); \
@@ -195,6 +221,8 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell:                                                       \
     case Gen_Haskell_Type:                                                  \
     case Gen_Haskell_Value:                                                 \
+    case Gen_Haskell_Wrappers:                                              \
+    case Gen_Haskell_Exports:                                               \
         break;                                                              \
     case Gen_Header:                                                        \
         printf("#define " str "(__ptr__,__ix__)  W_[__ptr__+SIZEOF_StgHeader+OFFSET_" str " + WDS(__ix__)]\n"); \
@@ -233,6 +261,8 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell:                                                       \
     case Gen_Haskell_Type:                                                  \
     case Gen_Haskell_Value:                                                 \
+    case Gen_Haskell_Wrappers:                                              \
+    case Gen_Haskell_Exports:                                               \
         break;                                                              \
     case Gen_Header:                                                        \
         printf("#define TSO_OFFSET_" str " (SIZEOF_StgHeader+SIZEOF_OPT_StgTSOProfInfo+OFFSET_" str ")\n"); \
@@ -248,6 +278,8 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell:                                                       \
     case Gen_Haskell_Type:                                                  \
     case Gen_Haskell_Value:                                                 \
+    case Gen_Haskell_Wrappers:                                              \
+    case Gen_Haskell_Exports:                                               \
         break;                                                              \
     case Gen_Header:                                                        \
     printf("#define " str "(__ptr__)  REP_" str "[__ptr__+TSO_OFFSET_" str "]\n") \
@@ -264,6 +296,8 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Header } mode;
     case Gen_Haskell:                                                       \
     case Gen_Haskell_Type:                                                  \
     case Gen_Haskell_Value:                                                 \
+    case Gen_Haskell_Wrappers:                                              \
+    case Gen_Haskell_Exports:                                               \
         break;                                                              \
     case Gen_Header:                                                        \
         printf("#ifdef " #option "\n");                                                            \
@@ -293,6 +327,12 @@ main(int argc, char *argv[])
         else if (0 == strcmp("--gen-haskell-value", argv[1])) {
             mode = Gen_Haskell_Value;
         }
+        else if (0 == strcmp("--gen-haskell-wrappers", argv[1])) {
+            mode = Gen_Haskell_Wrappers;
+        }
+        else if (0 == strcmp("--gen-haskell-exports", argv[1])) {
+            mode = Gen_Haskell_Exports;
+        }
         else {
             printf("Bad args\n");
             exit(1);
@@ -316,6 +356,9 @@ main(int argc, char *argv[])
         printf("PlatformConstants {\n");
         printf("    pc_platformConstants = ()\n");
         break;
+    case Gen_Haskell_Wrappers:
+    case Gen_Haskell_Exports:
+        break;
     case Gen_Header:
         printf("/* This file is created automatically.  Do not edit by hand.*/\n\n");
 
@@ -590,6 +633,8 @@ main(int argc, char *argv[])
     case Gen_Haskell_Value:
         printf("  }\n");
         break;
+    case Gen_Haskell_Wrappers:
+    case Gen_Haskell_Exports:
     case Gen_Header:
         break;
     }