Commit f8b8dc89 authored by Michael Beck's avatar Michael Beck
Browse files

- init function for inlining added

[r19143]
parent 0636e6a5
......@@ -55,6 +55,7 @@
#include "irgraph_t.h"
#include "type_t.h"
#include "entity_t.h"
#include "opt_inline_t.h"
#include "firmstat.h"
#include "irarch.h"
#include "reassoc_t.h"
......@@ -126,6 +127,8 @@ void init_firm(const firm_parameter_t *param)
firm_init_reassociation();
/* initialize function call optimization */
firm_init_funccalls();
/* initialize function inlining */
firm_init_inline();
/* Builds a construct allowing to access all information to be constructed
later. */
init_irprog_2();
......
......@@ -114,6 +114,30 @@ static int is_method_leaving_raise(ir_node *raise)
return 0;
}
/**
* returns an Alloc node if the node adr Select
* from one
*/
static ir_node *is_depend_alloc(ir_node *adr) {
ir_node *alloc;
if (get_irn_op(adr) != op_Sel)
return NULL;
/* should be a simple Sel */
if (get_Sel_n_indexs(adr) != 0)
return NULL;
alloc = skip_Proj(get_Sel_ptr(adr));
if (get_irn_op(alloc) != op_Alloc)
return NULL;
/* hmm, we depend on this Alloc */
ir_printf("depend alloc %+F\n", alloc);
return NULL;
}
/**
* determine if a value calculated by n "escape", ie
* is stored somewhere we could not track
......@@ -130,6 +154,15 @@ static int can_escape(ir_node *n) {
switch (get_irn_opcode(succ)) {
case iro_Store:
if (get_Store_value(succ) == n) {
ir_node *adr = get_Store_ptr(succ);
/*
* if this Alloc depends on another one,
* we can enqueue it
*/
if (is_depend_alloc(adr))
break;
/*
* We are storing n. As long as we do not further
* evaluate things, the pointer 'escape' here
......@@ -149,8 +182,7 @@ static int can_escape(ir_node *n) {
ir_node *ptr = get_Call_ptr(succ);
ir_entity *ent;
if (get_irn_op(ptr) == op_SymConst &&
get_SymConst_kind(ptr) == symconst_addr_ent) {
if (is_SymConst_addr_ent(ptr)) {
ent = get_SymConst_entity(ptr);
/* we know the called entity */
......@@ -163,7 +195,7 @@ static int can_escape(ir_node *n) {
}
}
}
else if (get_irn_op(ptr) == op_Sel) {
else if (is_Sel(ptr)) {
/* go through all possible callees */
for (k = get_Call_n_callees(succ) - 1; k >= 0; --k) {
ent = get_Call_callee(succ, k);
......@@ -297,7 +329,7 @@ static void find_allocation_calls(ir_node *call, void *ctx)
if (! is_Call(call))
return;
adr = get_Call_ptr(call);
if (! is_SymConst(adr) || get_SymConst_kind(adr) != symconst_addr_ent)
if (! is_SymConst_addr_ent(adr))
return;
ent = get_SymConst_entity(adr);
if (! env->callback(ent))
......@@ -399,6 +431,7 @@ static void transform_allocs(ir_graph *irg, walk_env_t *env)
DBG((dbgHandle, LEVEL_DEFAULT, "%+F allocation of %+F type %+F placed on frame\n", irg, alloc, tp));
snprintf(name, sizeof(name), "%s_NE_%u", get_entity_name(get_irg_entity(irg)), nr++);
name[sizeof(name) - 1] = '\0';
ent = new_d_entity(ftp, new_id_from_str(name), get_Alloc_type(alloc), dbg);
sel = new_rd_simpleSel(dbg, irg, get_nodes_block(alloc),
......
......@@ -50,6 +50,7 @@
#include "irouts.h"
#include "irloop_t.h"
#include "irbackedge_t.h"
#include "opt_inline_t.h"
#include "cgana.h"
#include "trouts.h"
#include "error.h"
......@@ -60,6 +61,7 @@
#include "irhooks.h"
#include "irtools.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg;)
/*------------------------------------------------------------------*/
/* Routines for dead node elimination / copying garbage collection */
......@@ -1212,9 +1214,6 @@ void inline_small_irgs(ir_graph *irg, int size) {
ir_graph *rem = current_ir_graph;
inline_env_t env;
call_entry *entry;
DEBUG_ONLY(firm_dbg_module_t *dbg;)
FIRM_DBG_REGISTER(dbg, "firm.opt.inline");
current_ir_graph = irg;
/* Handle graph state */
......@@ -1406,9 +1405,7 @@ void inline_leave_functions(int maxsize, int leavesize, int size, int ignore_run
const call_entry *centry;
pmap *copied_graphs;
pmap_entry *pm_entry;
DEBUG_ONLY(firm_dbg_module_t *dbg;)
FIRM_DBG_REGISTER(dbg, "firm.opt.inline");
rem = current_ir_graph;
obstack_init(&temp_obst);
......@@ -1836,9 +1833,7 @@ void inline_functions(int inline_threshold) {
const call_entry *centry;
pmap *copied_graphs;
pmap_entry *pm_entry;
DEBUG_ONLY(firm_dbg_module_t *dbg;)
FIRM_DBG_REGISTER(dbg, "firm.opt.inline");
rem = current_ir_graph;
obstack_init(&temp_obst);
......@@ -2016,3 +2011,7 @@ void inline_functions(int inline_threshold) {
obstack_free(&temp_obst, NULL);
current_ir_graph = rem;
}
void firm_init_inline(void) {
FIRM_DBG_REGISTER(dbg, "firm.opt.inline");
}
......@@ -19,12 +19,12 @@
/**
* @file
* @brief Internal irgopt functions.
* @version $Id$
* @brief Dead node elimination and Procedure Inlining.
* @version $Id: $
*/
#ifndef FIRM_IR_IRGOPT_T_H
#define FIRM_IR_IRGOPT_T_H
#ifndef FIRM_OPT_INLINE_T_H
#define FIRM_OPT_INLINE_T_H
void firm_copy_node (ir_node *n, void *env);
void firm_init_inline(void);
#endif
......@@ -1064,7 +1064,7 @@ fp_value *fc_val_from_ieee754(LLDBL l, char exp_size, char mant_size, fp_value *
temp = alloca(value_size);
/* CLEAR the buffer */
memset(result, 0, fc_get_buffer_length());
//memset(result, 0, fc_get_buffer_length());
result->desc.exponent_size = exp_size;
result->desc.mantissa_size = mant_size;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment