rocm.bindings.cyamd_comgr

rocm.bindings.cyamd_comgr#

2026-09-24

52 min read time

Applies to Linux and Windows

Advanced Micro Devices, Inc.

Cython declarations for the C-level interface. Use cimport rocm.bindings.cyamd_comgr from your Cython code to access these declarations directly.

See also

The high-level Python API is documented at rocm.bindings.amd_comgr.

# MIT License
#
# Copyright (c) 2021-2026 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


# This file has been autogenerated, do not modify.

from libc.stdint cimport *
ctypedef bint _Bool # bool is not a reserved keyword in C, _Bool is
cdef extern from "amd_comgr/amd_comgr.h":

    cdef int AMD_COMGR_INTERFACE_VERSION_MAJOR

    cdef int AMD_COMGR_INTERFACE_VERSION_MINOR

    cdef enum amd_comgr_status_s:
        AMD_COMGR_STATUS_SUCCESS
        AMD_COMGR_STATUS_ERROR
        AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT
        AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES

    ctypedef amd_comgr_status_s amd_comgr_status_t

    cdef enum amd_comgr_language_s:
        AMD_COMGR_LANGUAGE_NONE
        AMD_COMGR_LANGUAGE_OPENCL_1_2
        AMD_COMGR_LANGUAGE_OPENCL_2_0
        AMD_COMGR_LANGUAGE_HIP
        AMD_COMGR_LANGUAGE_LLVM_IR
        AMD_COMGR_LANGUAGE_LAST

    ctypedef amd_comgr_language_s amd_comgr_language_t

# 
# @brief Query additional information about a status code.
# 
# @param[in] status Status code.
# 
# @param[out] status_string A NUL-terminated string that describes
# the error status.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# status is an invalid status code, or @p status_string is NULL.
cdef amd_comgr_status_s amd_comgr_status_string(amd_comgr_status_s status,const char ** status_string) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the version of the code object manager interface
# supported.
# 
# An interface is backwards compatible with an implementation with an
# equal major version, and a greater than or equal minor version.
# 
# @param[out] major Major version number.
# 
# @param[out] minor Minor version number.
cdef void amd_comgr_get_version(size_t * major,size_t * minor) noexcept nogil


cdef extern from "amd_comgr/amd_comgr.h":

    cdef enum amd_comgr_data_kind_s:
        AMD_COMGR_DATA_KIND_UNDEF
        AMD_COMGR_DATA_KIND_SOURCE
        AMD_COMGR_DATA_KIND_INCLUDE
        AMD_COMGR_DATA_KIND_PRECOMPILED_HEADER
        AMD_COMGR_DATA_KIND_DIAGNOSTIC
        AMD_COMGR_DATA_KIND_LOG
        AMD_COMGR_DATA_KIND_BC
        AMD_COMGR_DATA_KIND_RELOCATABLE
        AMD_COMGR_DATA_KIND_EXECUTABLE
        AMD_COMGR_DATA_KIND_BYTES
        AMD_COMGR_DATA_KIND_FATBIN
        AMD_COMGR_DATA_KIND_AR
        AMD_COMGR_DATA_KIND_BC_BUNDLE
        AMD_COMGR_DATA_KIND_AR_BUNDLE
        AMD_COMGR_DATA_KIND_OBJ_BUNDLE
        AMD_COMGR_DATA_KIND_SPIRV
        AMD_COMGR_DATA_KIND_LAST

    ctypedef amd_comgr_data_kind_s amd_comgr_data_kind_t

    cdef struct amd_comgr_data_s:
        uint64_t handle

    ctypedef amd_comgr_data_s amd_comgr_data_t

    cdef struct amd_comgr_data_set_s:
        uint64_t handle

    ctypedef amd_comgr_data_set_s amd_comgr_data_set_t

    cdef struct amd_comgr_action_info_s:
        uint64_t handle

    ctypedef amd_comgr_action_info_s amd_comgr_action_info_t

    cdef struct amd_comgr_metadata_node_s:
        uint64_t handle

    ctypedef amd_comgr_metadata_node_s amd_comgr_metadata_node_t

    cdef struct amd_comgr_symbol_s:
        uint64_t handle

    ctypedef amd_comgr_symbol_s amd_comgr_symbol_t

    cdef struct amd_comgr_disassembly_info_s:
        uint64_t handle

    ctypedef amd_comgr_disassembly_info_s amd_comgr_disassembly_info_t

    cdef struct amd_comgr_symbolizer_info_s:
        uint64_t handle

    ctypedef amd_comgr_symbolizer_info_s amd_comgr_symbolizer_info_t

