architecture independent part of the codegen module
authorChristian Würdig <chriswue@ipd.info.uni-karlsruhe.de>
Tue, 25 Oct 2005 07:58:55 +0000 (07:58 +0000)
committerChristian Würdig <chriswue@ipd.info.uni-karlsruhe.de>
Tue, 25 Oct 2005 07:58:55 +0000 (07:58 +0000)
ir/be/firm2arch.c [new file with mode: 0644]
ir/be/firm2arch.h [new file with mode: 0644]
ir/be/firm2arch_nodes_attr.h [new file with mode: 0644]

diff --git a/ir/be/firm2arch.c b/ir/be/firm2arch.c
new file mode 100644 (file)
index 0000000..792c4fd
--- /dev/null
@@ -0,0 +1,67 @@
+/**
+ * Dumps Firm into CPU specific assembler format (the concrete
+ * implementations can be found in the <arch> subdirectories)
+ * @author Christian Wuerdig
+ * @date 18.10.2005
+ * @version $Id$
+ */
+
+#include <libfirm/firm.h>
+#include <libfirm/pseudo_irg.h>
+
+#include "firm2arch.h"
+
+/**
+ * Transforms all irgs into assembler irgs.
+ * Calls the interface function transform_node() which
+ * needs to be implemented for each architecture.
+ */
+void transform_firm() {
+  int i;
+
+  for (i = 0; i < get_irp_n_irgs(); i++) {
+    ir_graph *irg = get_irp_irg(i);
+
+    if (! is_pseudo_ir_graph(irg)) {
+      irg_walk_blkwise_graph(irg, NULL, transform_node, NULL);
+    }
+  }
+}
+
+/**
+ * Finishes the firm transformation. This function is called
+ * after register allocation and scheduling to build everything
+ * which can only be build after those phases e.g. function prolog
+ * and epilog.
+ * Calls the interface function finish_node_transformation which needs
+ * to be implemented for each architecture.
+ */
+void finish_transform() {
+  int i;
+
+  for (i = 0; i < get_irp_n_irgs(); i++) {
+    ir_graph *irg = get_irp_irg(i);
+
+    if (! is_pseudo_ir_graph(irg)) {
+ //     irg_walk_blkwise_graph(irg, NULL, finish_node_transformation, NULL);
+    }
+  }
+}
+
+/**
+ * Generates the architecture specific assembler code.
+ * Calls the interface functions firmbe_gen_decls() (dumps all global
+ * decls) and firmbe_gen_routine() (generates code for all routines) which
+ * need to be implemented for each architecture.
+ */
+void firmbe_gen_code(FILE *out) {
+  int i;
+
+//  firmbe_gen_decls(out);
+  for (i = 0; i < get_irp_n_irgs(); ++i) {
+    ir_graph *irg = get_irp_irg(i);
+
+//    if (! is_pseudo_ir_graph(irg))
+ //     firmbe_gen_routine(out, irg);
+  }
+}
diff --git a/ir/be/firm2arch.h b/ir/be/firm2arch.h
new file mode 100644 (file)
index 0000000..fa148aa
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef FIRM2ARCH_H
+#define FIRM2ARCH_H
+
+#include <libfirm/firm.h>
+
+void create_bearch_asm_opcodes(void);
+
+void transform_firm(void);
+
+extern void transform_node(ir_node *node, void *env);
+
+void finish_transform(void);
+
+extern void finish_node_transformation(ir_node *node, void *env);
+
+void firmbe_gen_code(FILE *out);
+
+extern void firmbe_gen_decls(FILE *out);
+extern void firmbe_gen_routine(FILE *out, ir_graph *irg);
+
+#endif
diff --git a/ir/be/firm2arch_nodes_attr.h b/ir/be/firm2arch_nodes_attr.h
new file mode 100644 (file)
index 0000000..538b8b3
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef NODES_ATTR_H
+#define NODES_ATTR_H
+
+typedef struct {
+  tarval *tv;
+  void *reg_constraints;
+} asmop_attr;
+
+#endif