Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : simd
http://hackage.haskell.org/trac/ghc/changeset/b331645af0adc6232c0ad397d0591d15873e9dc6 >--------------------------------------------------------------- commit b331645af0adc6232c0ad397d0591d15873e9dc6 Author: Geoffrey Mainland <[email protected]> Date: Wed Nov 2 13:59:54 2011 +0000 Add support for the LLVM insertelement and extractelement instructions. >--------------------------------------------------------------- compiler/llvmGen/Llvm/AbsSyn.hs | 15 +++++++++++++++ compiler/llvmGen/Llvm/PpLlvm.hs | 17 ++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletions(-) diff --git a/compiler/llvmGen/Llvm/AbsSyn.hs b/compiler/llvmGen/Llvm/AbsSyn.hs index 93bc62c..3074044 100644 --- a/compiler/llvmGen/Llvm/AbsSyn.hs +++ b/compiler/llvmGen/Llvm/AbsSyn.hs @@ -167,6 +167,21 @@ data LlvmExpression | Compare LlvmCmpOp LlvmVar LlvmVar {- | + Extract a scalar element from a vector + * val: The vector + * idx: The index of the scalar within the vector + -} + | Extract LlvmVar Int + + {- | + Insert a scalar element into a vector + * val: The source vector + * elt: The scalar to insert + * index: The index at which to insert the scalar + -} + | Insert LlvmVar LlvmVar Int + + {- | Allocate amount * sizeof(tp) bytes on the heap * tp: LlvmType to reserve room for * amount: The nr of tp's which must be allocated diff --git a/compiler/llvmGen/Llvm/PpLlvm.hs b/compiler/llvmGen/Llvm/PpLlvm.hs index f62d7bd..c98629c 100644 --- a/compiler/llvmGen/Llvm/PpLlvm.hs +++ b/compiler/llvmGen/Llvm/PpLlvm.hs @@ -192,6 +192,8 @@ ppLlvmExpression expr Malloc tp amount -> ppMalloc tp amount Phi tp precessors -> ppPhi tp precessors Asm asm c ty v se sk -> ppAsm asm c ty v se sk + Extract vec idx -> ppExtract vec idx + Insert vec elt idx -> ppInsert vec elt idx -------------------------------------------------------------------------------- @@ -254,7 +256,6 @@ ppCmpOp op left right = ppAssignment :: LlvmVar -> Doc -> Doc ppAssignment var expr = (text $ getName var) <+> equals <+> expr - -- XXX: On x86, vector types need to be 16-byte aligned for aligned access, but -- we have no way of guaranteeing that this is true with GHC (we would need to -- modify the layout of the stack and closures, change the storage manager, @@ -344,6 +345,20 @@ ppAsm asm constraints rty vars sideeffect alignstack = in text "call" <+> rty' <+> text "asm" <+> side <+> align <+> asm' <> comma <+> cons <> vars' +ppExtract :: LlvmVar -> Int -> Doc +ppExtract vec idx = + let idx' = LMLitVar $ LMIntLit (toInteger idx) i32 + in text "extractelement" + <+> (texts (getVarType vec)) <+> (text $ getName vec) <> comma + <+> (texts idx') + +ppInsert :: LlvmVar -> LlvmVar -> Int -> Doc +ppInsert vec elt idx = + let idx' = LMLitVar $ LMIntLit (toInteger idx) i32 + in text "insertelement" + <+> (texts (getVarType vec)) <+> (text $ getName vec) <> comma + <+> (texts (getVarType elt)) <+> (text $ getName elt) <> comma + <+> (texts idx') -------------------------------------------------------------------------------- -- * Misc functions _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
