#include "irgraph_t.h"
#include "irmode_t.h"
#include "typegmod.h"
-#include "array.h"
#include "irbackedge_t.h"
#include "irdump.h"
-#include "irflag.h"
#include "irop_t.h"
-
#include "irprog_t.h"
+#include "firmstat.h"
+
/* some constants fixing the positions of nodes predecessors
in the in array */
-#define CALL_PARAM_OFFSET 2
-#define SEL_INDEX_OFFSET 2
-#define RETURN_RESULT_OFFSET 1 /* mem is not a result */
-#define END_KEEPALIVE_OFFSET 0
-
-/* Declarations for inlineing */
-INLINE ir_node ** get_irn_in (const ir_node *node);
-INLINE ir_mode *get_irn_mode (const ir_node *node);
-INLINE ir_op *get_irn_op (const ir_node *node);
-INLINE opcode get_irn_opcode (const ir_node *node);
-INLINE ident *get_irn_opident (const ir_node *node);
-INLINE type *get_SymConst_type (ir_node *node);
-INLINE ir_node *skip_nop (ir_node *node);
-INLINE int is_Proj (const ir_node *node);
-
+#define CALL_PARAM_OFFSET 2
+#define FUNCCALL_PARAM_OFFSET 1
+#define SEL_INDEX_OFFSET 2
+#define RETURN_RESULT_OFFSET 1 /* mem is not a result */
+#define END_KEEPALIVE_OFFSET 0
static const char *pnc_name_arr [] = {
"False", "Eq", "Lt", "Le",
"Ne", "True"
};
-INLINE const char *get_pnc_string(int pnc) {
+/**
+ * returns the pnc name from an pnc constant
+ */
+const char *get_pnc_string(int pnc) {
return pnc_name_arr[pnc];
}
-
+/**
+ * Calculates the negated pnc condition.
+ */
int
get_negated_pnc(int pnc) {
switch (pnc) {
};
const char *symconst_name_arr [] = {
- "type_tag", "size", "linkage_ptr_info"
+ "type_tag", "size", "addr_name", "addr_ent"
};
void
{
}
-/* irnode constructor */
-/* create a new irnode in irg, with an op, mode, arity and */
-/* some incoming irnodes */
-/* this constructor is used in every specified irnode constructor */
-INLINE ir_node *
+/*
+ * irnode constructor.
+ * Create a new irnode in irg, with an op, mode, arity and
+ * some incoming irnodes.
+ * If arity is negative, a node with a dynamic array is created.
+ */
+ir_node *
new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mode,
- int arity, ir_node **in)
+ int arity, ir_node **in)
{
ir_node *res;
int node_size = offsetof (ir_node, attr) + op->attr_size;
+ assert(irg && op && mode);
res = (ir_node *) obstack_alloc (irg->obst, node_size);
+ memset((void *)res, 0, node_size);
res->kind = k_ir_node;
res->op = op;
res->node_nr = get_irp_new_node_nr();
#endif
+ stat_new_node(res);
+
return res;
}
/* Copies all attributes stored in the old node to the new node.
Assumes both have the same opcode and sufficient size. */
void
-copy_attrs (ir_node *old, ir_node *new) {
- assert (get_irn_op(old) == get_irn_op(new));
- memcpy (&new->attr, &old->attr, get_op_attr_size(get_irn_op(old)));
+copy_attrs (const ir_node *old_node, ir_node *new_node) {
+ assert(get_irn_op(old_node) == get_irn_op(new_node));
+ memcpy(&new_node->attr, &old_node->attr, get_op_attr_size(get_irn_op(old_node)));
}
-/** getting some parameters from ir_nodes **/
+/*-- getting some parameters from ir_nodes --*/
int
-is_ir_node (void *thing) {
- assert(thing);
- if (get_kind(thing) == k_ir_node)
- return 1;
- else
- return 0;
+(is_ir_node)(const void *thing) {
+ return __is_ir_node(thing);
}
-/* returns the number of predecessors without the block predecessor. */
-INLINE int
-get_irn_intra_arity (const ir_node *node) {
- assert(node);
- return ARR_LEN(node->in) - 1;
+int
+(get_irn_intra_arity)(const ir_node *node) {
+ return __get_irn_intra_arity(node);
}
-/* returns the number of predecessors without the block predecessor. */
-INLINE int
-get_irn_inter_arity (const ir_node *node) {
- assert(node);
- if (get_irn_opcode(node) == iro_Filter) {
- assert(node->attr.filter.in_cg);
- return ARR_LEN(node->attr.filter.in_cg) - 1;
- } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
- return ARR_LEN(node->attr.block.in_cg) - 1;
- }
- return get_irn_intra_arity(node);
+int
+(get_irn_inter_arity)(const ir_node *node) {
+ return __get_irn_inter_arity(node);
}
-/* returns the number of predecessors without the block predecessor. */
-INLINE int
-get_irn_arity (const ir_node *node) {
- assert(node);
- if (interprocedural_view) return get_irn_inter_arity(node);
- return get_irn_intra_arity(node);
+int
+(get_irn_arity)(const ir_node *node) {
+ return __get_irn_arity(node);
}
/* Returns the array with ins. This array is shifted with respect to the
The order of the predecessors in this array is not guaranteed, except that
lists of operands as predecessors of Block or arguments of a Call are
consecutive. */
-INLINE ir_node **
+ir_node **
get_irn_in (const ir_node *node) {
assert(node);
if (interprocedural_view) { /* handle Filter and Block specially */
return node->in;
}
-INLINE void
+void
set_irn_in (ir_node *node, int arity, ir_node **in) {
ir_node *** arr;
assert(node);
memcpy((*arr) + 1, in, sizeof(ir_node *) * arity);
}
-INLINE ir_node *
-get_irn_intra_n (ir_node *node, int n) {
- return (node->in[n + 1] = skip_nop(node->in[n + 1]));
+ir_node *
+(get_irn_intra_n)(ir_node *node, int n) {
+ return __get_irn_intra_n (node, n);
}
-INLINE ir_node*
-get_irn_inter_n (ir_node *node, int n) {
- /* handle Filter and Block specially */
- if (get_irn_opcode(node) == iro_Filter) {
- assert(node->attr.filter.in_cg);
- return (node->attr.filter.in_cg[n + 1] = skip_nop(node->attr.filter.in_cg[n + 1]));
- } else if (get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
- return (node->attr.block.in_cg[n + 1] = skip_nop(node->attr.block.in_cg[n + 1]));
- }
-
- return get_irn_intra_n (node, n);
+ir_node *
+(get_irn_inter_n)(ir_node *node, int n) {
+ return __get_irn_inter_n (node, n);
}
-/* to iterate through the predecessors without touching the array */
-/* To iterate over the operands iterate from 0 to i < get_irn_arity(),
- to iterate includind the Block predecessor iterate from i = -1 to
- i < get_irn_arity.
- If it is a block, the entry -1 is NULL. */
-INLINE ir_node *
-get_irn_n (ir_node *node, int n) {
- assert(node); assert(-1 <= n && n < get_irn_arity(node));
- if (interprocedural_view) return get_irn_inter_n (node, n);
- return get_irn_intra_n (node, n);
+ir_node *
+(get_irn_n)(ir_node *node, int n) {
+ return __get_irn_n (node, n);
}
-
-INLINE void
+void
set_irn_n (ir_node *node, int n, ir_node *in) {
- assert(node && -1 <= n && n < get_irn_arity(node));
+ assert(node && node->kind == k_ir_node && -1 <= n && n < get_irn_arity(node));
+ assert(in && in->kind == k_ir_node);
if ((n == -1) && (get_irn_opcode(node) == iro_Filter)) {
/* Change block pred in both views! */
node->in[n + 1] = in;
node->in[n + 1] = in;
}
-INLINE ir_mode *
-get_irn_mode (const ir_node *node)
-{
- assert (node);
- return node->mode;
+ir_mode *
+(get_irn_mode)(const ir_node *node) {
+ return __get_irn_mode(node);
}
-INLINE void
-set_irn_mode (ir_node *node, ir_mode *mode)
+void
+(set_irn_mode)(ir_node *node, ir_mode *mode)
{
- assert (node);
- node->mode=mode;
- return;
+ __set_irn_mode(node, mode);
}
-INLINE modecode
+modecode
get_irn_modecode (const ir_node *node)
{
assert (node);
}
/** Gets the string representation of the mode .*/
-INLINE const char *
+const char *
get_irn_modename (const ir_node *node)
{
assert(node);
return get_mode_name(node->mode);
}
-INLINE ident *
+ident *
get_irn_modeident (const ir_node *node)
{
assert(node);
return get_mode_ident(node->mode);
}
-INLINE ir_op *
-get_irn_op (const ir_node *node)
+ir_op *
+(get_irn_op)(const ir_node *node)
{
- assert (node);
- return node->op;
+ return __get_irn_op(node);
}
/* should be private to the library: */
-INLINE void
+void
set_irn_op (ir_node *node, ir_op *op)
{
assert (node);
node->op = op;
}
-INLINE opcode
-get_irn_opcode (const ir_node *node)
+opcode
+(get_irn_opcode)(const ir_node *node)
{
- assert (node);
- assert (k_ir_node == get_kind(node));
- assert (node -> op);
- return node->op->code;
+ return __get_irn_opcode(node);
}
-INLINE const char *
+const char *
get_irn_opname (const ir_node *node)
{
assert(node);
+ if ((get_irn_op((ir_node *)node) == op_Phi) &&
+ (get_irg_phase_state(get_irn_irg((ir_node *)node)) == phase_building) &&
+ (get_irn_arity((ir_node *)node) == 0)) return "Phi0";
return get_id_str(node->op->name);
}
-INLINE ident *
+ident *
get_irn_opident (const ir_node *node)
{
assert(node);
return node->op->name;
}
-INLINE unsigned long
-get_irn_visited (const ir_node *node)
+unsigned long
+(get_irn_visited)(const ir_node *node)
{
- assert (node);
- return node->visited;
+ return __get_irn_visited(node);
}
-INLINE void
-set_irn_visited (ir_node *node, unsigned long visited)
+void
+(set_irn_visited)(ir_node *node, unsigned long visited)
{
- assert (node);
- node->visited = visited;
+ __set_irn_visited(node, visited);
}
-INLINE void
-mark_irn_visited (ir_node *node) {
- assert (node);
- node->visited = current_ir_graph->visited;
+void
+(mark_irn_visited)(ir_node *node) {
+ __mark_irn_visited(node);
}
-INLINE int
-irn_not_visited (const ir_node *node) {
- assert (node);
- return (node->visited < current_ir_graph->visited);
+int
+(irn_not_visited)(const ir_node *node) {
+ return __irn_not_visited(node);
}
-INLINE int
-irn_visited (const ir_node *node) {
- assert (node);
- return (node->visited >= current_ir_graph->visited);
+int
+(irn_visited)(const ir_node *node) {
+ return __irn_visited(node);
}
-INLINE void
-set_irn_link (ir_node *node, void *link) {
- assert (node);
- /* Link field is used for Phi construction and various optimizations
- in iropt. */
- assert(get_irg_phase_state(current_ir_graph) != phase_building);
+void
+(set_irn_link)(ir_node *node, void *link) {
+ __set_irn_link(node, link);
+}
- node->link = link;
+void *
+(get_irn_link)(const ir_node *node) {
+ return __get_irn_link(node);
}
-INLINE void *
-get_irn_link (const ir_node *node) {
- assert (node);
- return node->link;
+op_pin_state
+(get_irn_pinned)(const ir_node *node) {
+ return __get_irn_pinned(node);
+}
+
+void set_irn_pinned(ir_node *node, op_pin_state state) {
+ /* due to optimization an opt may be turned into a Tuple */
+ if (get_irn_op(node) == op_Tuple)
+ return;
+
+ assert(node && get_op_pinned(get_irn_op(node)) == op_pin_state_exc_pinned);
+ assert(state == op_pin_state_pinned || state == op_pin_state_floats);
+
+ node->attr.except.pin_state = state;
+}
+
+#ifdef DO_HEAPANALYSIS
+/* Access the abstract interpretation information of a node.
+ Returns NULL if no such information is available. */
+struct abstval *get_irn_abst_value(ir_node *n) {
+ return n->av;
}
+/* Set the abstract interpretation information of a node. */
+void set_irn_abst_value(ir_node *n, struct abstval *os) {
+ n->av = os;
+}
+struct section *firm_get_irn_section(ir_node *n) {
+ return n->sec;
+}
+void firm_set_irn_section(ir_node *n, struct section *s) {
+ n->sec = s;
+}
+#endif /* DO_HEAPANALYSIS */
+
/* Outputs a unique number for this node */
-INLINE long
+long
get_irn_node_nr(const ir_node *node) {
assert(node);
#ifdef DEBUG_libfirm
return node->node_nr;
#else
- return (long)&node;
+ return (long)node;
#endif
}
-INLINE const_attr
+const_attr
get_irn_const_attr (ir_node *node)
{
assert (node->op == op_Const);
return node->attr.con;
}
-INLINE long
+long
get_irn_proj_attr (ir_node *node)
{
assert (node->op == op_Proj);
return node->attr.proj;
}
-INLINE alloc_attr
+alloc_attr
get_irn_alloc_attr (ir_node *node)
{
assert (node->op == op_Alloc);
return node->attr.a;
}
-INLINE type *
+type *
get_irn_free_attr (ir_node *node)
{
assert (node->op == op_Free);
return node->attr.f = skip_tid(node->attr.f);
}
-INLINE symconst_attr
+symconst_attr
get_irn_symconst_attr (ir_node *node)
{
assert (node->op == op_SymConst);
return node->attr.i;
}
-INLINE type *
+type *
get_irn_call_attr (ir_node *node)
{
assert (node->op == op_Call);
return node->attr.call.cld_tp = skip_tid(node->attr.call.cld_tp);
}
-INLINE sel_attr
+type *
+get_irn_funccall_attr (ir_node *node)
+{
+ assert (node->op == op_FuncCall);
+ return node->attr.call.cld_tp = skip_tid(node->attr.call.cld_tp);
+}
+
+sel_attr
get_irn_sel_attr (ir_node *node)
{
assert (node->op == op_Sel);
return node->attr.s;
}
-INLINE int
+int
get_irn_phi_attr (ir_node *node)
{
assert (node->op == op_Phi);
return node->attr.phi0_pos;
}
-INLINE block_attr
+block_attr
get_irn_block_attr (ir_node *node)
{
assert (node->op == op_Block);
return node->attr.block;
}
+load_attr
+get_irn_load_attr (ir_node *node)
+{
+ assert (node->op == op_Load);
+ return node->attr.load;
+}
+
+store_attr
+get_irn_store_attr (ir_node *node)
+{
+ assert (node->op == op_Store);
+ return node->attr.store;
+}
+
+except_attr
+get_irn_except_attr (ir_node *node)
+{
+ assert (node->op == op_Div || node->op == op_Quot ||
+ node->op == op_DivMod || node->op == op_Mod);
+ return node->attr.except;
+}
+
/** manipulate fields of individual nodes **/
/* this works for all except Block */
ir_node *
-get_nodes_Block (ir_node *node) {
+get_nodes_block (ir_node *node) {
assert (!(node->op == op_Block));
return get_irn_n(node, -1);
}
-INLINE void
-set_nodes_Block (ir_node *node, ir_node *block) {
+void
+set_nodes_block (ir_node *node, ir_node *block) {
assert (!(node->op == op_Block));
set_irn_n(node, -1, block);
}
}
/* Returns an array with the predecessors of the Block. Depending on
- the implementation of the graph datastructure this can be a copy of
+ the implementation of the graph data structure this can be a copy of
the internal representation of predecessors as well as the internal
array itself. Therefore writing to this array might obstruct the ir. */
-INLINE ir_node **
+ir_node **
get_Block_cfgpred_arr (ir_node *node)
{
assert ((node->op == op_Block));
}
-INLINE int
+int
get_Block_n_cfgpreds (ir_node *node) {
assert ((node->op == op_Block));
- return (get_irn_arity(node));
+ return get_irn_arity(node);
}
-INLINE ir_node *
+ir_node *
get_Block_cfgpred (ir_node *node, int pos) {
+ assert(node);
assert (node->op == op_Block);
- /* debug @@@
- if (-1 > pos || get_irn_arity(node) <= pos) {
- dump_ir_block_graph(current_ir_graph);
- printf("pos: %d, arity: %d ", pos, get_irn_arity(node));
- DDMN(node);
- } */
- assert(node); assert(-1 <= pos && pos < get_irn_arity(node));
+ assert(-1 <= pos && pos < get_irn_arity(node));
return get_irn_n(node, pos);
}
-INLINE void
+void
set_Block_cfgpred (ir_node *node, int pos, ir_node *pred) {
assert (node->op == op_Block);
set_irn_n(node, pos, pred);
}
-INLINE bool
+bool
get_Block_matured (ir_node *node) {
assert (node->op == op_Block);
return node->attr.block.matured;
}
-INLINE void
+void
set_Block_matured (ir_node *node, bool matured) {
assert (node->op == op_Block);
node->attr.block.matured = matured;
}
-INLINE unsigned long
+unsigned long
get_Block_block_visited (ir_node *node) {
assert (node->op == op_Block);
return node->attr.block.block_visited;
}
-INLINE void
+void
set_Block_block_visited (ir_node *node, unsigned long visit) {
assert (node->op == op_Block);
node->attr.block.block_visited = visit;
}
/* For this current_ir_graph must be set. */
-INLINE void
+void
mark_Block_block_visited (ir_node *node) {
assert (node->op == op_Block);
node->attr.block.block_visited = get_irg_block_visited(current_ir_graph);
}
-INLINE int
+int
Block_not_block_visited(ir_node *node) {
assert (node->op == op_Block);
return (node->attr.block.block_visited < get_irg_block_visited(current_ir_graph));
}
-INLINE ir_node *
+ir_node *
get_Block_graph_arr (ir_node *node, int pos) {
assert (node->op == op_Block);
return node->attr.block.graph_arr[pos+1];
}
-INLINE void
+void
set_Block_graph_arr (ir_node *node, int pos, ir_node *value) {
assert (node->op == op_Block);
node->attr.block.graph_arr[pos+1] = value;
}
-/* handler handling for Blocks * /
-void
-set_Block_handler (ir_node *block, ir_node *handler) {
- assert ((block->op == op_Block));
- assert ((handler->op == op_Block));
- block->attr.block.handler_entry = handler;
-}
-
-ir_node *
-get_Block_handler (ir_node *block) {
- assert ((block->op == op_Block));
- return (block->attr.block.handler_entry);
-}
-
-/ * handler handling for Nodes * /
-void
-set_Node_handler (ir_node *node, ir_node *handler) {
- set_Block_handler (get_nodes_Block (node), handler);
-}
-
-ir_node *
-get_Node_handler (ir_node *node) {
- return (get_Block_handler (get_nodes_Block (node)));
-}
-
-/ * 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 * /
-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);
if (node->attr.block.in_cg == NULL || arity != ARR_LEN(node->attr.block.in_cg) - 1) {
node->attr.block.cg_backedge = new_backedge_arr(current_ir_graph->obst, arity);
{
/* Fix backedge array. fix_backedges operates depending on
- interprocedural_view. */
+ interprocedural_view. */
bool ipv = interprocedural_view;
interprocedural_view = true;
fix_backedges(current_ir_graph->obst, node);
void set_Block_cg_cfgpred(ir_node * node, int pos, ir_node * pred) {
assert(node->op == op_Block &&
- node->attr.block.in_cg &&
- 0 <= pos && pos < ARR_LEN(node->attr.block.in_cg) - 1);
+ node->attr.block.in_cg &&
+ 0 <= pos && pos < ARR_LEN(node->attr.block.in_cg) - 1);
node->attr.block.in_cg[pos + 1] = pred;
}
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
+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;
+ assert(0 && " Why set irg? -- use set_irn_irg");
}
-INLINE int
+int
get_End_n_keepalives(ir_node *end) {
assert (end->op == op_End);
return (get_irn_arity(end) - END_KEEPALIVE_OFFSET);
}
-INLINE ir_node *
+ir_node *
get_End_keepalive(ir_node *end, int pos) {
assert (end->op == op_End);
return get_irn_n(end, pos + END_KEEPALIVE_OFFSET);
}
-INLINE void
+void
add_End_keepalive (ir_node *end, ir_node *ka) {
assert (end->op == op_End);
ARR_APP1 (ir_node *, end->in, ka);
}
-INLINE void
+void
set_End_keepalive(ir_node *end, int pos, ir_node *ka) {
assert (end->op == op_End);
set_irn_n(end, pos + END_KEEPALIVE_OFFSET, ka);
}
-INLINE void
+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 ... */
+ in array afterwards ... */
}
-ir_graph *get_EndReg_irg (ir_node *end) {
- return get_irn_irg(end);
-}
-
-ir_graph *get_EndExcept_irg (ir_node *end) {
- return get_irn_irg(end);
-}
/*
> Implementing the case construct (which is where the constant Proj node is
I know it's complicated.
Basically there are two proglems:
- determining the gaps between the projs
- - determining the biggest case constant to konw the proj number for
+ - determining the biggest case constant to know the proj number for
the default node.
I see several solutions:
1. Introduce a ProjDefault node. Solves both problems.
Solution 2 seems to be the best:
Computing the gaps in the Firm representation is not too hard, i.e.,
-libfirm can implement a routine that transforms betweeen the two
+libFIRM can implement a routine that transforms between the two
flavours. This is also possible for 1) but 2) does not require to
change any existing optimization.
Further it should be far simpler to determine the biggest constant than
dataflow analysis and 3) does not allow to convert the representation to
2a).
*/
-INLINE ir_node *
+ir_node *
get_Cond_selector (ir_node *node) {
assert (node->op == op_Cond);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Cond_selector (ir_node *node, ir_node *selector) {
assert (node->op == op_Cond);
set_irn_n(node, 0, selector);
}
-INLINE cond_kind
+cond_kind
get_Cond_kind (ir_node *node) {
assert (node->op == op_Cond);
return node->attr.c.kind;
}
-INLINE void
+void
set_Cond_kind (ir_node *node, cond_kind kind) {
assert (node->op == op_Cond);
node->attr.c.kind = kind;
}
-INLINE ir_node *
+long
+get_Cond_defaultProj (ir_node *node) {
+ assert (node->op == op_Cond);
+ return node->attr.c.default_proj;
+}
+
+ir_node *
get_Return_mem (ir_node *node) {
assert (node->op == op_Return);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Return_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_Return);
set_irn_n(node, 0, mem);
}
-INLINE int
+int
get_Return_n_ress (ir_node *node) {
assert (node->op == op_Return);
return (get_irn_arity(node) - RETURN_RESULT_OFFSET);
}
-INLINE ir_node **
+ir_node **
get_Return_res_arr (ir_node *node)
{
assert ((node->op == op_Return));
}
/*
-INLINE void
+void
set_Return_n_res (ir_node *node, int results) {
assert (node->op == op_Return);
}
*/
-INLINE ir_node *
+ir_node *
get_Return_res (ir_node *node, int pos) {
assert (node->op == op_Return);
assert (get_Return_n_ress(node) > pos);
return get_irn_n(node, pos + RETURN_RESULT_OFFSET);
}
-INLINE void
+void
set_Return_res (ir_node *node, int pos, ir_node *res){
assert (node->op == op_Return);
set_irn_n(node, pos + RETURN_RESULT_OFFSET, res);
}
-INLINE ir_node *
+ir_node *
get_Raise_mem (ir_node *node) {
assert (node->op == op_Raise);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Raise_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_Raise);
set_irn_n(node, 0, mem);
}
-INLINE ir_node *
+ir_node *
get_Raise_exo_ptr (ir_node *node) {
assert (node->op == op_Raise);
return get_irn_n(node, 1);
}
-INLINE void
+void
set_Raise_exo_ptr (ir_node *node, ir_node *exo_ptr) {
assert (node->op == op_Raise);
set_irn_n(node, 1, exo_ptr);
}
-INLINE tarval *get_Const_tarval (ir_node *node) {
+tarval *get_Const_tarval (ir_node *node) {
assert (node->op == op_Const);
return node->attr.con.tv;
}
-INLINE void
+void
set_Const_tarval (ir_node *node, tarval *con) {
assert (node->op == op_Const);
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 *
+type *
get_Const_type (ir_node *node) {
assert (node->op == op_Const);
return node->attr.con.tp;
}
-INLINE void
+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
+symconst_kind
get_SymConst_kind (const ir_node *node) {
assert (node->op == op_SymConst);
return node->attr.i.num;
}
-INLINE void
+void
set_SymConst_kind (ir_node *node, symconst_kind num) {
assert (node->op == op_SymConst);
node->attr.i.num = num;
}
-INLINE type *
+type *
get_SymConst_type (ir_node *node) {
assert ( (node->op == op_SymConst)
- && ( get_SymConst_kind(node) == type_tag
- || get_SymConst_kind(node) == size));
- return node->attr.i.tori.typ = skip_tid(node->attr.i.tori.typ);
+ && ( get_SymConst_kind(node) == symconst_type_tag
+ || get_SymConst_kind(node) == symconst_size));
+ return node->attr.i.sym.type_p = skip_tid(node->attr.i.sym.type_p);
}
-INLINE void
+void
set_SymConst_type (ir_node *node, type *tp) {
assert ( (node->op == op_SymConst)
- && ( get_SymConst_kind(node) == type_tag
- || get_SymConst_kind(node) == size));
- node->attr.i.tori.typ = tp;
+ && ( get_SymConst_kind(node) == symconst_type_tag
+ || get_SymConst_kind(node) == symconst_size));
+ node->attr.i.sym.type_p = tp;
+}
+
+ident *
+get_SymConst_name (ir_node *node) {
+ assert ( (node->op == op_SymConst)
+ && (get_SymConst_kind(node) == symconst_addr_name));
+ return node->attr.i.sym.ident_p;
+}
+
+void
+set_SymConst_name (ir_node *node, ident *name) {
+ assert ( (node->op == op_SymConst)
+ && (get_SymConst_kind(node) == symconst_addr_name));
+ node->attr.i.sym.ident_p = name;
}
-INLINE ident *
-get_SymConst_ptrinfo (ir_node *node) {
+
+/* Only to access SymConst of kind symconst_addr_ent. Else assertion: */
+entity *get_SymConst_entity (ir_node *node) {
assert ( (node->op == op_SymConst)
- && (get_SymConst_kind(node) == linkage_ptr_info));
- return node->attr.i.tori.ptrinfo;
+ && (get_SymConst_kind (node) == symconst_addr_ent));
+ return node->attr.i.sym.entity_p;
}
-INLINE void
-set_SymConst_ptrinfo (ir_node *node, ident *ptrinfo) {
+void set_SymConst_entity (ir_node *node, entity *ent) {
assert ( (node->op == op_SymConst)
- && (get_SymConst_kind(node) == linkage_ptr_info));
- node->attr.i.tori.ptrinfo = ptrinfo;
+ && (get_SymConst_kind(node) == symconst_addr_ent));
+ node->attr.i.sym.entity_p = ent;
}
-INLINE type_or_id_p
-get_SymConst_type_or_id (ir_node *node) {
+
+union symconst_symbol
+get_SymConst_symbol (ir_node *node) {
assert (node->op == op_SymConst);
- return &(node->attr.i.tori);
+ return node->attr.i.sym;
}
-INLINE void
-set_SymConst_type_or_id (ir_node *node, type_or_id_p tori) {
+void
+set_SymConst_symbol (ir_node *node, union symconst_symbol sym) {
assert (node->op == op_SymConst);
- memcpy (&(node->attr.i.tori), tori, sizeof(type_or_id));
+ //memcpy (&(node->attr.i.sym), sym, sizeof(type_or_id));
+ node->attr.i.sym = sym;
}
-INLINE ir_node *
+ir_node *
get_Sel_mem (ir_node *node) {
assert (node->op == op_Sel);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Sel_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_Sel);
set_irn_n(node, 0, mem);
}
-INLINE ir_node *
+ir_node *
get_Sel_ptr (ir_node *node) {
assert (node->op == op_Sel);
return get_irn_n(node, 1);
}
-INLINE void
+void
set_Sel_ptr (ir_node *node, ir_node *ptr) {
assert (node->op == op_Sel);
set_irn_n(node, 1, ptr);
}
-INLINE int
+int
get_Sel_n_indexs (ir_node *node) {
assert (node->op == op_Sel);
return (get_irn_arity(node) - SEL_INDEX_OFFSET);
}
-INLINE ir_node **
+ir_node **
get_Sel_index_arr (ir_node *node)
{
assert ((node->op == op_Sel));
return NULL;
}
-INLINE ir_node *
+ir_node *
get_Sel_index (ir_node *node, int pos) {
assert (node->op == op_Sel);
return get_irn_n(node, pos + SEL_INDEX_OFFSET);
}
-INLINE void
+void
set_Sel_index (ir_node *node, int pos, ir_node *index) {
assert (node->op == op_Sel);
set_irn_n(node, pos + SEL_INDEX_OFFSET, index);
}
-INLINE entity *
+entity *
get_Sel_entity (ir_node *node) {
assert (node->op == op_Sel);
return node->attr.s.ent;
}
-INLINE void
+void
set_Sel_entity (ir_node *node, entity *ent) {
assert (node->op == op_Sel);
node->attr.s.ent = ent;
Shr, Shrs, Rotate, Cmp */
-INLINE ir_node *
+ir_node *
get_Call_mem (ir_node *node) {
assert (node->op == op_Call);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Call_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_Call);
set_irn_n(node, 0, mem);
}
-INLINE ir_node *
+ir_node *
get_Call_ptr (ir_node *node) {
assert (node->op == op_Call);
return get_irn_n(node, 1);
}
-INLINE void
+void
set_Call_ptr (ir_node *node, ir_node *ptr) {
assert (node->op == op_Call);
set_irn_n(node, 1, ptr);
}
-INLINE ir_node **
+ir_node **
get_Call_param_arr (ir_node *node) {
assert (node->op == op_Call);
return (ir_node **)&get_irn_in(node)[CALL_PARAM_OFFSET + 1];
}
-INLINE int
+int
get_Call_n_params (ir_node *node) {
assert (node->op == op_Call);
return (get_irn_arity(node) - CALL_PARAM_OFFSET);
}
-INLINE int
+int
get_Call_arity (ir_node *node) {
assert (node->op == op_Call);
return get_Call_n_params(node);
}
-/* INLINE void
+/* void
set_Call_arity (ir_node *node, ir_node *arity) {
assert (node->op == op_Call);
}
*/
-INLINE ir_node *
+ir_node *
get_Call_param (ir_node *node, int pos) {
assert (node->op == op_Call);
return get_irn_n(node, pos + CALL_PARAM_OFFSET);
}
-INLINE void
+void
set_Call_param (ir_node *node, int pos, ir_node *param) {
assert (node->op == op_Call);
set_irn_n(node, pos + CALL_PARAM_OFFSET, param);
}
-INLINE type *
+type *
get_Call_type (ir_node *node) {
assert (node->op == op_Call);
return node->attr.call.cld_tp = skip_tid(node->attr.call.cld_tp);
}
-INLINE void
+void
set_Call_type (ir_node *node, type *tp) {
assert (node->op == op_Call);
assert (is_method_type(tp));
}
int Call_has_callees(ir_node *node) {
- return (node->attr.call.callee_arr != NULL);
+ assert(node && node->op == op_Call);
+ return ((get_irg_callee_info_state(get_irn_irg(node)) != irg_callee_info_none) &&
+ (node->attr.call.callee_arr != NULL));
}
int get_Call_n_callees(ir_node * node) {
- assert(node->op == op_Call && node->attr.call.callee_arr);
+ assert(node && node->op == op_Call && node->attr.call.callee_arr);
return ARR_LEN(node->attr.call.callee_arr);
}
entity * get_Call_callee(ir_node * node, int pos) {
- assert(node->op == op_Call && node->attr.call.callee_arr);
+ assert(pos >= 0 && pos < get_Call_n_callees(node));
return node->attr.call.callee_arr[pos];
}
-void set_Call_callee_arr(ir_node * node, int n, entity ** arr) {
+void set_Call_callee_arr(ir_node * node, const int n, entity ** arr) {
assert(node->op == op_Call);
if (node->attr.call.callee_arr == NULL || get_Call_n_callees(node) != n) {
node->attr.call.callee_arr = NEW_ARR_D(entity *, current_ir_graph->obst, n);
assert(node->op == op_CallBegin);
set_irn_n(node, 0, ptr);
}
-ir_graph * get_CallBegin_irg (ir_node *node) {
- return get_irn_irg(node);
-}
ir_node * get_CallBegin_call (ir_node *node) {
assert(node->op == op_CallBegin);
return node->attr.callbegin.call;
node->attr.callbegin.call = call;
}
-INLINE ir_node *
-get_Add_left (ir_node *node) {
- assert (node->op == op_Add);
+ir_node *
+get_FuncCall_ptr (ir_node *node) {
+ assert (node->op == op_FuncCall);
return get_irn_n(node, 0);
}
-INLINE void
-set_Add_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Add);
- set_irn_n(node, 0, left);
-}
-
-INLINE ir_node *
-get_Add_right (ir_node *node) {
- assert (node->op == op_Add);
- return get_irn_n(node, 1);
+void
+set_FuncCall_ptr (ir_node *node, ir_node *ptr) {
+ assert (node->op == op_FuncCall);
+ set_irn_n(node, 0, ptr);
}
-INLINE void
-set_Add_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Add);
- set_irn_n(node, 1, right);
+ir_node **
+get_FuncCall_param_arr (ir_node *node) {
+ assert (node->op == op_FuncCall);
+ return (ir_node **)&get_irn_in(node)[FUNCCALL_PARAM_OFFSET];
}
-INLINE ir_node *
-get_Sub_left (ir_node *node) {
- assert (node->op == op_Sub);
- return get_irn_n(node, 0);
+int
+get_FuncCall_n_params (ir_node *node) {
+ assert (node->op == op_FuncCall);
+ return (get_irn_arity(node) - FUNCCALL_PARAM_OFFSET);
}
-INLINE void
-set_Sub_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Sub);
- set_irn_n(node, 0, left);
+int
+get_FuncCall_arity (ir_node *node) {
+ assert (node->op == op_FuncCall);
+ return get_FuncCall_n_params(node);
}
-INLINE ir_node *
-get_Sub_right (ir_node *node) {
- assert (node->op == op_Sub);
- return get_irn_n(node, 1);
+/* void
+set_FuncCall_arity (ir_node *node, ir_node *arity) {
+ assert (node->op == op_FuncCall);
}
+*/
-INLINE void
-set_Sub_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Sub);
- set_irn_n(node, 1, right);
+ir_node *
+get_FuncCall_param (ir_node *node, int pos) {
+ assert (node->op == op_FuncCall);
+ return get_irn_n(node, pos + FUNCCALL_PARAM_OFFSET);
}
-
-INLINE ir_node *
-get_Minus_op (ir_node *node) {
- assert (node->op == op_Minus);
- return get_irn_n(node, 0);
+void
+set_FuncCall_param (ir_node *node, int pos, ir_node *param) {
+ assert (node->op == op_FuncCall);
+ set_irn_n(node, pos + FUNCCALL_PARAM_OFFSET, param);
}
-INLINE void
-set_Minus_op (ir_node *node, ir_node *op) {
- assert (node->op == op_Minus);
- set_irn_n(node, 0, op);
+type *
+get_FuncCall_type (ir_node *node) {
+ assert (node->op == op_FuncCall);
+ return node->attr.call.cld_tp = skip_tid(node->attr.call.cld_tp);
}
-
-INLINE ir_node *
-get_Mul_left (ir_node *node) {
- assert (node->op == op_Mul);
- return get_irn_n(node, 0);
+void
+set_FuncCall_type (ir_node *node, type *tp) {
+ assert (node->op == op_FuncCall);
+ assert (is_method_type(tp));
+ node->attr.call.cld_tp = tp;
}
-INLINE void
-set_Mul_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Mul);
- set_irn_n(node, 0, left);
+int FuncCall_has_callees(ir_node *node) {
+ return ((get_irg_callee_info_state(get_irn_irg(node)) != irg_callee_info_none) &&
+ (node->attr.call.callee_arr != NULL));
}
-INLINE ir_node *
-get_Mul_right (ir_node *node) {
- assert (node->op == op_Mul);
- return get_irn_n(node, 1);
+int get_FuncCall_n_callees(ir_node * node) {
+ assert(node->op == op_FuncCall && node->attr.call.callee_arr);
+ return ARR_LEN(node->attr.call.callee_arr);
}
-INLINE void
-set_Mul_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Mul);
- set_irn_n(node, 1, right);
+entity * get_FuncCall_callee(ir_node * node, int pos) {
+ assert(node->op == op_FuncCall && node->attr.call.callee_arr);
+ return node->attr.call.callee_arr[pos];
}
-INLINE ir_node *
-get_Quot_left (ir_node *node) {
- assert (node->op == op_Quot);
- return get_irn_n(node, 1);
+void set_FuncCall_callee_arr(ir_node * node, int n, entity ** arr) {
+ assert(node->op == op_FuncCall);
+ if (node->attr.call.callee_arr == NULL || get_Call_n_callees(node) != n) {
+ node->attr.call.callee_arr = NEW_ARR_D(entity *, current_ir_graph->obst, n);
+ }
+ memcpy(node->attr.call.callee_arr, arr, n * sizeof(entity *));
}
-INLINE void
-set_Quot_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Quot);
- set_irn_n(node, 1, left);
+void remove_FuncCall_callee_arr(ir_node * node) {
+ assert(node->op == op_FuncCall);
+ node->attr.call.callee_arr = NULL;
}
-INLINE ir_node *
-get_Quot_right (ir_node *node) {
- assert (node->op == op_Quot);
- return get_irn_n(node, 2);
-}
-INLINE void
-set_Quot_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Quot);
- set_irn_n(node, 2, right);
-}
+#define BINOP(OP) \
+ir_node * get_##OP##_left(ir_node *node) { \
+ assert(node->op == op_##OP); \
+ return get_irn_n(node, node->op->op_index); \
+} \
+void set_##OP##_left(ir_node *node, ir_node *left) { \
+ assert(node->op == op_##OP); \
+ set_irn_n(node, node->op->op_index, left); \
+} \
+ir_node *get_##OP##_right(ir_node *node) { \
+ assert(node->op == op_##OP); \
+ return get_irn_n(node, node->op->op_index + 1); \
+} \
+void set_##OP##_right(ir_node *node, ir_node *right) { \
+ assert(node->op == op_##OP); \
+ set_irn_n(node, node->op->op_index + 1, right); \
+}
+
+#define UNOP(OP) \
+ir_node *get_##OP##_op(ir_node *node) { \
+ assert(node->op == op_##OP); \
+ return get_irn_n(node, node->op->op_index); \
+} \
+void set_##OP##_op (ir_node *node, ir_node *op) { \
+ assert(node->op == op_##OP); \
+ set_irn_n(node, node->op->op_index, op); \
+}
+
+BINOP(Add)
+BINOP(Sub)
+UNOP(Minus)
+BINOP(Mul)
+BINOP(Quot)
-INLINE ir_node *
+ir_node *
get_Quot_mem (ir_node *node) {
assert (node->op == op_Quot);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Quot_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_Quot);
set_irn_n(node, 0, mem);
}
-INLINE ir_node *
-get_DivMod_left (ir_node *node) {
- assert (node->op == op_DivMod);
- return get_irn_n(node, 1);
-}
-
-INLINE void
-set_DivMod_left (ir_node *node, ir_node *left) {
- assert (node->op == op_DivMod);
- set_irn_n(node, 1, left);
-}
-
-INLINE ir_node *
-get_DivMod_right (ir_node *node) {
- assert (node->op == op_DivMod);
- return get_irn_n(node, 2);
-}
-
-INLINE void
-set_DivMod_right (ir_node *node, ir_node *right) {
- assert (node->op == op_DivMod);
- set_irn_n(node, 2, right);
-}
+BINOP(DivMod)
-INLINE ir_node *
+ir_node *
get_DivMod_mem (ir_node *node) {
assert (node->op == op_DivMod);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_DivMod_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_DivMod);
set_irn_n(node, 0, mem);
}
-INLINE ir_node *
-get_Div_left (ir_node *node) {
- assert (node->op == op_Div);
- return get_irn_n(node, 1);
-}
-
-INLINE void
-set_Div_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Div);
- set_irn_n(node, 1, left);
-}
-
-INLINE ir_node *
-get_Div_right (ir_node *node) {
- assert (node->op == op_Div);
- return get_irn_n(node, 2);
-}
-
-INLINE void
-set_Div_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Div);
- set_irn_n(node, 2, right);
-}
+BINOP(Div)
-INLINE ir_node *
+ir_node *
get_Div_mem (ir_node *node) {
assert (node->op == op_Div);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Div_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_Div);
set_irn_n(node, 0, mem);
}
-INLINE ir_node *
-get_Mod_left (ir_node *node) {
- assert (node->op == op_Mod);
- return get_irn_n(node, 1);
-}
+BINOP(Mod)
-INLINE void
-set_Mod_left (ir_node *node, ir_node *left) {
+ir_node *
+get_Mod_mem (ir_node *node) {
assert (node->op == op_Mod);
- set_irn_n(node, 1, left);
+ return get_irn_n(node, 0);
}
-INLINE ir_node *
-get_Mod_right (ir_node *node) {
+void
+set_Mod_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_Mod);
- return get_irn_n(node, 2);
+ set_irn_n(node, 0, mem);
}
-INLINE void
-set_Mod_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Mod);
- set_irn_n(node, 2, right);
-}
+UNOP(Abs)
+BINOP(And)
+BINOP(Or)
+BINOP(Eor)
+UNOP(Not)
+BINOP(Shl)
+BINOP(Shr)
+BINOP(Shrs)
+BINOP(Rot)
+BINOP(Cmp)
+UNOP(Conv)
+UNOP(Cast)
-INLINE ir_node *
-get_Mod_mem (ir_node *node) {
- assert (node->op == op_Mod);
- return get_irn_n(node, 0);
-}
-
-INLINE void
-set_Mod_mem (ir_node *node, ir_node *mem) {
- assert (node->op == op_Mod);
- set_irn_n(node, 0, mem);
-}
-
-INLINE ir_node *
-get_Abs_op (ir_node *node) {
- assert (node->op == op_Abs);
- return get_irn_n(node, 0);
+type *
+get_Cast_type (ir_node *node) {
+ assert (node->op == op_Cast);
+ return node->attr.cast.totype;
}
-INLINE void
-set_Abs_op (ir_node *node, ir_node *op) {
- assert (node->op == op_Abs);
- set_irn_n(node, 0, op);
+void
+set_Cast_type (ir_node *node, type *to_tp) {
+ assert (node->op == op_Cast);
+ node->attr.cast.totype = to_tp;
}
-INLINE ir_node *
-get_And_left (ir_node *node) {
- assert (node->op == op_And);
- return get_irn_n(node, 0);
+int
+is_unop (ir_node *node) {
+ return (node->op->opar == oparity_unary);
}
-INLINE void
-set_And_left (ir_node *node, ir_node *left) {
- assert (node->op == op_And);
- set_irn_n(node, 0, left);
-}
+ir_node *
+get_unop_op (ir_node *node) {
+ if (node->op->opar == oparity_unary)
+ return get_irn_n(node, node->op->op_index);
-INLINE ir_node *
-get_And_right (ir_node *node) {
- assert (node->op == op_And);
- return get_irn_n(node, 1);
+ assert(node->op->opar == oparity_unary);
+ return NULL;
}
-INLINE void
-set_And_right (ir_node *node, ir_node *right) {
- assert (node->op == op_And);
- set_irn_n(node, 1, right);
-}
+void
+set_unop_op (ir_node *node, ir_node *op) {
+ if (node->op->opar == oparity_unary)
+ set_irn_n(node, node->op->op_index, op);
-INLINE ir_node *
-get_Or_left (ir_node *node) {
- assert (node->op == op_Or);
- return get_irn_n(node, 0);
+ assert(node->op->opar == oparity_unary);
}
-INLINE void
-set_Or_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Or);
- set_irn_n(node, 0, left);
+int
+is_binop (ir_node *node) {
+ return (node->op->opar == oparity_binary);
}
-INLINE ir_node *
-get_Or_right (ir_node *node) {
- assert (node->op == op_Or);
- return get_irn_n(node, 1);
-}
+ir_node *
+get_binop_left (ir_node *node) {
+ if (node->op->opar == oparity_binary)
+ return get_irn_n(node, node->op->op_index);
-INLINE void
-set_Or_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Or);
- set_irn_n(node, 1, right);
+ assert(node->op->opar == oparity_binary);
+ return NULL;
}
-INLINE ir_node *
-get_Eor_left (ir_node *node) {
- assert (node->op == op_Eor);
- return get_irn_n(node, 0);
-}
+void
+set_binop_left (ir_node *node, ir_node *left) {
+ if (node->op->opar == oparity_binary)
+ set_irn_n(node, node->op->op_index, left);
-INLINE void
-set_Eor_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Eor);
- set_irn_n(node, 0, left);
+ assert (node->op->opar == oparity_binary);
}
-INLINE ir_node *
-get_Eor_right (ir_node *node) {
- assert (node->op == op_Eor);
- return get_irn_n(node, 1);
-}
+ir_node *
+get_binop_right (ir_node *node) {
+ if (node->op->opar == oparity_binary)
+ return get_irn_n(node, node->op->op_index + 1);
-INLINE void
-set_Eor_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Eor);
- set_irn_n(node, 1, right);
+ assert(node->op->opar == oparity_binary);
+ return NULL;
}
+void
+set_binop_right (ir_node *node, ir_node *right) {
+ if (node->op->opar == oparity_binary)
+ set_irn_n(node, node->op->op_index + 1, right);
-INLINE ir_node *
-get_Not_op (ir_node *node) {
- assert (node->op == op_Not);
- return get_irn_n(node, 0);
+ assert (node->op->opar == oparity_binary);
}
-INLINE void
-set_Not_op (ir_node *node, ir_node *op) {
- assert (node->op == op_Not);
- set_irn_n(node, 0, op);
-}
+int is_Phi (ir_node *n) {
+ ir_op *op;
+ assert(n);
+ op = get_irn_op(n);
-INLINE ir_node *
-get_Shl_left (ir_node *node) {
- assert (node->op == op_Shl);
- return get_irn_n(node, 0);
-}
+ if (op == op_Filter) return interprocedural_view;
-INLINE void
-set_Shl_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Shl);
- set_irn_n(node, 0, left);
-}
+ if (op == op_Phi)
+ return ((get_irg_phase_state(get_irn_irg(n)) != phase_building) ||
+ (get_irn_arity(n) > 0));
-INLINE ir_node *
-get_Shl_right (ir_node *node) {
- assert (node->op == op_Shl);
- return get_irn_n(node, 1);
+ return 0;
}
-INLINE void
-set_Shl_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Shl);
- set_irn_n(node, 1, right);
-}
+int is_Phi0 (ir_node *n) {
+ assert(n);
-INLINE ir_node *
-get_Shr_left (ir_node *node) {
- assert (node->op == op_Shr);
- return get_irn_n(node, 0);
+ return ((get_irn_op(n) == op_Phi) &&
+ (get_irn_arity(n) == 0) &&
+ (get_irg_phase_state(get_irn_irg(n)) == phase_building));
}
-INLINE void
-set_Shr_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Shr);
- set_irn_n(node, 0, left);
+ir_node **
+get_Phi_preds_arr (ir_node *node) {
+ assert (node->op == op_Phi);
+ return (ir_node **)&(get_irn_in(node)[1]);
}
-INLINE ir_node *
-get_Shr_right (ir_node *node) {
- assert (node->op == op_Shr);
- return get_irn_n(node, 1);
+int
+get_Phi_n_preds (ir_node *node) {
+ assert (is_Phi(node) || is_Phi0(node));
+ return (get_irn_arity(node));
}
-INLINE void
-set_Shr_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Shr);
- set_irn_n(node, 1, right);
+/*
+void set_Phi_n_preds (ir_node *node, int n_preds) {
+ assert (node->op == op_Phi);
}
+*/
-INLINE ir_node *
-get_Shrs_left (ir_node *node) {
- assert (node->op == op_Shrs);
- return get_irn_n(node, 0);
+ir_node *
+get_Phi_pred (ir_node *node, int pos) {
+ assert (is_Phi(node) || is_Phi0(node));
+ return get_irn_n(node, pos);
}
-INLINE void
-set_Shrs_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Shrs);
- set_irn_n(node, 0, left);
+void
+set_Phi_pred (ir_node *node, int pos, ir_node *pred) {
+ assert (is_Phi(node) || is_Phi0(node));
+ set_irn_n(node, pos, pred);
}
-INLINE ir_node *
-get_Shrs_right (ir_node *node) {
- assert (node->op == op_Shrs);
- return get_irn_n(node, 1);
-}
-INLINE void
-set_Shrs_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Shrs);
- set_irn_n(node, 1, right);
+int is_memop(ir_node *node) {
+ return ((get_irn_op(node) == op_Load) || (get_irn_op(node) == op_Store));
}
-INLINE ir_node *
-get_Rot_left (ir_node *node) {
- assert (node->op == op_Rot);
+ir_node *get_memop_mem (ir_node *node) {
+ assert(is_memop(node));
return get_irn_n(node, 0);
}
-INLINE void
-set_Rot_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Rot);
- set_irn_n(node, 0, left);
+void set_memop_mem (ir_node *node, ir_node *mem) {
+ assert(is_memop(node));
+ set_irn_n(node, 0, mem);
}
-INLINE ir_node *
-get_Rot_right (ir_node *node) {
- assert (node->op == op_Rot);
+ir_node *get_memop_ptr (ir_node *node) {
+ assert(is_memop(node));
return get_irn_n(node, 1);
}
-INLINE void
-set_Rot_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Rot);
- set_irn_n(node, 1, right);
+void set_memop_ptr (ir_node *node, ir_node *ptr) {
+ assert(is_memop(node));
+ set_irn_n(node, 1, ptr);
}
-INLINE ir_node *
-get_Cmp_left (ir_node *node) {
- assert (node->op == op_Cmp);
+ir_node *
+get_Load_mem (ir_node *node) {
+ assert (node->op == op_Load);
return get_irn_n(node, 0);
}
-INLINE void
-set_Cmp_left (ir_node *node, ir_node *left) {
- assert (node->op == op_Cmp);
- set_irn_n(node, 0, left);
+void
+set_Load_mem (ir_node *node, ir_node *mem) {
+ assert (node->op == op_Load);
+ set_irn_n(node, 0, mem);
}
-INLINE ir_node *
-get_Cmp_right (ir_node *node) {
- assert (node->op == op_Cmp);
+ir_node *
+get_Load_ptr (ir_node *node) {
+ assert (node->op == op_Load);
return get_irn_n(node, 1);
}
-INLINE void
-set_Cmp_right (ir_node *node, ir_node *right) {
- assert (node->op == op_Cmp);
- set_irn_n(node, 1, right);
-}
-
-INLINE ir_node *
-get_Conv_op (ir_node *node) {
- assert (node->op == op_Conv);
- return get_irn_n(node, 0);
-}
-
-INLINE void
-set_Conv_op (ir_node *node, ir_node *op) {
- assert (node->op == op_Conv);
- set_irn_n(node, 0, op);
-}
-
-INLINE ir_node *
-get_Cast_op (ir_node *node) {
- assert (node->op == op_Cast);
- return get_irn_n(node, 0);
-}
-
-INLINE void
-set_Cast_op (ir_node *node, ir_node *op) {
- assert (node->op == op_Cast);
- set_irn_n(node, 0, op);
-}
-
-INLINE type *
-get_Cast_type (ir_node *node) {
- assert (node->op == op_Cast);
- return node->attr.cast.totype;
-}
-
-INLINE void
-set_Cast_type (ir_node *node, type *to_tp) {
- assert (node->op == op_Cast);
- node->attr.cast.totype = to_tp;
-}
-
-INLINE int
-is_unop (ir_node *node) {
- return (node->op->opar == oparity_unary);
-}
-
-INLINE ir_node *
-get_unop_op (ir_node *node) {
- assert (is_unop(node));
- switch (get_irn_opcode (node)) {
- case iro_Minus: return get_Minus_op(node); break;
- case iro_Abs: return get_Abs_op(node); break;
- case iro_Not: return get_Not_op(node); break;
- case iro_Conv: return get_Conv_op(node); break;
- case iro_Cast: return get_Cast_op(node); break;
- default: return NULL;
- }
-}
-
-INLINE void
-set_unop_op (ir_node *node, ir_node *op) {
- assert (is_unop(node));
- switch (get_irn_opcode (node)) {
- case iro_Minus: set_Minus_op(node, op); break;
- case iro_Abs: set_Abs_op(node, op); break;
- case iro_Not: set_Not_op(node, op); break;
- case iro_Conv: set_Conv_op(node, op); break;
- case iro_Cast: set_Cast_op(node, op); break;
- default: ;
- }
-
-}
-
-int
-is_binop (ir_node *node) {
- return (node->op->opar == oparity_binary);
- /* return (node->op == op_Add ||
- node->op == op_Cmp ||
- node->op == op_Sub ||
- node->op == op_Mul ||
- node->op == op_Quot ||
- node->op == op_DivMod ||
- node->op == op_Div ||
- node->op == op_Mod ||
- node->op == op_And ||
- node->op == op_Or ||
- node->op == op_Eor ||
- node->op == op_Shl ||
- node->op == op_Shr ||
- node->op == op_Shrs ||
- node->op == op_Rot );
- */
-}
-
-INLINE ir_node *
-get_binop_left (ir_node *node) {
- assert (node->op->opar == oparity_binary);
-
- switch (get_irn_opcode (node)) {
- case iro_Add : return get_Add_left(node); break;
- case iro_Sub : return get_Sub_left(node); break;
- case iro_Mul : return get_Mul_left(node); break;
- case iro_Quot : return get_Quot_left(node); break;
- case iro_DivMod: return get_DivMod_left(node); break;
- case iro_Div : return get_Div_left(node); break;
- case iro_Mod : return get_Mod_left(node); break;
- case iro_And : return get_And_left(node); break;
- case iro_Or : return get_Or_left(node); break;
- case iro_Eor : return get_Eor_left(node); break;
- case iro_Shl : return get_Shl_left(node); break;
- case iro_Shr : return get_Shr_left(node); break;
- case iro_Shrs : return get_Shrs_left(node); break;
- case iro_Rot : return get_Rot_left(node); break;
- case iro_Cmp : return get_Cmp_left(node); break;
- default: return NULL;
- };
-}
-
-INLINE void
-set_binop_left (ir_node *node, ir_node *left) {
- assert (node->op->opar == oparity_binary);
-
- switch (get_irn_opcode (node)) {
- case iro_Add : set_Add_left(node, left); break;
- case iro_Sub : set_Sub_left(node, left); break;
- case iro_Mul : set_Mul_left(node, left); break;
- case iro_Quot : set_Quot_left(node, left); break;
- case iro_DivMod: set_DivMod_left(node, left); break;
- case iro_Div : set_Div_left(node, left); break;
- case iro_Mod : set_Mod_left(node, left); break;
- case iro_And : set_And_left(node, left); break;
- case iro_Or : set_Or_left(node, left); break;
- case iro_Eor : set_Eor_left(node, left); break;
- case iro_Shl : set_Shl_left(node, left); break;
- case iro_Shr : set_Shr_left(node, left); break;
- case iro_Shrs : set_Shrs_left(node, left); break;
- case iro_Rot : set_Rot_left(node, left); break;
- case iro_Cmp : set_Cmp_left(node, left); break;
- default: ;
- };
-}
-
-INLINE ir_node *
-get_binop_right (ir_node *node) {
- assert (node->op->opar == oparity_binary);
-
- switch (get_irn_opcode (node)) {
- case iro_Add : return get_Add_right(node); break;
- case iro_Sub : return get_Sub_right(node); break;
- case iro_Mul : return get_Mul_right(node); break;
- case iro_Quot : return get_Quot_right(node); break;
- case iro_DivMod: return get_DivMod_right(node); break;
- case iro_Div : return get_Div_right(node); break;
- case iro_Mod : return get_Mod_right(node); break;
- case iro_And : return get_And_right(node); break;
- case iro_Or : return get_Or_right(node); break;
- case iro_Eor : return get_Eor_right(node); break;
- case iro_Shl : return get_Shl_right(node); break;
- case iro_Shr : return get_Shr_right(node); break;
- case iro_Shrs : return get_Shrs_right(node); break;
- case iro_Rot : return get_Rot_right(node); break;
- case iro_Cmp : return get_Cmp_right(node); break;
- default: return NULL;
- };
-}
-
-INLINE void
-set_binop_right (ir_node *node, ir_node *right) {
- assert (node->op->opar == oparity_binary);
-
- switch (get_irn_opcode (node)) {
- case iro_Add : set_Add_right(node, right); break;
- case iro_Sub : set_Sub_right(node, right); break;
- case iro_Mul : set_Mul_right(node, right); break;
- case iro_Quot : set_Quot_right(node, right); break;
- case iro_DivMod: set_DivMod_right(node, right); break;
- case iro_Div : set_Div_right(node, right); break;
- case iro_Mod : set_Mod_right(node, right); break;
- case iro_And : set_And_right(node, right); break;
- case iro_Or : set_Or_right(node, right); break;
- case iro_Eor : set_Eor_right(node, right); break;
- case iro_Shl : set_Shl_right(node, right); break;
- case iro_Shr : set_Shr_right(node, right); break;
- case iro_Shrs : set_Shrs_right(node, right); break;
- case iro_Rot : set_Rot_right(node, right); break;
- case iro_Cmp : set_Cmp_right(node, right); break;
- default: ;
- };
-}
-
-INLINE int is_Phi (ir_node *n) {
- assert(n);
- return ((get_irn_op(n) == op_Phi) ||
- (get_irn_op(n) == op_Filter && interprocedural_view));
-}
-
-INLINE ir_node **
-get_Phi_preds_arr (ir_node *node) {
- assert (node->op == op_Phi);
- return (ir_node **)&(get_irn_in(node)[1]);
-}
-
-INLINE int
-get_Phi_n_preds (ir_node *node) {
- assert (is_Phi(node));
- return (get_irn_arity(node));
-}
-
-/*
-INLINE void set_Phi_n_preds (ir_node *node, int n_preds) {
- assert (node->op == op_Phi);
-}
-*/
-
-INLINE ir_node *
-get_Phi_pred (ir_node *node, int pos) {
- assert (is_Phi(node));
- return get_irn_n(node, pos);
-}
-
-INLINE void
-set_Phi_pred (ir_node *node, int pos, ir_node *pred) {
- assert (is_Phi(node));
- set_irn_n(node, pos, pred);
+void
+set_Load_ptr (ir_node *node, ir_node *ptr) {
+ assert (node->op == op_Load);
+ set_irn_n(node, 1, ptr);
}
-INLINE ir_node *
-get_Load_mem (ir_node *node) {
+ir_mode *
+get_Load_mode (ir_node *node) {
assert (node->op == op_Load);
- return get_irn_n(node, 0);
+ return node->attr.load.load_mode;
}
-INLINE void
-set_Load_mem (ir_node *node, ir_node *mem) {
+void
+set_Load_mode (ir_node *node, ir_mode *mode) {
assert (node->op == op_Load);
- set_irn_n(node, 0, mem);
+ node->attr.load.load_mode = mode;
}
-INLINE ir_node *
-get_Load_ptr (ir_node *node) {
+ent_volatility
+get_Load_volatility (ir_node *node) {
assert (node->op == op_Load);
- return get_irn_n(node, 1);
+ return node->attr.load.volatility;
}
-INLINE void
-set_Load_ptr (ir_node *node, ir_node *ptr) {
+void
+set_Load_volatility (ir_node *node, ent_volatility volatility) {
assert (node->op == op_Load);
- set_irn_n(node, 1, ptr);
+ node->attr.load.volatility = volatility;
}
-INLINE
+
ir_node *
get_Store_mem (ir_node *node) {
assert (node->op == op_Store);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Store_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_Store);
set_irn_n(node, 0, mem);
}
-INLINE ir_node *
+ir_node *
get_Store_ptr (ir_node *node) {
assert (node->op == op_Store);
return get_irn_n(node, 1);
}
-INLINE void
+void
set_Store_ptr (ir_node *node, ir_node *ptr) {
assert (node->op == op_Store);
set_irn_n(node, 1, ptr);
}
-INLINE ir_node *
+ir_node *
get_Store_value (ir_node *node) {
assert (node->op == op_Store);
return get_irn_n(node, 2);
}
-INLINE void
+void
set_Store_value (ir_node *node, ir_node *value) {
assert (node->op == op_Store);
set_irn_n(node, 2, value);
}
-INLINE ir_node *
+ent_volatility
+get_Store_volatility (ir_node *node) {
+ assert (node->op == op_Store);
+ return node->attr.store.volatility;
+}
+
+void
+set_Store_volatility (ir_node *node, ent_volatility volatility) {
+ assert (node->op == op_Store);
+ node->attr.store.volatility = volatility;
+}
+
+
+ir_node *
get_Alloc_mem (ir_node *node) {
assert (node->op == op_Alloc);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Alloc_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_Alloc);
set_irn_n(node, 0, mem);
}
-INLINE ir_node *
+ir_node *
get_Alloc_size (ir_node *node) {
assert (node->op == op_Alloc);
return get_irn_n(node, 1);
}
-INLINE void
+void
set_Alloc_size (ir_node *node, ir_node *size) {
assert (node->op == op_Alloc);
set_irn_n(node, 1, size);
}
-INLINE type *
+type *
get_Alloc_type (ir_node *node) {
assert (node->op == op_Alloc);
return node->attr.a.type = skip_tid(node->attr.a.type);
}
-INLINE void
+void
set_Alloc_type (ir_node *node, type *tp) {
assert (node->op == op_Alloc);
node->attr.a.type = tp;
}
-INLINE where_alloc
+where_alloc
get_Alloc_where (ir_node *node) {
assert (node->op == op_Alloc);
return node->attr.a.where;
}
-INLINE void
+void
set_Alloc_where (ir_node *node, where_alloc where) {
assert (node->op == op_Alloc);
node->attr.a.where = where;
}
-INLINE ir_node *
+ir_node *
get_Free_mem (ir_node *node) {
assert (node->op == op_Free);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Free_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_Free);
set_irn_n(node, 0, mem);
}
-INLINE ir_node *
+ir_node *
get_Free_ptr (ir_node *node) {
assert (node->op == op_Free);
return get_irn_n(node, 1);
}
-INLINE void
+void
set_Free_ptr (ir_node *node, ir_node *ptr) {
assert (node->op == op_Free);
set_irn_n(node, 1, ptr);
}
-INLINE ir_node *
+ir_node *
get_Free_size (ir_node *node) {
assert (node->op == op_Free);
return get_irn_n(node, 2);
}
-INLINE void
+void
set_Free_size (ir_node *node, ir_node *size) {
assert (node->op == op_Free);
set_irn_n(node, 2, size);
}
-INLINE type *
+type *
get_Free_type (ir_node *node) {
assert (node->op == op_Free);
return node->attr.f = skip_tid(node->attr.f);
}
-INLINE void
+void
set_Free_type (ir_node *node, type *tp) {
assert (node->op == op_Free);
node->attr.f = tp;
}
-INLINE ir_node **
+ir_node **
get_Sync_preds_arr (ir_node *node) {
assert (node->op == op_Sync);
return (ir_node **)&(get_irn_in(node)[1]);
}
-INLINE int
+int
get_Sync_n_preds (ir_node *node) {
assert (node->op == op_Sync);
return (get_irn_arity(node));
}
/*
-INLINE void
+void
set_Sync_n_preds (ir_node *node, int n_preds) {
assert (node->op == op_Sync);
}
*/
-INLINE ir_node *
+ir_node *
get_Sync_pred (ir_node *node, int pos) {
assert (node->op == op_Sync);
return get_irn_n(node, pos);
}
-INLINE void
+void
set_Sync_pred (ir_node *node, int pos, ir_node *pred) {
assert (node->op == op_Sync);
set_irn_n(node, pos, pred);
}
-INLINE ir_node *
+ir_node *
get_Proj_pred (ir_node *node) {
assert (is_Proj(node));
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Proj_pred (ir_node *node, ir_node *pred) {
assert (is_Proj(node));
set_irn_n(node, 0, pred);
}
-INLINE long
+long
get_Proj_proj (ir_node *node) {
assert (is_Proj(node));
if (get_irn_opcode(node) == iro_Proj) {
}
}
-INLINE void
+void
set_Proj_proj (ir_node *node, long proj) {
assert (node->op == op_Proj);
node->attr.proj = proj;
}
-INLINE ir_node **
+ir_node **
get_Tuple_preds_arr (ir_node *node) {
assert (node->op == op_Tuple);
return (ir_node **)&(get_irn_in(node)[1]);
}
-INLINE int
+int
get_Tuple_n_preds (ir_node *node) {
assert (node->op == op_Tuple);
return (get_irn_arity(node));
}
/*
-INLINE void
+void
set_Tuple_n_preds (ir_node *node, int n_preds) {
assert (node->op == op_Tuple);
}
*/
-INLINE ir_node *
+ir_node *
get_Tuple_pred (ir_node *node, int pos) {
assert (node->op == op_Tuple);
return get_irn_n(node, pos);
}
-INLINE void
+void
set_Tuple_pred (ir_node *node, int pos, ir_node *pred) {
assert (node->op == op_Tuple);
set_irn_n(node, pos, pred);
}
-INLINE ir_node *
+ir_node *
get_Id_pred (ir_node *node) {
assert (node->op == op_Id);
return get_irn_n(node, 0);
}
-INLINE void
+void
set_Id_pred (ir_node *node, ir_node *pred) {
assert (node->op == op_Id);
set_irn_n(node, 0, pred);
}
-INLINE ir_node *get_Confirm_value (ir_node *node) {
+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) {
+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) {
+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) {
+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) {
+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) {
+void set_Confirm_cmp (ir_node *node, pn_Cmp cmp) {
assert (node->op == op_Confirm);
node->attr.confirm_cmp = cmp;
}
-INLINE ir_node *
+ir_node *
get_Filter_pred (ir_node *node) {
assert(node->op == op_Filter);
return node->in[1];
}
-INLINE void
+void
set_Filter_pred (ir_node *node, ir_node *pred) {
assert(node->op == op_Filter);
node->in[1] = pred;
}
-INLINE long
+long
get_Filter_proj(ir_node *node) {
assert(node->op == op_Filter);
return node->attr.filter.proj;
}
-INLINE void
+void
set_Filter_proj (ir_node *node, long proj) {
assert(node->op == op_Filter);
node->attr.filter.proj = proj;
void set_Filter_cg_pred(ir_node * node, int pos, ir_node * pred) {
assert(node->op == op_Filter && node->attr.filter.in_cg &&
- 0 <= pos && pos < ARR_LEN(node->attr.filter.in_cg) - 1);
+ 0 <= pos && pos < ARR_LEN(node->attr.filter.in_cg) - 1);
node->attr.filter.in_cg[pos + 1] = pred;
}
int get_Filter_n_cg_preds(ir_node *node) {
ir_node *get_Filter_cg_pred(ir_node *node, int pos) {
int arity;
assert(node->op == op_Filter && node->attr.filter.in_cg &&
- 0 <= pos);
+ 0 <= pos);
arity = ARR_LEN(node->attr.filter.in_cg);
assert(pos < arity - 1);
return node->attr.filter.in_cg[pos + 1];
}
-INLINE ir_graph *
+ir_graph *
get_irn_irg(ir_node *node) {
if (get_irn_op(node) != op_Block)
node = get_nodes_block(node);
+ if (is_Bad(node)) /* sometimes bad is predecessor of nodes instead of block: in case of optimization */
+ node = get_nodes_block(node);
assert(get_irn_op(node) == op_Block);
return node->attr.block.irg;
}
-/******************************************************************/
+/*----------------------------------------------------------------*/
/* Auxiliary routines */
-/******************************************************************/
+/*----------------------------------------------------------------*/
-INLINE ir_node *
+ir_node *
skip_Proj (ir_node *node) {
/* don't assert node !!! */
if (node && is_Proj(node)) {
}
}
-INLINE ir_node *
+ir_node *
skip_Tuple (ir_node *node) {
ir_node *pred;
if (!get_opt_normalize()) return node;
- node = skip_nop(node);
+ node = skip_Id(node);
if (get_irn_op(node) == op_Proj) {
- pred = skip_nop(get_Proj_pred(node));
+ pred = skip_Id(get_Proj_pred(node));
if (get_irn_op(pred) == op_Proj) /* nested Tuple ? */
- pred = skip_nop(skip_Tuple(pred));
+ pred = skip_Id(skip_Tuple(pred));
if (get_irn_op(pred) == op_Tuple)
return get_Tuple_pred(pred, get_Proj_proj(node));
}
return node;
}
+/** returns operand of node if node is a Cast */
+ir_node *skip_Cast (ir_node *node) {
+ if (node && get_irn_op(node) == op_Cast) {
+ return skip_Id(get_irn_n(node, 0));
+ } else {
+ return node;
+ }
+}
+
#if 0
/* This should compact Id-cycles to self-cycles. It has the same (or less?) complexity
than any other approach, as Id chains are resolved and all point to the real node, or
all id's are self loops. */
-INLINE ir_node *
-skip_nop (ir_node *node) {
+ir_node *
+skip_Id (ir_node *node) {
/* don't assert node !!! */
if (!get_opt_normalize()) return node;
assert (get_irn_arity (node) > 0);
node->in[0+1] = node;
- res = skip_nop(rem_pred);
+ res = skip_Id(rem_pred);
if (res->op == op_Id) /* self-loop */ return node;
node->in[0+1] = res;
/* This should compact Id-cycles to self-cycles. It has the same (or less?) complexity
than any other approach, as Id chains are resolved and all point to the real node, or
all id's are self loops. */
-extern int opt_normalize;
-INLINE ir_node *
-skip_nop (ir_node *node) {
+ir_node *
+skip_Id (ir_node *node) {
ir_node *pred;
/* don't assert node !!! */
- if (!opt_normalize) return node;
+ if (!node || (node->op != op_Id)) return node;
+
+ if (!get_opt_normalize()) return node;
/* Don't use get_Id_pred: We get into an endless loop for
self-referencing Ids. */
- if (node && (node->op == op_Id) && (node != (pred = node->in[0+1]))) {
+ pred = node->in[0+1];
+
+ if (pred->op != op_Id) return pred;
+
+ if (node != pred) { /* not a self referencing Id. Resolve Id chain. */
+ ir_node *rem_pred, *res;
+
if (pred->op != op_Id) return pred; /* shortcut */
- ir_node *rem_pred = pred;
- ir_node *res;
+ rem_pred = pred;
assert (get_irn_arity (node) > 0);
- node->in[0+1] = node;
- res = skip_nop(rem_pred);
+ node->in[0+1] = node; /* turn us into a self referencing Id: shorten Id cycles. */
+ res = skip_Id(rem_pred);
if (res->op == op_Id) /* self-loop */ return node;
- node->in[0+1] = res;
+ node->in[0+1] = res; /* Turn Id chain into Ids all referencing the chain end. */
return res;
} else {
return node;
}
#endif
-
-
-INLINE ir_node *
-skip_Id (ir_node *node) {
- return skip_nop(node);
-}
-
-INLINE int
+int
is_Bad (ir_node *node) {
assert(node);
if ((node) && get_irn_opcode(node) == iro_Bad)
return 0;
}
-INLINE int
+int
is_no_Block (ir_node *node) {
assert(node);
return (get_irn_opcode(node) != iro_Block);
}
-INLINE int
+int
is_Block (ir_node *node) {
assert(node);
return (get_irn_opcode(node) == iro_Block);
}
/* returns true if node is a Unknown node. */
-INLINE int
+int
is_Unknown (ir_node *node) {
assert(node);
return (get_irn_opcode(node) == iro_Unknown);
}
-INLINE int
+int
is_Proj (const ir_node *node) {
assert(node);
return node->op == op_Proj
/* Returns true if the operation manipulates interprocedural control flow:
CallBegin, EndReg, EndExcept */
-INLINE int is_ip_cfop(ir_node *node) {
+int is_ip_cfop(ir_node *node) {
return is_ip_cfopcode(get_irn_op(node));
}
-ir_graph *get_ip_cfop_irg(ir_node *n) {
- return get_irn_irg(n);
-}
-
/* Returns true if the operation can change the control flow because
of an exception. */
int
is_fragile_op(ir_node *node) {
- return ( (get_irn_opcode(node) == iro_Call)
- || (get_irn_opcode(node) == iro_Quot)
- || (get_irn_opcode(node) == iro_DivMod)
- || (get_irn_opcode(node) == iro_Div)
- || (get_irn_opcode(node) == iro_Mod)
- || (get_irn_opcode(node) == iro_Load)
- || (get_irn_opcode(node) == iro_Store)
- || (get_irn_opcode(node) == iro_Alloc)
- || (get_irn_opcode(node) == iro_Bad)
- || (get_irn_opcode(node) == iro_Unknown));
+ return is_op_fragile(get_irn_op(node));
}
-
/* Returns the memory operand of fragile operations. */
ir_node *get_fragile_op_mem(ir_node *node) {
assert(node && is_fragile_op(node));
case iro_Unknown:
return node;
default: ;
- assert(0 && "not reached");
+ assert(0 && "should not be reached");
return NULL;
}
}
+
+/* Returns true if the operation is a forking control flow operation. */
+int
+is_forking_op(ir_node *node) {
+ return is_op_forking(get_irn_op(node));
+}
+
+#ifdef DEBUG_libfirm
+void dump_irn (ir_node *n) {
+ int i, arity = get_irn_arity(n);
+ printf("%s%s: %ld (%p)\n", get_irn_opname(n), get_mode_name(get_irn_mode(n)), get_irn_node_nr(n), (void *)n);
+ if (!is_Block(n)) {
+ ir_node *pred = get_irn_n(n, -1);
+ printf(" block: %s%s: %ld (%p)\n", get_irn_opname(pred), get_mode_name(get_irn_mode(pred)),
+ get_irn_node_nr(pred), (void *)pred);
+ }
+ printf(" preds: \n");
+ for (i = 0; i < arity; ++i) {
+ ir_node *pred = get_irn_n(n, i);
+ printf(" %d: %s%s: %ld (%p)\n", i, get_irn_opname(pred), get_mode_name(get_irn_mode(pred)),
+ get_irn_node_nr(pred), (void *)pred);
+ }
+}
+
+#else /* DEBUG_libfirm */
+void dump_irn (ir_node *n) {}
+#endif /* DEBUG_libfirm */