Add OALLOC*() to make allocating from obstacks a bit nicer.
[libfirm] / ir / stat / pattern_dmp.h
index 9cc7473..244eb3a 100644 (file)
-#ifndef _PATTERN_DMP_H_
-#define _PATTERN_DMP_H_
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief   Statistics for Firm. Dumping patterns.
+ * @author  Michael Beck
+ * @version $Id$
+ */
+#ifndef FIRM_STAT_PATTERN_DMP_H
+#define FIRM_STAT_PATTERN_DMP_H
 
 #include "counter.h"
 
 typedef struct _pattern_dumper_t pattern_dumper_t;
-typedef void (*DUMP_NEW_PATTERN_FUNC)(pattern_dumper_t *self, counter_t *cnt);
-typedef void (*DUMP_FINISH_PATTERN_FUNC)(pattern_dumper_t *self);
-typedef void (*DUMP_NODE_FUNC)(pattern_dumper_t *self, unsigned id, unsigned op_code, unsigned mode_code);
-typedef void (*DUMP_REF_FUNC)(pattern_dumper_t *self, unsigned id);
-typedef void (*DUMP_EDGE_FUNC)(pattern_dumper_t *self, unsigned id, unsigned parent, unsigned position);
-typedef void (*DUMP_START_CHILDREN_FUNC)(pattern_dumper_t *self, unsigned id);
-typedef void (*DUMP_FINISH_CHILDREN_FUNC)(pattern_dumper_t *self, unsigned id);
-
-struct _pattern_dumper_t {
-  DUMP_NEW_PATTERN_FUNC      dump_new_pattern;
-  DUMP_FINISH_PATTERN_FUNC   dump_finish_pattern;
-  DUMP_NODE_FUNC             dump_node;
-  DUMP_REF_FUNC              dump_ref;
-  DUMP_EDGE_FUNC             dump_edge;
-  DUMP_START_CHILDREN_FUNC   dump_start_children;
-  DUMP_FINISH_CHILDREN_FUNC  dump_finish_children;
-};
-
-extern pattern_dumper_t vcg_dump, stdout_dump;
 
 /**
- * starts a new pattern
+ * Starts a new pattern.
  */
 void pattern_dump_new_pattern(pattern_dumper_t *self, counter_t *cnt);
 
 /**
- * Finishes current pattern
+ * Finish the current pattern.
  */
 void pattern_dump_finish_pattern(pattern_dumper_t *self);
 
 /**
- * Dumps a node
+ * Dumps a node.
  */
-void pattern_dump_node(pattern_dumper_t *self, unsigned id, unsigned op_code, unsigned mode_code);
+void pattern_dump_node(pattern_dumper_t *self, unsigned id, unsigned op_code, unsigned mode_code, void *attr);
 
 /**
- * Dump a ref
+ * Dump a ref.
  */
 void pattern_dump_ref(pattern_dumper_t *self, unsigned id);
 
 /**
- * Dump an edge
+ * Dump an edge.
+ *
+ * @param tgt       The target ID
+ * @param src       The source ID
+ * @param pos       The edge position
+ * @param mode_code The mode_code of the edge
  */
-void pattern_dump_edge(pattern_dumper_t *self, unsigned id, unsigned parent, unsigned position);
+void pattern_dump_edge(pattern_dumper_t *self, unsigned tgt, unsigned src, unsigned pos, unsigned mode_code);
 
 /**
- * Start children dumper
+ * Start the children dumper.
  */
 void pattern_start_children(pattern_dumper_t *self, unsigned id);
 
 /**
- * finishes childred  dumper
+ * Finish the children dumper.
  */
 void pattern_finish_children(pattern_dumper_t *self, unsigned id);
 
-#endif /* _PATTERN_DMP_H_ */
+/**
+ * Finish the dumper, destroys the dumper object
+ */
+void pattern_end(pattern_dumper_t *self);
+
+/**
+ * Pattern dumper factory for text dumper.
+ */
+pattern_dumper_t *new_text_dumper(void);
+
+/**
+ * Pattern dumper factory for vcg dumper.
+ *
+ * @param vcg_name    name of the VCG file
+ * @param max_pattern maximum number of pattern to be dumped
+ */
+pattern_dumper_t *new_vcg_dumper(const char *vcg_name, unsigned max_pattern);
+
+/**
+ * return the mode index, only needed for statistics
+ */
+int stat_find_mode_index(const ir_mode *m);
+
+/**
+ * return the mode for a given index, only needed for statistics
+ */
+ir_mode *stat_mode_for_index(int idx);
+
+#endif /* FIRM_STAT_PATTERN_DMP_H */