[commit: ghc] master: Remove unneeded compatibility with LLVM < 3.6 (578d2ba)

git at git.haskell.org git at git.haskell.org
Tue May 19 06:26:41 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/578d2bad19b3e03fac4da1e5be4b22b73cef0a44/ghc

>---------------------------------------------------------------

commit 578d2bad19b3e03fac4da1e5be4b22b73cef0a44
Author: Michal Terepeta <michal.terepeta at gmail.com>
Date:   Tue May 19 01:23:03 2015 -0500

    Remove unneeded compatibility with LLVM < 3.6
    
    Since GHC requires at least LLVM 3.6, some of the special cases (for,
    e.g., LLVM 2.8 or 2.9) in the LLVM CodeGen can be simply removed.
    
    Reviewed By: rwbarton, austin
    
    Differential Revision: https://phabricator.haskell.org/D884
    
    GHC Trac Issues: #10074


>---------------------------------------------------------------

578d2bad19b3e03fac4da1e5be4b22b73cef0a44
 compiler/llvmGen/LlvmCodeGen/CodeGen.hs | 44 +++++++--------------------------
 1 file changed, 9 insertions(+), 35 deletions(-)

diff --git a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
index 3a7c05b..2c48c28 100644
--- a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
+++ b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
@@ -156,21 +156,6 @@ barrier = do
     let s = Fence False SyncSeqCst
     return (unitOL s, [])
 
--- | Memory barrier instruction for LLVM < 3.0
-oldBarrier :: LlvmM StmtData
-oldBarrier = do
-
-    (fv, _, tops) <- getInstrinct (fsLit "llvm.memory.barrier") LMVoid [i1, i1, i1, i1, i1]
-
-    let args = [lmTrue, lmTrue, lmTrue, lmTrue, lmTrue]
-    let s1 = Expr $ Call StdCall fv args llvmStdFunAttrs
-
-    return (unitOL s1, tops)
-
-    where
-        lmTrue :: LlvmVar
-        lmTrue  = mkIntLit i1 (-1)
-
 -- | Foreign Calls
 genCall :: ForeignTarget -> [CmmFormal] -> [CmmActual]
               -> LlvmM StmtData
@@ -179,12 +164,9 @@ genCall :: ForeignTarget -> [CmmFormal] -> [CmmActual]
 -- intrinsic function.
 genCall (PrimTarget MO_WriteBarrier) _ _ = do
     platform <- getLlvmPlatform
-    ver <- getLlvmVer
-    case () of
-     _ | platformArch platform `elem` [ArchX86, ArchX86_64, ArchSPARC]
-                    -> return (nilOL, [])
-       | ver > 29   -> barrier
-       | otherwise  -> oldBarrier
+    if platformArch platform `elem` [ArchX86, ArchX86_64, ArchSPARC]
+       then return (nilOL, [])
+       else barrier
 
 genCall (PrimTarget MO_Touch) _ _
  = return (nilOL, [])
@@ -206,9 +188,7 @@ genCall (PrimTarget (MO_UF_Conv _)) [_] args =
 -- Handle prefetching data
 genCall t@(PrimTarget (MO_Prefetch_Data localityInt)) [] args
   | 0 <= localityInt && localityInt <= 3 = do
-    ver <- getLlvmVer
-    let argTy | ver <= 29  = [i8Ptr, i32, i32]
-              | otherwise  = [i8Ptr, i32, i32, i32]
+    let argTy = [i8Ptr, i32, i32, i32]
         funTy = \name -> LMFunction $ LlvmFunctionDecl name ExternallyVisible
                              CC_Ccc LMVoid FixedArgs (tysToParams argTy) Nothing
 
@@ -219,8 +199,7 @@ genCall t@(PrimTarget (MO_Prefetch_Data localityInt)) [] args
     (argVars', stmts3)      <- castVars $ zip argVars argTy
 
     trash <- getTrashStmts
-    let argSuffix | ver <= 29  = [mkIntLit i32 0, mkIntLit i32 localityInt]
-                  | otherwise  = [mkIntLit i32 0, mkIntLit i32 localityInt, mkIntLit i32 1]
+    let argSuffix = [mkIntLit i32 0, mkIntLit i32 localityInt, mkIntLit i32 1]
         call = Expr $ Call StdCall fptr (argVars' ++ argSuffix) []
         stmts = stmts1 `appOL` stmts2 `appOL` stmts3
                 `appOL` trash `snocOL` call
@@ -255,12 +234,10 @@ genCall t@(PrimTarget op) [] args'
  | op == MO_Memcpy ||
    op == MO_Memset ||
    op == MO_Memmove = do
-    ver <- getLlvmVer
     dflags <- getDynFlags
     let (args, alignVal) = splitAlignVal args'
-        (isVolTy, isVolVal)
-              | ver >= 28       = ([i1], [mkIntLit i1 0])
-              | otherwise       = ([], [])
+        isVolTy = [i1]
+        isVolVal = [mkIntLit i1 0]
         argTy | op == MO_Memset = [i8Ptr, i8,    llvmWord dflags, i32] ++ isVolTy
               | otherwise       = [i8Ptr, i8Ptr, llvmWord dflags, i32] ++ isVolTy
         funTy = \name -> LMFunction $ LlvmFunctionDecl name ExternallyVisible
@@ -516,12 +493,9 @@ castVar v t | getVarType v == t
 cmmPrimOpFunctions :: CallishMachOp -> LlvmM LMString
 cmmPrimOpFunctions mop = do
 
-  ver <- getLlvmVer
   dflags <- getDynFlags
-  let intrinTy1 = (if ver >= 28
-                       then "p0i8.p0i8." else "") ++ showSDoc dflags (ppr $ llvmWord dflags)
-      intrinTy2 = (if ver >= 28
-                       then "p0i8." else "") ++ showSDoc dflags (ppr $ llvmWord dflags)
+  let intrinTy1 = "p0i8.p0i8." ++ showSDoc dflags (ppr $ llvmWord dflags)
+      intrinTy2 = "p0i8." ++ showSDoc dflags (ppr $ llvmWord dflags)
       unsupported = panic ("cmmPrimOpFunctions: " ++ show mop
                         ++ " not supported here")
 



More information about the ghc-commits mailing list