diff options
author | Geoffrey Mainland <mainland@apeiron.net> | 2012-11-15 10:16:29 +0000 |
---|---|---|
committer | Geoffrey Mainland <gmainlan@microsoft.com> | 2013-02-01 22:00:24 +0000 |
commit | cc56f34e71201e27e4e15af01a5a6258648d6a32 (patch) | |
tree | ed74568b892c8bf7466387424b4882e7379b68b0 /compiler/llvmGen/LlvmCodeGen/CodeGen.hs | |
parent | 089ac7171bee938bd52975d2f828cf0dd6b4b25b (diff) | |
download | haskell-cc56f34e71201e27e4e15af01a5a6258648d6a32.tar.gz |
Add prefetch primops.
Diffstat (limited to 'compiler/llvmGen/LlvmCodeGen/CodeGen.hs')
-rw-r--r-- | compiler/llvmGen/LlvmCodeGen/CodeGen.hs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs index 969bca8ec0..609be3d3b0 100644 --- a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs +++ b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs @@ -201,6 +201,25 @@ genCall _ (PrimTarget (MO_UF_Conv _)) [_] args = panic $ "genCall: Too many arguments to MO_UF_Conv. " ++ "Can only handle 1, given" ++ show (length args) ++ "." +-- Handle prefetching data +genCall env t@(PrimTarget MO_Prefetch_Data) [] args = do + let dflags = getDflags env + argTy = [i8Ptr, i32, i32, i32] + funTy = \name -> LMFunction $ LlvmFunctionDecl name ExternallyVisible + CC_Ccc LMVoid FixedArgs (tysToParams argTy) Nothing + + let (_, arg_hints) = foreignTargetHints t + let args_hints' = zip args arg_hints + (env1, argVars, stmts1, top1) <- arg_vars env args_hints' ([], nilOL, []) + (env2, fptr, stmts2, top2) <- getFunPtr env1 funTy t + (argVars', stmts3) <- castVars dflags $ zip argVars argTy + + let arguments = argVars' ++ [mkIntLit i32 0, mkIntLit i32 3, mkIntLit i32 1] + call = Expr $ Call StdCall fptr arguments [] + stmts = stmts1 `appOL` stmts2 `appOL` stmts3 + `appOL` trashStmts (getDflags env) `snocOL` call + return (env2, stmts, top1 ++ top2) + -- Handle popcnt function specifically since GHC only really has i32 and i64 -- types and things like Word8 are backed by an i32 and just present a logical -- i8 range. So we must handle conversions from i32 to i8 explicitly as LLVM @@ -521,6 +540,8 @@ cmmPrimOpFunctions env mop (MO_PopCnt w) -> fsLit $ "llvm.ctpop." ++ show (widthToLlvmInt w) + MO_Prefetch_Data -> fsLit "llvm.prefetch" + MO_S_QuotRem {} -> unsupported MO_U_QuotRem {} -> unsupported MO_U_QuotRem2 {} -> unsupported |