[commit: ghc] master: Define __GLASGOW_HASKELL_LLVM__ when using the LLVM back end. (d60df82)
Geoffrey Mainland
gmainlan at microsoft.com
Fri Feb 1 23:02:09 CET 2013
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/d60df8246c208ba37da20a97c974d9318d8ec02b
>---------------------------------------------------------------
commit d60df8246c208ba37da20a97c974d9318d8ec02b
Author: Geoffrey Mainland <gmainlan at microsoft.com>
Date: Wed Jun 20 11:36:27 2012 +0100
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.
>---------------------------------------------------------------
compiler/main/DriverPipeline.hs | 11 +++++++++++
docs/users_guide/phases.xml | 15 +++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 367e109..62ff424 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 d7ad995..f4019bd 100644
--- a/docs/users_guide/phases.xml
+++ b/docs/users_guide/phases.xml
@@ -387,6 +387,21 @@ $ cat foo.hspp</screen>
<varlistentry>
<term>
+ <constant>__GLASGOW_HASKELL_LLVM__</constant>
+ <indexterm><primary><constant>__GLASGOW_HASKELL_LLVM__</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>__GLASGOW_HASKELL_LLVM__</constant>
+ is the integer <replaceable>xy</replaceable>.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
<constant>__PARALLEL_HASKELL__</constant>
<indexterm><primary><constant>__PARALLEL_HASKELL__</constant></primary></indexterm>
</term>
More information about the ghc-commits
mailing list