From: yu.dongliang <18588496441@163.com> Date: Wed, 27 Dec 2023 16:45:56 +0000 (+0800) Subject: delete some unused code X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=04b3f67d69ec5edfb780b1148655e0dee8b73ae9;p=scf.git delete some unused code --- diff --git a/core/scf_dag.c b/core/scf_dag.c index 97b7d2a..0aefa7a 100644 --- a/core/scf_dag.c +++ b/core/scf_dag.c @@ -661,167 +661,6 @@ cmp_childs: return 1; } -int scf_dag_node_same2(scf_dag_node_t* dag_node, const scf_node_t* node) -{ - int i; - - if (node->split_flag) { - if (dag_node->var != _scf_operand_get(node)) - return 0; - node = node->split_parent; - } - - if (dag_node->type != node->type) - return 0; - - if (scf_type_is_var(node->type)) { - if (dag_node->var == node->var) - return 1; - else - return 0; - } - - if (SCF_OP_LOGIC_AND == node->type - || SCF_OP_LOGIC_OR == node->type - || SCF_OP_INC == node->type - || SCF_OP_DEC == node->type - || SCF_OP_INC_POST == node->type - || SCF_OP_DEC_POST == node->type) { - if (dag_node->var == _scf_operand_get((scf_node_t*)node)) - return 1; - return 0; - } - - if (!dag_node->childs) - return 0; - - if (SCF_OP_TYPE_CAST == node->type) { - scf_dag_node_t* dn0 = dag_node->childs->data[0]; - scf_variable_t* vn1 = _scf_operand_get(node->nodes[1]); - scf_node_t* n1 = node->nodes[1]; - - while (SCF_OP_EXPR == n1->type) - n1 = n1->nodes[0]; - - if (scf_dag_node_same2(dn0, n1) - && scf_variable_same_type(dag_node->var, node->result)) - return 1; - else - return 0; - - } else if (SCF_OP_ARRAY_INDEX == node->type) { - assert(3 == dag_node->childs->size); - assert(2 == node->nb_nodes); - goto cmp_childs; - - } else if (SCF_OP_ADDRESS_OF == node->type) { - assert(1 == node->nb_nodes); - - if (SCF_OP_ARRAY_INDEX == node->nodes[0]->type) { - assert(2 == node->nodes[0]->nb_nodes); - - if (!dag_node->childs || 3 != dag_node->childs->size) - return 0; - - node = node->nodes[0]; - goto cmp_childs; - - } else if (SCF_OP_POINTER == node->nodes[0]->type) { - assert(2 == node->nodes[0]->nb_nodes); - - if (!dag_node->childs || 2 != dag_node->childs->size) - return 0; - - node = node->nodes[0]; - goto cmp_childs; - } - } - - if (dag_node->childs->size != node->nb_nodes) - return 0; - -cmp_childs: - for (i = 0; i < node->nb_nodes; i++) { - scf_dag_node_t* dag_child = dag_node->childs->data[i]; - scf_node_t* child = node->nodes[i]; - - while (SCF_OP_EXPR == child->type) - child = child->nodes[0]; - - if (0 == scf_dag_node_same2(dag_child, child)) - return 0; - } - - return 1; -} - -scf_dag_node_t* scf_dag_find_node2(scf_list_t* h, const scf_node_t* node) -{ - scf_node_t* origin = (scf_node_t*)node; - - while (SCF_OP_EXPR == origin->type) - origin = origin->nodes[0]; - - scf_list_t* l; - for (l = scf_list_tail(h); l != scf_list_sentinel(h); l = scf_list_prev(l)) { - - scf_dag_node_t* dag_node = scf_list_data(l, scf_dag_node_t, list); - - if (scf_dag_node_same2(dag_node, origin)) - return dag_node; - } - - return NULL; -} - -int scf_dag_node_like (scf_dag_node_t* dn, const scf_node_t* node, scf_list_t* h) -{ - const scf_node_t* n1 = NULL; - scf_dag_node_t* dn0 = NULL; - scf_dag_node_t* dn1 = NULL; - scf_variable_t* vn1 = NULL; - scf_variable_t* res = _scf_operand_get(node); - - if (SCF_OP_TYPE_CAST == node->type) { - - dn0 = dn->childs->data[0]; - vn1 = _scf_operand_get(node->nodes[1]); - n1 = node->nodes[1]; - - while (SCF_OP_EXPR == n1->type) - n1 = n1->nodes[0]; - } else { - dn0 = dn; - n1 = node; - } - - if (scf_variable_same_type(dn->var, res)) { - - if (scf_dag_node_same(dn0, n1)) - return 1; - - dn1 = scf_dag_find_node(h, n1); - if (!dn1) { - - dn1 = scf_dag_find_node2(h, n1); - if (!dn1) - return 0; - } - - if (scf_dag_dn_same(dn0, dn1)) - return 1; - } - - scf_logd("var: %#lx, %#lx, type: %d, %d, node: %#lx, %#lx, same: %d\n", - 0xffff & (uintptr_t)dn0->var, - 0xffff & (uintptr_t)vn1, - dn->var->type, res->type, - 0xffff & (uintptr_t)dn, - 0xffff & (uintptr_t)node, - scf_variable_same_type(dn->var, res)); - return 0; -} - scf_dag_node_t* scf_dag_find_node(scf_list_t* h, const scf_node_t* node) { scf_node_t* origin = (scf_node_t*)node; diff --git a/core/scf_dag.h b/core/scf_dag.h index f90e9d1..f12135d 100644 --- a/core/scf_dag.h +++ b/core/scf_dag.h @@ -104,7 +104,6 @@ scf_dag_node_t* scf_dag_node_alloc(int type, scf_variable_t* var, const scf_no int scf_dag_node_add_child (scf_dag_node_t* parent, scf_dag_node_t* child); int scf_dag_node_same (scf_dag_node_t* dag_node, const scf_node_t* node); -int scf_dag_node_like (scf_dag_node_t* dag_node, const scf_node_t* node, scf_list_t* h); void scf_dag_node_free (scf_dag_node_t* dag_node); void scf_dag_node_free_list(scf_list_t* dag_list_head);