removed unused header
[libfirm] / ir / be / benode.c
index 706ef5d..06e0949 100644 (file)
@@ -1,17 +1,34 @@
-/**
- * @file   benode.c
- * @date   17.05.2005
- * @author Sebastian Hack
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
  *
- * Backend node support.
+ * This file is part of libFirm.
  *
- * This file provides Perm, Copy, Spill and Reload nodes.
+ * 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.
  *
- * Copyright (C) 2005-2006 Universitaet Karlsruhe
- * Released under the GPL
+ * 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       Backend node support for generic backend nodes.
+ * @author      Sebastian Hack
+ * @date        17.05.2005
+ * @version     $Id$
+ *
+ * Backend node support for generic backend nodes.
+ * This file provides Perm, Copy, Spill and Reload nodes.
  */
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
 #endif
 
 #include <stdlib.h>
@@ -190,7 +207,7 @@ static INLINE be_req_t *get_be_req(const ir_node *node, int pos)
        return pos < 0 ? &rd->req : &rd->in_req;
 }
 
-static inline arch_register_req_t *get_req(const ir_node *node, int pos)
+static INLINE arch_register_req_t *get_req(const ir_node *node, int pos)
 {
        be_req_t *bereq = get_be_req(node, pos);
        return &bereq->req;
@@ -1128,7 +1145,11 @@ be_node_get_irn_reg_req(const void *self, const ir_node *irn, int pos)
 const arch_register_t *
 be_node_get_irn_reg(const void *_self, const ir_node *irn)
 {
-       be_reg_data_t *r = retrieve_reg_data(irn);
+       be_reg_data_t *r;
+
+       if (get_irn_mode(irn) == mode_T)
+               return NULL;
+       r = retrieve_reg_data(irn);
        return r->reg;
 }
 
@@ -1245,7 +1266,8 @@ const arch_irn_handler_t be_node_irn_handler = {
 
 typedef struct {
        const arch_register_t *reg;
-       arch_register_req_t req;
+       arch_register_req_t    req;
+       arch_irn_flags_t       flags;
 } phi_attr_t;
 
 typedef struct {
@@ -1258,14 +1280,20 @@ typedef struct {
 #define get_phi_handler_from_handler(h)  container_of(h, phi_handler_t, irn_handler)
 #define get_phi_handler_from_ops(h)      container_of(h, phi_handler_t, irn_ops)
 
-static const void *phi_get_irn_ops(const arch_irn_handler_t *handler, const ir_node *irn)
+static
+const void *phi_get_irn_ops(const arch_irn_handler_t *handler,
+                            const ir_node *irn)
 {
-       const phi_handler_t *h = get_phi_handler_from_handler(handler);
-       return is_Phi(irn) && mode_is_datab(get_irn_mode(irn)) ? &h->irn_ops : NULL;
+       const phi_handler_t *h;
+       if(!is_Phi(irn) || !mode_is_datab(get_irn_mode(irn)))
+               return NULL;
+
+       h = get_phi_handler_from_handler(handler);
+       return &h->irn_ops;
 }
 
-static INLINE phi_attr_t *get_Phi_attr(const phi_handler_t *handler,
-                                       const ir_node *phi)
+static INLINE
+phi_attr_t *get_Phi_attr(const phi_handler_t *handler, const ir_node *phi)
 {
        phi_attr_t *attr = pmap_get(handler->phi_attrs, (void*) phi);
        if(attr == NULL) {
@@ -1363,49 +1391,75 @@ void be_set_phi_reg_req(const arch_env_t *arch_env, ir_node *node,
        memcpy(&attr->req, req, sizeof(req[0]));
 }
 
-static void phi_set_irn_reg(const void *self, ir_node *irn, const arch_register_t *reg)
+void be_set_phi_flags(const arch_env_t *arch_env, ir_node *node,
+                      arch_irn_flags_t flags)
+{
+       const arch_irn_ops_t *ops = arch_get_irn_ops(arch_env, node);
+       const phi_handler_t *handler = get_phi_handler_from_ops(ops);
+       phi_attr_t *attr;
+
+       assert(mode_is_datab(get_irn_mode(node)));
+
+       attr = get_Phi_attr(handler, node);
+       attr->flags = flags;
+}
+
+static
+void phi_set_irn_reg(const void *self, ir_node *irn, const arch_register_t *reg)
 {
        phi_handler_t *h = get_phi_handler_from_ops(self);
        phi_attr_t *attr = get_Phi_attr(h, irn);
        attr->reg = reg;
 }
 
-static const arch_register_t *phi_get_irn_reg(const void *self, const ir_node *irn)
+static
+const arch_register_t *phi_get_irn_reg(const void *self, const ir_node *irn)
 {
        phi_handler_t *h = get_phi_handler_from_ops(self);
        phi_attr_t *attr = get_Phi_attr(h, irn);
        return attr->reg;
 }
 
-static arch_irn_class_t phi_classify(const void *_self, const ir_node *irn)
+static
+arch_irn_class_t phi_classify(const void *self, const ir_node *irn)
 {
        return arch_irn_class_normal;
 }
 
-static arch_irn_flags_t phi_get_flags(const void *_self, const ir_node *irn)
+static
+arch_irn_flags_t phi_get_flags(const void *self, const ir_node *irn)
 {
-       return arch_irn_flags_none;
+       phi_handler_t *h = get_phi_handler_from_ops(self);
+       phi_attr_t *attr = get_Phi_attr(h, irn);
+       return attr->flags;
 }
 
-static ir_entity *phi_get_frame_entity(const void *_self, const ir_node *irn)
+static
+ir_entity *phi_get_frame_entity(const void *_self, const ir_node *irn)
 {
        return NULL;
 }
 
-static void phi_set_frame_entity(const void *_self, ir_node *irn, ir_entity *ent)
+static
+void phi_set_frame_entity(const void *_self, ir_node *irn, ir_entity *ent)
 {
+       assert(0);
 }
 
-static void phi_set_frame_offset(const void *_self, ir_node *irn, int bias)
+static
+void phi_set_frame_offset(const void *_self, ir_node *irn, int bias)
 {
+       assert(0);
 }
 
-static int phi_get_sp_bias(const void* self, const ir_node *irn)
+static
+int phi_get_sp_bias(const void* self, const ir_node *irn)
 {
        return 0;
 }
 
-static const arch_irn_ops_if_t phi_irn_ops = {
+static
+const arch_irn_ops_if_t phi_irn_ops = {
        phi_get_irn_reg_req,
        phi_set_irn_reg,
        phi_get_irn_reg,
@@ -1421,10 +1475,6 @@ static const arch_irn_ops_if_t phi_irn_ops = {
        NULL,    /* perform_memory_operand  */
 };
 
-static const arch_irn_handler_t phi_irn_handler = {
-       phi_get_irn_ops
-};
-
 arch_irn_handler_t *be_phi_handler_new(const arch_env_t *arch_env)
 {
        phi_handler_t *h           = xmalloc(sizeof(h[0]));
@@ -1442,12 +1492,6 @@ void be_phi_handler_free(arch_irn_handler_t *handler)
        free(handler);
 }
 
-const void *be_phi_get_irn_ops(const arch_irn_handler_t *self, const ir_node *irn)
-{
-       phi_handler_t *phi_handler = get_phi_handler_from_handler(self);
-       return is_Phi(irn) ? &phi_handler->irn_ops : NULL;
-}
-
 void be_phi_handler_reset(arch_irn_handler_t *handler)
 {
        phi_handler_t *h = get_phi_handler_from_handler(handler);