# 
# @brief Return the number of isa names supported by this version of
# the code object manager library.
# 
# The isa name specifies the instruction set architecture that should
# be used in the actions that involve machine code generation or
# inspection.
# 
# @param[out] count The number of isa names supported.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# count is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update action info object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_isa_count(size_t * count) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Return the Nth isa name supported by this version of the
# code object manager library.
# 
# @param[in] index The index of the isa name to be returned. The
# first isa name is index 0.
# 
# @param[out] isa_name A null terminated string that is the isa name
# being requested.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# index is greater than the number of isa name supported by this
# version of the code object manager library. @p isa_name is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update action info object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_isa_name(size_t index,const char ** isa_name) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get a handle to the metadata of an isa name.
# 
# The structure of the returned metadata is isa name specific and versioned
# with details specified in
# https://llvm.org/docs/AMDGPUUsage.html#code-object-metadata.
# It can include information about the
# limits for resources such as registers and memory addressing.
# 
# @param[in] isa_name The isa name to query.
# 
# @param[out] metadata A handle to the metadata of the isa name. If
# the isa name has no metadata then the returned handle has a kind of
# @p AMD_COMGR_METADATA_KIND_NULL. The handle must be destroyed
# using @c amd_comgr_destroy_metadata.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# name is NULL or is not an isa name supported by this version of the
# code object manager library. @p metadata is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_isa_metadata(const char * isa_name,amd_comgr_metadata_node_s * metadata) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Create a data object that can hold data of a specified kind.
# 
# @param[in] kind The kind of data the object is intended to hold.
# 
# @param[out] data A handle to the data object created. Its reference
# count is set to 1.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# kind is an invalid data kind, or @p
# AMD_COMGR_DATA_KIND_UNDEF. @p data is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to create the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_create_data(amd_comgr_data_kind_s kind,amd_comgr_data_s * data) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Indicate that no longer using a data object handle.
# 
# The reference count of the associated data object is
# decremented. If it reaches 0 it is destroyed.
# 
# @note Although this may lead to the destruction of a data object, it is not
# considered a mutation for the purposes of the restrictions described in @ref
# codeobjectmanager.
# 
# @param[in] data The data object to release.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# data is an invalid data object, or has kind @p
# AMD_COMGR_DATA_KIND_UNDEF.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_release_data(amd_comgr_data_s data) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the kind of the data object.
# 
# @param[in] data The data object to query.
# 
# @param[out] kind The kind of data the object.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# data is an invalid data object. @p kind is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to create the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_data_kind(amd_comgr_data_s data,amd_comgr_data_kind_s * kind) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Set the data content of a data object to the specified
# bytes.
# 
# Any previous value of the data object is overwritten. Any metadata
# associated with the data object is also replaced which invalidates
# all metadata handles to the old metadata.
# 
# @warning This function mutates the data object; see @ref codeobjectmanager
# for restrictions.
# 
# @param[in] data The data object to update.
# 
# @param[in] size The number of bytes in the data specified by @p bytes.
# 
# @param[in] bytes The bytes to set the data object to. The bytes are
# copied into the data object and can be freed after the call.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# data is an invalid data object, or has kind @p
# AMD_COMGR_DATA_KIND_UNDEF.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_set_data(amd_comgr_data_s data,size_t size,const char * bytes) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief For the given open posix file descriptor, map a slice of the
# file into the data object. The slice is specified by @p offset and @p size.
# Internally this API calls amd_comgr_set_data and resets data object's
# current state.
# 
# @warning This function mutates the data object; see @ref codeobjectmanager
# for restrictions.
# 
# @param[in, out] data The data object to update.
# 
# @param[in] file_descriptor The native file descriptor for an open file.
# The @p file_descriptor must not be passed into a system I/O function
# by any other thread while this function is executing.  The offset in
# the file descriptor may be updated based on the requested size and
# underlying platform. The @p file_descriptor may be closed immediately
# after this function returns.
# 
# @param[in] offset position relative to the start of the file
# specifying the beginning of the slice in @p file_descriptor.
# 
# @param[in] size Size in bytes of the slice.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The operation is successful.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data is an invalid or
# the map operation failed.
cdef amd_comgr_status_s amd_comgr_set_data_from_file_slice(amd_comgr_data_s data,int file_descriptor,uint64_t offset,uint64_t size) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Set the name associated with a data object.
# 
# When compiling, the full name of an include directive is used to
# reference the contents of the include data object with the same
# name. The name may also be used for other data objects in log and
# diagnostic output.
# 
# @warning This function mutates the data object; see @ref codeobjectmanager
# for restrictions.
# 
# @param[in] data The data object to update.
# 
# @param[in] name A null terminated string that specifies the name to
# use for the data object. If NULL then the name is set to the empty
# string.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# data is an invalid data object, or has kind @p
# AMD_COMGR_DATA_KIND_UNDEF.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_set_data_name(amd_comgr_data_s data,const char * name) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the data contents, and/or the size of the data
# associated with a data object.
# 
# @param[in] data The data object to query.
# 
# @param[in, out] size On entry, the size of @p bytes. On return, if @p bytes
# is NULL, set to the size of the data object contents.
# 
# @param[out] bytes If not NULL, then the first @p size bytes of the
# data object contents is copied. If NULL, no data is copied, and
# only @p size is updated (useful in order to find the size of buffer
# required to copy the data).
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# data is an invalid data object, or has kind @p
# AMD_COMGR_DATA_KIND_UNDEF. @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_data(amd_comgr_data_s data,size_t * size,char * bytes) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the data object name and/or name length.
# 
# @param[in] data The data object to query.
# 
# @param[in, out] size On entry, the size of @p name. On return, the size of
# the data object name including the terminating null character.
# 
# @param[out] name If not NULL, then the first @p size characters of the
# data object name are copied. If @p name is NULL, only @p size is updated
# (useful in order to find the size of buffer required to copy the name).
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# data is an invalid data object, or has kind @p
# AMD_COMGR_DATA_KIND_UNDEF. @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_data_name(amd_comgr_data_s data,size_t * size,char * name) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the data object isa name and/or isa name length.
# 
# @param[in] data The data object to query.
# 
# @param[in, out] size On entry, the size of @p isa_name. On return, if @p
# isa_name is NULL, set to the size of the isa name including the terminating
# null character.
# 
# @param[out] isa_name If not NULL, then the first @p size characters
# of the isa name are copied. If NULL, no isa name is copied, and
# only @p size is updated (useful in order to find the size of buffer
# required to copy the isa name).
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# data is an invalid data object, has kind @p
# AMD_COMGR_DATA_KIND_UNDEF, or is not an isa specific
# kind. @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_data_isa_name(amd_comgr_data_s data,size_t * size,char * isa_name) except? AMD_COMGR_STATUS_ERROR nogil


ctypedef void (*amd_comgr_create_symbolizer_info_anon_funptr_0) (const char *,void *)

