OSDN Git Service

PR c/39902
[pf3gnuchains/gcc-fork.git] / gcc / df-problems.c
index 0bfef8a..e19a51e 100644 (file)
@@ -1,6 +1,6 @@
 /* Standard problems for dataflow support routines.
    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008 Free Software Foundation, Inc.
+   2008, 2009 Free Software Foundation, Inc.
    Originally contributed by Michael P. Hayes 
              (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com)
    Major rewrite contributed by Danny Berlin (dberlin@dberlin.org)
@@ -157,27 +157,6 @@ df_print_bb_index (basic_block bb, FILE *file)
   fprintf (file, ")\n");
 }
 
-
-
-/* Make sure that the seen_in_insn and seen_in_block sbitmaps are set
-   up correctly. */
-
-static void
-df_set_seen (void)
-{
-  seen_in_block = BITMAP_ALLOC (&df_bitmap_obstack);
-  seen_in_insn = BITMAP_ALLOC (&df_bitmap_obstack);
-}
-
-
-static void
-df_unset_seen (void)
-{
-  BITMAP_FREE (seen_in_block);
-  BITMAP_FREE (seen_in_insn);
-}
-
-
 \f
 /*----------------------------------------------------------------------------
    REACHING DEFINITIONS
@@ -316,12 +295,66 @@ df_rd_alloc (bitmap all_blocks)
 }
 
 
-/* Process a list of DEFs for df_rd_bb_local_compute.  */
+/* Add the effect of the top artificial defs of BB to the reaching definitions
+   bitmap LOCAL_RD.  */
+
+void
+df_rd_simulate_artificial_defs_at_top (basic_block bb, bitmap local_rd)
+{
+  int bb_index = bb->index;
+  df_ref *def_rec;
+  for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
+    {
+      df_ref def = *def_rec;
+      if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
+       {
+         unsigned int dregno = DF_REF_REGNO (def);
+         if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
+           bitmap_clear_range (local_rd, 
+                               DF_DEFS_BEGIN (dregno), 
+                               DF_DEFS_COUNT (dregno));
+         bitmap_set_bit (local_rd, DF_REF_ID (def));
+       }
+    }
+}
+
+/* Add the effect of the defs of INSN to the reaching definitions bitmap
+   LOCAL_RD.  */
+
+void
+df_rd_simulate_one_insn (basic_block bb ATTRIBUTE_UNUSED, rtx insn,
+                        bitmap local_rd)
+{
+  unsigned uid = INSN_UID (insn);
+  df_ref *def_rec;
+
+  for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
+    {
+      df_ref def = *def_rec;
+      unsigned int dregno = DF_REF_REGNO (def);
+      if ((!(df->changeable_flags & DF_NO_HARD_REGS))
+          || (dregno >= FIRST_PSEUDO_REGISTER))
+        {
+          if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
+           bitmap_clear_range (local_rd, 
+                               DF_DEFS_BEGIN (dregno), 
+                               DF_DEFS_COUNT (dregno));
+         if (!(DF_REF_FLAGS (def) 
+               & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)))
+           bitmap_set_bit (local_rd, DF_REF_ID (def));
+       }
+    }
+}
+
+/* Process a list of DEFs for df_rd_bb_local_compute.  This is a bit
+   more complicated than just simulating, because we must produce the
+   gen and kill sets and hence deal with the two possible representations
+   of kill sets.   */
 
 static void
 df_rd_bb_local_compute_process_def (struct df_rd_bb_info *bb_info, 
                                    df_ref *def_rec,
-                                   enum df_ref_flags top_flag)
+                                   int top_flag)
 {
   while (*def_rec)
     {
@@ -433,7 +466,8 @@ df_rd_local_compute (bitmap all_blocks)
   bitmap sparse_invalidated = problem_data->sparse_invalidated_by_call;
   bitmap dense_invalidated = problem_data->dense_invalidated_by_call;
 
-  df_set_seen ();
+  seen_in_block = BITMAP_ALLOC (&df_bitmap_obstack);
+  seen_in_insn = BITMAP_ALLOC (&df_bitmap_obstack);
 
   df_maybe_reorganize_def_refs (DF_REF_ORDER_BY_REG);
 
@@ -452,7 +486,9 @@ df_rd_local_compute (bitmap all_blocks)
                          DF_DEFS_BEGIN (regno), 
                          DF_DEFS_COUNT (regno));
     }
-  df_unset_seen ();
+
+  BITMAP_FREE (seen_in_block);
+  BITMAP_FREE (seen_in_insn);
 }
 
 
@@ -672,9 +708,8 @@ static struct df_problem problem_RD =
 
 
 
-/* Create a new DATAFLOW instance and add it to an existing instance
-   of DF.  The returned structure is what is used to get at the
-   solution.  */
+/* Create a new RD instance and add it to the existing instance
+   of DF.  */
 
 void
 df_rd_add_problem (void)
@@ -2025,7 +2060,7 @@ df_chain_reset (bitmap blocks_to_clear ATTRIBUTE_UNUSED)
 static void
 df_chain_create_bb_process_use (bitmap local_rd,
                                df_ref *use_rec,
-                               enum df_ref_flags top_flag)
+                               int top_flag)
 {
   bitmap_iterator bi;
   unsigned int def_index;
@@ -2076,7 +2111,6 @@ df_chain_create_bb (unsigned int bb_index)
   struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
   rtx insn;
   bitmap cpy = BITMAP_ALLOC (NULL);
-  df_ref *def_rec;
 
   bitmap_copy (cpy, bb_info->in);
   bitmap_set_bit (df_chain->out_of_date_transfer_functions, bb_index);
@@ -2095,57 +2129,23 @@ df_chain_create_bb (unsigned int bb_index)
                                    DF_REF_AT_TOP);
 #endif
 
-  for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
-    {
-      df_ref def = *def_rec;
-      if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
-       {
-         unsigned int dregno = DF_REF_REGNO (def);
-         if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
-           bitmap_clear_range (cpy, 
-                               DF_DEFS_BEGIN (dregno), 
-                               DF_DEFS_COUNT (dregno));
-         bitmap_set_bit (cpy, DF_REF_ID (def));
-       }
-    }
+  df_rd_simulate_artificial_defs_at_top (bb, cpy);
   
   /* Process the regular instructions next.  */
   FOR_BB_INSNS (bb, insn)
-    {
-      df_ref *def_rec;
-      unsigned int uid = INSN_UID (insn);
-
-      if (!INSN_P (insn))
-       continue;
-
-      /* Now scan the uses and link them up with the defs that remain
-        in the cpy vector.  */
-      
-      df_chain_create_bb_process_use (cpy, DF_INSN_UID_USES (uid), 0);
-
-      if (df->changeable_flags & DF_EQ_NOTES)
-       df_chain_create_bb_process_use (cpy, DF_INSN_UID_EQ_USES (uid), 0);
+    if (INSN_P (insn))
+      {
+        unsigned int uid = INSN_UID (insn);
 
+        /* First scan the uses and link them up with the defs that remain
+          in the cpy vector.  */
+        df_chain_create_bb_process_use (cpy, DF_INSN_UID_USES (uid), 0);
+        if (df->changeable_flags & DF_EQ_NOTES)
+         df_chain_create_bb_process_use (cpy, DF_INSN_UID_EQ_USES (uid), 0);
 
-      /* Since we are going forwards, process the defs second.  This
-         pass only changes the bits in cpy.  */
-      for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
-       {
-         df_ref def = *def_rec;
-         unsigned int dregno = DF_REF_REGNO (def);
-         if ((!(df->changeable_flags & DF_NO_HARD_REGS))
-             || (dregno >= FIRST_PSEUDO_REGISTER))
-           {
-             if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
-               bitmap_clear_range (cpy, 
-                                   DF_DEFS_BEGIN (dregno), 
-                                   DF_DEFS_COUNT (dregno));
-             if (!(DF_REF_FLAGS (def) 
-                   & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)))
-               bitmap_set_bit (cpy, DF_REF_ID (def));
-           }
-       }
-    }
+        /* Since we are going forwards, process the defs second.  */
+        df_rd_simulate_one_insn (bb, insn, cpy);
+      }
 
   /* Create the chains for the artificial uses of the hard registers
      at the end of the block.  */
@@ -2325,10 +2325,10 @@ static struct df_problem problem_CHAIN =
    solution.  */
 
 void
-df_chain_add_problem (enum df_chain_flags chain_flags)
+df_chain_add_problem (unsigned int chain_flags)
 {
   df_add_problem (&problem_CHAIN);
-  df_chain->local_flags = (unsigned int)chain_flags;
+  df_chain->local_flags = chain_flags;
   df_chain->out_of_date_transfer_functions = BITMAP_ALLOC (NULL);
 }
 
