# HG changeset patch # User Mario de Sousa # Date 1331722309 0 # Node ID 7f839fb100c1247daffae0ff94dd6c5d62cbb488 # Parent b62a5ecce54d7d70fe62f16d0409c2e2d9a70d80 Cleaning up XORN, ANDN, and ORN operator code. diff -r b62a5ecce54d -r 7f839fb100c1 stage3/datatype_functions.cc --- a/stage3/datatype_functions.cc Wed Mar 14 10:44:17 2012 +0000 +++ b/stage3/datatype_functions.cc Wed Mar 14 10:51:49 2012 +0000 @@ -305,7 +305,7 @@ /**************************************************************/ /**************************************************************/ /**************************************************************/ - +/* table used by AND and ANDN operators, and and_expression */ const struct widen_entry widen_AND_table[] = { #define __and(TYPE) \ { &search_constant_type_c::TYPE##_type_name, &search_constant_type_c::TYPE##_type_name, &search_constant_type_c::TYPE##_type_name, widen_entry::ok }, \ @@ -318,7 +318,7 @@ { NULL, NULL, NULL, widen_entry::ok }, }; - +/* table used by OR and ORN operators, and or_expression */ const struct widen_entry widen_OR_table[] = { #define __or(TYPE) \ { &search_constant_type_c::TYPE##_type_name, &search_constant_type_c::TYPE##_type_name, &search_constant_type_c::TYPE##_type_name, widen_entry::ok }, \ @@ -332,7 +332,7 @@ }; - +/* table used by XOR and XORN operators, and xor_expression */ const struct widen_entry widen_XOR_table[] = { #define __xor(TYPE) \ { &search_constant_type_c::TYPE##_type_name, &search_constant_type_c::TYPE##_type_name, &search_constant_type_c::TYPE##_type_name, widen_entry::ok }, \ diff -r b62a5ecce54d -r 7f839fb100c1 stage3/fill_candidate_datatypes.cc --- a/stage3/fill_candidate_datatypes.cc Wed Mar 14 10:44:17 2012 +0000 +++ b/stage3/fill_candidate_datatypes.cc Wed Mar 14 10:51:49 2012 +0000 @@ -1106,61 +1106,12 @@ void *fill_candidate_datatypes_c::visit(IN_operator_c *symbol) {handle_implicit_il_fb_call(symbol, "IN", symbol->called_fb_declaration); return NULL;} void *fill_candidate_datatypes_c::visit(PT_operator_c *symbol) {handle_implicit_il_fb_call(symbol, "PT", symbol->called_fb_declaration); return NULL;} -void *fill_candidate_datatypes_c::visit(AND_operator_c *symbol) {return handle_binary_operator(widen_AND_table, symbol, prev_il_instruction, il_operand);} -void *fill_candidate_datatypes_c::visit(OR_operator_c *symbol) {return handle_binary_operator(widen_OR_table, symbol, prev_il_instruction, il_operand);} -void *fill_candidate_datatypes_c::visit(XOR_operator_c *symbol) {return handle_binary_operator(widen_XOR_table, symbol, prev_il_instruction, il_operand);} - - -void *fill_candidate_datatypes_c::visit(ANDN_operator_c *symbol) { - symbol_c *prev_instruction_type, *operand_type; - - if (NULL == prev_il_instruction) return NULL; - for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { - for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) { - prev_instruction_type = prev_il_instruction->candidate_datatypes[i]; - operand_type = il_operand->candidate_datatypes[j]; - if (is_type_equal(prev_instruction_type, operand_type) && - is_ANY_BIT_compatible(operand_type)) - add_datatype_to_candidate_list(symbol, prev_instruction_type); - } - } - if (debug) std::cout << "ANDN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; - return NULL; -} - -void *fill_candidate_datatypes_c::visit(ORN_operator_c *symbol) { - symbol_c *prev_instruction_type, *operand_type; - - if (NULL == prev_il_instruction) return NULL; - for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { - for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) { - prev_instruction_type = prev_il_instruction->candidate_datatypes[i]; - operand_type = il_operand->candidate_datatypes[j]; - if (is_type_equal(prev_instruction_type, operand_type) && - is_ANY_BIT_compatible(operand_type)) - add_datatype_to_candidate_list(symbol, prev_instruction_type); - } - } - if (debug) std::cout << "ORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; - return NULL; -} - -void *fill_candidate_datatypes_c::visit(XORN_operator_c *symbol) { - symbol_c *prev_instruction_type, *operand_type; - - if (NULL == prev_il_instruction) return NULL; - for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { - for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) { - prev_instruction_type = prev_il_instruction->candidate_datatypes[i]; - operand_type = il_operand->candidate_datatypes[j]; - if (is_type_equal(prev_instruction_type, operand_type) && - is_ANY_BIT_compatible(operand_type)) - add_datatype_to_candidate_list(symbol, prev_instruction_type); - } - } - if (debug) std::cout << "XORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; - return NULL; -} +void *fill_candidate_datatypes_c::visit( AND_operator_c *symbol) {return handle_binary_operator(widen_AND_table, symbol, prev_il_instruction, il_operand);} +void *fill_candidate_datatypes_c::visit( OR_operator_c *symbol) {return handle_binary_operator( widen_OR_table, symbol, prev_il_instruction, il_operand);} +void *fill_candidate_datatypes_c::visit( XOR_operator_c *symbol) {return handle_binary_operator(widen_XOR_table, symbol, prev_il_instruction, il_operand);} +void *fill_candidate_datatypes_c::visit(ANDN_operator_c *symbol) {return handle_binary_operator(widen_AND_table, symbol, prev_il_instruction, il_operand);} +void *fill_candidate_datatypes_c::visit( ORN_operator_c *symbol) {return handle_binary_operator( widen_OR_table, symbol, prev_il_instruction, il_operand);} +void *fill_candidate_datatypes_c::visit(XORN_operator_c *symbol) {return handle_binary_operator(widen_XOR_table, symbol, prev_il_instruction, il_operand);} void *fill_candidate_datatypes_c::visit(ADD_operator_c *symbol) {return handle_binary_operator(widen_ADD_table, symbol, prev_il_instruction, il_operand);} void *fill_candidate_datatypes_c::visit(SUB_operator_c *symbol) {return handle_binary_operator(widen_SUB_table, symbol, prev_il_instruction, il_operand);} diff -r b62a5ecce54d -r 7f839fb100c1 stage3/narrow_candidate_datatypes.cc --- a/stage3/narrow_candidate_datatypes.cc Wed Mar 14 10:44:17 2012 +0000 +++ b/stage3/narrow_candidate_datatypes.cc Wed Mar 14 10:51:49 2012 +0000 @@ -914,9 +914,9 @@ void *narrow_candidate_datatypes_c::visit( AND_operator_c *symbol) {return narrow_binary_operator(widen_AND_table, symbol);} void *narrow_candidate_datatypes_c::visit( OR_operator_c *symbol) {return narrow_binary_operator( widen_OR_table, symbol);} void *narrow_candidate_datatypes_c::visit( XOR_operator_c *symbol) {return narrow_binary_operator(widen_XOR_table, symbol);} -void *narrow_candidate_datatypes_c::visit(ANDN_operator_c *symbol) {return handle_il_instruction(symbol);} -void *narrow_candidate_datatypes_c::visit( ORN_operator_c *symbol) {return handle_il_instruction(symbol);} -void *narrow_candidate_datatypes_c::visit(XORN_operator_c *symbol) {return handle_il_instruction(symbol);} +void *narrow_candidate_datatypes_c::visit(ANDN_operator_c *symbol) {return narrow_binary_operator(widen_AND_table, symbol);} +void *narrow_candidate_datatypes_c::visit( ORN_operator_c *symbol) {return narrow_binary_operator( widen_OR_table, symbol);} +void *narrow_candidate_datatypes_c::visit(XORN_operator_c *symbol) {return narrow_binary_operator(widen_XOR_table, symbol);} void *narrow_candidate_datatypes_c::visit( ADD_operator_c *symbol) {return narrow_binary_operator(widen_ADD_table, symbol, &(symbol->deprecated_operation));} void *narrow_candidate_datatypes_c::visit( SUB_operator_c *symbol) {return narrow_binary_operator(widen_SUB_table, symbol, &(symbol->deprecated_operation));} void *narrow_candidate_datatypes_c::visit( MUL_operator_c *symbol) {return narrow_binary_operator(widen_MUL_table, symbol, &(symbol->deprecated_operation));} diff -r b62a5ecce54d -r 7f839fb100c1 stage3/print_datatypes_error.cc --- a/stage3/print_datatypes_error.cc Wed Mar 14 10:44:17 2012 +0000 +++ b/stage3/print_datatypes_error.cc Wed Mar 14 10:51:49 2012 +0000 @@ -900,36 +900,17 @@ void *print_datatypes_error_c::visit( IN_operator_c *symbol) {return handle_implicit_il_fb_invocation( "IN", symbol, symbol->called_fb_declaration);} void *print_datatypes_error_c::visit( PT_operator_c *symbol) {return handle_implicit_il_fb_invocation( "PT", symbol, symbol->called_fb_declaration);} -void *print_datatypes_error_c::visit(AND_operator_c *symbol) {return print_binary_operator_errors("AND", symbol);} -void *print_datatypes_error_c::visit( OR_operator_c *symbol) {return print_binary_operator_errors( "OR", symbol);} -void *print_datatypes_error_c::visit(XOR_operator_c *symbol) {return print_binary_operator_errors("XOR", symbol);} - -void *print_datatypes_error_c::visit(ANDN_operator_c *symbol) { - if ((symbol->candidate_datatypes.size() == 0) && - (il_operand->candidate_datatypes.size() > 0)) - STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'ANDN' operator."); - return NULL; -} - -void *print_datatypes_error_c::visit(ORN_operator_c *symbol) { - if ((symbol->candidate_datatypes.size() == 0) && - (il_operand->candidate_datatypes.size() > 0)) - STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'ORN' operator."); - return NULL; -} - -void *print_datatypes_error_c::visit(XORN_operator_c *symbol) { - if ((symbol->candidate_datatypes.size() == 0) && - (il_operand->candidate_datatypes.size() > 0)) - STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'ORN' operator."); - return NULL; -} - -void *print_datatypes_error_c::visit(ADD_operator_c *symbol) {return print_binary_operator_errors("ADD", symbol, symbol->deprecated_operation);} -void *print_datatypes_error_c::visit(SUB_operator_c *symbol) {return print_binary_operator_errors("SUB", symbol, symbol->deprecated_operation);} -void *print_datatypes_error_c::visit(MUL_operator_c *symbol) {return print_binary_operator_errors("MUL", symbol, symbol->deprecated_operation);} -void *print_datatypes_error_c::visit(DIV_operator_c *symbol) {return print_binary_operator_errors("DIV", symbol, symbol->deprecated_operation);} -void *print_datatypes_error_c::visit(MOD_operator_c *symbol) {return print_binary_operator_errors("MOD", symbol);} +void *print_datatypes_error_c::visit( AND_operator_c *symbol) {return print_binary_operator_errors("AND" , symbol);} +void *print_datatypes_error_c::visit( OR_operator_c *symbol) {return print_binary_operator_errors( "OR" , symbol);} +void *print_datatypes_error_c::visit( XOR_operator_c *symbol) {return print_binary_operator_errors("XOR" , symbol);} +void *print_datatypes_error_c::visit(ANDN_operator_c *symbol) {return print_binary_operator_errors("ANDN", symbol);} +void *print_datatypes_error_c::visit( ORN_operator_c *symbol) {return print_binary_operator_errors( "ORN", symbol);} +void *print_datatypes_error_c::visit(XORN_operator_c *symbol) {return print_binary_operator_errors("XORN", symbol);} +void *print_datatypes_error_c::visit( ADD_operator_c *symbol) {return print_binary_operator_errors("ADD" , symbol, symbol->deprecated_operation);} +void *print_datatypes_error_c::visit( SUB_operator_c *symbol) {return print_binary_operator_errors("SUB" , symbol, symbol->deprecated_operation);} +void *print_datatypes_error_c::visit( MUL_operator_c *symbol) {return print_binary_operator_errors("MUL" , symbol, symbol->deprecated_operation);} +void *print_datatypes_error_c::visit( DIV_operator_c *symbol) {return print_binary_operator_errors("DIV" , symbol, symbol->deprecated_operation);} +void *print_datatypes_error_c::visit( MOD_operator_c *symbol) {return print_binary_operator_errors("MOD" , symbol);} void *print_datatypes_error_c::visit(GT_operator_c *symbol) { return NULL;