# 
# @brief Create a symbolizer info object.
# 
# @param[in] code_object A data object denoting a code object for which
# symbolization should be performed. The kind of this object must be
# ::AMD_COMGR_DATA_KIND_RELOCATABLE, ::AMD_COMGR_DATA_KIND_EXECUTABLE,
# or ::AMD_COMGR_DATA_KIND_BYTES.
# 
# @param[in] print_symbol_callback Function called by a successfull
# symbolize query. @p symbol is a null-terminated string containing the
# symbolization of the address and @p user_data is an arbitary user data.
# The callback does not own @p symbol, and it cannot be referenced once
# the callback returns.
# 
# @param[out] symbolizer_info A handle to the symbolizer info object created.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if @p code_object is
# invalid or @p print_symbol_callback is null.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to create @p symbolizer_info as out of resources.
cdef amd_comgr_status_s amd_comgr_create_symbolizer_info(amd_comgr_data_s code_object,amd_comgr_create_symbolizer_info_anon_funptr_0 print_symbol_callback,amd_comgr_symbolizer_info_s * symbolizer_info) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Destroy symbolizer info object.
# 
# @param[in] symbolizer_info A handle to symbolizer info object to destroy.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS on successful execution.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if @p
# symbolizer_info is invalid.
cdef amd_comgr_status_s amd_comgr_destroy_symbolizer_info(amd_comgr_symbolizer_info_s symbolizer_info) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Symbolize an address.
# 
# The @p address is symbolized using the symbol definitions of the
# @p code_object specified when the @p symbolizer_info was created.
# The @p print_symbol_callback callback function specified when the
# @p symbolizer_info was created is called passing the
# symbolization result as @p symbol and @p user_data value.
# 
# If symbolization is not possible ::AMD_COMGR_STATUS_SUCCESS is returned and
# the string passed to the @p symbol argument of the @p print_symbol_callback
# specified when the @p symbolizer_info was created contains the text
# "<invalid>" or "??". This is consistent with `llvm-symbolizer` utility.
# 
# @param[in] symbolizer_info A handle to symbolizer info object which should be
# used to symbolize the @p address.
# 
# @param[in] address An unrelocated ELF address to which symbolization
# query should be performed.
# 
# @param[in] is_code if true, the symbolizer symbolize the address as code
# and the symbolization result contains filename, function name, line number
# and column number, else the symbolizer symbolize the address as data and
# the symbolizaion result contains symbol name, symbol's starting address
# and symbol size.
# 
# @param[in] user_data Arbitrary user-data passed to @p print_symbol_callback
# callback as described for @p symbolizer_info argument.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# symbolizer_info is an invalid data object.
cdef amd_comgr_status_s amd_comgr_symbolize(amd_comgr_symbolizer_info_s symbolizer_info,uint64_t address,_Bool is_code,void * user_data) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get a handle to the metadata of a data object.
# 
# @param[in] data The data object to query.
# 
# @param[out] metadata A handle to the metadata of the data
# object. If the data object has no metadata then the returned handle
# has a kind of @p AMD_COMGR_METADATA_KIND_NULL. The
# handle must be destroyed using @c amd_comgr_destroy_metadata.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# data is an invalid data object, or has kind @p
# AMD_COMGR_DATA_KIND_UNDEF. @p metadata is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_data_metadata(amd_comgr_data_s data,amd_comgr_metadata_node_s * metadata) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Destroy a metadata handle.
# 
# @param[in] metadata A metadata handle to destroy.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p metadata is an invalid
# metadata handle.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to update metadata
# handle as out of resources.
cdef amd_comgr_status_s amd_comgr_destroy_metadata(amd_comgr_metadata_node_s metadata) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Create a data set object.
# 
# @param[out] data_set A handle to the data set created. Initially it
# contains no data objects.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data_set is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to create the data
# set object as out of resources.
cdef amd_comgr_status_s amd_comgr_create_data_set(amd_comgr_data_set_s * data_set) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Destroy a data set object.
# 
# The reference counts of any associated data objects are decremented. Any
# handles to the data set object become invalid.
# 
# @param[in] data_set A handle to the data set object to destroy.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data_set is an invalid
# data set object.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to update data set
# object as out of resources.
cdef amd_comgr_status_s amd_comgr_destroy_data_set(amd_comgr_data_set_s data_set) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Add a data object to a data set object if it is not already added.
# 
# The reference count of the data object is incremented.
# 
# @param[in] data_set A handle to the data set object to be updated.
# 
# @param[in] data A handle to the data object to be added. If @p data_set
# already has the specified handle present, then it is not added. The order
# that data objects are added is preserved.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data_set is an invalid
# data set object. @p data is an invalid data object; has undef kind; has
# include kind but does not have a name.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to update data set
# object as out of resources.
cdef amd_comgr_status_s amd_comgr_data_set_add(amd_comgr_data_set_s data_set,amd_comgr_data_s data) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Remove all data objects of a specified kind from a data set object.
# 
# The reference count of the removed data objects is decremented.
# 
# @param[in] data_set A handle to the data set object to be updated.
# 
# @param[in] data_kind The data kind of the data objects to be removed. If @p
# AMD_COMGR_DATA_KIND_UNDEF is specified then all data objects are removed.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data_set is an invalid
# data set object. @p data_kind is an invalid data kind.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to update data set
# object as out of resources.
cdef amd_comgr_status_s amd_comgr_data_set_remove(amd_comgr_data_set_s data_set,amd_comgr_data_kind_s data_kind) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Return the number of data objects of a specified data kind that are
# added to a data set object.
# 
# @param[in] data_set A handle to the data set object to be queried.
# 
# @param[in] data_kind The data kind of the data objects to be counted.
# 
# @param[out] count The number of data objects of data kind @p data_kind.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data_set is an invalid
# data set object. @p data_kind is an invalid data kind or @p
# AMD_COMGR_DATA_KIND_UNDEF. @p count is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to query data set
# object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_data_count(amd_comgr_data_set_s data_set,amd_comgr_data_kind_s data_kind,size_t * count) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Return the Nth data object of a specified data kind that is added to a
# data set object.
# 
# The reference count of the returned data object is incremented.
# 
# @param[in] data_set A handle to the data set object to be queried.
# 
# @param[in] data_kind The data kind of the data object to be returned.
# 
# @param[in] index The index of the data object of data kind @data_kind to be
# returned. The first data object is index 0. The order of data objects matches
# the order that they were added to the data set object.
# 
# @param[out] data The data object being requested.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data_set is an invalid
# data set object. @p data_kind is an invalid data kind or @p
# AMD_COMGR_DATA_KIND_UNDEF. @p index is greater than the number of data
# objects of kind @p data_kind. @p data is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to query data set
# object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_data_get_data(amd_comgr_data_set_s data_set,amd_comgr_data_kind_s data_kind,size_t index,amd_comgr_data_s * data) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Create an action info object.
# 
# @param[out] action_info A handle to the action info object created.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to create the action info object as out of resources.
cdef amd_comgr_status_s amd_comgr_create_action_info(amd_comgr_action_info_s * action_info) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Destroy an action info object.
# 
# @param[in] action_info A handle to the action info object to destroy.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update action info object as out of resources.
cdef amd_comgr_status_s amd_comgr_destroy_action_info(amd_comgr_action_info_s action_info) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Set the isa name of an action info object.
# 
# When an action info object is created it has no isa name. Some
# actions require that the action info object has an isa name
# defined.
# 
# @param[in] action_info A handle to the action info object to be
# updated.
# 
# @param[in] isa_name A null terminated string that is the isa name. If NULL
# or the empty string then the isa name is cleared. The isa name is defined as
# the Code Object Target Identification string, described at
# https://llvm.org/docs/AMDGPUUsage.html#code-object-target-identification
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object. @p isa_name is not an
# isa name supported by this version of the code object manager
# library.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update action info object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_set_isa_name(amd_comgr_action_info_s action_info,const char * isa_name) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the isa name and/or isa name length.
# 
# @param[in] action_info The action info object to query.
# 
# @param[in, out] size On entry, the size of @p isa_name. On return, if @p
# isa_name is NULL, set to the size of the isa name including the terminating
# null character.
# 
# @param[out] isa_name If not NULL, then the first @p size characters of the
# isa name are copied into @p isa_name. If the isa name is not set then an
# empty string is copied into @p isa_name. If NULL, no name is copied, and
# only @p size is updated (useful in order to find the size of buffer required
# to copy the name).
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object. @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_get_isa_name(amd_comgr_action_info_s action_info,size_t * size,char * isa_name) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Set the source language of an action info object.
# 
# When an action info object is created it has no language defined
# which is represented by @p
# AMD_COMGR_LANGUAGE_NONE. Some actions require that
# the action info object has a source language defined.
# 
# @param[in] action_info A handle to the action info object to be
# updated.
# 
# @param[in] language The language to set. If @p
# AMD_COMGR_LANGUAGE_NONE then the language is cleared.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object. @p language is an
# invalid language.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update action info object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_set_language(amd_comgr_action_info_s action_info,amd_comgr_language_s language) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the language for an action info object.
# 
# @param[in] action_info The action info object to query.
# 
# @param[out] language The language of the action info opject. @p
# AMD_COMGR_LANGUAGE_NONE if not defined,
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object. @p language is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_get_language(amd_comgr_action_info_s action_info,amd_comgr_language_s * language) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Set the options array of an action info object.
# 
# This overrides any option strings or arrays previously set by calls to this
# function.
# 
# An @p action_info object which had its options set with this function can
# only have its option inspected with @p
# amd_comgr_action_info_get_option_list_count and @p
# amd_comgr_action_info_get_option_list_item.
# 
# @param[in] action_info A handle to the action info object to be updated.
# 
# @param[in] options An array of null terminated strings. May be NULL if @p
# count is zero, which will result in an empty options array.
# 
# @param[in] count The number of null terminated strings in @p options.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p action_info is an
# invalid action info object, or @p options is NULL and @p count is non-zero.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to update action
# info object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_set_option_list(amd_comgr_action_info_s action_info,const char ** options,size_t count) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Return the number of options in the options array.
# 
# The @p action_info object must have had its options set with @p
# amd_comgr_action_info_set_option_list.
# 
# @param[in] action_info The action info object to query.
# 
# @param[out] count The number of options in the options array.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR The options of @p action_info were never
# set, or not set with @p amd_comgr_action_info_set_option_list.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p action_info is an
# invalid action info object, or @p count is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to query the data
# object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_get_option_list_count(amd_comgr_action_info_s action_info,size_t * count) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Return the Nth option string in the options array and/or that
# option's length.
# 
# The @p action_info object must have had its options set with @p
# amd_comgr_action_info_set_option_list.
# 
# @param[in] action_info The action info object to query.
# 
# @param[in] index The index of the option to be returned. The first option
# index is 0. The order is the same as the options when they were added in @p
# amd_comgr_action_info_set_option_list.
# 
# @param[in, out] size On entry, the size of @p option. On return, if @option
# is NULL, set to the size of the Nth option string including the terminating
# null character.
# 
# @param[out] option If not NULL, then the first @p size characters of the Nth
# option string are copied into @p option. If NULL, no option string is
# copied, and only @p size is updated (useful in order to find the size of
# buffer required to copy the option string).
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR The options of @p action_info were never
# set, or not set with @p amd_comgr_action_info_set_option_list.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p action_info is an
# invalid action info object, @p index is invalid, or @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to query the data
# object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_get_option_list_item(amd_comgr_action_info_s action_info,size_t index,size_t * size,char * option) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Set the bundle entry IDs of an action info object.
# 
# When an action info object is created it has no bundle entry IDs. Some
# actions require that the action info object has bundle entry IDs
# defined.
# 
# @param[in] action_info A handle to the action info object to be
# updated.
# 
# @param[in] bundle_entry_ids An array of strings containing one or more
# bundle entry ID strings. If NULL then the bundle entry ID strings are
# cleared. These IDs are described at
# https://clang.llvm.org/docs/ClangOffloadBundler.html#bundle-entry-id
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object. @p contains an invalid
# bundle ID not supported by this version of the code object manager
# library.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update action info object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_set_bundle_entry_ids(amd_comgr_action_info_s action_info,const char ** bundle_entry_ids,size_t count) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get number of bundle entry IDs
# 
# @param[in] action_info The action info object to query.
# 
# @param[out] count The number of bundle entry IDs availible. This value
# can be used as an upper bound to the Index provided to the corresponding
# amd_comgr_get_bundle_entry_id() call.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object. @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_get_bundle_entry_id_count(amd_comgr_action_info_s action_info,size_t * count) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Fetch the Nth specific bundle entry ID or that ID's length.
# 
# @param[in] action_info The action info object to query.
# 
# @param[in] index The index of the bundle entry ID to be returned.
# 
# @param[in, out] size For out, the size of @p bundle_entry_id. For in,
# if @bundle_entry_id is NULL, set to the size of the Nth ID string including
# the terminating null character.
# 
# @param[out] bundle_entry_id If not NULL, then the first @p size characters of
# the Nth bundle entry ID string are copied into @p bundle_entry_id. If NULL,
# no bundle entry ID is copied, and only @p size is updated (useful in order
# to find the size of the buffer requried to copy the bundle_entry_id string).
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object. @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_get_bundle_entry_id(amd_comgr_action_info_s action_info,size_t index,size_t * size,char * bundle_entry_id) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Set whether the specified action should use an
# in-memory virtual file system (VFS).
# 
# @warning Environment variable @p AMD_COMGR_SAVE_TEMPS may override options
# set by this API and @p AMD_COMGR_USE_VFS. If @p AMD_COMGR_SAVE_TEMPS is set
# to "1", all actions are performed using the real file system irrespective of
# the value of @p should_use_vfs @p AMD_COMGR_USE_VFS;
# 
# @warning Environment variable @p AMD_COMGR_USE_VFS may override options
# set by this API. If @p AMD_COMGR_USE_VFS is set to "1", all actions
# are performed using VFS. If @p AMD_COMGR_USE_VFS is set to "0",
# none of the actions are performed using VFS.
# 
# If @p AMD_COMGR_USE_VFS is unset, this API can be used to selectively
# turn VFS usage on/off for specified actions.
# 
# @param[in] action_info A handle to the action info object to be
# updated.
# 
# @param[in] should_use_vfs A boolean that directs the choice to
# use the VFS.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object.
#
cdef amd_comgr_status_s amd_comgr_action_info_set_vfs(amd_comgr_action_info_s action_info,_Bool should_use_vfs) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Set the device library linking behavior of an action info object.
# 
# Device library linking can be either enforced or omitted for compilation
# actions.
# 
# @param[in] action_info A handle to the action info object to be
# updated.
# 
# @param[in] should_link_device_libs A boolean that directs the choice to
# link the device libraries.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object.
cdef amd_comgr_status_s amd_comgr_action_info_set_device_lib_linking(amd_comgr_action_info_s action_info,_Bool should_link_device_libs) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Set the block sizes for kernel cloning.
# 
# When an action info object is created it has no block sizes specified.
# When block sizes are set, SPIR-V translation and compilation actions
# (AMD_COMGR_ACTION_TRANSLATE_SPIRV_TO_BC and
# AMD_COMGR_ACTION_COMPILE_SPIRV_TO_RELOCATABLE) will automatically clone
# kernel functions for each specified block size, if the size is within the
# limits specified by the amdgpu-flat-work-group-size attribute on the kernel.
# The upper limit of the original kernel is assumed to represent the original
# kernel, so if corresponding block size is in the set of block sizes, no new
# kernel is generated for that block size.
# Cloned kernels will have the amdgpu-flat-work-group-size attribute set with
# an upper limit equal to the corresponding block size and the lower bound
# equal to the lower bound of the original kernel.
# Cloned kernels will have a name in the format of
# "<original_kernel_name>.bs<block_size>".
# 
# @param[in] action_info A handle to the action info object to be updated.
# 
# @param[in] block_sizes An array of block sizes (flat work group sizes) to
# compile kernel variants for. If NULL then the block sizes are cleared.
# 
# @param[in] count The number of elements in the @p block_sizes array.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p action_info is an
# invalid action info object, or @p block_sizes is NULL and @p count is
# non-zero.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to update action
# info object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_set_block_sizes(amd_comgr_action_info_s action_info,const size_t * block_sizes,size_t count) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the number of block sizes set for kernel cloning actions.
# 
# @param[in] action_info The action info object to query.
# 
# @param[out] count The number of block sizes set.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p action_info is an
# invalid action info object. @p count is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to query action
# info object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_get_block_sizes_count(amd_comgr_action_info_s action_info,size_t * count) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the block sizes set for kernel cloning actions.
# 
# @param[in] action_info The action info object to query.
# 
# @param[in] count The number of elements in the @p block_sizes array.
# 
# @param[out] block_sizes Array to store the block sizes. Must be large enough
# to hold @p count elements. Use amd_comgr_action_info_get_block_sizes_count
# to query the required size.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p action_info is an
# invalid action info object. @p block_sizes is NULL. @p count is less than
# the number of block sizes set.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to query action
# info object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_get_block_sizes(amd_comgr_action_info_s action_info,size_t count,size_t * block_sizes) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Set the working directory of an action info object.
# 
# When an action info object is created it has an empty working
# directory. Some actions use the working directory to resolve
# relative file paths.
# 
# @param[in] action_info A handle to the action info object to be
# updated.
# 
# @param[in] path A null terminated string that is the working
# directory path. If NULL or the empty string then the working
# directory is cleared.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update action info object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_set_working_directory_path(amd_comgr_action_info_s action_info,const char * path) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the working directory path and/or working directory path
# length of an action info object.
# 
# @param[in] action_info The action info object to query.
# 
# @param[in, out] size On entry, the size of @p path. On return, if @p path is
# NULL, set to the size of the working directory path including the
# terminating null character.
# 
# @param[out] path If not NULL, then the first @p size characters of
# the working directory path is copied. If the working directory path
# is not set then an empty string is copied. If NULL, the working
# directory path is not copied, and only @p size is updated (useful
# in order to find the size of buffer required to copy the working
# directory path).
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object. @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_action_info_get_working_directory_path(amd_comgr_action_info_s action_info,size_t * size,char * path) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Set whether logging is enabled for an action info object.
# 
# @param[in] action_info A handle to the action info object to be
# updated.
# 
# @param[in] logging Whether logging should be enabled or disable.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object.
cdef amd_comgr_status_s amd_comgr_action_info_set_logging(amd_comgr_action_info_s action_info,_Bool logging) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get whether logging is enabled for an action info object.
# 
# @param[in] action_info The action info object to query.
# 
# @param[out] logging Whether logging is enabled.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# action_info is an invalid action info object. @p logging is NULL.
cdef amd_comgr_status_s amd_comgr_action_info_get_logging(amd_comgr_action_info_s action_info,_Bool * logging) except? AMD_COMGR_STATUS_ERROR nogil


