- return get_irg_frame(irg);
- }
-}
-
-/**
- * Keep all memory edges of the given block.
- */
-static void keep_all_memory(ir_node *block)
-{
- ir_node *old = get_cur_block();
-
- set_cur_block(block);
- keep_alive(get_store());
- /* TODO: keep all memory edges from restricted pointers */
- set_cur_block(old);
-}
-
-static ir_node *reference_expression_enum_value_to_firm(
- const reference_expression_t *ref)
-{
- entity_t *entity = ref->entity;
- type_t *type = skip_typeref(entity->enum_value.enum_type);
- /* make sure the type is constructed */
- (void) get_ir_type(type);
-
- return new_Const(entity->enum_value.tv);
-}
-
-static ir_node *reference_expression_to_firm(const reference_expression_t *ref)
-{
- dbg_info *dbgi = get_dbg_info(&ref->base.source_position);
- entity_t *entity = ref->entity;
- assert(is_declaration(entity));
- type_t *type = skip_typeref(entity->declaration.type);
-
- /* make sure the type is constructed */
- (void) get_ir_type(type);
-
- if (entity->kind == ENTITY_FUNCTION && entity->function.btk != bk_none) {
- ir_entity *irentity = get_function_entity(entity, NULL);
- /* for gcc compatibility we have to produce (dummy) addresses for some
- * builtins which don't have entities */
- if (irentity == NULL) {
- source_position_t const *const pos = &ref->base.source_position;
- symbol_t const *const sym = ref->entity->base.symbol;
- warningf(WARN_OTHER, pos, "taking address of builtin '%Y'", sym);
-
- /* simply create a NULL pointer */
- ir_mode *mode = get_ir_mode_arithmetic(type_void_ptr);
- ir_node *res = new_Const(get_mode_null(mode));
-
- return res;
- }
- }
-
- switch ((declaration_kind_t) entity->declaration.kind) {
- case DECLARATION_KIND_UNKNOWN:
- break;
-
- case DECLARATION_KIND_LOCAL_VARIABLE: {
- ir_mode *const mode = get_ir_mode_storage(type);
- ir_node *const value = get_value(entity->variable.v.value_number, mode);
- return create_conv(NULL, value, get_ir_mode_arithmetic(type));
- }
- case DECLARATION_KIND_PARAMETER: {
- ir_mode *const mode = get_ir_mode_storage(type);
- ir_node *const value = get_value(entity->parameter.v.value_number,mode);
- return create_conv(NULL, value, get_ir_mode_arithmetic(type));
- }
- case DECLARATION_KIND_FUNCTION: {
- return create_symconst(dbgi, entity->function.irentity);
- }
- case DECLARATION_KIND_INNER_FUNCTION: {
- ir_mode *const mode = get_ir_mode_storage(type);
- if (!entity->function.goto_to_outer && !entity->function.need_closure) {
- /* inner function not using the closure */
- return create_symconst(dbgi, entity->function.irentity);
- } else {
- /* need trampoline here */
- return create_trampoline(dbgi, mode, entity->function.irentity);
- }
- }
- case DECLARATION_KIND_GLOBAL_VARIABLE: {
- const variable_t *variable = &entity->variable;
- ir_node *const addr = create_symconst(dbgi, variable->v.entity);
- return deref_address(dbgi, variable->base.type, addr);
- }
-
- case DECLARATION_KIND_LOCAL_VARIABLE_ENTITY: {
- ir_entity *irentity = entity->variable.v.entity;
- ir_node *frame = get_local_frame(irentity);
- ir_node *sel = new_d_simpleSel(dbgi, new_NoMem(), frame, irentity);
- return deref_address(dbgi, entity->declaration.type, sel);
- }
- case DECLARATION_KIND_PARAMETER_ENTITY: {
- ir_entity *irentity = entity->parameter.v.entity;
- ir_node *frame = get_local_frame(irentity);
- ir_node *sel = new_d_simpleSel(dbgi, new_NoMem(), frame, irentity);
- return deref_address(dbgi, entity->declaration.type, sel);