Hi,
I try to create and populate a new struct into my the generated code.
Something like:
struct ddm_temaplate{
int loop_interations;
int ddm_thread_num;
};
What I have up to now is the following:
static tree build_ddm_template_struct() {
tree type = lang_hooks.types.make_type(RECORD_TYPE);
tree id, field, fields;
id = get_identifier("loop_interations");
fields = build_decl (FIELD_DECL,id, integer_type_node);
id = get_identifier("ddm_thread_num");
field = build_decl (FIELD_DECL, id, integer_type_node);
TREE_CHAIN (field) = fields;
fields = field;
finish_builtin_struct(type, "__ddm_template", fields, NULL_TREE);
return type;
}
/* After this call I get somthing like struct __ddm_template
.ddm_template_instance.38; ...*/
static tree build_struct_instance(tree type) {
tree arg_struct_instance, var;
arg_struct_instance = create_tmp_var(type, ".ddm_template_instance");
return arg_struct_instance;
}
and I use them as
type = build_ddm_template_struct();
struct_instance = build_struct_instance(type);
fields = TYPE_FIELDS (type);
t = build3(COMPONENT_REF, type, struct_instance, fields, NULL_TREE);
tree astmt = build_gimple_modify_stmt(t,build_int_cstu
(lang_hooks.types.type_for_size (32, true),99));
print_generic_stmt(stderr, astmt,0); /* Here i get something like
.ddm_template_instance.38.loop_interations = 99; */
bsi_insert_after(&si, astmt, BSI_NEW_STMT);
This code will create an error when verify_loop_closed_ssa() is called.
I believe the problem is that loop_interations field does not get an SSA
name.
Can anyone help me fixing this problem.
Thanks in advance
Petros