From 807b219a3989ec8b868b40a09892638773be773b Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 6 Mar 2008 15:25:05 +0000 Subject: [PATCH] Implemented adding array sizes for Is abbreviations --- backends/BackendPasses.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/backends/BackendPasses.hs b/backends/BackendPasses.hs index 0c89896..67bddb0 100644 --- a/backends/BackendPasses.hs +++ b/backends/BackendPasses.hs @@ -41,8 +41,6 @@ squashArrays = makePassesDep where prereq = Prop.agg_namesDone ++ Prop.agg_typesDone ++ Prop.agg_functionsGone ++ [Prop.subscriptsPulledUp, Prop.arrayLiteralsExpanded] --- Prop.subscriptsPulledUp - -- | Identify processes that we'll need to compute the stack size of. identifyParProcs :: Data t => t -> PassM t identifyParProcs = doGeneric `extM` doProcess @@ -119,9 +117,17 @@ declareSizesArray = doGeneric `ext1M` doStructured = do t <- typeOfSpec spec case (spec,t) of (_,Just (A.Array ds _)) -> if elem A.UnknownDimension ds - then do let sizeSpec = A.Specification m' (append_sizes n) (A.Declaration m' (A.Array [A.Dimension $ length ds] A.Int) Nothing) + then case spec of + A.Is _ _ _ v@(A.Variable _ srcN) -> + do (A.Array srcDs _) <- typeOfVariable v + let sizeDiff = length srcDs - length ds + subSrcSizeVar = A.SubscriptedVariable m' (A.SubscriptFrom m' $ makeConstant m' sizeDiff) (A.Variable m' $ append_sizes srcN) + sizeSpecType = A.Is m' A.ValAbbrev (A.Array [A.Dimension $ length ds] A.Int) subSrcSizeVar + sizeSpec = A.Specification m' (append_sizes n) sizeSpecType s' <- doStructured s - return (A.Spec m sp $ A.Spec m sizeSpec $ s') -- TODO fix this + defineSizesName m' (append_sizes n) sizeSpecType + return (A.Spec m sp $ A.Spec m sizeSpec $ s') + _ -> doGeneric str --TODO IsExpr and Reshapes else do let n_sizes = append_sizes n sizeSpecType = makeStaticSizeSpec m' n_sizes ds sizeSpec = A.Specification m' n_sizes sizeSpecType