cdef extern from "amd_comgr/amd_comgr.h":

    cdef enum amd_comgr_action_kind_s:
        AMD_COMGR_ACTION_SOURCE_TO_PREPROCESSOR
        AMD_COMGR_ACTION_ADD_PRECOMPILED_HEADERS
        AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC
        AMD_COMGR_ACTION_LINK_BC_TO_BC
        AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE
        AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY
        AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_RELOCATABLE
        AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE
        AMD_COMGR_ACTION_ASSEMBLE_SOURCE_TO_RELOCATABLE
        AMD_COMGR_ACTION_DISASSEMBLE_RELOCATABLE_TO_SOURCE
        AMD_COMGR_ACTION_DISASSEMBLE_EXECUTABLE_TO_SOURCE
        AMD_COMGR_ACTION_DISASSEMBLE_BYTES_TO_SOURCE
        AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC
        AMD_COMGR_ACTION_COMPILE_SOURCE_TO_RELOCATABLE
        AMD_COMGR_ACTION_COMPILE_SOURCE_TO_EXECUTABLE
        AMD_COMGR_ACTION_UNBUNDLE
        AMD_COMGR_ACTION_COMPILE_SPIRV_TO_RELOCATABLE
        AMD_COMGR_ACTION_TRANSLATE_SPIRV_TO_BC
        AMD_COMGR_ACTION_COMPILE_SOURCE_TO_SPIRV
        AMD_COMGR_ACTION_LAST

    ctypedef amd_comgr_action_kind_s amd_comgr_action_kind_t

