static ir_entity *intern_new_entity(ir_type *owner, ir_entity_kind kind, ident *name, ir_type *type, dbg_info *dbgi) { assert(owner != NULL); ir_entity *res = XMALLOCZ(ir_entity); res->kind = k_entity; res->name = name; res->ld_name = NULL; res->type = type; res->owner = owner; res->entity_kind = kind; res->volatility = volatility_non_volatile; res->aligned = align_is_aligned; res->usage = ir_usage_unknown; res->compiler_gen = 0; res->visibility = ir_visibility_external; res->offset = -1; res->offset_bit_remainder = 0; res->alignment = 0; res->link = NULL; #ifdef DEBUG_libfirm res->nr = get_irp_new_node_nr(); #endif /* Remember entity in its owner. */ if (is_compound_type(owner)) add_compound_member(owner, res); res->visit = 0; set_entity_dbg_info(res, dbgi); return res; }
static ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc) { ir_graph *const res = alloc_graph(); /* Inform statistics here, as blocks will be already built on this graph. */ hook_new_graph(res, ent); /* graphs are in construction mode by default */ add_irg_constraints(res, IR_GRAPH_CONSTRAINT_CONSTRUCTION); irg_set_nloc(res, n_loc); res->irg_pinned_state = op_pin_state_pinned; res->callee_info_state = irg_callee_info_none; res->mem_disambig_opt = aa_opt_inherited; /*-- Type information for the procedure of the graph --*/ res->ent = ent; if (ent) set_entity_irg(ent, res); /*-- a class type so that it can contain "inner" methods as in Pascal. --*/ res->frame_type = new_type_frame(); /* the Anchor node must be created first */ res->anchor = new_r_Anchor(res); /*-- Nodes needed in every graph --*/ set_irg_end_block(res, new_r_immBlock(res)); set_irg_end(res, new_r_End(res, 0, NULL)); ir_node *const start_block = new_r_Block_noopt(res, 0, NULL); set_irg_start_block(res, start_block); set_irg_no_mem(res, new_r_NoMem(res)); res->index = get_irp_new_irg_idx(); #ifdef DEBUG_libfirm res->graph_nr = get_irp_new_node_nr(); #endif set_r_cur_block(res, start_block); return res; }
/** * Creates a deep copy of an entity. */ static ir_entity *deep_entity_copy(ir_entity *old) { ir_entity *newe = XMALLOC(ir_entity); *newe = *old; if (old->initializer != NULL) { /* FIXME: the initializers are NOT copied */ } else if (is_method_entity(old)) { /* do NOT copy them, reanalyze. This might be the best solution */ newe->attr.mtd_attr.param_access = NULL; newe->attr.mtd_attr.param_weight = NULL; } newe->overwrites = NULL; newe->overwrittenby = NULL; #ifdef DEBUG_libfirm newe->nr = get_irp_new_node_nr(); #endif hook_new_entity(newe); return newe; }
/** * Creates a new type representation: * * @param type_op the kind of this type. May not be type_id. * @param mode the mode to be used for this type, may be NULL * @param db debug info * * @return A new type of the given type. The remaining private attributes are * not initialized. The type is in state layout_undefined. */ static ir_type *new_type(tp_op const *type_op, ir_mode *mode, type_dbg_info *db) { size_t const node_size = offsetof(ir_type, attr) + type_op->attr_size; ir_type *const res = (ir_type*)xmalloc(node_size); memset(res, 0, node_size); res->kind = k_type; res->type_op = type_op; res->mode = mode; res->visibility = ir_visibility_external; res->flags = tf_none; res->size = 0; res->align = 0; res->visit = 0; res->link = NULL; res->dbi = db; #ifdef DEBUG_libfirm res->nr = get_irp_new_node_nr(); #endif /* defined DEBUG_libfirm */ add_irp_type(res); /* Remember the new type global. */ return res; }