From 130afd2613d53f950dc9dd8e0b0968777d5c450d Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Mon, 10 Nov 2025 16:13:47 +0800 Subject: [PATCH] 1, set 'start flag' of a new basic block to the 3ac code for 'assign to a pointer', 2, mov DAG optimizer of basic block before auto gc, 3, add x64 native 'seta, setb, setae, setbe' for float cmp, 4, fix: x64_inst_is_useful(). --- core/scf_3ac.c | 77 ++++++++++----------------- core/scf_operator_dag.c | 10 +++- core/scf_optimizer.c | 8 ++- core/scf_pointer_alias.c | 8 +-- native/x64/scf_x64_inst_cmp.c | 31 ++++++++++- native/x64/scf_x64_opcode.c | 6 +++ native/x64/scf_x64_opcode.h | 1 - native/x64/scf_x64_peephole.c | 23 +++++--- native/x64/scf_x64_rcg.c | 59 ++++++-------------- native/x64/scf_x64_util.h | 8 ++- parse/scf_dfa.c | 36 +++++++------ parse/scf_operator_handler_semantic.c | 20 ------- 12 files changed, 138 insertions(+), 149 deletions(-) diff --git a/core/scf_3ac.c b/core/scf_3ac.c index 37989c2..0e28716 100644 --- a/core/scf_3ac.c +++ b/core/scf_3ac.c @@ -502,7 +502,7 @@ void scf_3ac_code_print(scf_3ac_code_t* c, scf_list_t* sentinel) } if (c->srcs) { - + for (i = 0; i < c->srcs->size; i++) { src = c->srcs->data[i]; @@ -1252,49 +1252,37 @@ void scf_3ac_list_print(scf_list_t* h) static int _3ac_find_basic_block_start(scf_list_t* h) { - int start = 0; - scf_list_t* l; + scf_3ac_operand_t* dst; + scf_3ac_code_t* c; + scf_3ac_code_t* c2; + scf_variable_t* v; + scf_list_t* l; + scf_list_t* l2; - for (l = scf_list_head(h); l != scf_list_sentinel(h); l = scf_list_next(l)) { + int start = 0; - scf_3ac_code_t* c = scf_list_data(l, scf_3ac_code_t, list); + for (l = scf_list_head(h); l != scf_list_sentinel(h); l = scf_list_next(l)) { - scf_list_t* l2 = NULL; - scf_3ac_code_t* c2 = NULL; + c = scf_list_data(l, scf_3ac_code_t, list); if (!start) { c->basic_block_start = 1; start = 1; } -#if 0 - if (scf_type_is_assign_dereference(c->op->type)) { - - l2 = scf_list_next(&c->list); - if (l2 != scf_list_sentinel(h)) { - c2 = scf_list_data(l2, scf_3ac_code_t, list); - c2->basic_block_start = 1; - } - - c->basic_block_start = 1; - continue; - } - if (SCF_OP_DEREFERENCE == c->op->type) { - c->basic_block_start = 1; - continue; - } -#endif +#if 1 + if (SCF_OP_ASSIGN == c->op->type) { + dst = c->dsts->data[0]; + v = _scf_operand_get(dst->node); -#if 0 - if (SCF_OP_CALL == c->op->type) { + if (v->nb_pointers > 0) { + l2 = scf_list_next(&c->list); - l2 = scf_list_next(&c->list); - if (l2 != scf_list_sentinel(h)) { - c2 = scf_list_data(l2, scf_3ac_code_t, list); - c2->basic_block_start = 1; + if (l2 != scf_list_sentinel(h)) { + c2 = scf_list_data(l2, scf_3ac_code_t, list); + c2->basic_block_start = 1; + } + continue; } - -// c->basic_block_start = 1; - continue; } #endif @@ -1318,7 +1306,6 @@ static int _3ac_find_basic_block_start(scf_list_t* h) || SCF_OP_3AC_TEQ == c->op->type) { for (l2 = scf_list_next(&c->list); l2 != scf_list_sentinel(h); l2 = scf_list_next(l2)) { - c2 = scf_list_data(l2, scf_3ac_code_t, list); if (scf_type_is_setcc(c2->op->type)) @@ -1336,12 +1323,11 @@ static int _3ac_find_basic_block_start(scf_list_t* h) if (scf_type_is_jmp(c->op->type)) { - scf_3ac_operand_t* dst0 = c->dsts->data[0]; - - assert(dst0->code); + dst = c->dsts->data[0]; + assert(dst->code); // filter 1st expr of logic op, such as '&&', '||' - if (SCF_OP_3AC_TEQ == dst0->code->op->type) { + if (SCF_OP_3AC_TEQ == dst->code->op->type) { int ret = _3ac_filter_dst_teq(h, c); if (ret < 0) @@ -1349,7 +1335,6 @@ static int _3ac_find_basic_block_start(scf_list_t* h) } for (l2 = scf_list_prev(&c->list); l2 != scf_list_sentinel(h); l2 = scf_list_prev(l2)) { - c2 = scf_list_data(l2, scf_3ac_code_t, list); if (scf_type_is_setcc(c2->op->type)) @@ -1370,12 +1355,7 @@ static int _3ac_find_basic_block_start(scf_list_t* h) } #if 1 for (l = scf_list_head(h); l != scf_list_sentinel(h); ) { - - scf_3ac_code_t* c = scf_list_data(l, scf_3ac_code_t, list); - - scf_list_t* l2 = NULL; - scf_3ac_code_t* c2 = NULL; - scf_3ac_operand_t* dst0 = NULL; + c = scf_list_data(l, scf_3ac_code_t, list); if (SCF_OP_3AC_NOP == c->op->type) { assert(!c->jmp_dst_flag); @@ -1395,7 +1375,6 @@ static int _3ac_find_basic_block_start(scf_list_t* h) assert(!c->jmp_dst_flag); for (l2 = scf_list_next(&c->list); l2 != scf_list_sentinel(h); ) { - c2 = scf_list_data(l2, scf_3ac_code_t, list); if (c2->jmp_dst_flag) @@ -1408,10 +1387,10 @@ static int _3ac_find_basic_block_start(scf_list_t* h) c2 = NULL; } - l = scf_list_next(l); - dst0 = c->dsts->data[0]; + l = scf_list_next(l); + dst = c->dsts->data[0]; - if (l == &dst0->code->list) { + if (l == &dst->code->list) { scf_list_del(&c->list); scf_3ac_code_free(c); c = NULL; diff --git a/core/scf_operator_dag.c b/core/scf_operator_dag.c index cac9df1..a3142e8 100644 --- a/core/scf_operator_dag.c +++ b/core/scf_operator_dag.c @@ -373,8 +373,11 @@ static int _scf_dag_op_##name(scf_list_t* h, scf_dag_node_t* parent, scf_dag_nod } SCF_OP_CMP(eq, ==, SCF_OP_EQ) -SCF_OP_CMP(gt, >, SCF_OP_GT) -SCF_OP_CMP(lt, <, SCF_OP_LT) +SCF_OP_CMP(ne, !=, SCF_OP_NE) +SCF_OP_CMP(gt, >, SCF_OP_GT) +SCF_OP_CMP(ge, >=, SCF_OP_GE) +SCF_OP_CMP(lt, <, SCF_OP_LT) +SCF_OP_CMP(le, <=, SCF_OP_LE) scf_dag_operator_t dag_operators[] = { @@ -406,8 +409,11 @@ scf_dag_operator_t dag_operators[] = {SCF_OP_BIT_OR, SCF_OP_ASSOCIATIVITY_LEFT, _scf_dag_op_or}, {SCF_OP_EQ, SCF_OP_ASSOCIATIVITY_LEFT, _scf_dag_op_eq}, + {SCF_OP_NE, SCF_OP_ASSOCIATIVITY_LEFT, _scf_dag_op_ne}, {SCF_OP_GT, SCF_OP_ASSOCIATIVITY_LEFT, _scf_dag_op_gt}, + {SCF_OP_GE, SCF_OP_ASSOCIATIVITY_LEFT, _scf_dag_op_ge}, {SCF_OP_LT, SCF_OP_ASSOCIATIVITY_LEFT, _scf_dag_op_lt}, + {SCF_OP_LE, SCF_OP_ASSOCIATIVITY_LEFT, _scf_dag_op_le}, {SCF_OP_VLA_ALLOC, SCF_OP_ASSOCIATIVITY_LEFT, _scf_dag_op_vla_alloc}, {SCF_OP_RETURN, SCF_OP_ASSOCIATIVITY_LEFT, _scf_dag_op_return}, diff --git a/core/scf_optimizer.c b/core/scf_optimizer.c index d8e5da4..80099ab 100644 --- a/core/scf_optimizer.c +++ b/core/scf_optimizer.c @@ -45,15 +45,13 @@ static scf_optimizer_t* scf_optimizers[] = &scf_optimizer_pointer_aliases, &scf_optimizer_loads_saves, - &scf_optimizer_auto_gc_find, // global optimizer + &scf_optimizer_basic_block, + &scf_optimizer_const_teq, + &scf_optimizer_auto_gc_find, // global optimizer &scf_optimizer_dominators, - &scf_optimizer_auto_gc, - &scf_optimizer_basic_block, - &scf_optimizer_const_teq, - &scf_optimizer_active_vars, &scf_optimizer_loads_saves, diff --git a/core/scf_pointer_alias.c b/core/scf_pointer_alias.c index fde6de7..02af3c6 100644 --- a/core/scf_pointer_alias.c +++ b/core/scf_pointer_alias.c @@ -153,8 +153,10 @@ static int _bb_pointer_initeds(scf_vector_t* initeds, scf_list_t* bb_list_head, if (v->tmp_flag) return 0; - scf_loge("pointer '%s' is not inited, tmp_flag: %d, local_flag: %d, file: %s, line: %d\n", - v->w->text->data, v->tmp_flag, v->local_flag, v->w->file->data, v->w->line); + if (SCF_OP_ADDRESS_OF != dn->type) { + scf_loge("pointer '%s_%d_%d' is not inited, tmp_flag: %d, local_flag: %d, file: %s, line: %d\n", + v->w->text->data, v->w->line, v->w->pos, v->tmp_flag, v->local_flag, v->w->file->data, v->w->line); + } return SCF_POINTER_NOT_INIT; } @@ -1557,7 +1559,7 @@ int scf_pointer_alias(scf_vector_t* aliases, scf_dag_node_t* dn_alias, scf_3ac_c default: if (dn_alias->var && dn_alias->var->w) { v = dn_alias->var; - scf_loge("type: %d, v_%d_%d/%s\n", dn_alias->type, v->w->line, v->w->pos, v->w->text->data); + scf_loge("type: %d, v_%d_%d/%s/%#lx\n", dn_alias->type, v->w->line, v->w->pos, v->w->text->data, 0xffff & (uintptr_t)dn_alias->var); } else scf_loge("type: %d, v_%#lx\n", dn_alias->type, 0xffff & (uintptr_t)dn_alias->var); return -1; diff --git a/native/x64/scf_x64_inst_cmp.c b/native/x64/scf_x64_inst_cmp.c index ad09f1a..84c40f9 100644 --- a/native/x64/scf_x64_inst_cmp.c +++ b/native/x64/scf_x64_inst_cmp.c @@ -204,6 +204,35 @@ int x64_inst_cmp_set(scf_native_t* ctx, scf_3ac_code_t* c, int setcc_type) if (ret < 0) return ret; + scf_3ac_operand_t* src = c->srcs->data[0]; + scf_dag_node_t* dn = src->dag_node; + + int is_float = scf_variable_float(dn->var); + + switch (setcc_type) + { + case SCF_X64_SETG: + if (is_float) + setcc_type = SCF_X64_SETA; + break; + + case SCF_X64_SETGE: + if (is_float) + setcc_type = SCF_X64_SETAE; + break; + + case SCF_X64_SETL: + if (is_float) + setcc_type = SCF_X64_SETB; + break; + + case SCF_X64_SETLE: + if (is_float) + setcc_type = SCF_X64_SETBE; + break; + default: + break; + }; + return x64_inst_set(ctx, c, setcc_type); } - diff --git a/native/x64/scf_x64_opcode.c b/native/x64/scf_x64_opcode.c index 8254307..1b51082 100644 --- a/native/x64/scf_x64_opcode.c +++ b/native/x64/scf_x64_opcode.c @@ -241,6 +241,12 @@ scf_x64_OpCode_t x64_OpCodes[] = { {SCF_X64_SETL, "setl", 3, {0x0f, 0x9c, 0x0},2, 1,1, SCF_X64_E, 0,0, 0,{0,0}}, {SCF_X64_SETLE, "setle", 3, {0x0f, 0x9e, 0x0},2, 1,1, SCF_X64_E, 0,0, 0,{0,0}}, + {SCF_X64_SETA, "seta", 3, {0x0f, 0x97, 0x0},2, 1,1, SCF_X64_E, 0,0, 0,{0,0}}, + {SCF_X64_SETAE, "setae", 3, {0x0f, 0x93, 0x0},2, 1,1, SCF_X64_E, 0,0, 0,{0,0}}, + + {SCF_X64_SETB, "setb", 3, {0x0f, 0x92, 0x0},2, 1,1, SCF_X64_E, 0,0, 0,{0,0}}, + {SCF_X64_SETBE, "setbe", 3, {0x0f, 0x96, 0x0},2, 1,1, SCF_X64_E, 0,0, 0,{0,0}}, + {SCF_X64_ADDSS, "addss", 4, {0xf3, 0x0f, 0x58},3, 4,4, SCF_X64_E2G, 0,0, 0,{0,0}}, {SCF_X64_ADDSD, "addsd", 8, {0xf2, 0x0f, 0x58},3, 8,8, SCF_X64_E2G, 0,0, 0,{0,0}}, diff --git a/native/x64/scf_x64_opcode.h b/native/x64/scf_x64_opcode.h index 92cbec4..c471e2d 100644 --- a/native/x64/scf_x64_opcode.h +++ b/native/x64/scf_x64_opcode.h @@ -34,4 +34,3 @@ scf_x64_OpCode_t* x64_find_OpCode(const int type, const int OpBytes, const int int x64_find_OpCodes(scf_vector_t* results, const int type, const int OpBytes, const int RegBytes, const int EG); #endif - diff --git a/native/x64/scf_x64_peephole.c b/native/x64/scf_x64_peephole.c index 7a1d856..57f906c 100644 --- a/native/x64/scf_x64_peephole.c +++ b/native/x64/scf_x64_peephole.c @@ -339,7 +339,7 @@ static int x64_inst_is_useful(scf_instruction_t* inst, scf_instruction_t* std) if (x64_inst_data_is_reg(&inst->dst)) { scf_register_t* r0 = inst->dst.base; - scf_register_t* r1 = std->src.base; + scf_register_t* r1; if (SCF_X64_CALL == std->OpCode->type) { @@ -352,15 +352,25 @@ static int x64_inst_is_useful(scf_instruction_t* inst, scf_instruction_t* std) return 1; } else { + r1 = std->src.base; if (x64_inst_data_is_reg(&std->src)) { if (X64_COLOR_CONFLICT(r0->color, r1->color)) return 1; } - if (std->src.base == inst->dst.base - || std->src.index == inst->dst.base - || std->dst.index == inst->dst.base - || std->dst.base == inst->dst.base) + if (r1 && X64_COLOR_CONFLICT(r1->color, r0->color)) + return 1; + + r1 = std->src.index; + if (r1 && X64_COLOR_CONFLICT(r1->color, r0->color)) + return 1; + + r1 = std->dst.index; + if (r1 && X64_COLOR_CONFLICT(r1->color, r0->color)) + return 1; + + r1 = std->dst.base; + if (r1 && X64_COLOR_CONFLICT(r1->color, r0->color)) return 1; } @@ -502,9 +512,6 @@ static int _x64_peephole_function(scf_vector_t* tmp_insts, scf_function_t* f) assert(0 == scf_vector_del(c->instructions, inst)); assert(0 == scf_vector_del(tmp_insts, inst)); -// scf_logd("del: \n"); -// scf_instruction_print(inst); - free(inst); inst = NULL; } diff --git a/native/x64/scf_x64_rcg.c b/native/x64/scf_x64_rcg.c index bb0d728..79059a8 100644 --- a/native/x64/scf_x64_rcg.c +++ b/native/x64/scf_x64_rcg.c @@ -805,49 +805,22 @@ X64_RCG_SET(setge) X64_RCG_SET(setlt) X64_RCG_SET(setle) -static int _x64_rcg_eq_handler(scf_native_t* ctx, scf_3ac_code_t* c, scf_graph_t* g) -{ - scf_3ac_operand_t* dst = c->dsts->data[0]; - - int ret = _x64_rcg_make2(c, dst->dag_node, NULL, NULL); - if (ret < 0) - return ret; - - return _x64_rcg_make(c, g, dst->dag_node, NULL, NULL); -} - -static int _x64_rcg_ne_handler(scf_native_t* ctx, scf_3ac_code_t* c, scf_graph_t* g) -{ - scf_3ac_operand_t* dst = c->dsts->data[0]; - - int ret = _x64_rcg_make2(c, dst->dag_node, NULL, NULL); - if (ret < 0) - return ret; - - return _x64_rcg_make(c, g, dst->dag_node, NULL, NULL); -} - -static int _x64_rcg_gt_handler(scf_native_t* ctx, scf_3ac_code_t* c, scf_graph_t* g) -{ - scf_3ac_operand_t* dst = c->dsts->data[0]; - - int ret = _x64_rcg_make2(c, dst->dag_node, NULL, NULL); - if (ret < 0) - return ret; - - return _x64_rcg_make(c, g, dst->dag_node, NULL, NULL); -} - -static int _x64_rcg_lt_handler(scf_native_t* ctx, scf_3ac_code_t* c, scf_graph_t* g) -{ - scf_3ac_operand_t* dst = c->dsts->data[0]; - - int ret = _x64_rcg_make2(c, dst->dag_node, NULL, NULL); - if (ret < 0) - return ret; - - return _x64_rcg_make(c, g, dst->dag_node, NULL, NULL); +#define X64_RCG_CMP(op) \ +static int _x64_rcg_##op##_handler(scf_native_t* ctx, scf_3ac_code_t* c, scf_graph_t* g) \ +{ \ + scf_3ac_operand_t* dst = c->dsts->data[0]; \ + \ + int ret = _x64_rcg_make2(c, dst->dag_node, NULL, NULL); \ + if (ret < 0) \ + return ret; \ + return _x64_rcg_make(c, g, dst->dag_node, NULL, NULL); \ } +X64_RCG_CMP(eq) +X64_RCG_CMP(ne) +X64_RCG_CMP(gt) +X64_RCG_CMP(ge) +X64_RCG_CMP(lt) +X64_RCG_CMP(le) static int _x64_rcg_assign_handler(scf_native_t* ctx, scf_3ac_code_t* c, scf_graph_t* g) { @@ -1296,7 +1269,9 @@ static x64_rcg_handler_pt x64_rcg_handlers[SCF_N_3AC_OPS] = [SCF_OP_EQ ] = _x64_rcg_eq_handler, [SCF_OP_NE ] = _x64_rcg_ne_handler, [SCF_OP_GT ] = _x64_rcg_gt_handler, + [SCF_OP_GE ] = _x64_rcg_ge_handler, [SCF_OP_LT ] = _x64_rcg_lt_handler, + [SCF_OP_LE ] = _x64_rcg_le_handler, [SCF_OP_ASSIGN ] = _x64_rcg_assign_handler, [SCF_OP_ADD_ASSIGN ] = _x64_rcg_add_assign_handler, diff --git a/native/x64/scf_x64_util.h b/native/x64/scf_x64_util.h index 2458e9f..837c30a 100644 --- a/native/x64/scf_x64_util.h +++ b/native/x64/scf_x64_util.h @@ -74,6 +74,12 @@ enum scf_x64_OpCode_types { SCF_X64_SETL, SCF_X64_SETLE, + SCF_X64_SETA, + SCF_X64_SETAE, + + SCF_X64_SETB, + SCF_X64_SETBE, + SCF_X64_ADDSS, SCF_X64_ADDSD, @@ -83,7 +89,6 @@ enum scf_x64_OpCode_types { SCF_X64_MULSS, SCF_X64_MULSD, - // 41 SCF_X64_DIVSS, SCF_X64_DIVSD, @@ -93,7 +98,6 @@ enum scf_x64_OpCode_types { SCF_X64_UCOMISS, SCF_X64_UCOMISD, - // 47 SCF_X64_CVTSI2SD, SCF_X64_CVTSI2SS, diff --git a/parse/scf_dfa.c b/parse/scf_dfa.c index d8a1a93..e10711b 100644 --- a/parse/scf_dfa.c +++ b/parse/scf_dfa.c @@ -11,7 +11,7 @@ static scf_dfa_ops_t* dfa_ops_array[] = NULL, }; -static int _scf_dfa_node_parse_word(scf_dfa_t* dfa, scf_dfa_node_t* node, scf_vector_t* words, void* data); +static int _scf_dfa_node_parse_word(scf_dfa_t* dfa, scf_dfa_node_t* node, scf_vector_t* words, void* data, int pre_hook_flag); void scf_dfa_del_hook_by_name(scf_dfa_hook_t** pp, const char* name) { @@ -263,11 +263,14 @@ static int _scf_dfa_childs_parse_word(scf_dfa_t* dfa, scf_dfa_node_t** childs, i scf_logd("i: %d, nb_childs: %d, child: %s, w: %s\n", i, nb_childs, child->name, w->text->data); + int pre_hook_flag = 0; + scf_dfa_hook_t* hook = scf_dfa_find_hook(dfa, &(dfa->hooks[SCF_DFA_HOOK_PRE]), w); if (hook) { // if pre hook is set, deliver the word to the proper hook node. if (hook->node != child) continue; + pre_hook_flag = 1; scf_logi("\033[32mpre hook: %s\033[0m\n", hook->node->name); @@ -281,7 +284,7 @@ static int _scf_dfa_childs_parse_word(scf_dfa_t* dfa, scf_dfa_node_t** childs, i continue; } - int ret = _scf_dfa_node_parse_word(dfa, child, words, data); + int ret = _scf_dfa_node_parse_word(dfa, child, words, data, pre_hook_flag); if (SCF_DFA_OK == ret) return SCF_DFA_OK; @@ -294,7 +297,7 @@ static int _scf_dfa_childs_parse_word(scf_dfa_t* dfa, scf_dfa_node_t** childs, i return SCF_DFA_NEXT_SYNTAX; } -static int _scf_dfa_node_parse_word(scf_dfa_t* dfa, scf_dfa_node_t* node, scf_vector_t* words, void* data) +static int _scf_dfa_node_parse_word(scf_dfa_t* dfa, scf_dfa_node_t* node, scf_vector_t* words, void* data, int pre_hook_flag) { int ret = SCF_DFA_NEXT_WORD; scf_lex_word_t* w = words->data[words->size - 1]; @@ -332,30 +335,31 @@ static int _scf_dfa_node_parse_word(scf_dfa_t* dfa, scf_dfa_node_t* node, scf_ve printf("\n"); #endif - scf_dfa_hook_t* hook = scf_dfa_find_hook(dfa, &(dfa->hooks[SCF_DFA_HOOK_POST]), w); - if (hook) { - scf_dfa_node_t* hook_node = hook->node; + if (!pre_hook_flag) { + scf_dfa_hook_t* hook = scf_dfa_find_hook(dfa, &(dfa->hooks[SCF_DFA_HOOK_POST]), w); + if (hook) { + scf_dfa_node_t* hook_node = hook->node; - scf_dfa_clear_hooks(&(dfa->hooks[SCF_DFA_HOOK_POST]), hook->next); - hook = NULL; + scf_dfa_clear_hooks(&(dfa->hooks[SCF_DFA_HOOK_POST]), hook->next); + hook = NULL; - scf_logi("\033[32m post hook: %s->action()\033[0m\n", hook_node->name); + scf_logi("\033[32m post hook: %s->action()\033[0m\n", hook_node->name); - if (hook_node != node && hook_node->action) { + if (hook_node != node && hook_node->action) { - ret = hook_node->action(dfa, words, data); + ret = hook_node->action(dfa, words, data); - if (SCF_DFA_SWITCH_TO == ret) { - scf_logi("\033[32m post hook: switch to %s->%s\033[0m\n", node->name, hook_node->name); + if (SCF_DFA_SWITCH_TO == ret) { + scf_logi("\033[32m post hook: switch to %s->%s\033[0m\n", node->name, hook_node->name); - node = hook_node; - ret = SCF_DFA_NEXT_WORD; + node = hook_node; + ret = SCF_DFA_NEXT_WORD; + } } } } if (SCF_DFA_OK == ret) { - scf_dfa_hook_t** pp = &(dfa->hooks[SCF_DFA_HOOK_END]); while (*pp) { diff --git a/parse/scf_operator_handler_semantic.c b/parse/scf_operator_handler_semantic.c index e05302e..a80a216 100644 --- a/parse/scf_operator_handler_semantic.c +++ b/parse/scf_operator_handler_semantic.c @@ -3037,27 +3037,11 @@ static int _scf_op_semantic_cmp(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes static int _scf_op_semantic_eq(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void* data) { -#define CMPEQ_CHECK_FLOAT() \ - do { \ - assert(2 == nb_nodes); \ - scf_variable_t* v0 = _scf_operand_get(nodes[0]); \ - scf_variable_t* v1 = _scf_operand_get(nodes[1]); \ - \ - if (scf_variable_float(v0) || scf_variable_float(v1)) { \ - scf_loge("float type can't cmp equal\n"); \ - return -EINVAL; \ - } \ - } while (0) - - CMPEQ_CHECK_FLOAT(); - return _scf_op_semantic_cmp(ast, nodes, nb_nodes, data); } static int _scf_op_semantic_ne(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void* data) { - CMPEQ_CHECK_FLOAT(); - return _scf_op_semantic_cmp(ast, nodes, nb_nodes, data); } @@ -3068,8 +3052,6 @@ static int _scf_op_semantic_gt(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, static int _scf_op_semantic_ge(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void* data) { - CMPEQ_CHECK_FLOAT(); - return _scf_op_semantic_cmp(ast, nodes, nb_nodes, data); } @@ -3080,8 +3062,6 @@ static int _scf_op_semantic_lt(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, static int _scf_op_semantic_le(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void* data) { - CMPEQ_CHECK_FLOAT(); - return _scf_op_semantic_cmp(ast, nodes, nb_nodes, data); } -- 2.25.1