# 
# @brief Perform an action.
# 
# Each action ignores any data objects in @p input that it does not
# use. If logging is enabled in @info then @p result will have a log
# data object added. Any diagnostic data objects produced by the
# action will be added to @p result. See the description of each
# action in @p amd_comgr_action_kind_t.
# 
# @param[in] kind The action to perform.
# 
# @param[in] info The action info to use when performing the action.
# 
# @param[in] input The input data objects to the @p kind action.
# 
# @param[out] result Any data objects are removed before performing
# the action which then adds all data objects produced by the action.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR An error was
# reported when executing the action.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# kind is an invalid action kind. @p input_data or @p result_data are
# invalid action data object handles. See the description of each
# action in @p amd_comgr_action_kind_t for other
# conditions that result in this status.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_do_action(amd_comgr_action_kind_s kind,amd_comgr_action_info_s info,amd_comgr_data_set_s input,amd_comgr_data_set_s result) except? AMD_COMGR_STATUS_ERROR nogil


cdef extern from "amd_comgr/amd_comgr.h":

    cdef enum amd_comgr_metadata_kind_s:
        AMD_COMGR_METADATA_KIND_NULL
        AMD_COMGR_METADATA_KIND_STRING
        AMD_COMGR_METADATA_KIND_MAP
        AMD_COMGR_METADATA_KIND_LIST
        AMD_COMGR_METADATA_KIND_LAST

    ctypedef amd_comgr_metadata_kind_s amd_comgr_metadata_kind_t

# 
# @brief Get the kind of the metadata node.
# 
# @param[in] metadata The metadata node to query.
# 
# @param[out] kind The kind of the metadata node.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# metadata is an invalid metadata node. @p kind is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to create the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_metadata_kind(amd_comgr_metadata_node_s metadata,amd_comgr_metadata_kind_s * kind) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the string and/or string length from a metadata string
# node.
# 
# @param[in] metadata The metadata node to query.
# 
# @param[in, out] size On entry, the size of @p string. On return, if @p
# string is NULL, set to the size of the string including the terminating null
# character.
# 
# @param[out] string If not NULL, then the first @p size characters
# of the string are copied. If NULL, no string is copied, and only @p
# size is updated (useful in order to find the size of buffer required
# to copy the string).
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# metadata is an invalid metadata node, or does not have kind @p
# AMD_COMGR_METADATA_KIND_STRING. @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_metadata_string(amd_comgr_metadata_node_s metadata,size_t * size,char * string) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the map size from a metadata map node.
# 
# @param[in] metadata The metadata node to query.
# 
# @param[out] size The number of entries in the map.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# metadata is an invalid metadata node, or not of kind @p
# AMD_COMGR_METADATA_KIND_MAP. @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_metadata_map_size(amd_comgr_metadata_node_s metadata,size_t * size) except? AMD_COMGR_STATUS_ERROR nogil


ctypedef amd_comgr_status_s (*amd_comgr_iterate_map_metadata_anon_funptr_0) (amd_comgr_metadata_node_s,amd_comgr_metadata_node_s,void *)

# 
# @brief Iterate over the elements a metadata map node.
# 
# @warning The metadata nodes which are passed to the callback are not owned
# by the callback, and are freed just after the callback returns. The callback
# must not save any references to its parameters between iterations.
# 
# @param[in] metadata The metadata node to query.
# 
# @param[in] callback The function to call for each entry in the map. The
# entry's key is passed in @p key, the entry's value is passed in @p value, and
# @p user_data is passed as @p user_data. If the function returns with a status
# other than @p AMD_COMGR_STATUS_SUCCESS then iteration is stopped.
# 
# @param[in] user_data The value to pass to each invocation of @p
# callback. Allows context to be passed into the call back function.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR An error was
# reported by @p callback.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# metadata is an invalid metadata node, or not of kind @p
# AMD_COMGR_METADATA_KIND_MAP. @p callback is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to iterate the metadata as out of resources.
cdef amd_comgr_status_s amd_comgr_iterate_map_metadata(amd_comgr_metadata_node_s metadata,amd_comgr_iterate_map_metadata_anon_funptr_0 callback,void * user_data) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Use a string key to lookup an element of a metadata map
# node and return the entry value.
# 
# @param[in] metadata The metadata node to query.
# 
# @param[in] key A null terminated string that is the key to lookup.
# 
# @param[out] value The metadata node of the @p key element of the
# @p metadata map metadata node. The handle must be destroyed
# using @c amd_comgr_destroy_metadata.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR The map has no entry
# with a string key with the value @p key.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# metadata is an invalid metadata node, or not of kind @p
# AMD_COMGR_METADATA_KIND_MAP. @p key or @p value is
# NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to lookup metadata as out of resources.
cdef amd_comgr_status_s amd_comgr_metadata_lookup(amd_comgr_metadata_node_s metadata,const char * key,amd_comgr_metadata_node_s * value) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Get the list size from a metadata list node.
# 
# @param[in] metadata The metadata node to query.
# 
# @param[out] size The number of entries in the list.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# metadata is an invalid metadata node, or does nopt have kind @p
# AMD_COMGR_METADATA_KIND_LIST. @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_get_metadata_list_size(amd_comgr_metadata_node_s metadata,size_t * size) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Return the Nth metadata node of a list metadata node.
# 
# @param[in] metadata The metadata node to query.
# 
# @param[in] index The index being requested. The first list element
# is index 0.
# 
# @param[out] value The metadata node of the @p index element of the
# @p metadata list metadata node. The handle must be destroyed
# using @c amd_comgr_destroy_metadata.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p
# metadata is an invalid metadata node or not of kind @p
# AMD_COMGR_METADATA_INFO_LIST. @p index is greater
# than the number of list elements. @p value is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to update action data object as out of resources.
cdef amd_comgr_status_s amd_comgr_index_list_metadata(amd_comgr_metadata_node_s metadata,size_t index,amd_comgr_metadata_node_s * value) except? AMD_COMGR_STATUS_ERROR nogil


