*/
static int forbid_new_data = 0;
-/**
- * The amount of additional space for custom data to be allocated upon
- * creating a new node.
- */
unsigned firm_add_node_size = 0;
-/* register new space for every node */
unsigned firm_register_additional_node_data(unsigned size)
{
assert(!forbid_new_data && "Too late to register additional node data");
} s;
};
-/*
- * 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 *const *in)
{
hook_new_node(irg, res);
if (get_irg_phase_state(irg) == phase_backend) {
- be_info_new_node(res);
+ be_info_new_node(irg, res);
}
return res;
}
-/*-- getting some parameters from ir_nodes --*/
-
int (is_ir_node)(const void *thing)
{
return is_ir_node_(thing);
return get_irn_arity_(node);
}
-/* Returns the array with ins. This array is shifted with respect to the
- array accessed by get_irn_n: The block operand is at position 0 not -1.
- (@@@ This should be changed.)
- 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. */
ir_node **get_irn_in(const ir_node *node)
{
return node->in;
return get_irn_op_(node);
}
-/* should be private to the library: */
void (set_irn_op)(ir_node *node, ir_op *op)
{
set_irn_op_(node, op);
const char *get_irn_opname(const ir_node *node)
{
- assert(node);
- if (is_Phi0(node)) return "Phi0";
return get_id_str(node->op->name);
}
node->attr.except.pin_state = state;
}
-/* Outputs a unique number for this node */
long get_irn_node_nr(const ir_node *node)
{
assert(node);
return -1;
}
-/** manipulate fields of individual nodes **/
-
ir_node *(get_nodes_block)(const ir_node *node)
{
return get_nodes_block_(node);
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. */
ir_type *is_frame_pointer(const ir_node *n)
{
if (is_Proj(n) && (get_Proj_proj(n) == pn_Start_P_frame_base)) {
block->attr.block.extblk = extblk;
}
-/* returns the graph of a Block. */
ir_graph *(get_Block_irg)(const ir_node *block)
{
return get_Block_irg_(block);
entity = block->attr.block.entity;
if (entity == NULL) {
- ir_label_t nr;
- ir_type *glob;
-
- glob = get_glob_type();
- entity = new_entity(glob, id_unique("block_%u"), get_code_type());
+ ir_label_t nr = get_irp_next_label_nr();
+ entity = new_label_entity(nr);
set_entity_visibility(entity, ir_visibility_local);
set_entity_linkage(entity, IR_LINKAGE_CONSTANT);
- nr = get_irp_next_label_nr();
- set_entity_label(entity, nr);
set_entity_compiler_generated(entity, 1);
block->attr.block.entity = entity;
return entity;
}
-ir_entity *get_Block_entity(const ir_node *block)
-{
- assert(is_Block(block));
- return block->attr.block.entity;
-}
-
-void set_Block_entity(ir_node *block, ir_entity *entity)
-{
- assert(is_Block(block));
- assert(get_entity_type(entity) == get_code_type());
- block->attr.block.entity = entity;
-}
-
-int has_Block_entity(const ir_node *block)
-{
- return block->attr.block.entity != NULL;
-}
-
ir_node *(get_Block_phis)(const ir_node *block)
{
return get_Block_phis_(block);
add_Block_phi_(block, phi);
}
-/* Get the Block mark (single bit). */
unsigned (get_Block_mark)(const ir_node *block)
{
return get_Block_mark_(block);
}
-/* Set the Block mark (single bit). */
void (set_Block_mark)(ir_node *block, unsigned mark)
{
set_Block_mark_(block, mark);
set_irn_n(end, pos + END_KEEPALIVE_OFFSET, ka);
}
-/* Set new keep-alives */
void set_End_keepalives(ir_node *end, int n, ir_node *in[])
{
size_t e;
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS);
}
-/* Set new keep-alives from old keep-alives, skipping irn */
void remove_End_keepalive(ir_node *end, ir_node *irn)
{
int n = get_End_n_keepalives(end);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_OUTS);
}
-/* remove Bads, NoMems and doublets from the keep-alive set */
void remove_End_Bads_and_doublets(ir_node *end)
{
pset_new_t keeps;
node->attr.symc.sym.type_p = tp;
}
-
-/* Only to access SymConst of kind symconst_addr_ent. Else assertion: */
ir_entity *get_SymConst_entity(const ir_node *node)
{
assert(is_SymConst(node) && SYMCONST_HAS_ENT(get_SymConst_kind(node)));
set_irn_n(node, pos + BUILTIN_PARAM_OFFSET, param);
}
-/* Returns a human readable string for the ir_builtin_kind. */
const char *get_builtin_kind_name(ir_builtin_kind kind)
{
#define X(a) case a: return #a
node->attr.call.callee_arr = NULL;
}
-/* Checks for upcast.
- *
- * Returns true if the Cast node casts a class type to a super type.
- */
int is_Cast_upcast(ir_node *node)
{
ir_type *totype = get_Cast_type(node);
return is_SubClass_of(fromtype, totype);
}
-/* Checks for downcast.
- *
- * Returns true if the Cast node casts a class type to a sub type.
- */
int is_Cast_downcast(ir_node *node)
{
ir_type *totype = get_Cast_type(node);
set_irn_n(node, node->op->op_index + 1, right);
}
-int is_Phi0(const ir_node *n)
-{
- assert(n);
-
- return ((get_irn_op(n) == op_Phi) &&
- (get_irn_arity(n) == 0) &&
- (get_irg_phase_state(get_irn_irg(n)) == phase_building));
-}
-
ir_node **get_Phi_preds_arr(ir_node *node)
{
assert(is_Phi(node));
int get_Phi_n_preds(const ir_node *node)
{
- assert(is_Phi(node) || is_Phi0(node));
- return (get_irn_arity(node));
+ assert(is_Phi(node));
+ return get_irn_arity(node);
}
ir_node *get_Phi_pred(const ir_node *node, int pos)
{
- assert(is_Phi(node) || is_Phi0(node));
+ assert(is_Phi(node));
return get_irn_n(node, pos);
}
void set_Phi_pred(ir_node *node, int pos, ir_node *pred)
{
- assert(is_Phi(node) || is_Phi0(node));
+ assert(is_Phi(node));
set_irn_n(node, pos, pred);
}
int is_memop(const ir_node *node)
{
- unsigned code = get_irn_opcode(node);
- return (code == iro_Load || code == iro_Store);
+ return is_op_uses_memory(get_irn_op(node));
}
ir_node *get_memop_mem(const ir_node *node)
{
+ const ir_op *op = get_irn_op(node);
assert(is_memop(node));
- assert(n_Load_mem == 0 && n_Store_mem == 0);
- return get_irn_n(node, 0);
+ return get_irn_n(node, op->memory_index);
}
void set_memop_mem(ir_node *node, ir_node *mem)
{
+ const ir_op *op = get_irn_op(node);
assert(is_memop(node));
- assert(n_Load_mem == 0 && n_Store_mem == 0);
- set_irn_n(node, 0, mem);
+ set_irn_n(node, op->memory_index, mem);
}
-ir_node *get_memop_ptr(const ir_node *node)
-{
- assert(is_memop(node));
- assert(n_Load_mem == 1 && n_Store_mem == 1);
- return get_irn_n(node, 1);
-}
-
-void set_memop_ptr(ir_node *node, ir_node *ptr)
-{
- assert(is_memop(node));
- assert(n_Load_mem == 1 && n_Store_mem == 1);
- set_irn_n(node, 1, ptr);
-}
-
-
ir_node **get_Sync_preds_arr(ir_node *node)
{
assert(is_Sync(node));
return (get_irn_arity(node));
}
-/*
-void set_Sync_n_preds(ir_node *node, int n_preds)
-{
- assert(is_Sync(node));
-}
-*/
-
ir_node *get_Sync_pred(const ir_node *node, int pos)
{
assert(is_Sync(node));
set_irn_n(node, pos, pred);
}
-/* Add a new Sync predecessor */
void add_Sync_pred(ir_node *node, ir_node *pred)
{
assert(is_Sync(node));
set_irn_n(node, pos, pred);
}
-int get_ASM_n_input_constraints(const ir_node *node)
+size_t get_ASM_n_input_constraints(const ir_node *node)
{
assert(is_ASM(node));
return ARR_LEN(node->attr.assem.input_constraints);
}
-int get_ASM_n_output_constraints(const ir_node *node)
+size_t get_ASM_n_output_constraints(const ir_node *node)
{
assert(is_ASM(node));
return ARR_LEN(node->attr.assem.output_constraints);
}
-int get_ASM_n_clobbers(const ir_node *node)
+size_t get_ASM_n_clobbers(const ir_node *node)
{
assert(is_ASM(node));
return ARR_LEN(node->attr.assem.clobbers);
}
-/* returns the graph of a node */
ir_graph *(get_irn_irg)(const ir_node *node)
{
return get_irn_irg_(node);
}
-
-/*----------------------------------------------------------------*/
-/* Auxiliary routines */
-/*----------------------------------------------------------------*/
-
ir_node *skip_Proj(ir_node *node)
{
/* don't assert node !!! */
return node;
}
-/* returns operand of node if node is a Cast */
ir_node *skip_Cast(ir_node *node)
{
if (is_Cast(node))
return node;
}
-/* returns operand of node if node is a Cast */
const ir_node *skip_Cast_const(const ir_node *node)
{
if (is_Cast(node))
return node;
}
-/* returns operand of node if node is a Pin */
ir_node *skip_Pin(ir_node *node)
{
if (is_Pin(node))
return node;
}
-/* returns operand of node if node is a Confirm */
ir_node *skip_Confirm(ir_node *node)
{
if (is_Confirm(node))
return node;
}
-/* skip all high-level ops */
ir_node *skip_HighLevel_ops(ir_node *node)
{
while (is_op_highlevel(get_irn_op(node))) {
}
-/* 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.
- *
- * Note: This function takes 10% of mostly ANY the compiler run, so it's
- * a little bit "hand optimized".
- */
ir_node *skip_Id(ir_node *node)
{
+ /* 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.
+ *
+ * Note: This function takes 10% of mostly ANY the compiler run, so it's
+ * a little bit "hand optimized".
+ */
ir_node *pred;
/* don't assert node !!! */
return is_strictConv_(node);
}
-/* Returns true if node is a SymConst node with kind symconst_addr_ent. */
int (is_SymConst_addr_ent)(const ir_node *node)
{
return is_SymConst_addr_ent_(node);
}
-/* Returns true if the operation manipulates control flow. */
int is_cfop(const ir_node *node)
{
if (is_fragile_op(node) && ir_throws_exception(node))
return is_op_unknown_jump(get_irn_op(node));
}
-/* Returns true if the operation can change the control flow because
- of an exception. */
int is_fragile_op(const ir_node *node)
{
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));
- return get_irn_n(node, node->op->fragile_mem_index);
-}
-
-/* Returns true if the operation is a forking control flow operation. */
int (is_irn_forking)(const ir_node *node)
{
return is_irn_forking_(node);
copy_node_attr_(irg, old_node, new_node);
}
-/* Return the type attribute of a node n (SymConst, Call, Alloc, Free,
- Cast) or NULL.*/
ir_type *(get_irn_type_attr)(ir_node *node)
{
return get_irn_type_attr_(node);
}
-/* Return the entity attribute of a node n (SymConst, Sel) or NULL. */
ir_entity *(get_irn_entity_attr)(ir_node *node)
{
return get_irn_entity_attr_(node);
}
-/* Returns non-zero for constant-like nodes. */
int (is_irn_constlike)(const ir_node *node)
{
return is_irn_constlike_(node);
}
-/*
- * Returns non-zero for nodes that are allowed to have keep-alives and
- * are neither Block nor PhiM.
- */
int (is_irn_keep)(const ir_node *node)
{
return is_irn_keep_(node);
}
-/*
- * Returns non-zero for nodes that are always placed in the start block.
- */
int (is_irn_start_block_placed)(const ir_node *node)
{
return is_irn_start_block_placed_(node);
}
-/* Returns non-zero for nodes that are CSE neutral to its users. */
int (is_irn_cse_neutral)(const ir_node *node)
{
return is_irn_cse_neutral_(node);
}
-/* Gets the string representation of the jump prediction .*/
const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred)
{
#define X(a) case a: return #a
static ir_type *get_Null_type(const ir_node *n)
{
(void) n;
- return firm_unknown_type;
+ return get_unknown_type();
}
-/* Sets the get_type operation for an ir_op_ops. */
void firm_set_default_get_type_attr(unsigned code, ir_op_ops *ops)
{
switch (code) {
return NULL;
}
-/* Sets the get_type operation for an ir_op_ops. */
void firm_set_default_get_entity_attr(unsigned code, ir_op_ops *ops)
{
switch (code) {
case iro_SymConst: ops->get_entity_attr = get_SymConst_attr_entity; break;
case iro_Sel: ops->get_entity_attr = get_Sel_entity; break;
+ case iro_Block: ops->get_entity_attr = get_Block_entity; break;
default:
/* not allowed to be NULL */
if (! ops->get_entity_attr)
}
}
-/* Sets the debug information of a node. */
void (set_irn_dbg_info)(ir_node *n, dbg_info *db)
{
set_irn_dbg_info_(n, db);
}
-/**
- * Returns the debug information of an node.
- *
- * @param n The node.
- */
dbg_info *(get_irn_dbg_info)(const ir_node *n)
{
return get_irn_dbg_info_(n);
return res;
}
-/*
- * Calculate a hash value of a node.
- */
unsigned firm_default_hash(const ir_node *node)
{
unsigned h;
if (is_irn_cse_neutral(pred))
h *= 9;
else
- h = 9*h + HASH_PTR(pred);
+ h = 9*h + hash_ptr(pred);
}
/* ...mode,... */
- h = 9*h + HASH_PTR(get_irn_mode(node));
+ h = 9*h + hash_ptr(get_irn_mode(node));
/* ...and code */
- h = 9*h + HASH_PTR(get_irn_op(node));
+ h = 9*h + hash_ptr(get_irn_op(node));
return h;
}