-/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-* All rights reserved.
-*
-* Authors: Martin Trapp, Christian Schaefer, Goetz Lindenmaier
-*
-*/
-
-/* $Id$ */
+/*
+ * Project: libFIRM
+ * File name: ir/ir/irnode.c
+ * Purpose: Representation of an intermediate operation.
+ * Author: Martin Trapp, Christian Schaefer
+ * Modified by: Goetz Lindenmaier
+ * Created:
+ * CVS-ID: $Id$
+ * Copyright: (c) 1998-2003 Universität Karlsruhe
+ * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+ */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
+#include "ident.h"
#include "irnode_t.h"
#include "irgraph_t.h"
#include "irmode_t.h"
-#include "typegmod_t.h"
+#include "typegmod.h"
#include "array.h"
#include "irbackedge_t.h"
#include "irdump.h"
get_irn_opname (const ir_node *node)
{
assert(node);
- return id_to_str(node->op->name);
+ return get_id_str(node->op->name);
}
INLINE ident *
#ifdef DEBUG_libfirm
return node->node_nr;
#else
- return 0;
+ return (long)&node;
#endif
}
-INLINE tarval *
+INLINE const_attr
get_irn_const_attr (ir_node *node)
{
assert (node->op == op_Const);
set_irn_n(node, -1, block);
}
+/* Test whether arbitrary node is frame pointer, i.e. Proj(pn_Start_P_frame_base)
+ * from Start. If so returns frame type, else Null. */
+type *is_frame_pointer(ir_node *n) {
+ if ((get_irn_op(n) == op_Proj) &&
+ (get_Proj_proj(n) == pn_Start_P_frame_base)) {
+ ir_node *start = get_Proj_pred(n);
+ if (get_irn_op(start) == op_Start) {
+ return get_irg_frame_type(get_irn_irg(start));
+ }
+ }
+ return NULL;
+}
+
+/* Test whether arbitrary node is globals pointer, i.e. Proj(pn_Start_P_globals)
+ * from Start. If so returns global type, else Null. */
+type *is_globals_pointer(ir_node *n) {
+ if ((get_irn_op(n) == op_Proj) &&
+ (get_Proj_proj(n) == pn_Start_P_globals)) {
+ ir_node *start = get_Proj_pred(n);
+ if (get_irn_op(start) == op_Start) {
+ return get_glob_type();
+ }
+ }
+ return NULL;
+}
+
+/* Test whether arbitrary node is value arg base, i.e. Proj(pn_Start_P_value_arg_base)
+ * from Start. If so returns 1, else 0. */
+int is_value_arg_pointer(ir_node *n) {
+ if ((get_irn_op(n) == op_Proj) &&
+ (get_Proj_proj(n) == pn_Start_P_value_arg_base) &&
+ (get_irn_op(get_Proj_pred(n)) == op_Start))
+ return 1;
+ return 0;
+}
+
/* Returns an array with the predecessors of the Block. Depending on
the implementation of the graph datastructure this can be a copy of
the internal representation of predecessors as well as the internal
node->attr.block.graph_arr[pos+1] = value;
}
-/* handler handling for Blocks */
+/* handler handling for Blocks * /
void
set_Block_handler (ir_node *block, ir_node *handler) {
assert ((block->op == op_Block));
return (block->attr.block.handler_entry);
}
-/* handler handling for Nodes */
+/ * handler handling for Nodes * /
void
set_Node_handler (ir_node *node, ir_node *handler) {
set_Block_handler (get_nodes_Block (node), handler);
return (get_Block_handler (get_nodes_Block (node)));
}
-/* exc_t handling for Blocks */
+/ * exc_t handling for Blocks * /
void set_Block_exc (ir_node *block, exc_t exc) {
assert ((block->op == op_Block));
block->attr.block.exc = exc;
exc_t get_Block_exc (ir_node *block) {
assert ((block->op == op_Block));
-
return (block->attr.block.exc);
}
-/* exc_t handling for Nodes */
+/ * exc_t handling for Nodes * /
void set_Node_exc (ir_node *node, exc_t exc) {
set_Block_exc (get_nodes_Block (node), exc);
}
exc_t get_Node_exc (ir_node *node) {
return (get_Block_exc (get_nodes_Block (node)));
}
+*/
void set_Block_cg_cfgpred_arr(ir_node * node, int arity, ir_node ** in) {
assert(node->op == op_Block);
node->attr.block.in_cg = NULL;
}
+/* Start references the irg it is in. */
+INLINE ir_graph *
+get_Start_irg(ir_node *node) {
+ return get_irn_irg(node);
+}
+
+INLINE void
+set_Start_irg(ir_node *node, ir_graph *irg) {
+ assert(node->op == op_Start);
+ assert(is_ir_graph(irg));
+ assert(0 && " Why set irg? ");
+ //node->attr.start.irg = irg;
+}
+
INLINE int
get_End_n_keepalives(ir_node *end) {
assert (end->op == op_End);
INLINE void
free_End (ir_node *end) {
assert (end->op == op_End);
+ end->kind = k_BAD;
/* DEL_ARR_F(end->in); GL @@@ tut nicht ! */
end->in = NULL; /* @@@ make sure we get an error if we use the
in array afterwards ... */
}
-ir_graph *get_EndReg_irg (const ir_node *end) {
- assert (end->op == op_EndReg);
- return end->attr.end.irg;
+ir_graph *get_EndReg_irg (ir_node *end) {
+ return get_irn_irg(end);
}
-ir_graph *get_EndExcept_irg (const ir_node *end) {
- assert (end->op == op_EndReg);
- return end->attr.end.irg;
+ir_graph *get_EndExcept_irg (ir_node *end) {
+ return get_irn_irg(end);
}
/*
INLINE tarval *get_Const_tarval (ir_node *node) {
assert (node->op == op_Const);
- return get_irn_const_attr(node);
+ return node->attr.con.tv;
}
INLINE void
set_Const_tarval (ir_node *node, tarval *con) {
assert (node->op == op_Const);
- node->attr.con = con;
+ node->attr.con.tv = con;
+}
+
+
+/* The source language type. Must be an atomic type. Mode of type must
+ be mode of node. For tarvals from entities type must be pointer to
+ entity type. */
+INLINE type *
+get_Const_type (ir_node *node) {
+ assert (node->op == op_Const);
+ return node->attr.con.tp;
}
+INLINE void
+set_Const_type (ir_node *node, type *tp) {
+ assert (node->op == op_Const);
+ if (tp != unknown_type) {
+ assert (is_atomic_type(tp));
+ assert (get_type_mode(tp) == get_irn_mode(node));
+ assert (!tarval_is_entity(get_Const_tarval(node)) ||
+ (is_pointer_type(tp) &&
+ (get_pointer_points_to_type(tp) ==
+ get_entity_type(get_tarval_entity(get_Const_tarval(node))))));
+ }
+
+ node->attr.con.tp = tp;
+}
+
+
INLINE symconst_kind
get_SymConst_kind (const ir_node *node) {
assert (node->op == op_SymConst);
set_irn_n(node, 0, ptr);
}
ir_graph * get_CallBegin_irg (ir_node *node) {
- assert(node->op == op_CallBegin);
- return node->attr.callbegin.irg;
+ return get_irn_irg(node);
}
ir_node * get_CallBegin_call (ir_node *node) {
assert(node->op == op_CallBegin);
set_irn_n(node, 0, pred);
}
+INLINE ir_node *get_Confirm_value (ir_node *node) {
+ assert (node->op == op_Confirm);
+ return get_irn_n(node, 0);
+}
+INLINE void set_Confirm_value (ir_node *node, ir_node *value) {
+ assert (node->op == op_Confirm);
+ set_irn_n(node, 0, value);
+}
+INLINE ir_node *get_Confirm_bound (ir_node *node) {
+ assert (node->op == op_Confirm);
+ return get_irn_n(node, 1);
+}
+INLINE void set_Confirm_bound (ir_node *node, ir_node *bound) {
+ assert (node->op == op_Confirm);
+ set_irn_n(node, 0, bound);
+}
+INLINE pn_Cmp get_Confirm_cmp (ir_node *node) {
+ assert (node->op == op_Confirm);
+ return node->attr.confirm_cmp;
+}
+INLINE void set_Confirm_cmp (ir_node *node, pn_Cmp cmp) {
+ assert (node->op == op_Confirm);
+ node->attr.confirm_cmp = cmp;
+}
+
INLINE ir_node *
get_Filter_pred (ir_node *node) {
INLINE ir_graph *
get_irn_irg(ir_node *node) {
- if (get_irn_op(node) == op_CallBegin) {
- return node->attr.callbegin.irg;
- } else if (get_irn_op(node) == op_EndReg ||
- get_irn_op(node) == op_EndExcept) {
- return node->attr.end.irg;
- } else {
- assert(0 && "no irg attr");
- return NULL;
- }
+ if (get_irn_op(node) != op_Block)
+ node = get_nodes_block(node);
+ assert(get_irn_op(node) == op_Block);
+ return node->attr.block.irg;
}
}
ir_graph *get_ip_cfop_irg(ir_node *n) {
- switch (get_irn_opcode(n)) {
- case iro_EndReg:
- return get_EndReg_irg(n);
- case iro_EndExcept:
- return get_EndExcept_irg(n);
- case iro_CallBegin:
- return get_CallBegin_irg(n);
- default:
- assert(is_ip_cfop(n));
- }
- return NULL; /* should never be reached */
+ return get_irn_irg(n);
}
/* Returns true if the operation can change the control flow because