ctypedef amd_comgr_status_s (*amd_comgr_iterate_symbols_anon_funptr_0) (amd_comgr_symbol_s,void *)

# 
# @brief Iterate over the symbols of a machine code object.
# 
# For a AMD_COMGR_DATA_KIND_RELOCATABLE the symbols in the ELF symtab section
# are iterated. For a AMD_COMGR_DATA_KIND_EXECUTABLE the symbols in the ELF
# dynsymtab are iterated.
# 
# @param[in] data The data object to query.
# 
# @param[in] callback The function to call for each symbol in the machine code
# data object. The symbol handle is passed in @p symbol and @p user_data is
# passed as @p user_data. If the function returns with a status other than @p
# AMD_COMGR_STATUS_SUCCESS then iteration is stopped.
# 
# @param[in] user_data The value to pass to each invocation of @p
# callback. Allows context to be passed into the call back function.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR An error was
# reported by @p callback.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data is an invalid data
# object, or not of kind @p AMD_COMGR_DATA_KIND_RELOCATABLE or
# AMD_COMGR_DATA_KIND_EXECUTABLE. @p callback is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to iterate the data object as out of resources.
cdef amd_comgr_status_s amd_comgr_iterate_symbols(amd_comgr_data_s data,amd_comgr_iterate_symbols_anon_funptr_0 callback,void * user_data) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Lookup a symbol in a machine code object by name.
# 
# For a AMD_COMGR_DATA_KIND_RELOCATABLE the symbols in the ELF symtab section
# are inspected. For a AMD_COMGR_DATA_KIND_EXECUTABLE the symbols in the ELF
# dynsymtab are inspected.
# 
# @param[in] data The data object to query.
# 
# @param[in] name A null terminated string that is the symbol name to lookup.
# 
# @param[out] symbol The symbol with the @p name.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR The machine code object has no symbol
# with @p name.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data is an invalid data
# object, or not of kind @p AMD_COMGR_DATA_KIND_RELOCATABLE or
# AMD_COMGR_DATA_KIND_EXECUTABLE.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to lookup symbol as out of resources.
cdef amd_comgr_status_s amd_comgr_symbol_lookup(amd_comgr_data_s data,const char * name,amd_comgr_symbol_s * symbol) except? AMD_COMGR_STATUS_ERROR nogil


cdef extern from "amd_comgr/amd_comgr.h":

    cdef enum amd_comgr_symbol_type_s:
        AMD_COMGR_SYMBOL_TYPE_UNKNOWN
        AMD_COMGR_SYMBOL_TYPE_NOTYPE
        AMD_COMGR_SYMBOL_TYPE_OBJECT
        AMD_COMGR_SYMBOL_TYPE_FUNC
        AMD_COMGR_SYMBOL_TYPE_SECTION
        AMD_COMGR_SYMBOL_TYPE_FILE
        AMD_COMGR_SYMBOL_TYPE_COMMON
        AMD_COMGR_SYMBOL_TYPE_AMDGPU_HSA_KERNEL

    ctypedef amd_comgr_symbol_type_s amd_comgr_symbol_type_t

    cdef enum amd_comgr_symbol_info_s:
        AMD_COMGR_SYMBOL_INFO_NAME_LENGTH
        AMD_COMGR_SYMBOL_INFO_NAME
        AMD_COMGR_SYMBOL_INFO_TYPE
        AMD_COMGR_SYMBOL_INFO_SIZE
        AMD_COMGR_SYMBOL_INFO_IS_UNDEFINED
        AMD_COMGR_SYMBOL_INFO_VALUE
        AMD_COMGR_SYMBOL_INFO_LAST

    ctypedef amd_comgr_symbol_info_s amd_comgr_symbol_info_t

# 
# @brief Query information about a machine code object symbol.
# 
# @param[in] symbol The symbol to query.
# 
# @param[in] attribute Attribute to query.
# 
# @param[out] value Pointer to an application-allocated buffer where to store
# the value of the attribute. If the buffer passed by the application is not
# large enough to hold the value of attribute, the behavior is undefined. The
# type of value returned is specified by @p amd_comgr_symbol_info_t.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has
# been executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR The @p symbol does not have the requested @p
# attribute.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p symbol is an invalid
# symbol. @p attribute is an invalid value. @p value is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES
# Unable to query symbol as out of resources.
cdef amd_comgr_status_s amd_comgr_symbol_get_info(amd_comgr_symbol_s symbol,amd_comgr_symbol_info_s attribute,void * value) except? AMD_COMGR_STATUS_ERROR nogil


ctypedef uint64_t (*amd_comgr_create_disassembly_info_anon_funptr_0) (uint64_t,char *,uint64_t,void *)

ctypedef void (*amd_comgr_create_disassembly_info_anon_funptr_1) (const char *,void *)

ctypedef void (*amd_comgr_create_disassembly_info_anon_funptr_2) (uint64_t,void *)

# 
# @brief Create a disassembly info object.
# 
# @param[in] isa_name A null terminated string that is the isa name of the
# target to disassemble for. The isa name is defined as the Code Object Target
# Identification string, described at
# https://llvm.org/docs/AMDGPUUsage.html#code-object-target-identification
# 
# @param[in] read_memory_callback Function called to request @p size bytes
# from the program address space at @p from be read into @p to. The requested
# @p size is never zero. Returns the number of bytes which could be read, with
# the guarantee that no additional bytes will be available in any subsequent
# call.
# 
# @param[in] print_instruction_callback Function called after a successful
# disassembly. @p instruction is a null terminated string containing the
# disassembled instruction. The callback does not own @p instruction, and it
# cannot be referenced once the callback returns.
# 
# @param[in] print_address_annotation_callback Function called after @c
# print_instruction_callback returns, once for each instruction operand which
# was resolved to an absolute address. @p address is the absolute address in
# the program address space. It is intended to append a symbolic
# form of the address, perhaps as a comment, after the instruction disassembly
# produced by @c print_instruction_callback.
# 
# @param[out] disassembly_info A handle to the disassembly info object
# created.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The disassembly info object was created.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p isa_name is NULL or
# invalid; or @p read_memory_callback, @p print_instruction_callback,
# or @p print_address_annotation_callback is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to create the
# disassembly info object as out of resources.
cdef amd_comgr_status_s amd_comgr_create_disassembly_info(const char * isa_name,amd_comgr_create_disassembly_info_anon_funptr_0 read_memory_callback,amd_comgr_create_disassembly_info_anon_funptr_1 print_instruction_callback,amd_comgr_create_disassembly_info_anon_funptr_2 print_address_annotation_callback,amd_comgr_disassembly_info_s * disassembly_info) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Destroy a disassembly info object.
# 
# @param[in] disassembly_info A handle to the disassembly info object to
# destroy.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The disassembly info object was
# destroyed.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p disassembly_info is an
# invalid disassembly info object.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to destroy the
# disassembly info object as out of resources.
cdef amd_comgr_status_s amd_comgr_destroy_disassembly_info(amd_comgr_disassembly_info_s disassembly_info) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Disassemble a single instruction.
# 
# @param[in] address The address of the first byte of the instruction in the
# program address space.
# 
# @param[in] user_data Arbitrary user-data passed to each callback function
# during disassembly.
# 
# @param[out] size The number of bytes consumed to decode the
# instruction, or consumed while failing to decode an invalid instruction.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The disassembly was successful.
# 
# @retval ::AMD_COMGR_STATUS_ERROR The disassembly failed.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p disassembly_info is
# invalid or @p size is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to disassemble the
# instruction as out of resources.
cdef amd_comgr_status_s amd_comgr_disassemble_instruction(amd_comgr_disassembly_info_s disassembly_info,uint64_t address,void * user_data,uint64_t * size) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Demangle a symbol name.
# 
# @param[in] mangled_symbol_name A data object of kind @p
# AMD_COMGR_DATA_KIND_BYTES containing the mangled symbol name.
# 
# @param[out] demangled_symbol_name A handle to the data object of kind @p
# AMD_COMGR_DATA_KIND_BYTES created and set to contain the demangled symbol
# name in case of successful completion. The handle must be released using
# @c amd_comgr_release_data. @p demangled_symbol_name is not updated for
# an error case.
# 
# @note If the @p mangled_symbol_name cannot be demangled, it will be copied
# without changes to the @p demangled_symbol_name and AMD_COMGR_STATUS_SUCCESS
# is returned.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p mangled_symbol_name is
# an invalid data object or not of kind @p AMD_COMGR_DATA_KIND_BYTES or
# @p demangled_symbol_name is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Out of resources.
cdef amd_comgr_status_s amd_comgr_demangle_symbol_name(amd_comgr_data_s mangled_symbol_name,amd_comgr_data_s * demangled_symbol_name) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Fetch mangled symbol names from a code object.
# 
# @param[in] data A data object of kind @p
# AMD_COMGR_DATA_KIND_EXECUTABLE or @p AMD_COMGR_DATA_KIND_BC
# 
# @param[out] count The number of mangled names retrieved. This value
# can be used as an upper bound to the Index provided to the corresponding
# amd_comgr_get_mangled_name() call.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data is
# an invalid data object or not of kind @p AMD_COMGR_DATA_KIND_EXECUTABLE or
# @p AMD_COMGR_DATA_KIND_BC.
#
cdef amd_comgr_status_s amd_comgr_populate_mangled_names(amd_comgr_data_s data,size_t * count) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Fetch the Nth specific mangled name from a set of populated names or
# that name's length.
# 
# The @p data must have had its mangled names populated with @p
# amd_comgr_populate_mangled_names.
# 
# @param[in] data A data object of kind @p
# AMD_COMGR_DATA_KIND_EXECUTABLE or @p AMD_COMGR_DATA_KIND_BC used to
# identify which set of mangled names to retrive from.
# 
# @param[in] index The index of the mangled name to be returned.
# 
# @param[in, out] size For out, the size of @p mangled_name. For in,
# if @mangled_name is NULL, set to the size of the Nth option string including
# the terminating null character.
# 
# @param[out] mangled_name If not NULL, then the first @p size characters of
# the Nth mangled name string are copied into @p mangled_name. If NULL, no
# mangled name string is copied, and only @p size is updated (useful in order
# to find the size of the buffer requried to copy the mangled_name string).
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR @p data has not been used to
# populate a set of mangled names, or index is greater than the count of
# mangled names for that data object
#
cdef amd_comgr_status_s amd_comgr_get_mangled_name(amd_comgr_data_s data,size_t index,size_t * size,char * mangled_name) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Populate a name expression map from a given code object.
# 
# Used to map stub names *__amdgcn_name_expr_* in bitcodes and code
# objects generated by hip runtime to an associated (unmangled) name
# expression and (mangled) symbol name.
# 
# @param[in] data A data object of kind @p
# AMD_COMGR_DATA_KIND_EXECUTABLE or @p AMD_COMGR_DATA_KIND_BC
# 
# @param[out] count The number of name expressions mapped. This value
# can be used as an upper bound to the Index provided to the corresponding
# amd_comgr_map_name_expression_to_symbol_name() call.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data is
# an invalid data object or not of kind @p AMD_COMGR_DATA_KIND_EXECUTABLE or
# @p AMD_COMGR_DATA_KIND_BC.
# 
# @retval ::AMD_COMGR_STATUS_ERROR LLVM API failure, which should be
# accompanied by an LLVM error message to stderr
#
cdef amd_comgr_status_s amd_comgr_populate_name_expression_map(amd_comgr_data_s data,size_t * count) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Fetch a related symbol name for a given name expression;
# or that name's length.
# 
# The @p data must have had its name expression map populated with @p
# amd_comgr_populate_name_expression_map.
# 
# @param[in] data A data object of kind @p
# AMD_COMGR_DATA_KIND_EXECUTABLE or @p AMD_COMGR_DATA_KIND_BC used to
# identify which map of name expressions to retrieve from.
# 
# @param[in, out] size For out, the size of @p symbol_name. For in,
# if @symbol_name is NULL, set to the size of the Nth option string including
# the terminating null character.
# 
# @param[in] name_expression A character array of a name expression. This name
# is used as the key to the name expression map in order to locate the desired
# @symbol_name.
# 
# @param[out] symbol_name If not NULL, then the first @p size characters of
# the symbol name string mapped from @name_expression are copied into @p
# symbol_name. If NULL, no symbol name string is copied, and only @p size is
# updated (useful in order to find the size of the buffer required to copy the
# symbol_name string).
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function executed successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR @p data object is not valid (NULL or not of
# type bitcode or code object)
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p name_expression is not
# present in the name expression map.
#
cdef amd_comgr_status_s amd_comgr_map_name_expression_to_symbol_name(amd_comgr_data_s data,size_t * size,const char * name_expression,char * symbol_name) except? AMD_COMGR_STATUS_ERROR nogil


cdef extern from "amd_comgr/amd_comgr.h":

    cdef struct code_object_info_s:
        const char * isa
        size_t size
        uint64_t offset

    ctypedef code_object_info_s amd_comgr_code_object_info_t

# 
# @ brief Given a bundled code object and list of target id strings, extract
# correponding code object information.
# 
# @param[in] data The data object for bundled code object. This should be
# of kind AMD_COMGR_DATA_KIND_FATBIN or AMD_COMGR_DATA_KIND_EXECUTABLE or
# AMD_COMGR_DATA_KIND_BYTES. The API interprets the data object of kind
# AMD_COMGR_DATA_KIND_FATBIN as a clang offload bundle and of kind
# AMD_COMGR_DATA_KIND_EXECUTABLE as an executable shared object. For a data
# object of type AMD_COMGR_DATA_KIND_BYTES the API first inspects the data
# passed to determine if it is a fatbin or an executable and performs
# the lookup.
# 
# @param[in, out] info_list A list of code object information structure
# initialized with null terminated target id strings. If the target id
# is matched in the code object bundle the corresponding code object
# information is updated with offset and size of the code object. If the
# target id is not found the offset and size are set to 0.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR The code object bundle header is incorrect
# or reading bundle entries failed.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data is not of
# kind AMD_COMGR_DATA_KIND_FATBIN, or AMD_COMGR_DATA_KIND_BYTES or
# AMD_COMGR_DATA_KIND_EXECUTABLE or either @p info_list is NULL.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if the @p data has
# invalid data.
cdef amd_comgr_status_s amd_comgr_lookup_code_object(amd_comgr_data_s data,code_object_info_s * info_list,size_t info_list_size) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @ brief Given a code object and an ELF virtual address, map the ELF virtual
# address to a code object offset. Also, determine if the ELF virtual address
# maps to an offset in a data region that is defined by the ELF file, but that
# does not occupy bytes in the ELF file. This is typically true of offsets that
# that refer to runtime or heap allocated memory. For ELF files with defined
# sections, these data regions are referred to as NOBITS or .bss sections.
# 
# @param[in] data The data object to be inspected for the given ELF virtual
# address. This should be of kind AMD_COMGR_DATA_KIND_EXECUTABLE.
# 
# @param[in] elf_virtual_address The address used to calculate the code object
# offset.
# 
# @param[out] code_object_offset The code object offset returned to the caller
# based on the given ELF virtual address.
# 
# @param[out] slice_size For nobits regions: the size in bytes, starting from
# the provided virtual address up to the end of the segment. In this case, the
# slice size represents the number of contiguous unreadable addresses following
# the provided address.
# 
# For bits regions: the size in bytes, starting from the provided virtual
# address up to either the end of the segment, or the start of a NOBITS region.
# In this case, slice size represents the number of contiguous readable
# addresses following the provided address.
# 
# @param[out] nobits Set to true if the code object offset points to a location
# in a data region that does not occupy bytes in the ELF file, as described
# above.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS The function has been executed
# successfully.
# 
# @retval ::AMD_COMGR_STATUS_ERROR The provided code object has an invalid
# header due to a mismatch in magic, class, data, version, abi, type, or
# machine.
# 
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data is not of
# kind AMD_COMGR_DATA_KIND_EXECUTABLE or invalid, or that the provided @p
# elf_virtual_address is not within the ranges covered by the object's
# load-type program headers.
cdef amd_comgr_status_s amd_comgr_map_elf_virtual_address_to_code_object_offset(amd_comgr_data_s data,uint64_t elf_virtual_address,uint64_t * code_object_offset,uint64_t * slice_size,_Bool * nobits) except? AMD_COMGR_STATUS_ERROR nogil


# 
# @brief Rewrite a code object from one ISA to another.
# 
# Rewrites GPU instructions in the ELF code object so that it can execute
# on a different target ISA. This includes both same-family stepping
# patches (e.g. B0 to A0) and cross-family transpilation.
# The input ELF is not modified; a new data object is created and returned.
# 
# A successful call means COMGR produced a valid output code object, not
# necessarily that the output bytes differ from the input. If the
# source/target ISA pair selects no enabled transformation, the output is a
# copy of the input.
# 
# Currently supported transformations:
#   - GFX1250 B0 to A0
# 
# Additional source/target ISA pairs may be added in future releases.
# Unsupported @p source_isa_name / @p target_isa_name combinations return
# @c AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT.
# 
# @param[in] input A data object of kind @p AMD_COMGR_DATA_KIND_EXECUTABLE
#   containing the input ELF code object bytes.
# @param[in] source_isa_name A null terminated string that is the isa name
#   the code object was compiled for. The isa name is defined as the Code
#   Object Target Identification string, described at
#   https://llvm.org/docs/AMDGPUUsage.html#code-object-target-identification
# @param[in] target_isa_name A null terminated string that is the isa name
#   of the target GPU.
# @param[out] output A handle to a data object of kind @p
#   AMD_COMGR_DATA_KIND_EXECUTABLE containing the rewritten ELF. The caller
#   must release this handle using @c amd_comgr_release_data when done.
#   @p output is not modified on failure.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS Patching completed successfully.
# @retval ::AMD_COMGR_STATUS_ERROR An internal error occurred.
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p input is an invalid
#   data object, is not of kind @p AMD_COMGR_DATA_KIND_EXECUTABLE, does not
#   contain data bytes, or @p source_isa_name or @p target_isa_name is NULL,
#   or the source/target isa name combination is not supported.
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to allocate
#   the output data object.
cdef amd_comgr_status_s amd_comgr_hotswap_rewrite(amd_comgr_data_s input,const char * source_isa_name,const char * target_isa_name,amd_comgr_data_s * output) except? AMD_COMGR_STATUS_ERROR nogil


cdef extern from "amd_comgr/amd_comgr.h":

    cdef enum amd_comgr_hotswap_rewrite_flag_s:
        AMD_COMGR_HOTSWAP_REWRITE_FLAG_NONE
        AMD_COMGR_HOTSWAP_REWRITE_FLAG_ENTRY_TRAMPOLINES
        AMD_COMGR_HOTSWAP_REWRITE_FLAG_STRICT_MODE

    ctypedef amd_comgr_hotswap_rewrite_flag_s amd_comgr_hotswap_rewrite_flag_t

    cdef struct amd_comgr_hotswap_rewrite_options_s:
        size_t size
        uint64_t flags

    ctypedef amd_comgr_hotswap_rewrite_options_s amd_comgr_hotswap_rewrite_options_t

# 
# @brief Rewrite a code object from one ISA to another with explicit options.
# 
# Rewrites GPU instructions in the ELF code object so that it can execute
# on a different target ISA. This includes both same-family stepping
# patches (e.g. B0 to A0) and cross-family transpilation.
# The input ELF is not modified; a new data object is created and returned.
# 
# A successful call means COMGR produced a valid output code object, not
# necessarily that the output bytes differ from the input. If the
# source/target ISA pair and rewrite options select no enabled transformation,
# the output is a copy of the input.
# 
# Currently supported transformations:
#   - GFX1250 B0 to A0
#   - GFX125x entry trampolines when requested by @p rewrite_options
#   - GFX1250 B0 strict-mode mask workarounds when requested by
#     @p rewrite_options
# 
# Additional source/target ISA pairs may be added in future releases.
# Unsupported @p source_isa_name / @p target_isa_name combinations return
# @c AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT.
# 
# @param[in] input A data object of kind @p AMD_COMGR_DATA_KIND_EXECUTABLE
#   containing the input ELF code object bytes.
# @param[in] source_isa_name A null terminated string that is the isa name
#   the code object was compiled for. The isa name is defined as the Code
#   Object Target Identification string, described at
#   https://llvm.org/docs/AMDGPUUsage.html#code-object-target-identification
# @param[in] target_isa_name A null terminated string that is the isa name
#   of the target GPU.
# @param[in] rewrite_options Options controlling optional rewrite behavior.
#   Must not be NULL. Unknown flag bits return
#   @c AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT.
# @param[out] output A handle to a data object of kind @p
#   AMD_COMGR_DATA_KIND_EXECUTABLE containing the rewritten ELF. The caller
#   must release this handle using @c amd_comgr_release_data when done.
#   @p output is not modified on failure.
# 
# @retval ::AMD_COMGR_STATUS_SUCCESS Patching completed successfully.
# @retval ::AMD_COMGR_STATUS_ERROR An internal error occurred.
# @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p input is an invalid
#   data object, is not of kind @p AMD_COMGR_DATA_KIND_EXECUTABLE, does not
#   contain data bytes, @p source_isa_name, @p target_isa_name, @p
#   rewrite_options, or @p output is NULL, the source/target isa name
#   combination is not supported, the options structure is too small, or
#   unsupported option flags are set.
# @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES Unable to allocate
#   the output data object.
cdef amd_comgr_status_s amd_comgr_hotswap_rewrite_with_options(amd_comgr_data_s input,const char * source_isa_name,const char * target_isa_name,const amd_comgr_hotswap_rewrite_options_s * rewrite_options,amd_comgr_data_s * output) except? AMD_COMGR_STATUS_ERROR nogil


cdef bint __amd_comgr_has_symbol(const char* name) noexcept nogil