@@ -2490,8 +2490,8 @@ df_byte_lr_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
   unsigned int regno;
   unsigned int index = 0;
   unsigned int max_reg = max_reg_num();
-  struct df_byte_lr_problem_data *problem_data 
-    = problem_data = XNEW (struct df_byte_lr_problem_data);
+  struct df_byte_lr_problem_data *problem_data
+    = XNEW (struct df_byte_lr_problem_data);
 
   df_byte_lr->problem_data = problem_data;
 
@@ -3893,19 +3893,21 @@ df_simulate_one_insn_forwards (basic_block bb, rtx insn, bitmap live)
   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
     {
       switch (REG_NOTE_KIND (link))
+       {
        case REG_DEAD:
        case REG_UNUSED:
-       {
-         rtx reg = XEXP (link, 0);
-         int regno = REGNO (reg);
-         if (regno < FIRST_PSEUDO_REGISTER)
-           {
-             int n = hard_regno_nregs[regno][GET_MODE (reg)];
-             while (--n >= 0)
-               bitmap_clear_bit (live, regno + n);
-           }
-         else 
-           bitmap_clear_bit (live, regno);
+         {
+           rtx reg = XEXP (link, 0);
+           int regno = REGNO (reg);
+           if (regno < FIRST_PSEUDO_REGISTER)
+             {
+               int n = hard_regno_nregs[regno][GET_MODE (reg)];
+               while (--n >= 0)
+                 bitmap_clear_bit (live, regno + n);
+             }
+           else 
+             bitmap_clear_bit (live, regno);
+         }
          break;
        default:
          break;
@@ -3933,3 +3935,465 @@ df_simulate_finalize_forwards (basic_block bb, bitmap live)
 }
 
 
+\f
+/*----------------------------------------------------------------------------
+   MULTIPLE DEFINITIONS
+
+   Find the locations in the function reached by multiple definition sites
+   for a pseudo.  In and out bitvectors are built for each basic
+   block.
+
+   The gen and kill sets for the problem are obvious.  Together they
+   include all defined registers in a basic block; the gen set includes
+   registers where a partial or conditional or may-clobber definition is
+   last in the BB, while the kill set includes registers with a complete
+   definition coming last.  However, the computation of the dataflow
+   itself is interesting.
+
+   The idea behind it comes from SSA form's iterated dominance frontier
+   criterion for inserting PHI functions.  Just like in that case, we can use
+   the dominance frontier to find places where multiple definitions meet;
+   a register X defined in a basic block BB1 has multiple definitions in
+   basic blocks in BB1's dominance frontier.
+
+   So, the in-set of a basic block BB2 is not just the union of the
+   out-sets of BB2's predecessors, but includes some more bits that come
+   from the basic blocks of whose dominance frontier BB2 is part (BB1 in
+   the previous paragraph).  I called this set the init-set of BB2.
+
+      (Note: I actually use the kill-set only to build the init-set.
+      gen bits are anyway propagated from BB1 to BB2 by dataflow).
+
+    For example, if you have
+
+       BB1 : r10 = 0
+             r11 = 0
+             if <...> goto BB2 else goto BB3;
+
+       BB2 : r10 = 1
+             r12 = 1
+             goto BB3;
+
+       BB3 :
+
+    you have BB3 in BB2's dominance frontier but not in BB1's, so that the
+    init-set of BB3 includes r10 and r12, but not r11.  Note that we do
+    not need to iterate the dominance frontier, because we do not insert
+    anything like PHI functions there!  Instead, dataflow will take care of
+    propagating the information to BB3's successors. 
+   ---------------------------------------------------------------------------*/
+
+/* Scratch var used by transfer functions.  This is used to do md analysis
+   only for live registers.  */
+static bitmap df_md_scratch;
+
+/* Set basic block info.  */
+
+static void
+df_md_set_bb_info (unsigned int index, 
+                   struct df_md_bb_info *bb_info)
+{
+  gcc_assert (df_md);
+  gcc_assert (index < df_md->block_info_size);
+  df_md->block_info[index] = bb_info;
+}
+
+
+static void
+df_md_free_bb_info (basic_block bb ATTRIBUTE_UNUSED, 
+                    void *vbb_info)
+{
+  struct df_md_bb_info *bb_info = (struct df_md_bb_info *) vbb_info;
+  if (bb_info)
+    {
+      BITMAP_FREE (bb_info->kill);
+      BITMAP_FREE (bb_info->gen);
+      BITMAP_FREE (bb_info->init);
+      BITMAP_FREE (bb_info->in);
+      BITMAP_FREE (bb_info->out);
+      pool_free (df_md->block_pool, bb_info);
+    }
+}
+
+
+/* Allocate or reset bitmaps for DF_MD. The solution bits are
+   not touched unless the block is new.  */
+
+static void 
+df_md_alloc (bitmap all_blocks)
+{
+  unsigned int bb_index;
+  bitmap_iterator bi;
+
+  if (!df_md->block_pool)
+    df_md->block_pool = create_alloc_pool ("df_md_block pool", 
+                                           sizeof (struct df_md_bb_info), 50);
+
+  df_grow_bb_info (df_md);
+  df_md_scratch = BITMAP_ALLOC (NULL);
+
+  EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
+    {
+      struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
+      if (bb_info)
+        { 
+          bitmap_clear (bb_info->init);
+          bitmap_clear (bb_info->gen);
+          bitmap_clear (bb_info->kill);
+          bitmap_clear (bb_info->in);
+          bitmap_clear (bb_info->out);
+        }
+      else
+        { 
+          bb_info = (struct df_md_bb_info *) pool_alloc (df_md->block_pool);
+          df_md_set_bb_info (bb_index, bb_info);
+          bb_info->init = BITMAP_ALLOC (NULL);
+          bb_info->gen = BITMAP_ALLOC (NULL);
+          bb_info->kill = BITMAP_ALLOC (NULL);
+          bb_info->in = BITMAP_ALLOC (NULL);
+          bb_info->out = BITMAP_ALLOC (NULL);
+        }
+    }
+
+  df_md->optional_p = true;
+}
+
+/* Add the effect of the top artificial defs of BB to the multiple definitions
+   bitmap LOCAL_MD.  */
+
+void
+df_md_simulate_artificial_defs_at_top (basic_block bb, bitmap local_md)
+{
+  int bb_index = bb->index;
+  df_ref *def_rec;
+  for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
+    {
+      df_ref def = *def_rec;
+      if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
+       {
+         unsigned int dregno = DF_REF_REGNO (def);
+         if (DF_REF_FLAGS (def)
+             & (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER))
+           bitmap_set_bit (local_md, dregno);
+         else
+           bitmap_clear_bit (local_md, dregno);
+       }
+    }
+}
+
+
+/* Add the effect of the defs of INSN to the reaching definitions bitmap
+   LOCAL_MD.  */
+
+void
+df_md_simulate_one_insn (basic_block bb ATTRIBUTE_UNUSED, rtx insn,
+                        bitmap local_md)
+{
+  unsigned uid = INSN_UID (insn);
+  df_ref *def_rec;
+
+  for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
+    {
+      df_ref def = *def_rec;
+      unsigned int dregno = DF_REF_REGNO (def);
+      if ((!(df->changeable_flags & DF_NO_HARD_REGS))
+          || (dregno >= FIRST_PSEUDO_REGISTER))
+        {
+          if (DF_REF_FLAGS (def)
+             & (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER))
+           bitmap_set_bit (local_md, DF_REF_ID (def));
+         else
+           bitmap_clear_bit (local_md, DF_REF_ID (def));
+        }
+    }
+}
+
+static void
+df_md_bb_local_compute_process_def (struct df_md_bb_info *bb_info, 
+                                    df_ref *def_rec,
+                                    int top_flag)
+{
+  df_ref def;
+  bitmap_clear (seen_in_insn);
+
+  while ((def = *def_rec++) != NULL)
+    {
+      unsigned int dregno = DF_REF_REGNO (def);
+      if (((!(df->changeable_flags & DF_NO_HARD_REGS))
+           || (dregno >= FIRST_PSEUDO_REGISTER))
+         && top_flag == (DF_REF_FLAGS (def) & DF_REF_AT_TOP))
+       {
+          if (!bitmap_bit_p (seen_in_insn, dregno))
+           {
+             if (DF_REF_FLAGS (def)
+                 & (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER))
+               {
+                 bitmap_set_bit (bb_info->gen, dregno);
+                 bitmap_clear_bit (bb_info->kill, dregno);
+               }
+             else
+               {
+                 /* When we find a clobber and a regular def,
+                    make sure the regular def wins.  */
+                 bitmap_set_bit (seen_in_insn, dregno);
+                 bitmap_set_bit (bb_info->kill, dregno);
+                 bitmap_clear_bit (bb_info->gen, dregno);
+               }
+           }
+       }
+    }
+}
+
+
+/* Compute local multiple def info for basic block BB.  */
+
+static void
+df_md_bb_local_compute (unsigned int bb_index)
+{
+  basic_block bb = BASIC_BLOCK (bb_index);
+  struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
+  rtx insn;
+
+  /* Artificials are only hard regs.  */
+  if (!(df->changeable_flags & DF_NO_HARD_REGS))
+    df_md_bb_local_compute_process_def (bb_info, 
+                                        df_get_artificial_defs (bb_index),
+                                        DF_REF_AT_TOP);
+
+  FOR_BB_INSNS (bb, insn)
+    {
+      unsigned int uid = INSN_UID (insn);
+      if (!INSN_P (insn))
+        continue;
+
+      df_md_bb_local_compute_process_def (bb_info, DF_INSN_UID_DEFS (uid), 0);
+    }
+
+  if (!(df->changeable_flags & DF_NO_HARD_REGS))
+    df_md_bb_local_compute_process_def (bb_info, 
+                                        df_get_artificial_defs (bb_index),
+                                        0);
+}
+
+/* Compute local reaching def info for each basic block within BLOCKS.  */
+
+static void
+df_md_local_compute (bitmap all_blocks)
+{
+  unsigned int bb_index, df_bb_index;
+  bitmap_iterator bi1, bi2;
+  basic_block bb;
+  bitmap *frontiers;
+
+  seen_in_insn = BITMAP_ALLOC (NULL);
+
+  EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi1)
+    {
+      df_md_bb_local_compute (bb_index);
+    }
+  
+  BITMAP_FREE (seen_in_insn);
+
+  frontiers = XNEWVEC (bitmap, last_basic_block);
+  FOR_ALL_BB (bb)
+    frontiers[bb->index] = BITMAP_ALLOC (NULL);
+
+  compute_dominance_frontiers (frontiers);
+
+  /* Add each basic block's kills to the nodes in the frontier of the BB.  */
+  EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi1)
+    {
+      bitmap kill = df_md_get_bb_info (bb_index)->kill;
+      EXECUTE_IF_SET_IN_BITMAP (frontiers[bb_index], 0, df_bb_index, bi2)
+       {
+         basic_block bb = BASIC_BLOCK (df_bb_index);
+         if (bitmap_bit_p (all_blocks, df_bb_index))
+           bitmap_ior_and_into (df_md_get_bb_info (df_bb_index)->init, kill,
+                                df_get_live_in (bb));
+       }
+    }
+
+  FOR_ALL_BB (bb)
+    BITMAP_FREE (frontiers[bb->index]);
+  free (frontiers);
+}
+
+
+/* Reset the global solution for recalculation.  */
+
+static void 
+df_md_reset (bitmap all_blocks)
+{
+  unsigned int bb_index;
+  bitmap_iterator bi;
+
+  EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
+    {
+      struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
+      gcc_assert (bb_info);
+      bitmap_clear (bb_info->in);
+      bitmap_clear (bb_info->out);
+    }
+}
+
+static bool
+df_md_transfer_function (int bb_index)
+{
+  basic_block bb = BASIC_BLOCK (bb_index);
+  struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
+  bitmap in = bb_info->in;
+  bitmap out = bb_info->out;
+  bitmap gen = bb_info->gen;
+  bitmap kill = bb_info->kill;
+
+  /* We need to use a scratch set here so that the value returned from
+     this function invocation properly reflects if the sets changed in
+     a significant way; i.e. not just because the live set was anded
+     in.  */
+  bitmap_and (df_md_scratch, gen, df_get_live_out (bb));
+
+  /* Multiple definitions of a register are not relevant if it is not
+     used.  Thus we trim the result to the places where it is live.  */
+  bitmap_and_into (in, df_get_live_in (bb));
+
+  return bitmap_ior_and_compl (out, df_md_scratch, in, kill);
+}
+
+/* Initialize the solution bit vectors for problem.  */
+
+static void 
+df_md_init (bitmap all_blocks)
+{
+  unsigned int bb_index;
+  bitmap_iterator bi;
+
+  EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
+    {
+      struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
+      
+      bitmap_copy (bb_info->in, bb_info->init);
+      df_md_transfer_function (bb_index);
+    }
+}
+
+static void
+df_md_confluence_0 (basic_block bb)
+{
+  struct df_md_bb_info *bb_info = df_md_get_bb_info (bb->index);
+  bitmap_copy (bb_info->in, bb_info->init);
+} 
+
+/* In of target gets or of out of source.  */
+
+static void
+df_md_confluence_n (edge e)
+{
+  bitmap op1 = df_md_get_bb_info (e->dest->index)->in;
+  bitmap op2 = df_md_get_bb_info (e->src->index)->out;
+
+  if (e->flags & EDGE_FAKE) 
+    return;
+
+  if (e->flags & EDGE_EH)
+    bitmap_ior_and_compl_into (op1, op2, regs_invalidated_by_call_regset);
+  else
+    bitmap_ior_into (op1, op2);
+}
+
+/* Free all storage associated with the problem.  */
+
+static void
+df_md_free (void)
+{
+  unsigned int i;
+  for (i = 0; i < df_md->block_info_size; i++)
+    {
+      struct df_md_bb_info *bb_info = df_md_get_bb_info (i);
+      if (bb_info)
+       {
+         BITMAP_FREE (bb_info->kill);
+         BITMAP_FREE (bb_info->gen);
+         BITMAP_FREE (bb_info->init);
+         BITMAP_FREE (bb_info->in);
+         BITMAP_FREE (bb_info->out);
+       }
+    }
+
+  BITMAP_FREE (df_md_scratch);
+  free_alloc_pool (df_md->block_pool);
+
+  df_md->block_info_size = 0;
+  free (df_md->block_info);
+  free (df_md);
+}
+
+
+/* Debugging info at top of bb.  */
+
+static void
+df_md_top_dump (basic_block bb, FILE *file)
+{
+  struct df_md_bb_info *bb_info = df_md_get_bb_info (bb->index);
+  if (!bb_info || !bb_info->in)
+    return;
+      
+  fprintf (file, ";; md  in  \t");
+  df_print_regset (file, bb_info->in);
+  fprintf (file, ";; md  init  \t");
+  df_print_regset (file, bb_info->init);
+  fprintf (file, ";; md  gen \t");
+  df_print_regset (file, bb_info->gen);
+  fprintf (file, ";; md  kill \t");
+  df_print_regset (file, bb_info->kill);
+}
+
+/* Debugging info at bottom of bb.  */
+
+static void
+df_md_bottom_dump (basic_block bb, FILE *file)
+{
+  struct df_md_bb_info *bb_info = df_md_get_bb_info (bb->index);
+  if (!bb_info || !bb_info->out)
+    return;
+  
+  fprintf (file, ";; md  out \t");
+  df_print_regset (file, bb_info->out);
+}  
+
+static struct df_problem problem_MD =
+{
+  DF_MD,                      /* Problem id.  */
+  DF_FORWARD,                 /* Direction.  */
+  df_md_alloc,                /* Allocate the problem specific data.  */
+  df_md_reset,                /* Reset global information.  */
+  df_md_free_bb_info,         /* Free basic block info.  */
+  df_md_local_compute,        /* Local compute function.  */
+  df_md_init,                 /* Init the solution specific data.  */
+  df_worklist_dataflow,       /* Worklist solver.  */
+  df_md_confluence_0,         /* Confluence operator 0.  */ 
+  df_md_confluence_n,         /* Confluence operator n.  */ 
+  df_md_transfer_function,    /* Transfer function.  */
+  NULL,                       /* Finalize function.  */
+  df_md_free,                 /* Free all of the problem information.  */
+  df_md_free,                 /* Remove this problem from the stack of dataflow problems.  */
+  NULL,                       /* Debugging.  */
+  df_md_top_dump,             /* Debugging start block.  */
+  df_md_bottom_dump,          /* Debugging end block.  */
+  NULL,                              /* Incremental solution verify start.  */
+  NULL,                              /* Incremental solution verify end.  */
+  NULL,                       /* Dependent problem.  */
+  TV_DF_MD,                   /* Timing variable.  */ 
+  false                       /* Reset blocks on dropping out of blocks_to_analyze.  */
+};
+
+/* Create a new MD instance and add it to the existing instance
+   of DF.  */
+
+void
+df_md_add_problem (void)
+{
+  df_add_problem (&problem_MD);
+}
+
+
+