* ISA base class.
*/
struct _arch_isa_t {
- const arch_isa_if_t *impl;
+ const arch_isa_if_t *impl;
const arch_register_t *sp; /** The stack pointer register. */
const arch_register_t *bp; /** The base pointer register. */
const int stack_dir; /** -1 for decreasing, 1 for increasing. */
+ const be_main_env_t *main_env; /** the be main environment */
};
#define arch_isa_stack_dir(isa) ((isa)->stack_dir)
/**
* Initialize the isa interface.
- * @param file_handle the file handle to write the output to
- * @return a new isa instance
+ * @param file_handle the file handle to write the output to
+ * @param main_env the be main environment
+ * @return a new isa instance
*/
void *(*init)(FILE *file_handle);
* @param file_handle The file handle
* @return The environment.
*/
-extern arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa, FILE *file_handle);
+extern arch_env_t *arch_env_init(arch_env_t *env, const arch_isa_if_t *isa, FILE *file_handle, be_main_env_t *main_env);
/**
* Add a node handler to the environment.
memset(env, 0, sizeof(*env));
obstack_init(&env->obst);
env->arch_env = obstack_alloc(&env->obst, sizeof(env->arch_env[0]));
- env->arch_env->constructor_entities = pset_new_ptr(5);
env->options = &be_options;
FIRM_DBG_REGISTER(env->dbg, "be.main");
- arch_env_init(env->arch_env, isa_if, file_handle);
+ arch_env_init(env->arch_env, isa_if, file_handle, env);
/* Register the irn handler of the architecture */
if (arch_isa_get_irn_handler(env->arch_env->isa))
ir_graph *prof_init_irg = be_profile_instrument();
pset_insert_ptr(env.arch_env->constructor_entities, get_irg_entity(prof_init_irg));
}
- be_profile_read("test.c"); //FIXME
+ be_profile_read("test.c.prof"); //FIXME
/* For all graphs */
for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
if(bb == start_block || bb == get_irg_end_block(irg))
return;
- cnst = new_r_Const_long(irg, start_block, mode_Iu, get_mode_size_bytes(mode_Iu) * id);
+ cnst = new_r_Const_long(irg, start_block, mode_Iu, get_mode_size_bytes(mode_Iu) * id);
offset = new_r_Add(irg, bb, address, cnst, mode_P);
- load = new_r_Load(irg, bb, new_NoMem(), offset, mode_Iu);
- projm = new_r_Proj(irg, bb, load, mode_M, pn_Load_M);
- proji = new_r_Proj(irg, bb, load, mode_Iu, pn_Load_res);
- cnst = new_r_Const_long(irg, start_block, mode_Iu, 1);
- add = new_r_Add(irg, bb, proji, cnst, mode_Iu);
- store = new_r_Store(irg, bb, projm, offset, add);
- projm = new_r_Proj(irg, bb, store, mode_M, pn_Store_M);
+ load = new_r_Load(irg, bb, new_NoMem(), offset, mode_Iu);
+ projm = new_r_Proj(irg, bb, load, mode_M, pn_Load_M);
+ proji = new_r_Proj(irg, bb, load, mode_Iu, pn_Load_res);
+ cnst = new_r_Const_long(irg, start_block, mode_Iu, 1);
+ add = new_r_Add(irg, bb, proji, cnst, mode_Iu);
+ store = new_r_Store(irg, bb, projm, offset, add);
+ projm = new_r_Proj(irg, bb, store, mode_M, pn_Store_M);
keep_alive(projm);
}
entity *init_ent;
ir_graph *irg;
ir_node *bb;
+ ir_type *empty_frame_type;
uint = new_type_primitive(new_id_from_str("__uint"), mode_Iu);
uintptr = new_type_pointer(new_id_from_str("__uintptr"), uint, mode_P);
irg = new_ir_graph(ent, 0);
set_current_ir_graph(irg);
+ empty_frame_type = get_irg_frame_type(irg);
+ set_type_size_bytes(empty_frame_type, 0);
bb = get_cur_block();
bb, //ir_node * block,
get_irg_initial_mem(irg), //ir_node * store,
symconst, //ir_node * callee,
- 3, //int arity,
+ 4, //int arity,
ins, //ir_node ** in,
init_type //ir_type * tp
);
ir_node *const_block = get_irg_start_block(const_irg);
int n, i;
unsigned int n_blocks = 0;
- entity *bblock_id, *bblock_counts, *bblock_count, *ent_filename;
+ entity *bblock_id, *bblock_counts, *ent_filename;
ir_type *array_type, *integer_type, *string_type, *character_type;
tarval **tarval_array, **tarval_string;
char *filename = "test.c"; //FIXME
set_entity_variability(bblock_id, variability_initialized);
bblock_counts = new_entity(get_glob_type(), new_id_from_str("__BLOCK_COUNTS"), array_type);
set_entity_variability(bblock_counts, variability_initialized);
- bblock_count = new_entity(get_glob_type(), new_id_from_str("__N_BLOCKS"), integer_type);
- set_entity_variability(bblock_count, variability_initialized);
ent_filename = new_entity(get_glob_type(), new_id_from_str("__FUNCTION_NAME"), string_type);
set_entity_variability(ent_filename, variability_initialized);
}
set_array_entity_values(bblock_counts, tarval_array, n_blocks);
- /* initialize the block count entity */
- set_atomic_ent_value(bblock_count, new_r_Const_long(const_irg, const_block, mode_Iu, n_blocks));
-
/* initialize function name string constant */
tarval_string = alloca(sizeof(*tarval_string) * (filename_len));
for(i = 0; i < filename_len; ++i) {
ir_graph *irg = get_irp_irg(n);
/* generate a symbolic constant pointing to the count array */
- sym.entity_p = bblock_count;
+ sym.entity_p = bblock_counts;
wd.symconst = new_r_SymConst(irg, get_irg_start_block(irg), sym, symconst_addr_ent);
irg_block_walk_graph(irg, block_id_walker, NULL, &wd);