MCPcopy Create free account
hub / github.com/a2flo/floor / translate_function_info

Function translate_function_info

compute/universal_binary.cpp:1540–1597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1538 }
1539
1540 vector<llvm_toolchain::function_info> translate_function_info(const vector<function_info_dynamic_v2>& functions) {
1541 vector<llvm_toolchain::function_info> ret;
1542
1543 for (const auto& func : functions) {
1544 llvm_toolchain::function_info entry {
1545 .name = func.name,
1546 .type = func.static_function_info.type,
1547 .flags = func.static_function_info.flags,
1548 };
1549
1550 uint32_t arg_idx = 0u;
1551 if (entry.type != llvm_toolchain::FUNCTION_TYPE::ARGUMENT_BUFFER_STRUCT) {
1552 entry.required_local_size = func.static_function_info.details.local_size;
1553 } else {
1554 arg_idx = func.static_function_info.details.argument_buffer_index;
1555 }
1556
1557 for (const auto& arg : func.args) {
1558 entry.args.emplace_back(llvm_toolchain::arg_info {
1559 .size = arg.argument_size,
1560 .address_space = arg.address_space,
1561 .image_type = arg.image_type,
1562 .image_access = arg.image_access,
1563 .special_type = arg.special_type,
1564 });
1565 }
1566
1567 if (entry.type != llvm_toolchain::FUNCTION_TYPE::ARGUMENT_BUFFER_STRUCT) {
1568 ret.emplace_back(entry);
1569 } else {
1570 bool found_func = false;
1571 for (auto riter = ret.rbegin(); riter != ret.rend(); ++riter) {
1572 if (riter->name == entry.name) {
1573 found_func = true;
1574 if (arg_idx >= (uint32_t)riter->args.size()) {
1575 log_error("argument index $ is out-of-bounds for function $ with $ args", arg_idx, entry.name, riter->args.size());
1576 return {};
1577 }
1578
1579 auto& arg = riter->args[arg_idx];
1580 if (arg.special_type != llvm_toolchain::SPECIAL_TYPE::ARGUMENT_BUFFER) {
1581 log_error("argument index $ in function $ is not an argument buffer", arg_idx, entry.name);
1582 return {};
1583 }
1584
1585 arg.argument_buffer_info = std::move(entry);
1586 break;
1587 }
1588 }
1589 if (!found_func) {
1590 log_error("didn't find function $ for argument buffer", entry.name);
1591 return {};
1592 }
1593 }
1594 }
1595
1596 return ret;
1597 }

Callers 4

add_universal_binaryMethod · 0.85
add_universal_binaryMethod · 0.85
add_universal_binaryMethod · 0.85
add_universal_binaryMethod · 0.85

Calls 3

rbeginMethod · 0.45
rendMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected