llvm-general 3.3.12.1 → 3.3.13.0
raw patch · 9 files changed
+109/−20 lines, 9 filesdep ~llvm-generaldep ~llvm-general-pure
Dependency ranges changed: llvm-general, llvm-general-pure
Files
- llvm-general.cabal +9/−6
- src/LLVM/General/Internal/FFI/PassManager.hs +6/−0
- src/LLVM/General/Internal/FFI/PassManagerC.cpp +19/−5
- src/LLVM/General/Internal/FFI/Threading.hs +17/−0
- src/LLVM/General/Internal/FFI/Transforms.hs +1/−0
- src/LLVM/General/Internal/PassManager.hs +16/−9
- src/LLVM/General/Internal/Threading.hs +33/−0
- src/LLVM/General/Threading.hs +7/−0
- src/LLVM/General/Transforms.hs +1/−0
llvm-general.cabal view
@@ -1,5 +1,5 @@ name: llvm-general-version: 3.3.12.1+version: 3.3.13.0 license: BSD3 license-file: LICENSE author: Benjamin S.Scarlet <fgthb0@greynode.net>@@ -16,7 +16,7 @@ handles almost all of the stateful complexities of using the LLVM API to build IR; and it supports moving IR not only from Haskell into LLVM C++ objects, but the other direction - from LLVM C++ into Haskell. .- For haddock, see <http://bscarlet.github.io/llvm-general/3.3.12.1/doc/html/llvm-general/index.html>.+ For haddock, see <http://bscarlet.github.io/llvm-general/3.3.13.0/doc/html/llvm-general/index.html>. extra-source-files: src/LLVM/General/Internal/FFI/Analysis.h src/LLVM/General/Internal/FFI/BinaryOperator.h@@ -40,7 +40,7 @@ type: git location: git://github.com/bscarlet/llvm-general.git branch: llvm-3.3- tag: v3.3.12.1+ tag: v3.3.13.0 flag shared-llvm description: link against llvm shared rather than static library@@ -64,7 +64,7 @@ parsec >= 3.1.3, array >= 0.4.0.0, setenv >= 0.1.0,- llvm-general-pure == 3.3.12.1+ llvm-general-pure == 3.3.13.0 extra-libraries: stdc++ hs-source-dirs: src extensions:@@ -90,6 +90,7 @@ LLVM.General.Target LLVM.General.Target.LibraryFunction LLVM.General.Target.Options+ LLVM.General.Threading LLVM.General.Transforms other-modules:@@ -128,6 +129,7 @@ LLVM.General.Internal.RMWOperation LLVM.General.Internal.String LLVM.General.Internal.Target+ LLVM.General.Internal.Threading LLVM.General.Internal.Type LLVM.General.Internal.Value LLVM.General.Internal.FFI.Analysis@@ -160,6 +162,7 @@ LLVM.General.Internal.FFI.RawOStream LLVM.General.Internal.FFI.SMDiagnostic LLVM.General.Internal.FFI.Target+ LLVM.General.Internal.FFI.Threading LLVM.General.Internal.FFI.Transforms LLVM.General.Internal.FFI.Type LLVM.General.Internal.FFI.User@@ -199,8 +202,8 @@ HUnit >= 1.2.4.2, test-framework-quickcheck2 >= 0.3.0.1, QuickCheck >= 2.5.1.1,- llvm-general == 3.3.12.1,- llvm-general-pure == 3.3.12.1,+ llvm-general == 3.3.13.0,+ llvm-general-pure == 3.3.13.0, containers >= 0.4.2.1, mtl >= 2.0.1.0 hs-source-dirs: test
src/LLVM/General/Internal/FFI/PassManager.hs view
@@ -129,3 +129,9 @@ foreign import ccall unsafe "LLVM_General_PassManagerBuilderSetLibraryInfo" passManagerBuilderSetLibraryInfo :: Ptr PassManagerBuilder -> Ptr TargetLibraryInfo -> IO ()++foreign import ccall unsafe "LLVM_General_PassManagerBuilderSetLoopVectorize" passManagerBuilderSetLoopVectorize ::+ Ptr PassManagerBuilder -> LLVMBool -> IO ()++foreign import ccall unsafe "LLVM_General_PassManagerBuilderSetSuperwordLevelParallelismVectorize" passManagerBuilderSetSuperwordLevelParallelismVectorize ::+ Ptr PassManagerBuilder -> LLVMBool -> IO ()
src/LLVM/General/Internal/FFI/PassManagerC.cpp view
@@ -240,12 +240,26 @@ void LLVM_General_PassManagerBuilderSetLibraryInfo(- LLVMPassManagerBuilderRef PMB,- LLVMTargetLibraryInfoRef l+ LLVMPassManagerBuilderRef PMB,+ LLVMTargetLibraryInfoRef l ) {- // The PassManager frees the TargetLibraryInfo when done,- // but we also free our ref, so give it a new copy.- unwrap(PMB)->LibraryInfo = new TargetLibraryInfo(*unwrap(l));+ // The PassManager frees the TargetLibraryInfo when done,+ // but we also free our ref, so give it a new copy.+ unwrap(PMB)->LibraryInfo = new TargetLibraryInfo(*unwrap(l));+}++void LLVM_General_PassManagerBuilderSetLoopVectorize(+ LLVMPassManagerBuilderRef PMB,+ LLVMBool runLoopVectorization+) {+ unwrap(PMB)->LoopVectorize = runLoopVectorization;+}++void LLVM_General_PassManagerBuilderSetSuperwordLevelParallelismVectorize(+ LLVMPassManagerBuilderRef PMB,+ LLVMBool runSLPVectorization+) {+ unwrap(PMB)->SLPVectorize = runSLPVectorization; } }
+ src/LLVM/General/Internal/FFI/Threading.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE+ ForeignFunctionInterface+ #-}+module LLVM.General.Internal.FFI.Threading where++import Foreign.C++import LLVM.General.Internal.FFI.LLVMCTypes++foreign import ccall unsafe "LLVMStartMultithreaded" startMultithreaded ::+ IO LLVMBool++foreign import ccall unsafe "LLVMStopMultithreaded" stopMultithreaded ::+ IO ()++foreign import ccall unsafe "LLVMIsMultithreaded" isMultithreaded ::+ IO LLVMBool
src/LLVM/General/Internal/FFI/Transforms.hs view
@@ -33,6 +33,7 @@ "OldScalarReplacementOfAggregates" -> "ScalarReplAggregates" "SimplifyControlFlowGraph" -> "CFGSimplification" "SparseConditionalConstantPropagation" -> "SCCP"+ "SuperwordLevelParallelismVectorize" -> "SLPVectorize" h -> h patchImpls = [ "AddressSanitizer",
src/LLVM/General/Internal/PassManager.hs view
@@ -55,8 +55,12 @@ sizeLevel :: Maybe Word, unitAtATime :: Maybe Bool, simplifyLibCalls :: Maybe Bool,+ loopVectorize :: Maybe Bool,+ superwordLevelParallelismVectorize :: Maybe Bool, useInlinerWithThreshold :: Maybe Word,- curatedTargetLibraryInfo :: Maybe TargetLibraryInfo+ dataLayout :: Maybe DataLayout,+ targetLibraryInfo :: Maybe TargetLibraryInfo,+ targetMachine :: Maybe TargetMachine } -- | Helper to make a curated 'PassSetSpec'@@ -65,8 +69,12 @@ sizeLevel = Nothing, unitAtATime = Nothing, simplifyLibCalls = Nothing,+ loopVectorize = Nothing,+ superwordLevelParallelismVectorize = Nothing, useInlinerWithThreshold = Nothing,- curatedTargetLibraryInfo = Nothing+ dataLayout = Nothing,+ targetLibraryInfo = Nothing,+ targetMachine = Nothing } -- | an empty 'PassSetSpec'@@ -83,6 +91,10 @@ createPassManager :: PassSetSpec -> IO (Ptr FFI.PassManager) createPassManager pss = flip runAnyContT return $ do pm <- liftIO $ FFI.createPassManager+ forM_ (dataLayout pss) $ \dl -> liftIO $ withFFIDataLayout dl $ FFI.addDataLayoutPass pm + forM_ (targetLibraryInfo pss) $ \(TargetLibraryInfo tli) -> do+ liftIO $ FFI.addTargetLibraryInfoPass pm tli+ forM_ (targetMachine pss) $ \(TargetMachine tm) -> liftIO $ FFI.addAnalysisPasses tm pm case pss of s@CuratedPassSetSpec {} -> liftIO $ do bracket FFI.passManagerBuilderCreate FFI.passManagerBuilderDispose $ \b -> do@@ -92,16 +104,11 @@ handleOption FFI.passManagerBuilderSetDisableUnitAtATime (liftM not . unitAtATime) handleOption FFI.passManagerBuilderSetDisableSimplifyLibCalls (liftM not . simplifyLibCalls) handleOption FFI.passManagerBuilderUseInlinerWithThreshold useInlinerWithThreshold- case (curatedTargetLibraryInfo s) of- (Just (TargetLibraryInfo tl)) -> FFI.passManagerBuilderSetLibraryInfo b tl- Nothing -> return ()+ handleOption FFI.passManagerBuilderSetLoopVectorize loopVectorize+ handleOption FFI.passManagerBuilderSetSuperwordLevelParallelismVectorize superwordLevelParallelismVectorize FFI.passManagerBuilderPopulateModulePassManager b pm PassSetSpec ps dl tli tm' -> do tl <- liftIO $ maybe (return nullPtr) (\(TargetMachine tm) -> FFI.getTargetLowering tm) tm'- forM_ tli $ \(TargetLibraryInfo tli) -> do- liftIO $ FFI.addTargetLibraryInfoPass pm tli- forM_ dl $ \dl -> liftIO $ withFFIDataLayout dl $ FFI.addDataLayoutPass pm - forM_ tm' $ \(TargetMachine tm) -> liftIO $ FFI.addAnalysisPasses tm pm forM_ ps $ \p -> $( do TH.TyConI (TH.DataD _ _ _ cons _) <- TH.reify ''Pass
+ src/LLVM/General/Internal/Threading.hs view
@@ -0,0 +1,33 @@+module LLVM.General.Internal.Threading (+ setMultithreaded,+ isMultithreaded+ ) where++import Control.Concurrent.MVar+import System.IO.Unsafe+import Control.Monad++import qualified LLVM.General.Internal.FFI.Threading as FFI++import LLVM.General.Internal.Coding++lock :: MVar ()+{-# NOINLINE lock #-}+lock = unsafePerformIO $ newMVar ()++-- | Set the multithreading mode of LLVM. If it is disabled (as by default) locks are not enforced.+setMultithreaded :: Bool -> IO ()+setMultithreaded s = do+ takeMVar lock+ multi <- isMultithreaded+ case (s,multi) of+ (True,False) -> do+ success <- decodeM =<< FFI.startMultithreaded+ when (not success) $ error "setMultithreaded: LLVM not built with threading support"+ (False,True) -> FFI.stopMultithreaded+ _ -> return ()+ putMVar lock ()++-- | Check if multithreading is enabled in LLVM+isMultithreaded :: IO Bool+isMultithreaded = FFI.isMultithreaded >>= decodeM
+ src/LLVM/General/Threading.hs view
@@ -0,0 +1,7 @@+-- | functionality necessary when running LLVM in multiple threads at the same time.+module LLVM.General.Threading (+ setMultithreaded,+ isMultithreaded+ ) where++import LLVM.General.Internal.Threading
src/LLVM/General/Transforms.hs view
@@ -106,6 +106,7 @@ fastDependencyAnalysis :: Bool } | LoopVectorize+ | SuperwordLevelParallelismVectorize -- here begin the instrumentation passes | EdgeProfiler