自己定义了一个函数:
bool phead_is_merge_into_head(const IR1_INST *const pir1, FLAG_PATTERN_ITEM *item, FLAG_PATTERN_PHEAD* phead_for_tail) {
CONDITION c = pir1->get_cond();
uint8 phead_number = phead_for_tail->phead_number;
bool b = true;
switch(c) {
case COND_EQ:
case COND_NE:
for (int i = 0; i < phead_number; ++i)
b &= phead_is_same_head_under_eq_ne(item->head->get_opcode(),phead_for_tail->phead[i]->get_opcode());
return b;
case COND_CS:
case COND_CC:
for (int i = 0; i < phead_number; ++i)
b &= phead_is_same_head_under_eq_ne(item->head->get_opcode(),phead_for_tail->phead[i]->get_opcode());
case COND_MI:
case COND_PL:
for (int i = 0; i < phead_number; ++i)
b &= phead_is_same_head_under_mi_pl(item->head->get_opcode(),phead_for_tail->phead[i]->get_opcode());
case COND_HI:
case COND_LS:
for (int i = 0; i < phead_number; ++i)
b &= phead_is_same_head_under_hi_ls(item->head->get_opcode(),phead_for_tail->phead[i]->get_opcode());
case COND_GE:
case COND_LT:
for (int i = 0; i < phead_number; ++i)
b &= phead_is_same_head_under_ge_lt(item->head->get_opcode(),phead_for_tail->phead[i]->get_opcode());
case COND_GT:
case COND_LE:
for (int i = 0; i < phead_number; ++i)
b &= phead_is_same_head_under_gt_le(item->head->get_opcode(),phead_for_tail->phead[i]->get_opcode());
default:
return false;
}
}
后面这样写
if (phead_is_merge_into_head)
编译时会出现warning: the address of 'bool phead_is_merge_into_head(const IR1_INST*, FLAG_PATTERN_ITEM*, FLAG_PATTERN_PHEAD*)' will always evaluate as 'true。
这里没有函数参数,所以函数名作为一个指针,这样判断地址是否为true,会always true。是吧?