summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Mainland <gmainlan@microsoft.com>2012-06-20 11:36:27 +0100
committerGeoffrey Mainland <gmainlan@microsoft.com>2013-02-01 22:00:23 +0000
commitd60df8246c208ba37da20a97c974d9318d8ec02b (patch)
tree46cf1b543f6fc73f45e7344be4deeaa130b4859f
parent1ee495b61fffcfa70495a539635c325a0ab5ddf7 (diff)
downloadhaskell-d60df8246c208ba37da20a97c974d9318d8ec02b.tar.gz
Define __GLASGOW_HASKELL_LLVM__ when using the LLVM back end.
When compiling via LLVM, GHC now defines the CPP symbol __GLASGOW_HASKELL_LLVM__ to the version of LLVM used, e.g., __GLASGOW_HASKELL_LLVM__ is defined to be 30 for LLVM version 3.0.
-rw-r--r--compiler/main/DriverPipeline.hs11
-rw-r--r--docs/users_guide/phases.xml15
2 files changed, 26 insertions, 0 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 367e109880..62ff424bb6 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -2013,10 +2013,13 @@ doCpp dflags raw include_cc_opts input_fn output_fn = do
[ "-D__SSE2__=1" | sse2 || sse4_2 ] ++
[ "-D__SSE4_2__=1" | sse4_2 ]
+ backend_defs <- getBackendDefs dflags
+
cpp_prog ( map SysTools.Option verbFlags
++ map SysTools.Option include_paths
++ map SysTools.Option hsSourceCppOpts
++ map SysTools.Option target_defs
+ ++ map SysTools.Option backend_defs
++ map SysTools.Option hscpp_opts
++ map SysTools.Option cc_opts
++ map SysTools.Option sse_defs
@@ -2035,6 +2038,14 @@ doCpp dflags raw include_cc_opts input_fn output_fn = do
, SysTools.FileOption "" output_fn
])
+getBackendDefs :: DynFlags -> IO [String]
+getBackendDefs dflags | hscTarget dflags == HscLlvm = do
+ llvmVer <- figureLlvmVersion dflags
+ return [ "-D__GLASGOW_HASKELL_LLVM__="++show llvmVer ]
+
+getBackendDefs _ =
+ return []
+
hsSourceCppOpts :: [String]
-- Default CPP defines in Haskell source
hsSourceCppOpts =
diff --git a/docs/users_guide/phases.xml b/docs/users_guide/phases.xml
index d7ad9955d3..f4019bd8cd 100644
--- a/docs/users_guide/phases.xml
+++ b/docs/users_guide/phases.xml
@@ -387,6 +387,21 @@ $ cat foo.hspp</screen>
<varlistentry>
<term>
+ <constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;LLVM&lowbar;&lowbar;</constant>
+ <indexterm><primary><constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;LLVM&lowbar;&lowbar;</constant></primary></indexterm>
+ </term>
+ <listitem>
+ <para>Only defined when <option>-fllvm</option> is specified. When GHC
+ is using version
+ <literal><replaceable>x</replaceable>.<replaceable>y</replaceable>.<replaceable>z</replaceable></literal>
+ of LLVM, the value of
+ <constant>&lowbar;&lowbar;GLASGOW&lowbar;HASKELL&lowbar;LLVM&lowbar;&lowbar;</constant>
+ is the integer <replaceable>xy</replaceable>.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
<constant>&lowbar;&lowbar;PARALLEL&lowbar;HASKELL&lowbar;&lowbar;</constant>
<indexterm><primary><constant>&lowbar;&lowbar;PARALLEL&lowbar;HASKELL&lowbar;&lowbar;</constant></primary></indexterm>
</term>