|
51 | 51 | // Add deprecation support for Comgr on Linux
|
52 | 52 | // This can be removed in favor of generic [[deprecated]] in C23, which should
|
53 | 53 | // also allow us to more easily include support on Windows
|
| 54 | + |
| 55 | +#ifndef AMD_COMGR_DEPRECATED |
| 56 | +#ifdef AMD_COMGR_BUILD |
| 57 | +#define AMD_COMGR_DEPRECATED(msg) // empty |
| 58 | +#endif |
| 59 | +#endif |
| 60 | + |
54 | 61 | #ifndef AMD_COMGR_DEPRECATED
|
55 | 62 | #if defined __GNUC__ && (__GNUC__ > 5 || defined __clang__)
|
56 | 63 | #define AMD_COMGR_DEPRECATED(msg) __attribute__((deprecated(msg)))
|
@@ -203,6 +210,12 @@ extern "C" {
|
203 | 210 | */
|
204 | 211 | #define AMD_COMGR_VERSION_2_5
|
205 | 212 |
|
| 213 | +/** |
| 214 | + * The function was introduced or changed in version 2.6 of the interface |
| 215 | + * and has the symbol version string of ``"@amd_comgr_NAME@_2.6"``. |
| 216 | + */ |
| 217 | +#define AMD_COMGR_VERSION_2_6 |
| 218 | + |
206 | 219 | /** @} */
|
207 | 220 |
|
208 | 221 | /**
|
@@ -1572,8 +1585,9 @@ typedef enum amd_comgr_action_kind_s {
|
1572 | 1585 | * Return @p AMD_COMGR_STATUS_ERROR if the link or unbundling fails.
|
1573 | 1586 | *
|
1574 | 1587 | * Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT
|
1575 |
| - * if isa name is not set in @p info and does not match the isa name |
1576 |
| - * of all bc data objects in @p input. |
| 1588 | + * if IsaName is not set in @p info and does not match the isa name |
| 1589 | + * of all bc data objects in @p input, or if the Name field is not set for |
| 1590 | + * any DataObject in the input set. |
1577 | 1591 | */
|
1578 | 1592 | AMD_COMGR_ACTION_LINK_BC_TO_BC = 0x4,
|
1579 | 1593 | /**
|
@@ -1731,10 +1745,27 @@ typedef enum amd_comgr_action_kind_s {
|
1731 | 1745 | * if isa name or language is not set in @p info.
|
1732 | 1746 | */
|
1733 | 1747 | AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC = 0xF,
|
| 1748 | + /** |
| 1749 | + * Compile a single source data object in @p input in order. For each |
| 1750 | + * successful compilation add a relocatable data object to @p result. |
| 1751 | + * Resolve any include source names using the names of include data objects |
| 1752 | + * in @p input. Resolve any include relative path names using the |
| 1753 | + * working directory path in @p info. Produce relocatable for hip name in @p |
| 1754 | + * info. Compile the source for the language in @p info. Link against |
| 1755 | + * the device-specific and language-specific bitcode device libraries |
| 1756 | + * required for compilation. Currently only supports HIP language. |
| 1757 | + * |
| 1758 | + * Return @p AMD_COMGR_STATUS_ERROR if any compilation |
| 1759 | + * fails. |
| 1760 | + * |
| 1761 | + * Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT |
| 1762 | + * if isa name or language is not set in @p info. |
| 1763 | + */ |
| 1764 | + AMD_COMGR_ACTION_COMPILE_SOURCE_TO_RELOCATABLE = 0x10, |
1734 | 1765 | /**
|
1735 | 1766 | * Marker for last valid action kind.
|
1736 | 1767 | */
|
1737 |
| - AMD_COMGR_ACTION_LAST = AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC |
| 1768 | + AMD_COMGR_ACTION_LAST = AMD_COMGR_ACTION_COMPILE_SOURCE_TO_RELOCATABLE |
1738 | 1769 | } amd_comgr_action_kind_t;
|
1739 | 1770 |
|
1740 | 1771 | /**
|
@@ -2386,6 +2417,76 @@ amd_comgr_get_mangled_name(
|
2386 | 2417 | size_t *size,
|
2387 | 2418 | char *mangled_name) AMD_COMGR_VERSION_2_5;
|
2388 | 2419 |
|
| 2420 | +/** |
| 2421 | + * @brief Populate a name expression map from a given code object. |
| 2422 | + * |
| 2423 | + * Used to map stub names *__amdgcn_name_expr_* in bitcodes and code |
| 2424 | + * objects generated by hip runtime to an associated (unmangled) name |
| 2425 | + * expression and (mangled) symbol name. |
| 2426 | + * |
| 2427 | + * @param[in] data A data object of kind @p |
| 2428 | + * AMD_COMGR_DATA_KIND_EXECUTABLE or @p AMD_COMGR_DATA_KIND_BC |
| 2429 | + * |
| 2430 | + * @param[out] count The number of name expressions mapped. This value |
| 2431 | + * can be used as an upper bound to the Index provided to the corresponding |
| 2432 | + * amd_comgr_map_name_expression_to_symbol_name() call. |
| 2433 | + * |
| 2434 | + * @retval ::AMD_COMGR_STATUS_SUCCESS The function executed successfully. |
| 2435 | + * |
| 2436 | + * @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data is |
| 2437 | + * an invalid data object or not of kind @p AMD_COMGR_DATA_KIND_EXECUTABLE or |
| 2438 | + * @p AMD_COMGR_DATA_KIND_BC. |
| 2439 | + * |
| 2440 | + * @retval ::AMD_COMGR_STATUS_ERROR LLVM API failure, which should be |
| 2441 | + * accompanied by an LLVM error message to stderr |
| 2442 | + * |
| 2443 | + */ |
| 2444 | +amd_comgr_status_t AMD_COMGR_API |
| 2445 | +amd_comgr_populate_name_expression_map( |
| 2446 | + amd_comgr_data_t data, |
| 2447 | + size_t *count) AMD_COMGR_VERSION_2_6; |
| 2448 | + |
| 2449 | +/** |
| 2450 | + * @brief Fetch a related symbol name for a given name expression; |
| 2451 | + * or that name's length. |
| 2452 | + * |
| 2453 | + * The @p data must have had its name expression map populated with @p |
| 2454 | + * amd_comgr_populate_name_expression_map. |
| 2455 | + * |
| 2456 | + * @param[in] data A data object of kind @p |
| 2457 | + * AMD_COMGR_DATA_KIND_EXECUTABLE or @p AMD_COMGR_DATA_KIND_BC used to |
| 2458 | + * identify which map of name expressions to retrieve from. |
| 2459 | + * |
| 2460 | + * @param[in, out] size For out, the size of @p symbol_name. For in, |
| 2461 | + * if @symbol_name is NULL, set to the size of the Nth option string including |
| 2462 | + * the terminating null character. |
| 2463 | + * |
| 2464 | + * @param[in] name_expression A character array of a name expression. This name |
| 2465 | + * is used as the key to the name expression map in order to locate the desired |
| 2466 | + * @symbol_name. |
| 2467 | + * |
| 2468 | + * @param[out] symbol_name If not NULL, then the first @p size characters of |
| 2469 | + * the symbol name string mapped from @name_expression are copied into @p |
| 2470 | + * symbol_name. If NULL, no symbol name string is copied, and only @p size is |
| 2471 | + * updated (useful in order to find the size of the buffer required to copy the |
| 2472 | + * symbol_name string). |
| 2473 | + * |
| 2474 | + * @retval ::AMD_COMGR_STATUS_SUCCESS The function executed successfully. |
| 2475 | + * |
| 2476 | + * @retval ::AMD_COMGR_STATUS_ERROR @p data object is not valid (NULL or not of |
| 2477 | + * type bitcode or code object) |
| 2478 | + * |
| 2479 | + * @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p name_expression is not |
| 2480 | + * present in the name expression map. |
| 2481 | + * |
| 2482 | + */ |
| 2483 | +amd_comgr_status_t AMD_COMGR_API |
| 2484 | +amd_comgr_map_name_expression_to_symbol_name( |
| 2485 | + amd_comgr_data_t data, |
| 2486 | + size_t *size, |
| 2487 | + char *name_expression, |
| 2488 | + char *symbol_name) AMD_COMGR_VERSION_2_6; |
| 2489 | + |
2389 | 2490 | /**
|
2390 | 2491 | * @brief A data structure for Code object information.
|
2391 | 2492 | */
|
|
0 commit comments