| 439 | } |
| 440 | |
| 441 | const Constant* ConstantManager::GetNumericVectorConstantWithWords( |
| 442 | const Vector* type, const std::vector<uint32_t>& literal_words) { |
| 443 | const auto* element_type = type->element_type(); |
| 444 | uint32_t words_per_element = 0; |
| 445 | if (const auto* float_type = element_type->AsFloat()) |
| 446 | words_per_element = float_type->width() / 32; |
| 447 | else if (const auto* int_type = element_type->AsInteger()) |
| 448 | words_per_element = int_type->width() / 32; |
| 449 | else if (element_type->AsBool() != nullptr) |
| 450 | words_per_element = 1; |
| 451 | |
| 452 | if (words_per_element != 1 && words_per_element != 2) return nullptr; |
| 453 | |
| 454 | if (words_per_element * type->element_count() != |
| 455 | static_cast<uint32_t>(literal_words.size())) { |
| 456 | return nullptr; |
| 457 | } |
| 458 | |
| 459 | std::vector<uint32_t> element_ids; |
| 460 | for (uint32_t i = 0; i < type->element_count(); ++i) { |
| 461 | auto first_word = literal_words.begin() + (words_per_element * i); |
| 462 | std::vector<uint32_t> const_data(first_word, |
| 463 | first_word + words_per_element); |
| 464 | const analysis::Constant* element_constant = |
| 465 | GetConstant(element_type, const_data); |
| 466 | auto element_id = GetDefiningInstruction(element_constant)->result_id(); |
| 467 | element_ids.push_back(element_id); |
| 468 | } |
| 469 | |
| 470 | return GetConstant(type, element_ids); |
| 471 | } |
| 472 | |
| 473 | uint32_t ConstantManager::GetFloatConstId(float val) { |
| 474 | const Constant* c = GetFloatConst(val); |
no test coverage detected