int scf_dn_status_copy_dn(scf_dn_status_t* dst, scf_dn_status_t* src)
{
- scf_dn_index_t* di;
+ scf_dn_index_t* di;
int i;
if (!dst || !src)
int scf_dn_status_copy_alias(scf_dn_status_t* dst, scf_dn_status_t* src)
{
- scf_dn_index_t* di;
+ scf_dn_index_t* di;
int i;
if (!dst || !src)
}
}
- ds2->dag_node = ds->dag_node;
- ds2->dereference = ds->dereference;
+ ds2->dag_node = ds->dag_node;
+ ds2->dereference = ds->dereference;
- ds2->alias = ds->alias;
- ds2->alias_type = ds->alias_type;
+ ds2->alias = ds->alias;
+ ds2->alias_type = ds->alias_type;
- ds2->active = ds->active;
- ds2->inited = ds->inited;
- ds2->updated = ds->updated;
- ds2->ret = ds->ret;
+ ds2->active = ds->active;
+ ds2->inited = ds->inited;
+ ds2->updated = ds->updated;
+ ds2->ret = ds->ret;
return ds2;
}
int i;
if (ds) {
-
assert(ds->refs > 0);
if (--ds->refs > 0)
int i;
if (ds->dag_node) {
-
v = ds->dag_node->var;
printf("dn: v_%d_%d/%s ", v->w->line, v->w->pos, v->w->text->data);
dn->node = (scf_node_t*)node;
-#if 1
+#if 0
if (SCF_OP_CALL == type) {
scf_logw("dn: %#lx, dn->type: %d", 0xffff & (uintptr_t)dn, dn->type);
if (var) {
if (ds0->dn_indexes->size != ds1->dn_indexes->size)
return -1;
+ scf_dn_index_t* di0;
+ scf_dn_index_t* di1;
int i;
- for (i = 0; i < ds0->dn_indexes->size; i++) {
- scf_dn_index_t* di0 = ds0->dn_indexes->data[i];
- scf_dn_index_t* di1 = ds1->dn_indexes->data[i];
+ for (i = 0; i < ds0->dn_indexes->size; i++) {
+ di0 = ds0->dn_indexes->data[i];
+ di1 = ds1->dn_indexes->data[i];
if (!cmp(di0, di1))
return -1;
if (v0->alias_indexes->size != v1->alias_indexes->size)
return -1;
+ scf_dn_index_t* di0;
+ scf_dn_index_t* di1;
int i;
- for (i = 0; i < v0->alias_indexes->size; i++) {
- scf_dn_index_t* di0 = v0->alias_indexes->data[i];
- scf_dn_index_t* di1 = v1->alias_indexes->data[i];
+ for (i = 0; i < v0->alias_indexes->size; i++) {
+ di0 = v0->alias_indexes->data[i];
+ di1 = v1->alias_indexes->data[i];
if (!scf_dn_index_like(di0, di1))
return -1;
void scf_dag_node_free_list(scf_list_t* dag_list_head)
{
- scf_list_t* l;
+ scf_dag_node_t* dn;
+ scf_list_t* l;
for (l = scf_list_head(dag_list_head); l != scf_list_sentinel(dag_list_head); ) {
-
- scf_dag_node_t* dn = scf_list_data(l, scf_dag_node_t, list);
+ dn = scf_list_data(l, scf_dag_node_t, list);
l = scf_list_next(l);
if (dn->type != node->type)
return 0;
- if (SCF_OP_ADDRESS_OF == node->type) {
+ if (SCF_OP_ADDRESS_OF == node->type)
scf_logd("type: %d, %d, node: %#lx, %#lx, ", dn->type, node->type, 0xffff & (uintptr_t)dn, 0xffff & (uintptr_t)node);
- }
if (scf_type_is_var(node->type)) {
if (dn->var == node->var)
if (v0 && v0->w && v1 && v1->w) {
if (v0->type != v1->type) {
- scf_loge("v0: %d/%s_%#lx, split_flag: %d\n", v0->w->line, v0->w->text->data, 0xffff & (uintptr_t)v0, node->split_flag);
- scf_loge("v1: %d/%s_%#lx\n", v1->w->line, v1->w->text->data, 0xffff & (uintptr_t)v1);
+ scf_logd("v0: %d/%s_%#lx, split_flag: %d\n", v0->w->line, v0->w->text->data, 0xffff & (uintptr_t)v0, node->split_flag);
+ scf_logd("v1: %d/%s_%#lx\n", v1->w->line, v1->w->text->data, 0xffff & (uintptr_t)v1);
}
}
scf_dag_node_t* scf_dag_find_node(scf_list_t* h, const scf_node_t* node)
{
- scf_list_t* l;
- scf_node_t* origin = (scf_node_t*)node;
+ scf_dag_node_t* dn;
+ scf_list_t* l;
+ scf_node_t* origin = (scf_node_t*)node;
while (SCF_OP_EXPR == origin->type)
origin = origin->nodes[0];
for (l = scf_list_tail(h); l != scf_list_sentinel(h); l = scf_list_prev(l)) {
-
- scf_dag_node_t* dn = scf_list_data(l, scf_dag_node_t, list);
+ dn = scf_list_data(l, scf_dag_node_t, list);
if (scf_dag_node_same(dn, origin))
return dn;
int scf_dag_find_roots(scf_list_t* h, scf_vector_t* roots)
{
- scf_list_t* l;
- for (l = scf_list_head(h); l != scf_list_sentinel(h); l = scf_list_next(l)) {
+ scf_dag_node_t* dn;
+ scf_list_t* l;
- scf_dag_node_t* dag_node = scf_list_data(l, scf_dag_node_t, list);
+ for (l = scf_list_head(h); l != scf_list_sentinel(h); l = scf_list_next(l)) {
+ dn = scf_list_data(l, scf_dag_node_t, list);
- if (!dag_node->parents) {
- int ret = scf_vector_add(roots, dag_node);
+ if (!dn->parents) {
+ int ret = scf_vector_add(roots, dn);
if (ret < 0)
return ret;
}
int scf_dag_find_leafs(scf_list_t* h, scf_vector_t* leafs)
{
- scf_list_t* l;
- for (l = scf_list_head(h); l != scf_list_sentinel(h); l = scf_list_next(l)) {
+ scf_dag_node_t* dn;
+ scf_list_t* l;
- scf_dag_node_t* dn = scf_list_data(l, scf_dag_node_t, list);
+ for (l = scf_list_head(h); l != scf_list_sentinel(h); l = scf_list_next(l)) {
+ dn = scf_list_data(l, scf_dag_node_t, list);
if (!dn->childs) {
int ret = scf_vector_add_unique(leafs, dn);
if (!root->childs)
return scf_vector_add_unique(leafs, root);
+ scf_dag_node_t* dn;
int i;
- for (i = 0; i < root->childs->size; i++) {
- scf_dag_node_t* child = root->childs->data[i];
+ for (i = 0; i < root->childs->size; i++) {
+ dn = root->childs->data[i];
- int ret = scf_dag_root_find_leafs(child, leafs);
+ int ret = scf_dag_root_find_leafs(dn, leafs);
if (ret < 0)
return ret;
}
int scf_dag_vector_find_leafs(scf_vector_t* roots, scf_vector_t* leafs)
{
+ scf_dag_node_t* root;
int i;
- for (i = 0; i < roots->size; i++) {
- scf_dag_node_t* root = roots->data[i];
+ for (i = 0; i < roots->size; i++) {
+ root = roots->data[i];
int ret = scf_dag_root_find_leafs(root, leafs);
if (ret < 0)
if (SCF_OP_ARRAY_INDEX == type) {
if (scf_variable_const(dn_index->var))
-
di->index = dn_index->var->data.i;
else
di->index = -1;
static int __ds_for_dn(scf_dn_status_t* ds, scf_dag_node_t* dn_base)
{
- scf_dag_node_t* dn_index;
- scf_dag_node_t* dn_scale;
- scf_dn_index_t* di;
+ scf_dag_node_t* dn_index;
+ scf_dag_node_t* dn_scale;
+ scf_dn_index_t* di;
int ret;
return 0;
if (v->global_flag) {
- scf_loge("bb: %p, index: %d, global pointer v_%d_%d/%s is not inited\n", bb, bb->index, v->w->line, v->w->pos, v->w->text->data);
+ if (v->nb_pointers > 0)
+ scf_logw("global pointer '%s' is not inited, file: %s, line: %d\n", v->w->text->data, v->w->file->data, v->w->line);
return 0;
}
return 0;
if (dn->node->split_flag) {
- scf_loge("dn->node->split_parent: %d, %p\n", dn->node->split_parent->type, dn->node->split_parent);
- assert(dn->node->split_parent->type == SCF_OP_CALL
- || dn->node->split_parent->type == SCF_OP_CREATE);
+ scf_logd("dn->node->split_parent: %d, %p\n", dn->node->split_parent->type, dn->node->split_parent);
+ assert(dn->node->split_parent->type == SCF_OP_CALL
+ || dn->node->split_parent->type == SCF_OP_CREATE);
return 0;
}
if (ds->dn_indexes)
return 0;
- scf_loge("bb: %p, index: %d, pointer v_%d_%d/%s is not inited\n", bb, bb->index, v->w->line, v->w->pos, v->w->text->data);
-
+ scf_loge("pointer '%s' is not inited, file: %s, line: %d\n", v->w->text->data, v->w->file->data, v->w->line);
return SCF_POINTER_NOT_INIT;
}
}
}
- scf_loge("initeds->size: %d\n", initeds->size);
+ scf_logd("initeds->size: %d\n", initeds->size);
int i;
for (i = 0; i < initeds->size; i++) {
scf_basic_block_t* bb2 = initeds->data[i];
- scf_loge("bb2: %p, %d\n", bb2, bb2->index);
+ scf_logd("bb2: %p, %d\n", bb2, bb2->index);
}
ret = _bb_dfs_check_initeds(bb_list_head, bb, initeds);
v = dn->var;
if (!v->arg_flag && !v->global_flag) {
- scf_loge("in bb: %p, index: %d, pointer v_%d_%d/%s may not be inited\n",
- bb, bb->index, v->w->line, v->w->pos, v->w->text->data);
-
+ scf_loge("pointer '%s' is not inited, file: %s, line: %d\n", v->w->text->data, v->w->file->data, v->w->line);
return SCF_POINTER_NOT_INIT;
}
return 0;
return 0;
if (v->global_flag) {
- scf_loge("bb: %p, index: %d, global pointer v_%d_%d/%s is not inited\n", bb, bb->index, v->w->line, v->w->pos, v->w->text->data);
+ if (v->nb_pointers > 0)
+ scf_logw("global pointer '%s' is not inited, file: %s, line: %d\n", v->w->text->data, v->w->file->data, v->w->line);
return 0;
}
return 0;
if (dn->node->split_flag) {
- scf_loge("dn->node->split_parent: %d, %p\n", dn->node->split_parent->type, dn->node->split_parent);
assert(dn->node->split_parent->type == SCF_OP_CALL
- || dn->node->split_parent->type == SCF_OP_CREATE);
-
+ || dn->node->split_parent->type == SCF_OP_CREATE);
return 0;
}
if (ds->dn_indexes)
return 0;
- scf_loge("bb: %p, index: %d, pointer v_%d_%d/%s is not inited\n", bb, bb->index, v->w->line, v->w->pos, v->w->text->data);
-
+ scf_loge("pointer '%s' is not inited, file: %s, line: %d\n", v->w->text->data, v->w->file->data, v->w->line);
return SCF_POINTER_NOT_INIT;
}
}
return 0;
}
-
int _expr_add_var(scf_parse_t* parse, dfa_data_t* d);
typedef struct {
- scf_vector_t* init_exprs;
+ scf_lex_word_t* assign;
+ scf_vector_t* init_exprs;
- dfa_index_t* current_index;
- int current_n;
+ dfa_index_t* current_index;
+ int current_n;
+ int current_dim;
- int current_dim;
-
- int nb_lbs;
- int nb_rbs;
+ int nb_lbs;
+ int nb_rbs;
} init_module_data_t;
static int _do_data_init(scf_dfa_t* dfa, scf_vector_t* words, dfa_data_t* d)
int i = 0;
if (d->current_var->nb_dimentions > 0)
- ret = scf_array_init(parse->ast, w, d->current_var, md->init_exprs);
+ ret = scf_array_init(parse->ast, md->assign, d->current_var, md->init_exprs);
else if (d->current_var->type >= SCF_STRUCT)
- ret = scf_struct_init(parse->ast, w, d->current_var, md->init_exprs);
+ ret = scf_struct_init(parse->ast, md->assign, d->current_var, md->init_exprs);
if (ret < 0)
goto error;
ie = NULL;
}
+ md->assign = NULL;
+
scf_vector_free(md->init_exprs);
md->init_exprs = NULL;
static int _data_action_entry(scf_dfa_t* dfa, scf_vector_t* words, void* data)
{
+ assert(words->size >= 2);
+
scf_parse_t* parse = dfa->priv;
dfa_data_t* d = data;
- scf_lex_word_t* w = words->data[words->size - 1];
+ scf_lex_word_t* w = words->data[words->size - 2];
init_module_data_t* md = d->module_datas[dfa_module_init_data.index];
+ assert(SCF_LEX_WORD_ASSIGN == w->type);
+
+ md->assign = w;
md->nb_lbs = 0;
md->nb_rbs = 0;