stage3/fill_candidate_datatypes.cc
changeset 481 16f943328696
parent 480 8a58d7b8b26c
child 483 7f839fb100c1
equal deleted inserted replaced
480:8a58d7b8b26c 481:16f943328696
  1104 void *fill_candidate_datatypes_c::visit(CD_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "CD", symbol->called_fb_declaration); return NULL;}
  1104 void *fill_candidate_datatypes_c::visit(CD_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "CD", symbol->called_fb_declaration); return NULL;}
  1105 void *fill_candidate_datatypes_c::visit(PV_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "PV", symbol->called_fb_declaration); return NULL;}
  1105 void *fill_candidate_datatypes_c::visit(PV_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "PV", symbol->called_fb_declaration); return NULL;}
  1106 void *fill_candidate_datatypes_c::visit(IN_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "IN", symbol->called_fb_declaration); return NULL;}
  1106 void *fill_candidate_datatypes_c::visit(IN_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "IN", symbol->called_fb_declaration); return NULL;}
  1107 void *fill_candidate_datatypes_c::visit(PT_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "PT", symbol->called_fb_declaration); return NULL;}
  1107 void *fill_candidate_datatypes_c::visit(PT_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "PT", symbol->called_fb_declaration); return NULL;}
  1108 
  1108 
  1109 
  1109 void *fill_candidate_datatypes_c::visit(AND_operator_c *symbol) {return handle_binary_operator(widen_AND_table, symbol, prev_il_instruction, il_operand);}
  1110 void *fill_candidate_datatypes_c::visit(AND_operator_c *symbol) {
  1110 void *fill_candidate_datatypes_c::visit(OR_operator_c  *symbol) {return handle_binary_operator(widen_OR_table,  symbol, prev_il_instruction, il_operand);}
       
  1111 void *fill_candidate_datatypes_c::visit(XOR_operator_c *symbol) {return handle_binary_operator(widen_XOR_table, symbol, prev_il_instruction, il_operand);}
       
  1112 
       
  1113 
       
  1114 void *fill_candidate_datatypes_c::visit(ANDN_operator_c *symbol) {
  1111 	symbol_c *prev_instruction_type, *operand_type;
  1115 	symbol_c *prev_instruction_type, *operand_type;
  1112 
  1116 
  1113 	if (NULL == prev_il_instruction) return NULL;
  1117 	if (NULL == prev_il_instruction) return NULL;
  1114 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1118 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1115 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1119 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1118 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1122 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1119 					is_ANY_BIT_compatible(operand_type))
  1123 					is_ANY_BIT_compatible(operand_type))
  1120 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1124 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1121 		}
  1125 		}
  1122 	}
  1126 	}
  1123 	if (debug) std::cout <<  "AND [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1127 	if (debug) std::cout <<  "ANDN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1124 	return NULL;
  1128 	return NULL;
  1125 }
  1129 }
  1126 
  1130 
  1127 void *fill_candidate_datatypes_c::visit(OR_operator_c *symbol) {
  1131 void *fill_candidate_datatypes_c::visit(ORN_operator_c *symbol) {
  1128 	symbol_c *prev_instruction_type, *operand_type;
  1132 	symbol_c *prev_instruction_type, *operand_type;
  1129 
  1133 
  1130 	if (NULL == prev_il_instruction) return NULL;
  1134 	if (NULL == prev_il_instruction) return NULL;
  1131 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1135 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1132 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1136 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1135 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1139 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1136 					is_ANY_BIT_compatible(operand_type))
  1140 					is_ANY_BIT_compatible(operand_type))
  1137 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1141 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1138 		}
  1142 		}
  1139 	}
  1143 	}
  1140 	if (debug) std::cout <<  "OR [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1144 	if (debug) std::cout <<  "ORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1141 	return NULL;
  1145 	return NULL;
  1142 }
  1146 }
  1143 
  1147 
  1144 void *fill_candidate_datatypes_c::visit(XOR_operator_c *symbol) {
  1148 void *fill_candidate_datatypes_c::visit(XORN_operator_c *symbol) {
  1145 	symbol_c *prev_instruction_type, *operand_type;
  1149 	symbol_c *prev_instruction_type, *operand_type;
  1146 
  1150 
  1147 	if (NULL == prev_il_instruction) return NULL;
  1151 	if (NULL == prev_il_instruction) return NULL;
  1148 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1152 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
  1149 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1153 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
  1152 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1156 			if (is_type_equal(prev_instruction_type, operand_type) &&
  1153 					is_ANY_BIT_compatible(operand_type))
  1157 					is_ANY_BIT_compatible(operand_type))
  1154 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1158 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
  1155 		}
  1159 		}
  1156 	}
  1160 	}
  1157 	if (debug) std::cout <<  "XOR [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
       
  1158 	return NULL;
       
  1159 }
       
  1160 
       
  1161 void *fill_candidate_datatypes_c::visit(ANDN_operator_c *symbol) {
       
  1162 	symbol_c *prev_instruction_type, *operand_type;
       
  1163 
       
  1164 	if (NULL == prev_il_instruction) return NULL;
       
  1165 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
       
  1166 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
       
  1167 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
       
  1168 			operand_type = il_operand->candidate_datatypes[j];
       
  1169 			if (is_type_equal(prev_instruction_type, operand_type) &&
       
  1170 					is_ANY_BIT_compatible(operand_type))
       
  1171 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
       
  1172 		}
       
  1173 	}
       
  1174 	if (debug) std::cout <<  "ANDN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
       
  1175 	return NULL;
       
  1176 }
       
  1177 
       
  1178 void *fill_candidate_datatypes_c::visit(ORN_operator_c *symbol) {
       
  1179 	symbol_c *prev_instruction_type, *operand_type;
       
  1180 
       
  1181 	if (NULL == prev_il_instruction) return NULL;
       
  1182 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
       
  1183 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
       
  1184 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
       
  1185 			operand_type = il_operand->candidate_datatypes[j];
       
  1186 			if (is_type_equal(prev_instruction_type, operand_type) &&
       
  1187 					is_ANY_BIT_compatible(operand_type))
       
  1188 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
       
  1189 		}
       
  1190 	}
       
  1191 	if (debug) std::cout <<  "ORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
       
  1192 	return NULL;
       
  1193 }
       
  1194 
       
  1195 void *fill_candidate_datatypes_c::visit(XORN_operator_c *symbol) {
       
  1196 	symbol_c *prev_instruction_type, *operand_type;
       
  1197 
       
  1198 	if (NULL == prev_il_instruction) return NULL;
       
  1199 	for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
       
  1200 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
       
  1201 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
       
  1202 			operand_type = il_operand->candidate_datatypes[j];
       
  1203 			if (is_type_equal(prev_instruction_type, operand_type) &&
       
  1204 					is_ANY_BIT_compatible(operand_type))
       
  1205 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
       
  1206 		}
       
  1207 	}
       
  1208 	if (debug) std::cout <<  "XORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1161 	if (debug) std::cout <<  "XORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1209 	return NULL;
  1162 	return NULL;
  1210 }
  1163 }
  1211 
  1164 
  1212 void *fill_candidate_datatypes_c::visit(ADD_operator_c *symbol) {return handle_binary_operator(widen_ADD_table, symbol, prev_il_instruction, il_operand);}
  1165 void *fill_candidate_datatypes_c::visit(ADD_operator_c *symbol) {return handle_binary_operator(widen_ADD_table, symbol, prev_il_instruction, il_operand);}
  1415 /* B.3 - Language ST (Structured Text) */
  1368 /* B.3 - Language ST (Structured Text) */
  1416 /***************************************/
  1369 /***************************************/
  1417 /***********************/
  1370 /***********************/
  1418 /* B 3.1 - Expressions */
  1371 /* B 3.1 - Expressions */
  1419 /***********************/
  1372 /***********************/
  1420 
  1373 void *fill_candidate_datatypes_c::visit(or_expression_c  *symbol) {return handle_binary_expression(widen_OR_table,  symbol, symbol->l_exp, symbol->r_exp);}
  1421 void *fill_candidate_datatypes_c::visit(or_expression_c *symbol) {
  1374 void *fill_candidate_datatypes_c::visit(xor_expression_c *symbol) {return handle_binary_expression(widen_XOR_table, symbol, symbol->l_exp, symbol->r_exp);}
  1422 	symbol->l_exp->accept(*this);
  1375 void *fill_candidate_datatypes_c::visit(and_expression_c *symbol) {return handle_binary_expression(widen_AND_table, symbol, symbol->l_exp, symbol->r_exp);}
  1423 	symbol->r_exp->accept(*this);
       
  1424 	for (unsigned  int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
       
  1425 		for (unsigned  int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
       
  1426 			if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
       
  1427 					&& is_ANY_BIT_compatible(symbol->l_exp->candidate_datatypes[i]))
       
  1428 				add_datatype_to_candidate_list(symbol, symbol->l_exp->candidate_datatypes[i]);
       
  1429 		}
       
  1430 	}
       
  1431 	return NULL;
       
  1432 }
       
  1433 
       
  1434 
       
  1435 void *fill_candidate_datatypes_c::visit(xor_expression_c *symbol) {
       
  1436 	symbol->l_exp->accept(*this);
       
  1437 	symbol->r_exp->accept(*this);
       
  1438 
       
  1439 	for (unsigned  int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
       
  1440 		for (unsigned  int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
       
  1441 			if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
       
  1442 					&& is_ANY_BIT_compatible(symbol->l_exp->candidate_datatypes[i]))
       
  1443 				add_datatype_to_candidate_list(symbol, symbol->l_exp->candidate_datatypes[i]);
       
  1444 		}
       
  1445 	}
       
  1446 	return NULL;
       
  1447 }
       
  1448 
       
  1449 
       
  1450 void *fill_candidate_datatypes_c::visit(and_expression_c *symbol) {
       
  1451 	symbol->l_exp->accept(*this);
       
  1452 	symbol->r_exp->accept(*this);
       
  1453 
       
  1454 	for (unsigned  int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
       
  1455 		for (unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
       
  1456 			if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
       
  1457 					&& is_ANY_BIT_compatible(symbol->l_exp->candidate_datatypes[i]))
       
  1458 				add_datatype_to_candidate_list(symbol, symbol->l_exp->candidate_datatypes[i]);
       
  1459 		}
       
  1460 	}
       
  1461 	return NULL;
       
  1462 }
       
  1463 
  1376 
  1464 
  1377 
  1465 void *fill_candidate_datatypes_c::visit(equ_expression_c *symbol) {
  1378 void *fill_candidate_datatypes_c::visit(equ_expression_c *symbol) {
  1466 	symbol->l_exp->accept(*this);
  1379 	symbol->l_exp->accept(*this);
  1467 	symbol->r_exp->accept(*this);
  1380 	symbol->r_exp->accept(*this);