Commit d60df824 authored by gmainlan@microsoft.com's avatar gmainlan@microsoft.com
Browse files

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.
parent 1ee495b6
......@@ -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 =
......
......@@ -385,6 +385,21 @@ $ cat foo.hspp</screen>
</listitem>
</varlistentry>
<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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment