Blob Blame History Raw
diff --git a/src/SDCCnaddr.cc b/src/SDCCnaddr.cc
index 1330de3..213d644 100644
--- a/src/SDCCnaddr.cc
+++ b/src/SDCCnaddr.cc
@@ -21,6 +21,42 @@
 
 #include "SDCCnaddr.hpp"
 
+// A quick-and-dirty function to get the CFG from sdcc (a simplified version of the function from SDCCralloc.hpp).
+void
+create_cfg_naddr(cfg_t &cfg, iCode *start_ic, ebbIndex *ebbi)
+{
+  iCode *ic;
+
+  std::map<int, unsigned int> key_to_index;
+  {
+    int i;
+
+    for (ic = start_ic, i = 0; ic; ic = ic->next, i++)
+      {
+        boost::add_vertex(cfg);
+        key_to_index[ic->key] = i;
+        cfg[i].ic = ic;
+      }
+  }
+
+  // Get control flow graph from sdcc.
+  for (ic = start_ic; ic; ic = ic->next)
+    {
+      if (ic->op != GOTO && ic->op != RETURN && ic->op != JUMPTABLE && ic->next)
+        boost::add_edge(key_to_index[ic->key], key_to_index[ic->next->key], 3.0f, cfg);
+
+      if (ic->op == GOTO)
+        boost::add_edge(key_to_index[ic->key], key_to_index[eBBWithEntryLabel(ebbi, ic->label)->sch->key], 6.0f, cfg);
+      else if (ic->op == RETURN)
+        boost::add_edge(key_to_index[ic->key], key_to_index[eBBWithEntryLabel(ebbi, returnLabel)->sch->key], 6.0f, cfg);
+      else if (ic->op == IFX)
+        boost::add_edge(key_to_index[ic->key], key_to_index[eBBWithEntryLabel(ebbi, IC_TRUE(ic) ? IC_TRUE(ic) : IC_FALSE(ic))->sch->key], 6.0f, cfg);
+      else if (ic->op == JUMPTABLE)
+        for (symbol *lbl = (symbol *)(setFirstItem (IC_JTLABELS (ic))); lbl; lbl = (symbol *)(setNextItem (IC_JTLABELS (ic))))
+          boost::add_edge(key_to_index[ic->key], key_to_index[eBBWithEntryLabel(ebbi, lbl)->sch->key], 6.0f, cfg);
+    }
+}
+
 int
 switchAddressSpacesOptimally (iCode *ic, ebbIndex *ebbi)
 {
diff --git a/src/SDCCnaddr.hpp b/src/SDCCnaddr.hpp
index 1cfec51..3096baa 100644
--- a/src/SDCCnaddr.hpp
+++ b/src/SDCCnaddr.hpp
@@ -48,9 +48,9 @@ extern "C"
 typedef short int naddrspace_t; // Named address spaces. -1: Undefined, Others: see map.
 
 #ifdef HAVE_STX_BTREE_SET_H
-typedef stx::btree_set<naddrspace_t> naddrspaceset_t; // Faster than std::set
+typedef stx::btree_set<unsigned short int> naddrspaceset_t; // Faster than std::set
 #else
-typedef std::set<naddrspace_t> naddrspaceset_t;
+typedef std::set<unsigned short int> naddrspaceset_t;
 #endif
 
 struct assignment_naddr
@@ -113,45 +113,9 @@ struct tree_dec_naddr_node
   assignment_list_naddr_t assignments;
 };
 
-typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, cfg_naddr_node, float> cfg_t; // The edge property is the cost of subdividing he edge and inserting a bank switching instruction.
+typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, cfg_naddr_node, float> cfg_t; // The edge property is the cost of subdividing the edge and inserting a bank switching instruction.
 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, tree_dec_naddr_node> tree_dec_naddr_t;
 
-// A quick-and-dirty function to get the CFG from sdcc (a simplified version of the function from SDCCralloc.hpp).
-void
-create_cfg_naddr(cfg_t &cfg, iCode *start_ic, ebbIndex *ebbi)
-{
-  iCode *ic;
-
-  std::map<int, unsigned int> key_to_index;
-  {
-    int i;
-
-    for (ic = start_ic, i = 0; ic; ic = ic->next, i++)
-      {
-        boost::add_vertex(cfg);
-        key_to_index[ic->key] = i;
-        cfg[i].ic = ic;
-      }
-  }
-
-  // Get control flow graph from sdcc.
-  for (ic = start_ic; ic; ic = ic->next)
-    {
-      if (ic->op != GOTO && ic->op != RETURN && ic->op != JUMPTABLE && ic->next)
-        boost::add_edge(key_to_index[ic->key], key_to_index[ic->next->key], 3.0f, cfg);
-
-      if (ic->op == GOTO)
-        boost::add_edge(key_to_index[ic->key], key_to_index[eBBWithEntryLabel(ebbi, ic->label)->sch->key], 6.0f, cfg);
-      else if (ic->op == RETURN)
-        boost::add_edge(key_to_index[ic->key], key_to_index[eBBWithEntryLabel(ebbi, returnLabel)->sch->key], 6.0f, cfg);
-      else if (ic->op == IFX)
-        boost::add_edge(key_to_index[ic->key], key_to_index[eBBWithEntryLabel(ebbi, IC_TRUE(ic) ? IC_TRUE(ic) : IC_FALSE(ic))->sch->key], 6.0f, cfg);
-      else if (ic->op == JUMPTABLE)
-        for (symbol *lbl = (symbol *)(setFirstItem (IC_JTLABELS (ic))); lbl; lbl = (symbol *)(setNextItem (IC_JTLABELS (ic))))
-          boost::add_edge(key_to_index[ic->key], key_to_index[eBBWithEntryLabel(ebbi, lbl)->sch->key], 6.0f, cfg);
-    }
-}
-
 // Annotate nodes of the control flow graph with the set of possible named address spaces active there.
 void annotate_cfg_naddr(cfg_t &cfg, std::map<naddrspace_t, const symbol *> &addrspaces)
 {
@@ -435,7 +399,7 @@ int tree_dec_naddrswitch_nodes(T_t &T, typename boost::graph_traits<T_t>::vertex
 }
 
 template <class G_t>
-void implement_assignment(const assignment_naddr &a, const G_t &G, const std::map<naddrspace_t, const symbol *> addrspaces)
+static void implement_naddr_assignment(const assignment_naddr &a, const G_t &G, const std::map<naddrspace_t, const symbol *> addrspaces)
 {
   typedef typename boost::graph_traits<G_t>::vertex_descriptor vertex_t;
   typedef typename boost::graph_traits<G_t>::edge_iterator ei_t;
@@ -479,7 +443,7 @@ int tree_dec_address_switch(T_t &T, const G_t &G, const std::map<naddrspace_t, c
   std::cout.flush();
 #endif
 
-  implement_assignment(winner, G, addrspaces);
+  implement_naddr_assignment(winner, G, addrspaces);
 
   return(0);
 }
diff --git a/src/SDCCralloc.hpp b/src/SDCCralloc.hpp
index cbcf5e2..a621678 100644
--- a/src/SDCCralloc.hpp
+++ b/src/SDCCralloc.hpp
@@ -419,7 +419,7 @@ create_cfg(cfg_t &cfg, con_t &con, ebbIndex *ebbi)
   for (var_t i = boost::num_vertices(con) - 1; i >= 0; i--)
     {
       cfg_sym_t cfg2;
-      boost::copy_graph(cfg, cfg2);
+      boost::copy_graph(cfg, cfg2, boost::vertex_copy(forget_properties()).edge_copy(forget_properties()));
       for (int j = boost::num_vertices(cfg) - 1; j >= 0; j--)
         {
           if (cfg[j].alive.find(i) == cfg[j].alive.end())
@@ -436,7 +436,7 @@ create_cfg(cfg_t &cfg, con_t &con, ebbIndex *ebbi)
 #endif
           // Non-connected CFGs shouldn't exist either. Another problem with dead code eliminarion.
           cfg_sym_t cfg2;
-          boost::copy_graph(cfg, cfg2);
+          boost::copy_graph(cfg, cfg2, boost::vertex_copy(forget_properties()).edge_copy(forget_properties()));
           std::vector<boost::graph_traits<cfg_t>::vertices_size_type> component(num_vertices(cfg2));
           boost::connected_components(cfg2, &component[0]);
 
diff --git a/src/SDCCtree_dec.hpp b/src/SDCCtree_dec.hpp
index e5b1de3..2dce8a6 100644
--- a/src/SDCCtree_dec.hpp
+++ b/src/SDCCtree_dec.hpp
@@ -53,6 +53,14 @@
 #include <boost/graph/copy.hpp>
 #include <boost/graph/adjacency_list.hpp>
 
+struct forget_properties
+{
+  template<class T1, class T2>
+  void operator()(const T1&, const T2&) const
+  {
+  }
+};
+
 // Thorup algorithm D.
 // The use of the multimap makes the complexity of this O(|I|log|I|), which could be reduced to O(|I|).
 template <class l_t>
@@ -97,7 +105,7 @@ template <class I_t>
 void thorup_E(std::multimap<unsigned int, unsigned int> &M, const I_t &I)
 {
   typedef typename boost::graph_traits<I_t>::adjacency_iterator adjacency_iter_t;
-  typedef typename boost::graph_traits<I_t>::vertex_iterator vertex_iter_t;
+//  typedef typename boost::graph_traits<I_t>::vertex_iterator vertex_iter_t;
   typedef typename boost::property_map<I_t, boost::vertex_index_t>::type index_map;
   index_map index = boost::get(boost::vertex_index, I);
 
@@ -152,7 +160,7 @@ void thorup_elimination_ordering(l_t &l, const G_t &G)
 {
   // Should we do this? Or just use G as J? The Thorup paper seems unclear, it speaks of statements that contain jumps to other statements, but does it count as a jump, when they're just subsequent?
   boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> J;
-  boost::copy_graph(G, J);
+  boost::copy_graph(G, J, boost::vertex_copy(forget_properties()).edge_copy(forget_properties()));
   for (unsigned int i = 0; i < boost::num_vertices(J) - 1; i++)
     remove_edge(i, i + 1, J);
 
@@ -256,7 +264,7 @@ void tree_decomposition_from_elimination_ordering(T_t &T, const std::list<unsign
 
   // Todo: Implement a graph adaptor for boost that allows to treat directed graphs as undirected graphs.
   boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> G_sym;
-  boost::copy_graph(G, G_sym);
+  boost::copy_graph(G, G_sym, boost::vertex_copy(forget_properties()).edge_copy(forget_properties()));
 
   std::vector<bool> active(boost::num_vertices(G), true);