packages feed

feldspar-compiler 0.3 → 0.3.1

raw patch · 4 files changed

+42/−23 lines, 4 filesdep ~feldspar-languagePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: feldspar-language

API changes (from Hackage documentation)

Files

Feldspar/C/feldspar_c99.c view
@@ -876,7 +876,7 @@         exit (8);     }     fprintf(trace_log_file, -          "The logging started at %02d-%02d-%04d %02d:%02d:%02d.\n", +          "Logging started at %02d-%02d-%04d %02d:%02d:%02d.\n",            lt.wDay, lt.wMonth, lt.wYear, lt.wHour, lt.wMinute, lt.wSecond);     fflush(trace_log_file);     trace_start_time = GetTickCount();@@ -908,7 +908,7 @@         exit (8);     }     strftime(timestr, 80, "%d-%b-%Y %H:%M:%S", timeinfo);-    fprintf(trace_log_file, "The logging started at %s.\n", timestr);+    fprintf(trace_log_file, "Logging started at %s.\n", timestr);     fflush(trace_log_file);     gettimeofday(&trace_start_time, NULL); }@@ -931,7 +931,7 @@  void traceEnd() {-    fprintf(trace_log_file, "The logging finished.\n");+    fprintf(trace_log_file, "Logging finished.\n");     fclose(trace_log_file); } 
Feldspar/C/feldspar_tic64x.c view
@@ -973,7 +973,7 @@         exit (8);     }     strftime(timestr, 80, "%d-%b-%Y %H:%M:%S", timeinfo);-    fprintf(trace_log_file, "The logging started at %s.\n", timestr);+    fprintf(trace_log_file, "Logging started at %s.\n", timestr);     fflush(trace_log_file);     trace_start_time = time(NULL); }@@ -985,7 +985,7 @@  void traceEnd() {-    fprintf(trace_log_file, "The logging finished.\n");+    fprintf(trace_log_file, "Logging finished.\n");     fclose(trace_log_file); } 
Feldspar/Compiler/Plugins/BackwardPropagation.hs view
@@ -37,6 +37,7 @@ import Feldspar.Compiler.Plugins.PropagationUtils import qualified Data.Map as Map import qualified Data.List as List+import qualified Data.Set as Set import Data.Maybe import Feldspar.Compiler.Options @@ -139,7 +140,7 @@     transformBlock self d origBlock u = Block {             blockDeclarations = recursivelyTransformedBlockDeclarations u,             blockInstructions = recursivelyTransformedBlockInstructions u,-            blockSemInf = unChain $ checkInDeclatation origBlock $ upwardsInfoFromBlockInstructions u+            blockSemInf = checkInDeclatation origBlock $ upwardsInfoFromBlockInstructions u         }      transformPrimitiveProgramInProgram self d origPrimitive u = PrimitiveProgram $ Primitive {             primitiveInstruction = recursivelyTransformedPrimitiveInstruction u,@@ -232,30 +233,48 @@     type To PropagationTransform = ()     type Downwards PropagationTransform = [(VariableData, LeftValueData ())]     type Upwards PropagationTransform = ()-    downwardsBlock self d origBlock = foldl addChain (blockSemInf origBlock) d+    downwardsBlock self d origBlock = unChain $ foldl addChain (blockSemInf origBlock) d     downwardsLocalDeclaration self d origLocDecl = []-    transformBlock self d orig u = delUnusedDecl (map fst $ foldl addChain (blockSemInf orig) d) orig (recursivelyTransformedBlockDeclarations u) (recursivelyTransformedBlockInstructions u)-    transformPrimitiveProgramInProgram self d origPrimitive u =-        case primitiveSemInf origPrimitive of-            Nothing -> makedPrim-            Just (var,outD,_)-                | List.elem (var,outD) d || ((List.elem (getLvName outD) $ map fst d) && (List.elem var $ map fst d) ) -> EmptyProgram $ Empty ()-                | otherwise -> makedPrim+    transformBlock self d orig u = delUnusedDecl (map fst $ downwardsBlock self d orig) orig (recursivelyTransformedBlockDeclarations u) (recursivelyTransformedBlockInstructions u)+    transformPrimitiveProgramInProgram self d origPrimitive u = +        case isIdentity $ instructionData newInstr of+            True -> EmptyProgram $ Empty ()+            False -> makedPrim         where-              makedPrim = PrimitiveProgram $ Primitive {-                primitiveInstruction = recursivelyTransformedPrimitiveInstruction u,+            makedPrim = PrimitiveProgram $ Primitive {+                primitiveInstruction = newInstr,                 primitiveSemInf =()             }-    transformVariableLeftValueInLeftValue self d origVar = case List.find (\(a,b) -> a == {-newVar-} variableData origVar) d of+            newInstr = recursivelyTransformedPrimitiveInstruction u+            isIdentity (AssignmentInstruction a) = isIdentity' (assignmentRhs a) (assignmentLhs a)+            isIdentity (ProcedureCallInstruction p)+                | nameOfProcedureToCall p == "copy" = case map actualParameterData $ actualParametersOfProcedureToCall p of+                    [InputActualParameter i,OutputActualParameter o] -> isIdentity' i o+                    _ -> False+                | otherwise = False+            isIdentity' e l = List.elem (expressionData e) [LeftValueExpression $ swapArrayIndex l, LeftValueExpression l]+            swapArrayIndex :: LeftValue () -> LeftValue ()+            swapArrayIndex l = setIndex $ (\(a,b)->(a,reverse b)) $ getIndex l+            getIndex :: LeftValue () -> (Variable (), [Expression ()])+            getIndex lv = getIndex2 $ leftValueData lv+            getIndex2 (VariableLeftValue v) = (v,[])+            getIndex2 (ArrayElemReferenceLeftValue a) = (fst $ getIndex $ arrayName a, (arrayIndex a):(snd $ getIndex $ arrayName a))            +            setIndex :: (Variable (), [Expression ()]) -> LeftValue ()+            setIndex x = LeftValue (setIndex2 x) ()+            setIndex2 (v,[]) = VariableLeftValue v+            setIndex2 (v,(x:xs)) = ArrayElemReferenceLeftValue $ ArrayElemReference (setIndex (v,xs)) x ()+    transformVariableLeftValueInLeftValue self d origVar = case List.find (\(a,b) -> a == variableData origVar) d of             Nothing -> VariableLeftValue $ origVar {                     variableSemInf = ()                 }             Just (var,out) -> out-        --where-        --    newVar = variableData $ recursivelyTransformedVariableLeftValueContents u-+             unChain :: [(VariableData, LeftValueData ())] -> [(VariableData, LeftValueData ())]-unChain s = foldl addChain [] s+unChain s = unchain' s where+    unchain' s+        | s == unchain'' s = s+        | otherwise = unchain'' s+    unchain'' s = foldl addChain [] s  addChain :: [(VariableData, LeftValueData ())] -> (VariableData, LeftValueData ()) -> [(VariableData, LeftValueData ())] addChain [] pair = [pair]
feldspar-compiler.cabal view
@@ -1,5 +1,5 @@ name:           feldspar-compiler-version:        0.3+version:        0.3.1 cabal-version:  >= 1.6 build-type:     Simple license:        BSD3@@ -47,7 +47,7 @@     Feldspar.Fs2dot    build-depends:-    feldspar-language == 0.3,+    feldspar-language == 0.3.1,     base >= 4 && < 4.3,     containers,     haskell-src-exts,