packages feed

cnc-spec-compiler 0.2.0.0 → 0.2.0.1

raw patch · 7 files changed

+146/−41 lines, 7 filesdep +graphvizdep −Graphalyzedep −hscursesdep ~pretty

Dependencies added: graphviz

Dependencies removed: Graphalyze, hscurses

Dependency ranges changed: pretty

Files

Intel/Cnc/Spec/CncViz.hs view
@@ -8,7 +8,7 @@  import Intel.Cnc.Spec.TraceVacuum import Intel.Cnc.Spec.CncGraph-import Intel.Cnc.Spec.Curses+-- import Intel.Cnc.Spec.Curses () -- Disabling for now to avoid build deps [2011.08.12]; not used yet. import Intel.Cnc.Spec.Util import qualified Intel.Cnc.Spec.Passes.ReadHarch as H 
Intel/Cnc/Spec/Curses.hs view
@@ -2,6 +2,8 @@  {-|    A Curses-based user interface. ++  Mostly finished.... but currently unused.  -}  module Intel.Cnc.Spec.Curses where
Intel/Cnc/Spec/GraphAnalysis.hs view
@@ -19,10 +19,121 @@  import Test.HUnit import qualified Data.Graph.Inductive as G-import Data.Graph.Analysis.Algorithms.Common +-- import Data.Graph.Analysis.Algorithms.Common (cyclesIn') -- from package Graphalyze+ import Intel.Cnc.Spec.GatherGraph (exampleGraph) import Text.PrettyPrint.HughesPJClass++----------------------------------------------------------------------------------------------------++-- <DUPLICATED CODE FROM GRAPHALYZE PACKAGE.>  (To avoid the extra dependencies.)+-- This was distributed with the following further-reduced BSD-style license:+--+      -- Copyright (c) 2008, Ivan Lazar Miljenovic <Ivan.Miljenovic@gmail.com>+      -- All rights reserved.++      -- Redistribution and use in source and binary forms, with or without+      -- modification, are permitted provided that the following conditions are met:++      -- 1. Redistributions of source code must retain the above copyright notice,+      --    this list of conditions and the following disclaimer.+      -- 2. Redistributions in binary form must reproduce the above copyright+      --    notice, this list of conditions and the following disclaimer in the+      --    documentation and/or other materials provided with the distribution.++      -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+      -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+      -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+      -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE+      -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR+      -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF+      -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS+      -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN+      -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)+      -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+      -- POSSIBILITY OF SUCH DAMAGE.++import Control.Arrow(first)+import Data.Function (on)+import Control.Monad (ap)++-- | A grouping of 'LNode's.+type LNGroup a = [G.LNode a]+-- | A grouping of 'Node's.+type NGroup = [G.Node]++addLabels    :: (G.Graph g) => g a b -> [G.Node] -> [G.LNode a]+addLabels gr = map (ap (,) (fromJust . G.lab gr))++-- | Return true if and only if the list contains a single element.+single     :: [a] -> Bool+single [_] = True+single  _  = False++-- | Makes the graph a simple one, by removing all duplicate edges and loops.+--   The edges removed if duplicates exist are arbitrary.+mkSimple :: (G.DynGraph gr) => gr a b -> gr a b+mkSimple = G.gmap simplify+    where+      rmLoops n = filter ((/=) n . snd)+      rmDups = nubBy ((P.==) `on` snd)+      simpleEdges n = rmDups . rmLoops n+      simplify (p,n,l,s) = (p',n,l,s')+          where+            p' = simpleEdges n p+            s' = simpleEdges n s++-- | Find all possible paths from this given node, avoiding loops,+--   cycles, etc.+pathTree             :: (G.DynGraph g) => G.Decomp g a b -> [NGroup]+pathTree (Nothing,_) = []+pathTree (Just ct,g)+    | G.isEmpty g = []+    | null sucs = [[n]]+    | otherwise = (:) [n] . map (n:) . concatMap (subPathTree g') $ sucs+    where+      n = G.node' ct+      sucs = G.suc' ct+      -- Avoid infinite loops by not letting it continue any further+      ct' = makeLeaf ct+      g' = ct' G.& g+      subPathTree gr n' = pathTree $ G.match n' gr++-- | Remove all outgoing edges+makeLeaf           :: G.Context a b -> G.Context a b+makeLeaf (p,n,a,_) = (p', n, a, [])+    where+      -- Ensure there isn't an edge (n,n)+      p' = filter (\(_,n') -> n' /= n) p++-- | Find all cycles in the given graph.+cyclesIn   :: (G.DynGraph g) => g a b -> [LNGroup a]+cyclesIn g = map (addLabels g) (cyclesIn' g)++-- | Find all cycles in the given graph, returning just the nodes.+cyclesIn' :: (G.DynGraph g) => g a b -> [NGroup]+cyclesIn' = concat . unfoldr findCycles . mkSimple++-- | Find all cycles containing a chosen node.+findCycles :: (G.DynGraph g) => g a b -> Maybe ([NGroup], g a b)+findCycles g+    | G.isEmpty g = Nothing+    | otherwise = Just . getCycles . G.matchAny $ g+    where+      getCycles (ctx,g') = (cyclesFor (ctx, g'), g')++-- | Find all cycles for the given node.+cyclesFor :: (G.DynGraph g) => G.GDecomp g a b -> [NGroup]+cyclesFor = map init .+            filter isCycle .+            pathTree .+            first Just+    where+      isCycle p = not (single p) P.&& (head p P.== last p)++-- </DUPLICATE>+   ----------------------------------------------------------------------------------------------------
Intel/Cnc/Spec/MainExecutable.hs view
@@ -45,7 +45,7 @@  import System.Environment import System.Console.GetOpt-import System.Console.ANSI+import System.Console.ANSI  import System.FilePath.Posix import System.IO import System.IO.Unsafe
Intel/Cnc/Spec/Util.hs view
@@ -174,10 +174,8 @@   -- Also, overloading the string constants themselves is nice:-#if __GLASGOW_HASKELL__ >= 701-instance IsString Doc where-    fromString s = text s-#endif+-- instance IsString Doc where -- Now this is in 'pretty' itself+--     fromString s = text s instance IsString Atom where     fromString s = toAtom s 
Intel/Cnc/Spec/Version.hs view
@@ -1,4 +1,4 @@ -- WARNING: This file is generated from the .cabal file. module Intel.Cnc.Spec.Version where-version = "0.2"-builddate = "2011-08-11 20:36:57.60858 UTC"+version = "0.2.0.1"+builddate = "2011-08-12 18:23:46.080124 UTC"
cnc-spec-compiler.cabal view
@@ -1,6 +1,6 @@ Name:           cnc-spec-compiler -Version:        0.2.0.0+Version:        0.2.0.1 -- [2010.11.10] 0.1.3.100 Bumping slightly after change to CNC_ASSUME_TR1 -- [2010.11.10] 0.1.3.101 New scheme for extracting version from cabal file. -- [2010.12.06] 0.1.3.102 Bumped for recent translator plugin rearchitecture.@@ -12,7 +12,7 @@ -- [2011.01.25] 0.1.3.108 Bumped for new binary trace format. -- [2011.08.10] 0.2.0.0   Bumped because the Spec Compiler has been factored --                        into its own repo.-+-- [2011.08.12] 0.2.0.1   Bumped for new build flag, BasicBuild for low-dependency building.  License: BSD3 License-file:   LICENSE@@ -29,7 +29,7 @@  patterns are stored in a specification, which can be used by this  tool to generate code which will orchestrate the execution of the graph. -Category: system, concurrent+Category: Compilers/Interpreters, Parallelism Cabal-Version: >=1.6  build-type: Simple@@ -48,39 +48,33 @@   Main-is:           Intel/Cnc/Spec/Main.hs   Build-Depends:     base >= 3 && < 5                    , directory, process, containers, unix, bytestring, array-                   , prettyclass, pretty, HUnit, mtl+                   -- For IsString:+                   , pretty >= 1.1.0.0 +--                   , pretty < 1.1+                   , prettyclass, HUnit, mtl                    , stringtable-atom, filepath, split-                   , parsec >= 3.1.0-                   , hscurses, ansi-terminal-                   , fgl-                   , zlib, binary--- graphviz is needed for GraphAnalysis.hs (not just visualization):-                   , Graphalyze ---		   , graphviz---                 , haxr, HTTP, network--- For visualization:-                   , hubigraph------ [2011.08.11] There are currently polyparse dependency problems.---   hubigraph -> haxr -> HaXml -> polyparse------ I am addressing this currently by pinning older versions:-                   , HaXml == 1.20.2-                   , haxr  == 3000.8.2--  extensions: CPP--- Disabling for now.  We will make this optional:---  if (! BasicBuild) ---    cpp-options: -DCNCVIZ+                   , parsec >= 3.1.0, fgl, zlib, binary+                   , ansi-terminal+                   -- graphviz is needed for GraphAnalysis.hs (not just visualization):+		   -- Graphalyze has extensive dependencies... I've duplicated the relevant code:+                   -- , Graphalyze +  -- For visualization:+  if !flag(BasicBuild) {+     cpp-options: -DCNCVIZ+     -- Including the fancy terminal functionality with the visualization features:+     Build-Depends:    hubigraph, graphviz+                     -- [2011.08.11] There are currently polyparse dependency problems.+                     --   hubigraph -> haxr -> HaXml -> polyparse+                     -- I am addressing this currently by pinning older versions:+                     , HaXml == 1.20.2+                     , haxr  == 3000.8.2+                     -- Don't need this one yet:+                     --  , hscurses+  } +  extensions: CPP   other-modules:  -                  -- Intel.Cnc.Spec.AST    Intel.Cnc.Spec.CncLexer    Intel.Cnc.Spec.CncGrammar-                  -- Intel.Cnc.Spec.SrcLoc Intel.Cnc.Spec.GatherGraph Intel.Cnc.Spec.Codegen.CppOld-                  -- Intel.Cnc.Spec.MainExecutable Intel.Cnc.Spec.Version Intel.Cnc.Spec.Globals-                  -- Intel.Cnc.Spec.Util Intel.Cnc.Spec.CncGraph Intel.Cnc.Spec.TagFun-                  -- Intel.Cnc.Spec.TypeDef-                  -- Intel.Cnc.Spec.Passes.ReadHarch                    Intel.Cnc.BenchSynth Intel.Cnc.EasyEmit Intel.Cnc.Spec.GraphAnalysis                   Intel.Cnc.Spec.CncLexer Intel.Cnc.Spec.GatherGraph Intel.Cnc.Spec.Main                   Intel.Cnc.Spec.MainExecutable Intel.Cnc.Spec.Util