summaryrefslogtreecommitdiff
path: root/utils/genprimopcode/Parser.y
diff options
context:
space:
mode:
authorGeoffrey Mainland <gmainlan@microsoft.com>2013-08-21 16:18:24 +0100
committerGeoffrey Mainland <gmainlan@microsoft.com>2013-09-22 22:33:59 -0400
commit16b350a4227c96e09533c6f165895f50003d3801 (patch)
treef2fbf6f0f4b5ea2a406cd6a078fc1cb7cce31ad5 /utils/genprimopcode/Parser.y
parentda5a647c0c49fee7531ef4c076b1c9e6a9d0fe6d (diff)
downloadhaskell-16b350a4227c96e09533c6f165895f50003d3801.tar.gz
SIMD primops are now generated using schemas that are polymorphic in
width and element type. SIMD primops are now polymorphic in vector size and element type, but only internally to the compiler. More specifically, utils/genprimopcode has been extended so that it "knows" about SIMD vectors. This allows us to, for example, write a single definition for the "add two vectors" primop in primops.txt.pp and have it instantiated at many vector types. This generates a primop in GHC.Prim for each vector type at which "add two vectors" is instantiated, but only one data constructor for the PrimOp data type, so the code generator is much, much simpler.
Diffstat (limited to 'utils/genprimopcode/Parser.y')
-rw-r--r--utils/genprimopcode/Parser.y29
1 files changed, 26 insertions, 3 deletions
diff --git a/utils/genprimopcode/Parser.y b/utils/genprimopcode/Parser.y
index eb76cb0407..07ef03b986 100644
--- a/utils/genprimopcode/Parser.y
+++ b/utils/genprimopcode/Parser.y
@@ -32,6 +32,10 @@ import Syntax
'#)' { THashCloseParen }
'{' { TOpenBrace }
'}' { TCloseBrace }
+ '[' { TOpenBracket }
+ ']' { TCloseBracket }
+ '<' { TOpenAngle }
+ '>' { TCloseAngle }
section { TSection }
primop { TPrimop }
pseudoop { TPseudoop }
@@ -50,6 +54,10 @@ import Syntax
infixl { TInfixL }
infixr { TInfixR }
nothing { TNothing }
+ vector { TVector }
+ SCALAR { TSCALAR }
+ VECTOR { TVECTOR }
+ VECTUPLE { TVECTUPLE }
thats_all_folks { TThatsAllFolks }
lowerName { TLowerName $$ }
upperName { TUpperName $$ }
@@ -74,6 +82,7 @@ pOption : lowerName '=' false { OptionFalse $1 }
| lowerName '=' true { OptionTrue $1 }
| lowerName '=' pStuffBetweenBraces { OptionString $1 $3 }
| lowerName '=' integer { OptionInteger $1 $3 }
+ | vector '=' pVectorTemplate { OptionVector $3 }
| fixity '=' pInfix { OptionFixity $3 }
pInfix :: { Maybe Fixity }
@@ -147,6 +156,17 @@ pInside :: { String }
pInside : '{' pInsides '}' { "{" ++ $2 ++ "}" }
| noBraces { $1 }
+pVectorTemplate :: { [(String, String, Int)] }
+pVectorTemplate : '[' pVectors ']' { $2 }
+
+pVectors :: { [(String, String, Int)] }
+pVectors : pVector ',' pVectors { [$1] ++ $3 }
+ | pVector { [$1] }
+ | {- empty -} { [] }
+
+pVector :: { (String, String, Int) }
+pVector : '<' upperName ',' upperName ',' integer '>' { ($2, $4, $6) }
+
pType :: { Ty }
pType : paT '->' pType { TyF $1 $3 }
| paT '=>' pType { TyC $1 $3 }
@@ -175,9 +195,12 @@ ppT :: { Ty }
ppT : lowerName { TyVar $1 }
| pTycon { TyApp $1 [] }
-pTycon :: { String }
-pTycon : upperName { $1 }
- | '(' ')' { "()" }
+pTycon :: { TyCon }
+pTycon : upperName { TyCon $1 }
+ | '(' ')' { TyCon "()" }
+ | SCALAR { SCALAR }
+ | VECTOR { VECTOR }
+ | VECTUPLE { VECTUPLE }
{
parse :: String -> Either String Info