From 547536de4aae5bab8147d0dba739affbc9228fca Mon Sep 17 00:00:00 2001 From: Andrzej Janik Date: Mon, 18 Aug 2025 20:12:57 +0200 Subject: [PATCH] Add more instructions, tighten generated assembly (#475) --- comgr/src/lib.rs | 147 ++++++++++++- dark_api/src/fatbin.rs | 4 +- dark_api/src/lib.rs | 2 +- ext/amd_comgr-sys/README | 9 +- ext/amd_comgr-sys/src/comgr2.rs | 203 ++++++++++-------- ext/amd_comgr-sys/src/comgr3.rs | 199 ++++++++++------- ptx/lib/zluda_ptx_impl.bc | Bin 12444 -> 12264 bytes ptx/lib/zluda_ptx_impl.cpp | 6 +- ptx/src/pass/insert_post_saturation.rs | 2 + .../instruction_mode_to_global_mode/mod.rs | 2 + ptx/src/pass/llvm/attributes.rs | 4 +- ptx/src/pass/llvm/emit.rs | 58 ++++- .../replace_instructions_with_functions.rs | 25 +-- ptx/src/test/ll/_attributes.ll | 2 +- ptx/src/test/ll/abs.ll | 16 +- ptx/src/test/ll/activemask.ll | 2 +- ptx/src/test/ll/assertfail.ll | 2 +- ptx/src/test/ll/bar_red_and_pred.ll | 10 +- ptx/src/test/ll/bfe.ll | 2 +- ptx/src/test/ll/bfi.ll | 2 +- ptx/src/test/ll/call.ll | 4 +- ptx/src/test/ll/call_rnd.ll | 4 +- ptx/src/test/ll/cp_async.ll | 16 +- ptx/src/test/ll/cvt_f64_f32.ll | 2 +- ptx/src/test/ll/cvt_rni.ll | 8 +- ptx/src/test/ll/cvt_rzi.ll | 15 +- ptx/src/test/ll/cvt_sat_s_u.ll | 6 +- ptx/src/test/ll/div_ftz.ll | 4 +- ptx/src/test/ll/div_noftz.ll | 4 +- ptx/src/test/ll/dp4a.ll | 48 +++++ ptx/src/test/ll/ex2.ll | 13 +- ptx/src/test/ll/extern_func.ll | 2 +- ptx/src/test/ll/extern_shared_call.ll | 2 +- ptx/src/test/ll/lanemask_lt.ll | 2 +- ptx/src/test/ll/lg2.ll | 13 +- ptx/src/test/ll/multiple_return.ll | 18 +- ptx/src/test/ll/nanosleep.ll | 2 +- ptx/src/test/ll/ntid.ll | 2 +- ptx/src/test/ll/pred_not.ll | 4 +- ptx/src/test/ll/rcp.ll | 13 +- ptx/src/test/ll/setp.ll | 4 +- ptx/src/test/ll/setp_gt.ll | 4 +- ptx/src/test/ll/setp_leu.ll | 4 +- ptx/src/test/ll/setp_nan.ll | 16 +- ptx/src/test/ll/setp_num.ll | 16 +- ptx/src/test/ll/shared_unify_extern.ll | 4 +- ptx/src/test/ll/shared_unify_local.ll | 4 +- ptx/src/test/ll/shfl_sync_bfly_b32_pred.ll | 12 +- ptx/src/test/ll/shfl_sync_down_b32_pred.ll | 12 +- ptx/src/test/ll/shfl_sync_idx_b32_pred.ll | 12 +- ptx/src/test/ll/shfl_sync_mode_b32.ll | 10 +- ptx/src/test/ll/shfl_sync_up_b32_pred.ll | 12 +- ptx/src/test/ll/shr_oob.ll | 12 +- ptx/src/test/ll/sqrt.ll | 2 +- ptx/src/test/ll/sqrt_rn_ftz.ll | 2 +- ptx/src/test/ll/stateful_ld_st_ntid.ll | 2 +- ptx/src/test/ll/stateful_ld_st_ntid_chain.ll | 2 +- ptx/src/test/ll/stateful_ld_st_ntid_sub.ll | 2 +- ptx/src/test/ll/tanh.ll | 12 +- ptx/src/test/ll/tid.ll | 2 +- ptx/src/test/ll/trap.ll | 16 ++ ptx/src/test/ll/vector.ll | 2 +- ptx/src/test/spirv_run/dp4a.ptx | 26 +++ ptx/src/test/spirv_run/mod.rs | 39 +++- ptx/src/test/spirv_run/trap.ptx | 11 + ptx_parser/src/ast.rs | 43 ++++ ptx_parser/src/lib.rs | 26 +++ ptx_parser_macros_impl/src/parser.rs | 30 ++- zluda/src/impl/module.rs | 2 +- zluda_trace/src/lib.rs | 48 ++++- 70 files changed, 885 insertions(+), 383 deletions(-) create mode 100644 ptx/src/test/ll/dp4a.ll create mode 100644 ptx/src/test/ll/trap.ll create mode 100644 ptx/src/test/spirv_run/dp4a.ptx create mode 100644 ptx/src/test/spirv_run/trap.ptx diff --git a/comgr/src/lib.rs b/comgr/src/lib.rs index f5e4e30..9c5671b 100644 --- a/comgr/src/lib.rs +++ b/comgr/src/lib.rs @@ -175,22 +175,35 @@ impl Data { } } +#[derive(Clone, Copy, Debug)] +struct Symbol(u64); + +impl Symbol { + fn comgr2(&self) -> comgr2::amd_comgr_symbol_t { + comgr2::amd_comgr_symbol_s { handle: self.0 } + } + + fn comgr3(&self) -> comgr3::amd_comgr_symbol_t { + comgr3::amd_comgr_symbol_s { handle: self.0 } + } +} + pub fn compile_bitcode( comgr: &Comgr, gcn_arch: &str, main_buffer: &[u8], - attributes_buffer: &[u8], ptx_impl: &[u8], + attributes_buffer: &[u8], compiler_hook: Option<&dyn Fn(&Vec, String)>, ) -> Result, Error> { let bitcode_data_set = DataSet::new(comgr)?; let main_bitcode_data = Data::new(comgr, DataKind::Bc, c"zluda.bc", main_buffer)?; bitcode_data_set.add(&main_bitcode_data)?; + let stdlib_bitcode_data = Data::new(comgr, DataKind::Bc, c"ptx_impl.bc", ptx_impl)?; + bitcode_data_set.add(&stdlib_bitcode_data)?; let attributes_bitcode_data = Data::new(comgr, DataKind::Bc, c"attributes.bc", attributes_buffer)?; bitcode_data_set.add(&attributes_bitcode_data)?; - let stdlib_bitcode_data = Data::new(comgr, DataKind::Bc, c"ptx_impl.bc", ptx_impl)?; - bitcode_data_set.add(&stdlib_bitcode_data)?; let linking_info = ActionInfo::new(comgr)?; let linked_data_set = comgr.do_action(ActionKind::LinkBcToBc, &linking_info, &bitcode_data_set)?; @@ -214,6 +227,9 @@ pub fn compile_bitcode( c"-Xclang", c"-fdenormal-fp-math=dynamic", c"-O3", + // To consider + //c"-mllvm", + //c"-amdgpu-internalize-symbols", c"-mno-wavefrontsize64", c"-mcumode", // Useful for inlining reports, combined with AMD_COMGR_SAVE_TEMPS=1 AMD_COMGR_EMIT_VERBOSE_LOGS=1 AMD_COMGR_REDIRECT_LOGS=stderr @@ -263,6 +279,22 @@ pub fn compile_bitcode( executable } +pub fn get_symbols(comgr: &Comgr, elf: &[u8]) -> Result, Error> { + let elf = Data::new(comgr, DataKind::Executable, c"elf.o", elf)?; + let mut symbols = Vec::new(); + comgr.iterate_symbols(&elf, &mut |symbol| { + let type_ = unsafe { comgr.symbol_get_info::(symbol, SymbolInfo::Type)? }; + let name_length = unsafe { comgr.symbol_get_info::(symbol, SymbolInfo::NameLength)? }; + let mut name = + unsafe { comgr.symbol_get_buffer(symbol, SymbolInfo::Name, name_length as usize + 1)? }; + name.pop(); + let name = String::from_utf8(name).map_err(|_| Error::UNKNOWN)?; + symbols.push((type_, name)); + Ok(()) + })?; + Ok(symbols) +} + pub fn get_clang_version(comgr: &Comgr) -> Result { let version_string_set = DataSet::new(comgr)?; let version_string = Data::new( @@ -310,6 +342,8 @@ pub enum Comgr { V3(amd_comgr_sys::comgr3::Comgr3), } +type SymbolIterator = dyn FnMut(Symbol) -> Result<(), Error>; + impl Comgr { pub fn new() -> Result { unsafe { libloading::Library::new(os::COMGR3) } @@ -351,16 +385,78 @@ impl Comgr { (major, minor) >= (2, 9) } - fn do_action( - &self, + fn do_action<'a>( + &'a self, kind: ActionKind, action: &ActionInfo, data_set: &DataSet, - ) -> Result { + ) -> Result, Error> { let result = DataSet::new(self)?; call_dispatch!(self => amd_comgr_do_action(kind, action, data_set, result)); Ok(result) } + + fn iterate_symbols<'this>( + &'this self, + data: &Data, + mut fn_: &mut (dyn FnMut(Symbol) -> Result<(), Error> + 'this), + ) -> Result<(), Error> { + let thin_pointer = &mut fn_; + match self { + Comgr::V2(comgr) => { + unsafe { + comgr.amd_comgr_iterate_symbols( + data.comgr2(), + Some(Self::iterate_callback_v2), + mem::transmute(thin_pointer), + ) + }?; + } + Comgr::V3(comgr) => { + unsafe { + comgr.amd_comgr_iterate_symbols( + data.comgr3(), + Some(Self::iterate_callback_v3), + mem::transmute(thin_pointer), + ) + }?; + } + } + Ok(()) + } + + extern "C" fn iterate_callback_v3( + symbol: comgr3::amd_comgr_symbol_t, + user_data: *mut ::std::os::raw::c_void, + ) -> Result<(), comgr3::amd_comgr_status_s> { + let user_data = unsafe { mem::transmute::<_, &mut &mut SymbolIterator>(user_data) }; + (*user_data)(Symbol(symbol.handle)).map_err(Into::into) + } + + extern "C" fn iterate_callback_v2( + symbol: comgr2::amd_comgr_symbol_t, + user_data: *mut ::std::os::raw::c_void, + ) -> Result<(), comgr2::amd_comgr_status_s> { + let user_data = unsafe { mem::transmute::<_, &mut &mut SymbolIterator>(user_data) }; + (*user_data)(Symbol(symbol.handle)).map_err(Into::into) + } + + unsafe fn symbol_get_info(&self, symbol: Symbol, attribute: SymbolInfo) -> Result { + let mut value = unsafe { mem::zeroed::() }; + call_dispatch!(self => amd_comgr_symbol_get_info(symbol, attribute, { ptr::from_mut(&mut value).cast() })); + Ok(value) + } + + unsafe fn symbol_get_buffer( + &self, + symbol: Symbol, + attribute: SymbolInfo, + length: usize, + ) -> Result, Error> { + let mut value = vec![0u8; length]; + call_dispatch!(self => amd_comgr_symbol_get_info(symbol, attribute, { value.as_mut_ptr().cast() })); + Ok(value) + } } #[derive(Debug, thiserror::Error)] @@ -388,12 +484,24 @@ impl From for Error { } } +impl Into for Error { + fn into(self) -> comgr2::amd_comgr_status_s { + comgr2::amd_comgr_status_s(self.0) + } +} + impl From for Error { fn from(status: comgr3::amd_comgr_status_s) -> Self { Error(status.0) } } +impl Into for Error { + fn into(self) -> comgr3::amd_comgr_status_s { + comgr3::amd_comgr_status_s(self.0) + } +} + macro_rules! impl_into { ($self_type:ident, $to_type:ident, [$($from:ident => $to:ident),+]) => { #[derive(Copy, Clone)] @@ -405,6 +513,7 @@ macro_rules! impl_into { } impl $self_type { + #[allow(dead_code)] fn comgr2(self) -> comgr2::$to_type { match self { $( @@ -413,6 +522,7 @@ macro_rules! impl_into { } } + #[allow(dead_code)] fn comgr3(self) -> comgr3::$to_type { match self { $( @@ -435,6 +545,31 @@ impl_into!( ] ); +impl_into!( + SymbolType, + amd_comgr_symbol_type_t, + [ + Unknown => AMD_COMGR_SYMBOL_TYPE_UNKNOWN, + NoType => AMD_COMGR_SYMBOL_TYPE_NOTYPE, + Object => AMD_COMGR_SYMBOL_TYPE_OBJECT, + Func => AMD_COMGR_SYMBOL_TYPE_FUNC, + Section => AMD_COMGR_SYMBOL_TYPE_SECTION, + File => AMD_COMGR_SYMBOL_TYPE_FILE, + Common => AMD_COMGR_SYMBOL_TYPE_COMMON, + AmdgpuHsaKernel => AMD_COMGR_SYMBOL_TYPE_AMDGPU_HSA_KERNEL + ] +); + +impl_into!( + SymbolInfo, + amd_comgr_symbol_info_t, + [ + NameLength => AMD_COMGR_SYMBOL_INFO_NAME_LENGTH, + Name => AMD_COMGR_SYMBOL_INFO_NAME, + Type => AMD_COMGR_SYMBOL_INFO_TYPE + ] +); + impl_into!( DataKind, amd_comgr_data_kind_t, diff --git a/dark_api/src/fatbin.rs b/dark_api/src/fatbin.rs index 7fb4493..8d7868d 100644 --- a/dark_api/src/fatbin.rs +++ b/dark_api/src/fatbin.rs @@ -106,7 +106,7 @@ impl<'a> FatbinSubmodule<'a> { FatbinSubmodule { header } } - pub fn get_files(&self) -> FatbinFileIterator { + pub fn get_files(&self) -> FatbinFileIterator<'a> { unsafe { FatbinFileIterator::new(self.header) } } } @@ -200,7 +200,7 @@ impl<'a> FatbinFileIterator<'a> { Self { file_buffer } } - pub unsafe fn next(&mut self) -> Result, ParseError> { + pub unsafe fn next(&mut self) -> Result>, ParseError> { if self.file_buffer.len() < std::mem::size_of::() { return Ok(None); } diff --git a/dark_api/src/lib.rs b/dark_api/src/lib.rs index 53c6073..e2ad634 100644 --- a/dark_api/src/lib.rs +++ b/dark_api/src/lib.rs @@ -124,7 +124,7 @@ macro_rules! dark_api { result } - pub fn get(&self, key: &cuda_types::cuda::CUuuid) -> Option { + pub fn get(&self, key: &cuda_types::cuda::CUuuid) -> Option> { match key { $( &Self::$name => { diff --git a/ext/amd_comgr-sys/README b/ext/amd_comgr-sys/README index a3e8e79..1ea190c 100644 --- a/ext/amd_comgr-sys/README +++ b/ext/amd_comgr-sys/README @@ -1,4 +1,9 @@ # On ROCm 6.3 and lower -bindgen --rust-target 1.77 /opt/rocm-6.3.4/include/amd_comgr/amd_comgr.h -o src/comgr2.rs --no-layout-tests --default-enum-style=newtype --no-derive-debug --must-use-type amd_comgr_status_t --allowlist-var "^AMD_COMGR.*$" --dynamic-loading Comgr2 --allowlist-function amd_comgr_do_action --allowlist-function amd_comgr_action_data_get_data --allowlist-function amd_comgr_action_info_set_isa_name --allowlist-function amd_comgr_action_info_set_language --allowlist-function amd_comgr_create_action_info --allowlist-function amd_comgr_create_data --allowlist-function amd_comgr_create_data_set --allowlist-function amd_comgr_data_set_add --allowlist-function amd_comgr_destroy_action_info --allowlist-function amd_comgr_destroy_data_set --allowlist-function amd_comgr_get_data --allowlist-function amd_comgr_set_data --allowlist-function amd_comgr_set_data_name --allowlist-function amd_comgr_action_info_set_option_list --allowlist-function amd_comgr_get_version +wget https://repo.radeon.com/rocm/apt/6.3.4/pool/main/c/comgr6.3.4/comgr6.3.4_2.8.0.60304-76~24.04_amd64.deb +apt install ./rocm-core6.3.4_6.3.4.60304-76~24.04_amd64.deb +wget https://repo.radeon.com/rocm/apt/6.3.4/pool/main/r/rocm-core6.3.4/rocm-core6.3.4_6.3.4.60304-76~24.04_amd64.deb +apt install ./comgr6.3.4_2.8.0.60304-76~24.04_amd64.deb +cargo install bindgen-cli +bindgen --rust-target 1.77 /opt/rocm-6.3.4/include/amd_comgr/amd_comgr.h -o src/comgr2.rs --no-layout-tests --default-enum-style=newtype --no-derive-debug --must-use-type amd_comgr_status_t --allowlist-var "^AMD_COMGR.*$" --dynamic-loading Comgr2 --allowlist-function amd_comgr_do_action --allowlist-function amd_comgr_action_data_get_data --allowlist-function amd_comgr_action_info_set_isa_name --allowlist-function amd_comgr_action_info_set_language --allowlist-function amd_comgr_create_action_info --allowlist-function amd_comgr_create_data --allowlist-function amd_comgr_create_data_set --allowlist-function amd_comgr_data_set_add --allowlist-function amd_comgr_destroy_action_info --allowlist-function amd_comgr_destroy_data_set --allowlist-function amd_comgr_get_data --allowlist-function amd_comgr_set_data --allowlist-function amd_comgr_set_data_name --allowlist-function amd_comgr_action_info_set_option_list --allowlist-function amd_comgr_get_version --allowlist-function amd_comgr_iterate_symbols --allowlist-function amd_comgr_symbol_get_info --allowlist-type amd_comgr_symbol_type_t # On ROCm 6.4 and higher -bindgen --rust-target 1.77 /opt/rocm/include/amd_comgr/amd_comgr.h -o src/comgr3.rs --no-layout-tests --default-enum-style=newtype --no-derive-debug --must-use-type amd_comgr_status_t --allowlist-var "^AMD_COMGR.*$" --dynamic-loading Comgr3 --allowlist-function amd_comgr_do_action --allowlist-function amd_comgr_action_data_get_data --allowlist-function amd_comgr_action_info_set_isa_name --allowlist-function amd_comgr_action_info_set_language --allowlist-function amd_comgr_create_action_info --allowlist-function amd_comgr_create_data --allowlist-function amd_comgr_create_data_set --allowlist-function amd_comgr_data_set_add --allowlist-function amd_comgr_destroy_action_info --allowlist-function amd_comgr_destroy_data_set --allowlist-function amd_comgr_get_data --allowlist-function amd_comgr_set_data --allowlist-function amd_comgr_set_data_name --allowlist-function amd_comgr_action_info_set_option_list --allowlist-function amd_comgr_get_version +bindgen --rust-target 1.77 /opt/rocm/include/amd_comgr/amd_comgr.h -o src/comgr3.rs --no-layout-tests --default-enum-style=newtype --no-derive-debug --must-use-type amd_comgr_status_t --allowlist-var "^AMD_COMGR.*$" --dynamic-loading Comgr3 --allowlist-function amd_comgr_do_action --allowlist-function amd_comgr_action_data_get_data --allowlist-function amd_comgr_action_info_set_isa_name --allowlist-function amd_comgr_action_info_set_language --allowlist-function amd_comgr_create_action_info --allowlist-function amd_comgr_create_data --allowlist-function amd_comgr_create_data_set --allowlist-function amd_comgr_data_set_add --allowlist-function amd_comgr_destroy_action_info --allowlist-function amd_comgr_destroy_data_set --allowlist-function amd_comgr_get_data --allowlist-function amd_comgr_set_data --allowlist-function amd_comgr_set_data_name --allowlist-function amd_comgr_action_info_set_option_list --allowlist-function amd_comgr_get_version --allowlist-function amd_comgr_iterate_symbols --allowlist-function amd_comgr_symbol_get_info --allowlist-type amd_comgr_symbol_type_t diff --git a/ext/amd_comgr-sys/src/comgr2.rs b/ext/amd_comgr-sys/src/comgr2.rs index 9811644..44a4268 100644 --- a/ext/amd_comgr-sys/src/comgr2.rs +++ b/ext/amd_comgr-sys/src/comgr2.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.71.1 */ +/* automatically generated by rust-bindgen 0.72.0 */ pub const AMD_COMGR_INTERFACE_VERSION_MAJOR: u32 = 2; pub const AMD_COMGR_INTERFACE_VERSION_MINOR: u32 = 8; @@ -6,13 +6,9 @@ impl amd_comgr_status_s { #[doc = " A generic error has occurred."] pub const AMD_COMGR_STATUS_ERROR: amd_comgr_status_s = amd_comgr_status_s(unsafe { ::std::num::NonZeroU32::new_unchecked(1) }); -} -impl amd_comgr_status_s { #[doc = " One of the actual arguments does not meet a precondition stated\n in the documentation of the corresponding formal argument. This\n includes both invalid Action types, and invalid arguments to\n valid Action types."] pub const AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT: amd_comgr_status_s = amd_comgr_status_s(unsafe { ::std::num::NonZeroU32::new_unchecked(2) }); -} -impl amd_comgr_status_s { #[doc = " Failed to allocate the necessary resources."] pub const AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES: amd_comgr_status_s = amd_comgr_status_s(unsafe { ::std::num::NonZeroU32::new_unchecked(3) }); @@ -25,28 +21,16 @@ type amd_comgr_status_t = Result<(), self::amd_comgr_status_s>; impl amd_comgr_language_s { #[doc = " No high level language."] pub const AMD_COMGR_LANGUAGE_NONE: amd_comgr_language_s = amd_comgr_language_s(0); -} -impl amd_comgr_language_s { #[doc = " OpenCL 1.2."] pub const AMD_COMGR_LANGUAGE_OPENCL_1_2: amd_comgr_language_s = amd_comgr_language_s(1); -} -impl amd_comgr_language_s { #[doc = " OpenCL 2.0."] pub const AMD_COMGR_LANGUAGE_OPENCL_2_0: amd_comgr_language_s = amd_comgr_language_s(2); -} -impl amd_comgr_language_s { #[doc = " AMD Hetrogeneous C++ (HC)."] pub const AMD_COMGR_LANGUAGE_HC: amd_comgr_language_s = amd_comgr_language_s(3); -} -impl amd_comgr_language_s { #[doc = " HIP."] pub const AMD_COMGR_LANGUAGE_HIP: amd_comgr_language_s = amd_comgr_language_s(4); -} -impl amd_comgr_language_s { #[doc = " LLVM IR, either textual (.ll) or bitcode (.bc) format."] pub const AMD_COMGR_LANGUAGE_LLVM_IR: amd_comgr_language_s = amd_comgr_language_s(5); -} -impl amd_comgr_language_s { #[doc = " Marker for last valid language."] pub const AMD_COMGR_LANGUAGE_LAST: amd_comgr_language_s = amd_comgr_language_s(5); } @@ -59,65 +43,35 @@ pub use self::amd_comgr_language_s as amd_comgr_language_t; impl amd_comgr_data_kind_s { #[doc = " No data is available."] pub const AMD_COMGR_DATA_KIND_UNDEF: amd_comgr_data_kind_s = amd_comgr_data_kind_s(0); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a textual main source."] pub const AMD_COMGR_DATA_KIND_SOURCE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(1); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a textual source that is included in the main source\n or other include source."] pub const AMD_COMGR_DATA_KIND_INCLUDE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(2); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a precompiled-header source that is included in the main\n source or other include source."] pub const AMD_COMGR_DATA_KIND_PRECOMPILED_HEADER: amd_comgr_data_kind_s = amd_comgr_data_kind_s(3); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a diagnostic output."] pub const AMD_COMGR_DATA_KIND_DIAGNOSTIC: amd_comgr_data_kind_s = amd_comgr_data_kind_s(4); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a textual log output."] pub const AMD_COMGR_DATA_KIND_LOG: amd_comgr_data_kind_s = amd_comgr_data_kind_s(5); -} -impl amd_comgr_data_kind_s { #[doc = " The data is compiler LLVM IR bit code for a specific isa."] pub const AMD_COMGR_DATA_KIND_BC: amd_comgr_data_kind_s = amd_comgr_data_kind_s(6); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a relocatable machine code object for a specific isa."] pub const AMD_COMGR_DATA_KIND_RELOCATABLE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(7); -} -impl amd_comgr_data_kind_s { #[doc = " The data is an executable machine code object for a specific\n isa. An executable is the kind of code object that can be loaded\n and executed."] pub const AMD_COMGR_DATA_KIND_EXECUTABLE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(8); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a block of bytes."] pub const AMD_COMGR_DATA_KIND_BYTES: amd_comgr_data_kind_s = amd_comgr_data_kind_s(9); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a fat binary (clang-offload-bundler output)."] pub const AMD_COMGR_DATA_KIND_FATBIN: amd_comgr_data_kind_s = amd_comgr_data_kind_s(16); -} -impl amd_comgr_data_kind_s { #[doc = " The data is an archive."] pub const AMD_COMGR_DATA_KIND_AR: amd_comgr_data_kind_s = amd_comgr_data_kind_s(17); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a bitcode bundle."] pub const AMD_COMGR_DATA_KIND_BC_BUNDLE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(18); -} -impl amd_comgr_data_kind_s { #[doc = " The data is an archive bundle."] pub const AMD_COMGR_DATA_KIND_AR_BUNDLE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(19); -} -impl amd_comgr_data_kind_s { #[doc = " The data is an object file bundle."] pub const AMD_COMGR_DATA_KIND_OBJ_BUNDLE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(20); -} -impl amd_comgr_data_kind_s { #[doc = " Marker for last valid data kind."] pub const AMD_COMGR_DATA_KIND_LAST: amd_comgr_data_kind_s = amd_comgr_data_kind_s(20); } @@ -151,100 +105,70 @@ pub struct amd_comgr_action_info_s { } #[doc = " @brief A handle to an action information object.\n\n An action information object holds all the necessary information,\n excluding the input data objects, required to perform an action."] pub type amd_comgr_action_info_t = amd_comgr_action_info_s; +#[doc = " @brief A handle to a machine code object symbol.\n\n A symbol handle is used to obtain the properties of symbols of a machine code\n object. A symbol handle is invalidated when the data object containing the\n symbol is destroyed."] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct amd_comgr_symbol_s { + pub handle: u64, +} +#[doc = " @brief A handle to a machine code object symbol.\n\n A symbol handle is used to obtain the properties of symbols of a machine code\n object. A symbol handle is invalidated when the data object containing the\n symbol is destroyed."] +pub type amd_comgr_symbol_t = amd_comgr_symbol_s; impl amd_comgr_action_kind_s { #[doc = " Preprocess each source data object in @p input in order. For each\n successful preprocessor invocation, add a source data object to @p result.\n Resolve any include source names using the names of include data objects\n in @p input. Resolve any include relative path names using the working\n directory path in @p info. Preprocess the source for the language in @p\n info.\n\n Return @p AMD_COMGR_STATUS_ERROR if any preprocessing fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_SOURCE_TO_PREPROCESSOR: amd_comgr_action_kind_s = amd_comgr_action_kind_s(0); -} -impl amd_comgr_action_kind_s { #[doc = " Copy all existing data objects in @p input to @p output, then add the\n device-specific and language-specific precompiled headers required for\n compilation.\n\n Currently the only supported languages are @p AMD_COMGR_LANGUAGE_OPENCL_1_2\n and @p AMD_COMGR_LANGUAGE_OPENCL_2_0.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if isa name or language\n is not set in @p info, or the language is not supported."] pub const AMD_COMGR_ACTION_ADD_PRECOMPILED_HEADERS: amd_comgr_action_kind_s = amd_comgr_action_kind_s(1); -} -impl amd_comgr_action_kind_s { #[doc = " Compile each source data object in @p input in order. For each\n successful compilation add a bc data object to @p result. Resolve\n any include source names using the names of include data objects\n in @p input. Resolve any include relative path names using the\n working directory path in @p info. Produce bc for isa name in @p\n info. Compile the source for the language in @p info.\n\n Return @p AMD_COMGR_STATUS_ERROR if any compilation\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC: amd_comgr_action_kind_s = amd_comgr_action_kind_s(2); -} -impl amd_comgr_action_kind_s { #[doc = " Copy all existing data objects in @p input to @p output, then add the\n device-specific and language-specific bitcode libraries required for\n compilation.\n\n Currently the only supported languages are @p AMD_COMGR_LANGUAGE_OPENCL_1_2,\n @p AMD_COMGR_LANGUAGE_OPENCL_2_0, and @p AMD_COMGR_LANGUAGE_HIP.\n\n The options in @p info should be set to a set of language-specific flags.\n For OpenCL and HIP these include:\n\n correctly_rounded_sqrt\n daz_opt\n finite_only\n unsafe_math\n wavefrontsize64\n\n For example, to enable daz_opt and unsafe_math, the options should be set\n as:\n\n const char *options[] = {\"daz_opt, \"unsafe_math\"};\n size_t optionsCount = sizeof(options) / sizeof(options[0]);\n amd_comgr_action_info_set_option_list(info, options, optionsCount);\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if isa name or language\n is not set in @p info, the language is not supported, an unknown\n language-specific flag is supplied, or a language-specific flag is\n repeated.\n\n @deprecated since 1.7\n @warning This action, followed by @c AMD_COMGR_ACTION_LINK_BC_TO_BC, may\n result in subtle bugs due to incorrect linking of the device libraries.\n The @c AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC action can\n be used as a workaround which ensures the link occurs correctly."] pub const AMD_COMGR_ACTION_ADD_DEVICE_LIBRARIES: amd_comgr_action_kind_s = amd_comgr_action_kind_s(3); -} -impl amd_comgr_action_kind_s { #[doc = " Link a collection of bitcodes, bundled bitcodes, and bundled bitcode\n archives in @p into a single composite (unbundled) bitcode @p.\n Any device library bc data object must be explicitly added to @p input if\n needed.\n\n Return @p AMD_COMGR_STATUS_ERROR if the link or unbundling fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if IsaName is not set in @p info and does not match the isa name\n of all bc data objects in @p input, or if the Name field is not set for\n any DataObject in the input set."] pub const AMD_COMGR_ACTION_LINK_BC_TO_BC: amd_comgr_action_kind_s = amd_comgr_action_kind_s(4); -} -impl amd_comgr_action_kind_s { #[doc = " Optimize each bc data object in @p input and create an optimized bc data\n object to @p result.\n\n Return @p AMD_COMGR_STATUS_ERROR if the optimization fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all bc data objects in @p input."] pub const AMD_COMGR_ACTION_OPTIMIZE_BC_TO_BC: amd_comgr_action_kind_s = amd_comgr_action_kind_s(5); -} -impl amd_comgr_action_kind_s { #[doc = " Perform code generation for each bc data object in @p input in\n order. For each successful code generation add a relocatable data\n object to @p result.\n\n Return @p AMD_COMGR_STATUS_ERROR if any code\n generation fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all bc data objects in @p input."] pub const AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(6); -} -impl amd_comgr_action_kind_s { #[doc = " Perform code generation for each bc data object in @p input in\n order. For each successful code generation add an assembly source data\n object to @p result.\n\n Return @p AMD_COMGR_STATUS_ERROR if any code\n generation fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all bc data objects in @p input."] pub const AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY: amd_comgr_action_kind_s = amd_comgr_action_kind_s(7); -} -impl amd_comgr_action_kind_s { #[doc = " Link each relocatable data object in @p input together and add\n the linked relocatable data object to @p result. Any device\n library relocatable data object must be explicitly added to @p\n input if needed.\n\n Return @p AMD_COMGR_STATUS_ERROR if the link fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all relocatable data objects in @p input."] pub const AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_RELOCATABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(8); -} -impl amd_comgr_action_kind_s { #[doc = " Link each relocatable data object in @p input together and add\n the linked executable data object to @p result. Any device\n library relocatable data object must be explicitly added to @p\n input if needed.\n\n Return @p AMD_COMGR_STATUS_ERROR if the link fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all relocatable data objects in @p input."] pub const AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(9); -} -impl amd_comgr_action_kind_s { #[doc = " Assemble each source data object in @p input in order into machine code.\n For each successful assembly add a relocatable data object to @p result.\n Resolve any include source names using the names of include data objects in\n @p input. Resolve any include relative path names using the working\n directory path in @p info. Produce relocatable for isa name in @p info.\n\n Return @p AMD_COMGR_STATUS_ERROR if any assembly fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if isa name is not set in\n @p info."] pub const AMD_COMGR_ACTION_ASSEMBLE_SOURCE_TO_RELOCATABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(10); -} -impl amd_comgr_action_kind_s { #[doc = " Disassemble each relocatable data object in @p input in\n order. For each successful disassembly add a source data object to\n @p result.\n\n Return @p AMD_COMGR_STATUS_ERROR if any disassembly\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all relocatable data objects in @p input."] pub const AMD_COMGR_ACTION_DISASSEMBLE_RELOCATABLE_TO_SOURCE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(11); -} -impl amd_comgr_action_kind_s { #[doc = " Disassemble each executable data object in @p input in order. For\n each successful disassembly add a source data object to @p result.\n\n Return @p AMD_COMGR_STATUS_ERROR if any disassembly\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all relocatable data objects in @p input."] pub const AMD_COMGR_ACTION_DISASSEMBLE_EXECUTABLE_TO_SOURCE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(12); -} -impl amd_comgr_action_kind_s { #[doc = " Disassemble each bytes data object in @p input in order. For each\n successful disassembly add a source data object to @p\n result. Only simple assembly language commands are generate that\n corresponf to raw bytes are supported, not any directives that\n control the code object layout, or symbolic branch targets or\n names.\n\n Return @p AMD_COMGR_STATUS_ERROR if any disassembly\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info"] pub const AMD_COMGR_ACTION_DISASSEMBLE_BYTES_TO_SOURCE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(13); -} -impl amd_comgr_action_kind_s { #[doc = " Compile each source data object in @p input in order. For each\n successful compilation add a fat binary to @p result. Resolve\n any include source names using the names of include data objects\n in @p input. Resolve any include relative path names using the\n working directory path in @p info. Produce fat binary for isa name in @p\n info. Compile the source for the language in @p info.\n\n Return @p AMD_COMGR_STATUS_ERROR if any compilation\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info.\n\n @deprecated since 2.5\n @see in-process compilation via AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC, etc.\n insteaad"] pub const AMD_COMGR_ACTION_COMPILE_SOURCE_TO_FATBIN: amd_comgr_action_kind_s = amd_comgr_action_kind_s(14); -} -impl amd_comgr_action_kind_s { #[doc = " Compile each source data object in @p input in order. For each\n successful compilation add a bc data object to @p result. Resolve\n any include source names using the names of include data objects\n in @p input. Resolve any include relative path names using the\n working directory path in @p info. Produce bc for isa name in @p\n info. Compile the source for the language in @p info. Link against\n the device-specific and language-specific bitcode device libraries\n required for compilation.\n\n Return @p AMD_COMGR_STATUS_ERROR if any compilation\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC: amd_comgr_action_kind_s = amd_comgr_action_kind_s(15); -} -impl amd_comgr_action_kind_s { #[doc = " Compile a single source data object in @p input in order. For each\n successful compilation add a relocatable data object to @p result.\n Resolve any include source names using the names of include data objects\n in @p input. Resolve any include relative path names using the\n working directory path in @p info. Produce relocatable for hip name in @p\n info. Compile the source for the language in @p info. Link against\n the device-specific and language-specific bitcode device libraries\n required for compilation. Currently only supports HIP language.\n\n Return @p AMD_COMGR_STATUS_ERROR if any compilation\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_COMPILE_SOURCE_TO_RELOCATABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(16); -} -impl amd_comgr_action_kind_s { #[doc = " Compile each source data object in @p input and create a single executabele\n in @p result. Resolve any include source names using the names of include\n data objects in @p input. Resolve any include relative path names using the\n working directory path in @p info. Produce executable for isa name in @p\n info. Compile the source for the language in @p info. Link against\n the device-specific and language-specific bitcode device libraries\n required for compilation.\n\n Return @p AMD_COMGR_STATUS_ERROR if any compilation\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_COMPILE_SOURCE_TO_EXECUTABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(17); -} -impl amd_comgr_action_kind_s { #[doc = " Unbundle each source data object in @p input. These objects can be\n bitcode bundles, or an archive containing bitcode bundles. For each\n successful unbundling, add a bc object or archive object to @p result,\n depending on the corresponding input.\n\n Return @p AMD_COMGR_STATUS_ERROR if any unbundling\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_UNBUNDLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(18); -} -impl amd_comgr_action_kind_s { #[doc = " Marker for last valid action kind."] pub const AMD_COMGR_ACTION_LAST: amd_comgr_action_kind_s = amd_comgr_action_kind_s(18); } @@ -254,6 +178,55 @@ impl amd_comgr_action_kind_s { pub struct amd_comgr_action_kind_s(pub ::std::os::raw::c_uint); #[doc = " @brief The kinds of actions that can be performed."] pub use self::amd_comgr_action_kind_s as amd_comgr_action_kind_t; +impl amd_comgr_symbol_type_s { + #[doc = " The symbol's type is unknown.\n\n The user should not infer any specific type for symbols which return\n `AMD_COMGR_SYMBOL_TYPE_UNKNOWN`, and these symbols may return different\n types in future releases."] + pub const AMD_COMGR_SYMBOL_TYPE_UNKNOWN: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(-1); + #[doc = " The symbol's type is not specified."] + pub const AMD_COMGR_SYMBOL_TYPE_NOTYPE: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(0); + #[doc = " The symbol is associated with a data object, such as a variable, an array,\n and so on."] + pub const AMD_COMGR_SYMBOL_TYPE_OBJECT: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(1); + #[doc = " The symbol is associated with a function or other executable code."] + pub const AMD_COMGR_SYMBOL_TYPE_FUNC: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(2); + #[doc = " The symbol is associated with a section. Symbol table entries of this type\n exist primarily for relocation."] + pub const AMD_COMGR_SYMBOL_TYPE_SECTION: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(3); + #[doc = " Conventionally, the symbol's name gives the name of the source file\n associated with the object file."] + pub const AMD_COMGR_SYMBOL_TYPE_FILE: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(4); + #[doc = " The symbol labels an uninitialized common block."] + pub const AMD_COMGR_SYMBOL_TYPE_COMMON: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(5); + #[doc = " The symbol is associated with an AMDGPU Code Object V2 kernel function."] + pub const AMD_COMGR_SYMBOL_TYPE_AMDGPU_HSA_KERNEL: amd_comgr_symbol_type_s = + amd_comgr_symbol_type_s(10); +} +#[repr(transparent)] +#[doc = " @brief Machine code object symbol type."] +#[derive(Copy, Clone, Hash, PartialEq, Eq)] +pub struct amd_comgr_symbol_type_s(pub ::std::os::raw::c_int); +#[doc = " @brief Machine code object symbol type."] +pub use self::amd_comgr_symbol_type_s as amd_comgr_symbol_type_t; +impl amd_comgr_symbol_info_s { + #[doc = " The length of the symbol name in bytes. Does not include the NUL\n terminator. The type of this attribute is uint64_t."] + pub const AMD_COMGR_SYMBOL_INFO_NAME_LENGTH: amd_comgr_symbol_info_s = + amd_comgr_symbol_info_s(0); + #[doc = " The name of the symbol. The type of this attribute is character array with\n the length equal to the value of the @p AMD_COMGR_SYMBOL_INFO_NAME_LENGTH\n attribute plus 1 for a NUL terminator."] + pub const AMD_COMGR_SYMBOL_INFO_NAME: amd_comgr_symbol_info_s = amd_comgr_symbol_info_s(1); + #[doc = " The kind of the symbol. The type of this attribute is @p\n amd_comgr_symbol_type_t."] + pub const AMD_COMGR_SYMBOL_INFO_TYPE: amd_comgr_symbol_info_s = amd_comgr_symbol_info_s(2); + #[doc = " Size of the variable. The value of this attribute is undefined if the\n symbol is not a variable. The type of this attribute is uint64_t."] + pub const AMD_COMGR_SYMBOL_INFO_SIZE: amd_comgr_symbol_info_s = amd_comgr_symbol_info_s(3); + #[doc = " Indicates whether the symbol is undefined. The type of this attribute is\n bool."] + pub const AMD_COMGR_SYMBOL_INFO_IS_UNDEFINED: amd_comgr_symbol_info_s = + amd_comgr_symbol_info_s(4); + #[doc = " The value of the symbol. The type of this attribute is uint64_t."] + pub const AMD_COMGR_SYMBOL_INFO_VALUE: amd_comgr_symbol_info_s = amd_comgr_symbol_info_s(5); + #[doc = " Marker for last valid symbol info."] + pub const AMD_COMGR_SYMBOL_INFO_LAST: amd_comgr_symbol_info_s = amd_comgr_symbol_info_s(5); +} +#[repr(transparent)] +#[doc = " @brief Machine code object symbol attributes."] +#[derive(Copy, Clone, Hash, PartialEq, Eq)] +pub struct amd_comgr_symbol_info_s(pub ::std::os::raw::c_uint); +#[doc = " @brief Machine code object symbol attributes."] +pub use self::amd_comgr_symbol_info_s as amd_comgr_symbol_info_t; pub struct Comgr2 { __library: ::libloading::Library, pub amd_comgr_get_version: @@ -351,6 +324,27 @@ pub struct Comgr2 { ) -> amd_comgr_status_t, ::libloading::Error, >, + pub amd_comgr_iterate_symbols: Result< + unsafe extern "C" fn( + data: amd_comgr_data_t, + callback: ::std::option::Option< + unsafe extern "C" fn( + symbol: amd_comgr_symbol_t, + user_data: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t, + >, + user_data: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t, + ::libloading::Error, + >, + pub amd_comgr_symbol_get_info: Result< + unsafe extern "C" fn( + symbol: amd_comgr_symbol_t, + attribute: amd_comgr_symbol_info_t, + value: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t, + ::libloading::Error, + >, } impl Comgr2 { pub unsafe fn new

(path: P) -> Result @@ -396,6 +390,12 @@ impl Comgr2 { .get(b"amd_comgr_action_info_set_option_list\0") .map(|sym| *sym); let amd_comgr_do_action = __library.get(b"amd_comgr_do_action\0").map(|sym| *sym); + let amd_comgr_iterate_symbols = __library + .get(b"amd_comgr_iterate_symbols\0") + .map(|sym| *sym); + let amd_comgr_symbol_get_info = __library + .get(b"amd_comgr_symbol_get_info\0") + .map(|sym| *sym); Ok(Comgr2 { __library, amd_comgr_get_version, @@ -413,6 +413,8 @@ impl Comgr2 { amd_comgr_action_info_set_language, amd_comgr_action_info_set_option_list, amd_comgr_do_action, + amd_comgr_iterate_symbols, + amd_comgr_symbol_get_info, }) } #[doc = " @brief Get the version of the code object manager interface\n supported.\n\n An interface is backwards compatible with an implementation with an\n equal major version, and a greater than or equal minor version.\n\n @param[out] major Major version number.\n\n @param[out] minor Minor version number."] @@ -593,4 +595,35 @@ impl Comgr2 { .as_ref() .expect("Expected function, got error."))(kind, info, input, result) } + #[must_use] + #[doc = " @brief Iterate over the symbols of a machine code object.\n\n For a AMD_COMGR_DATA_KIND_RELOCATABLE the symbols in the ELF symtab section\n are iterated. For a AMD_COMGR_DATA_KIND_EXECUTABLE the symbols in the ELF\n dynsymtab are iterated.\n\n @param[in] data The data object to query.\n\n @param[in] callback The function to call for each symbol in the machine code\n data object. The symbol handle is passed in @p symbol and @p user_data is\n passed as @p user_data. If the function returns with a status other than @p\n AMD_COMGR_STATUS_SUCCESS then iteration is stopped.\n\n @param[in] user_data The value to pass to each invocation of @p\n callback. Allows context to be passed into the call back function.\n\n @retval ::AMD_COMGR_STATUS_SUCCESS The function has\n been executed successfully.\n\n @retval ::AMD_COMGR_STATUS_ERROR An error was\n reported by @p callback.\n\n @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data is an invalid data\n object, or not of kind @p AMD_COMGR_DATA_KIND_RELOCATABLE or\n AMD_COMGR_DATA_KIND_EXECUTABLE. @p callback is NULL.\n\n @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES\n Unable to iterate the data object as out of resources."] + pub unsafe fn amd_comgr_iterate_symbols( + &self, + data: amd_comgr_data_t, + callback: ::std::option::Option< + unsafe extern "C" fn( + symbol: amd_comgr_symbol_t, + user_data: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t, + >, + user_data: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t { + (self + .amd_comgr_iterate_symbols + .as_ref() + .expect("Expected function, got error."))(data, callback, user_data) + } + #[must_use] + #[doc = " @brief Query information about a machine code object symbol.\n\n @param[in] symbol The symbol to query.\n\n @param[in] attribute Attribute to query.\n\n @param[out] value Pointer to an application-allocated buffer where to store\n the value of the attribute. If the buffer passed by the application is not\n large enough to hold the value of attribute, the behavior is undefined. The\n type of value returned is specified by @p amd_comgr_symbol_info_t.\n\n @retval ::AMD_COMGR_STATUS_SUCCESS The function has\n been executed successfully.\n\n @retval ::AMD_COMGR_STATUS_ERROR The @p symbol does not have the requested @p\n attribute.\n\n @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p symbol is an invalid\n symbol. @p attribute is an invalid value. @p value is NULL.\n\n @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES\n Unable to query symbol as out of resources."] + pub unsafe fn amd_comgr_symbol_get_info( + &self, + symbol: amd_comgr_symbol_t, + attribute: amd_comgr_symbol_info_t, + value: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t { + (self + .amd_comgr_symbol_get_info + .as_ref() + .expect("Expected function, got error."))(symbol, attribute, value) + } } diff --git a/ext/amd_comgr-sys/src/comgr3.rs b/ext/amd_comgr-sys/src/comgr3.rs index c0c1474..b20a7ab 100644 --- a/ext/amd_comgr-sys/src/comgr3.rs +++ b/ext/amd_comgr-sys/src/comgr3.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.71.1 */ +/* automatically generated by rust-bindgen 0.72.0 */ pub const AMD_COMGR_INTERFACE_VERSION_MAJOR: u32 = 3; pub const AMD_COMGR_INTERFACE_VERSION_MINOR: u32 = 0; @@ -6,13 +6,9 @@ impl amd_comgr_status_s { #[doc = " A generic error has occurred."] pub const AMD_COMGR_STATUS_ERROR: amd_comgr_status_s = amd_comgr_status_s(unsafe { ::std::num::NonZeroU32::new_unchecked(1) }); -} -impl amd_comgr_status_s { #[doc = " One of the actual arguments does not meet a precondition stated\n in the documentation of the corresponding formal argument. This\n includes both invalid Action types, and invalid arguments to\n valid Action types."] pub const AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT: amd_comgr_status_s = amd_comgr_status_s(unsafe { ::std::num::NonZeroU32::new_unchecked(2) }); -} -impl amd_comgr_status_s { #[doc = " Failed to allocate the necessary resources."] pub const AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES: amd_comgr_status_s = amd_comgr_status_s(unsafe { ::std::num::NonZeroU32::new_unchecked(3) }); @@ -25,24 +21,14 @@ type amd_comgr_status_t = Result<(), self::amd_comgr_status_s>; impl amd_comgr_language_s { #[doc = " No high level language."] pub const AMD_COMGR_LANGUAGE_NONE: amd_comgr_language_s = amd_comgr_language_s(0); -} -impl amd_comgr_language_s { #[doc = " OpenCL 1.2."] pub const AMD_COMGR_LANGUAGE_OPENCL_1_2: amd_comgr_language_s = amd_comgr_language_s(1); -} -impl amd_comgr_language_s { #[doc = " OpenCL 2.0."] pub const AMD_COMGR_LANGUAGE_OPENCL_2_0: amd_comgr_language_s = amd_comgr_language_s(2); -} -impl amd_comgr_language_s { #[doc = " HIP."] pub const AMD_COMGR_LANGUAGE_HIP: amd_comgr_language_s = amd_comgr_language_s(3); -} -impl amd_comgr_language_s { #[doc = " LLVM IR, either textual (.ll) or bitcode (.bc) format."] pub const AMD_COMGR_LANGUAGE_LLVM_IR: amd_comgr_language_s = amd_comgr_language_s(4); -} -impl amd_comgr_language_s { #[doc = " Marker for last valid language."] pub const AMD_COMGR_LANGUAGE_LAST: amd_comgr_language_s = amd_comgr_language_s(4); } @@ -55,69 +41,37 @@ pub use self::amd_comgr_language_s as amd_comgr_language_t; impl amd_comgr_data_kind_s { #[doc = " No data is available."] pub const AMD_COMGR_DATA_KIND_UNDEF: amd_comgr_data_kind_s = amd_comgr_data_kind_s(0); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a textual main source."] pub const AMD_COMGR_DATA_KIND_SOURCE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(1); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a textual source that is included in the main source\n or other include source."] pub const AMD_COMGR_DATA_KIND_INCLUDE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(2); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a precompiled-header source that is included in the main\n source or other include source."] pub const AMD_COMGR_DATA_KIND_PRECOMPILED_HEADER: amd_comgr_data_kind_s = amd_comgr_data_kind_s(3); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a diagnostic output."] pub const AMD_COMGR_DATA_KIND_DIAGNOSTIC: amd_comgr_data_kind_s = amd_comgr_data_kind_s(4); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a textual log output."] pub const AMD_COMGR_DATA_KIND_LOG: amd_comgr_data_kind_s = amd_comgr_data_kind_s(5); -} -impl amd_comgr_data_kind_s { #[doc = " The data is compiler LLVM IR bit code for a specific isa."] pub const AMD_COMGR_DATA_KIND_BC: amd_comgr_data_kind_s = amd_comgr_data_kind_s(6); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a relocatable machine code object for a specific isa."] pub const AMD_COMGR_DATA_KIND_RELOCATABLE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(7); -} -impl amd_comgr_data_kind_s { #[doc = " The data is an executable machine code object for a specific\n isa. An executable is the kind of code object that can be loaded\n and executed."] pub const AMD_COMGR_DATA_KIND_EXECUTABLE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(8); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a block of bytes."] pub const AMD_COMGR_DATA_KIND_BYTES: amd_comgr_data_kind_s = amd_comgr_data_kind_s(9); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a fat binary (clang-offload-bundler output)."] pub const AMD_COMGR_DATA_KIND_FATBIN: amd_comgr_data_kind_s = amd_comgr_data_kind_s(16); -} -impl amd_comgr_data_kind_s { #[doc = " The data is an archive."] pub const AMD_COMGR_DATA_KIND_AR: amd_comgr_data_kind_s = amd_comgr_data_kind_s(17); -} -impl amd_comgr_data_kind_s { #[doc = " The data is a bitcode bundle."] pub const AMD_COMGR_DATA_KIND_BC_BUNDLE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(18); -} -impl amd_comgr_data_kind_s { #[doc = " The data is an archive bundle."] pub const AMD_COMGR_DATA_KIND_AR_BUNDLE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(19); -} -impl amd_comgr_data_kind_s { #[doc = " The data is an object file bundle."] pub const AMD_COMGR_DATA_KIND_OBJ_BUNDLE: amd_comgr_data_kind_s = amd_comgr_data_kind_s(20); -} -impl amd_comgr_data_kind_s { #[doc = " The data is SPIR-V IR"] pub const AMD_COMGR_DATA_KIND_SPIRV: amd_comgr_data_kind_s = amd_comgr_data_kind_s(21); -} -impl amd_comgr_data_kind_s { #[doc = " Marker for last valid data kind."] pub const AMD_COMGR_DATA_KIND_LAST: amd_comgr_data_kind_s = amd_comgr_data_kind_s(21); } @@ -151,90 +105,64 @@ pub struct amd_comgr_action_info_s { } #[doc = " @brief A handle to an action information object.\n\n An action information object holds all the necessary information,\n excluding the input data objects, required to perform an action."] pub type amd_comgr_action_info_t = amd_comgr_action_info_s; +#[doc = " @brief A handle to a machine code object symbol.\n\n A symbol handle is used to obtain the properties of symbols of a machine code\n object. A symbol handle is invalidated when the data object containing the\n symbol is destroyed."] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct amd_comgr_symbol_s { + pub handle: u64, +} +#[doc = " @brief A handle to a machine code object symbol.\n\n A symbol handle is used to obtain the properties of symbols of a machine code\n object. A symbol handle is invalidated when the data object containing the\n symbol is destroyed."] +pub type amd_comgr_symbol_t = amd_comgr_symbol_s; impl amd_comgr_action_kind_s { #[doc = " Preprocess each source data object in @p input in order. For each\n successful preprocessor invocation, add a source data object to @p result.\n Resolve any include source names using the names of include data objects\n in @p input. Resolve any include relative path names using the working\n directory path in @p info. Preprocess the source for the language in @p\n info.\n\n Return @p AMD_COMGR_STATUS_ERROR if any preprocessing fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_SOURCE_TO_PREPROCESSOR: amd_comgr_action_kind_s = amd_comgr_action_kind_s(0); -} -impl amd_comgr_action_kind_s { #[doc = " Copy all existing data objects in @p input to @p output, then add the\n device-specific and language-specific precompiled headers required for\n compilation.\n\n Currently the only supported languages are @p AMD_COMGR_LANGUAGE_OPENCL_1_2\n and @p AMD_COMGR_LANGUAGE_OPENCL_2_0.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if isa name or language\n is not set in @p info, or the language is not supported."] pub const AMD_COMGR_ACTION_ADD_PRECOMPILED_HEADERS: amd_comgr_action_kind_s = amd_comgr_action_kind_s(1); -} -impl amd_comgr_action_kind_s { #[doc = " Compile each source data object in @p input in order. For each\n successful compilation add a bc data object to @p result. Resolve\n any include source names using the names of include data objects\n in @p input. Resolve any include relative path names using the\n working directory path in @p info. Produce bc for isa name in @p\n info. Compile the source for the language in @p info.\n\n Return @p AMD_COMGR_STATUS_ERROR if any compilation\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC: amd_comgr_action_kind_s = amd_comgr_action_kind_s(2); -} -impl amd_comgr_action_kind_s { #[doc = " Link a collection of bitcodes, bundled bitcodes, and bundled bitcode\n archives in @p into a single composite (unbundled) bitcode @p.\n Any device library bc data object must be explicitly added to @p input if\n needed.\n\n Return @p AMD_COMGR_STATUS_ERROR if the link or unbundling fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if IsaName is not set in @p info and does not match the isa name\n of all bc data objects in @p input, or if the Name field is not set for\n any DataObject in the input set."] pub const AMD_COMGR_ACTION_LINK_BC_TO_BC: amd_comgr_action_kind_s = amd_comgr_action_kind_s(3); -} -impl amd_comgr_action_kind_s { #[doc = " Perform code generation for each bc data object in @p input in\n order. For each successful code generation add a relocatable data\n object to @p result.\n\n Return @p AMD_COMGR_STATUS_ERROR if any code\n generation fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all bc data objects in @p input."] pub const AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(4); -} -impl amd_comgr_action_kind_s { #[doc = " Perform code generation for each bc data object in @p input in\n order. For each successful code generation add an assembly source data\n object to @p result.\n\n Return @p AMD_COMGR_STATUS_ERROR if any code\n generation fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all bc data objects in @p input."] pub const AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY: amd_comgr_action_kind_s = amd_comgr_action_kind_s(5); -} -impl amd_comgr_action_kind_s { #[doc = " Link each relocatable data object in @p input together and add\n the linked relocatable data object to @p result. Any device\n library relocatable data object must be explicitly added to @p\n input if needed.\n\n Return @p AMD_COMGR_STATUS_ERROR if the link fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all relocatable data objects in @p input."] pub const AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_RELOCATABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(6); -} -impl amd_comgr_action_kind_s { #[doc = " Link each relocatable data object in @p input together and add\n the linked executable data object to @p result. Any device\n library relocatable data object must be explicitly added to @p\n input if needed.\n\n Return @p AMD_COMGR_STATUS_ERROR if the link fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all relocatable data objects in @p input."] pub const AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(7); -} -impl amd_comgr_action_kind_s { #[doc = " Assemble each source data object in @p input in order into machine code.\n For each successful assembly add a relocatable data object to @p result.\n Resolve any include source names using the names of include data objects in\n @p input. Resolve any include relative path names using the working\n directory path in @p info. Produce relocatable for isa name in @p info.\n\n Return @p AMD_COMGR_STATUS_ERROR if any assembly fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if isa name is not set in\n @p info."] pub const AMD_COMGR_ACTION_ASSEMBLE_SOURCE_TO_RELOCATABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(8); -} -impl amd_comgr_action_kind_s { #[doc = " Disassemble each relocatable data object in @p input in\n order. For each successful disassembly add a source data object to\n @p result.\n\n Return @p AMD_COMGR_STATUS_ERROR if any disassembly\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all relocatable data objects in @p input."] pub const AMD_COMGR_ACTION_DISASSEMBLE_RELOCATABLE_TO_SOURCE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(9); -} -impl amd_comgr_action_kind_s { #[doc = " Disassemble each executable data object in @p input in order. For\n each successful disassembly add a source data object to @p result.\n\n Return @p AMD_COMGR_STATUS_ERROR if any disassembly\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info and does not match the isa name\n of all relocatable data objects in @p input."] pub const AMD_COMGR_ACTION_DISASSEMBLE_EXECUTABLE_TO_SOURCE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(10); -} -impl amd_comgr_action_kind_s { #[doc = " Disassemble each bytes data object in @p input in order. For each\n successful disassembly add a source data object to @p\n result. Only simple assembly language commands are generate that\n corresponf to raw bytes are supported, not any directives that\n control the code object layout, or symbolic branch targets or\n names.\n\n Return @p AMD_COMGR_STATUS_ERROR if any disassembly\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name is not set in @p info"] pub const AMD_COMGR_ACTION_DISASSEMBLE_BYTES_TO_SOURCE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(11); -} -impl amd_comgr_action_kind_s { #[doc = " Compile each source data object in @p input in order. For each\n successful compilation add a bc data object to @p result. Resolve\n any include source names using the names of include data objects\n in @p input. Resolve any include relative path names using the\n working directory path in @p info. Produce bc for isa name in @p\n info. Compile the source for the language in @p info. Link against\n the device-specific and language-specific bitcode device libraries\n required for compilation.\n\n Return @p AMD_COMGR_STATUS_ERROR if any compilation\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC: amd_comgr_action_kind_s = amd_comgr_action_kind_s(12); -} -impl amd_comgr_action_kind_s { #[doc = " Compile a single source data object in @p input in order. For each\n successful compilation add a relocatable data object to @p result.\n Resolve any include source names using the names of include data objects\n in @p input. Resolve any include relative path names using the\n working directory path in @p info. Produce relocatable for hip name in @p\n info. Compile the source for the language in @p info. Link against\n the device-specific and language-specific bitcode device libraries\n required for compilation. Currently only supports HIP language.\n\n Return @p AMD_COMGR_STATUS_ERROR if any compilation\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_COMPILE_SOURCE_TO_RELOCATABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(13); -} -impl amd_comgr_action_kind_s { #[doc = " Compile each source data object in @p input and create a single executabele\n in @p result. Resolve any include source names using the names of include\n data objects in @p input. Resolve any include relative path names using the\n working directory path in @p info. Produce executable for isa name in @p\n info. Compile the source for the language in @p info. Link against\n the device-specific and language-specific bitcode device libraries\n required for compilation.\n\n Return @p AMD_COMGR_STATUS_ERROR if any compilation\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_COMPILE_SOURCE_TO_EXECUTABLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(14); -} -impl amd_comgr_action_kind_s { #[doc = " Unbundle each source data object in @p input. These objects can be\n bitcode bundles, or an archive containing bitcode bundles. For each\n successful unbundling, add a bc object or archive object to @p result,\n depending on the corresponding input.\n\n Return @p AMD_COMGR_STATUS_ERROR if any unbundling\n fails.\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if isa name or language is not set in @p info."] pub const AMD_COMGR_ACTION_UNBUNDLE: amd_comgr_action_kind_s = amd_comgr_action_kind_s(15); -} -impl amd_comgr_action_kind_s { #[doc = " Translate each source SPIR-V object in @p input into LLVM IR Bitcode.\n For each successful translation, add a bc object to @p result *\n\n Return @p AMD_COMGR_STATUS_ERROR if any translation fails\n\n Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT\n if any input is not SPIR-V."] pub const AMD_COMGR_ACTION_TRANSLATE_SPIRV_TO_BC: amd_comgr_action_kind_s = amd_comgr_action_kind_s(19); -} -impl amd_comgr_action_kind_s { #[doc = " Marker for last valid action kind."] pub const AMD_COMGR_ACTION_LAST: amd_comgr_action_kind_s = amd_comgr_action_kind_s(19); } @@ -244,6 +172,55 @@ impl amd_comgr_action_kind_s { pub struct amd_comgr_action_kind_s(pub ::std::os::raw::c_uint); #[doc = " @brief The kinds of actions that can be performed."] pub use self::amd_comgr_action_kind_s as amd_comgr_action_kind_t; +impl amd_comgr_symbol_type_s { + #[doc = " The symbol's type is unknown.\n\n The user should not infer any specific type for symbols which return\n `AMD_COMGR_SYMBOL_TYPE_UNKNOWN`, and these symbols may return different\n types in future releases."] + pub const AMD_COMGR_SYMBOL_TYPE_UNKNOWN: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(-1); + #[doc = " The symbol's type is not specified."] + pub const AMD_COMGR_SYMBOL_TYPE_NOTYPE: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(0); + #[doc = " The symbol is associated with a data object, such as a variable, an array,\n and so on."] + pub const AMD_COMGR_SYMBOL_TYPE_OBJECT: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(1); + #[doc = " The symbol is associated with a function or other executable code."] + pub const AMD_COMGR_SYMBOL_TYPE_FUNC: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(2); + #[doc = " The symbol is associated with a section. Symbol table entries of this type\n exist primarily for relocation."] + pub const AMD_COMGR_SYMBOL_TYPE_SECTION: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(3); + #[doc = " Conventionally, the symbol's name gives the name of the source file\n associated with the object file."] + pub const AMD_COMGR_SYMBOL_TYPE_FILE: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(4); + #[doc = " The symbol labels an uninitialized common block."] + pub const AMD_COMGR_SYMBOL_TYPE_COMMON: amd_comgr_symbol_type_s = amd_comgr_symbol_type_s(5); + #[doc = " The symbol is associated with an AMDGPU Code Object V2 kernel function."] + pub const AMD_COMGR_SYMBOL_TYPE_AMDGPU_HSA_KERNEL: amd_comgr_symbol_type_s = + amd_comgr_symbol_type_s(10); +} +#[repr(transparent)] +#[doc = " @brief Machine code object symbol type."] +#[derive(Copy, Clone, Hash, PartialEq, Eq)] +pub struct amd_comgr_symbol_type_s(pub ::std::os::raw::c_int); +#[doc = " @brief Machine code object symbol type."] +pub use self::amd_comgr_symbol_type_s as amd_comgr_symbol_type_t; +impl amd_comgr_symbol_info_s { + #[doc = " The length of the symbol name in bytes. Does not include the NUL\n terminator. The type of this attribute is uint64_t."] + pub const AMD_COMGR_SYMBOL_INFO_NAME_LENGTH: amd_comgr_symbol_info_s = + amd_comgr_symbol_info_s(0); + #[doc = " The name of the symbol. The type of this attribute is character array with\n the length equal to the value of the @p AMD_COMGR_SYMBOL_INFO_NAME_LENGTH\n attribute plus 1 for a NUL terminator."] + pub const AMD_COMGR_SYMBOL_INFO_NAME: amd_comgr_symbol_info_s = amd_comgr_symbol_info_s(1); + #[doc = " The kind of the symbol. The type of this attribute is @p\n amd_comgr_symbol_type_t."] + pub const AMD_COMGR_SYMBOL_INFO_TYPE: amd_comgr_symbol_info_s = amd_comgr_symbol_info_s(2); + #[doc = " Size of the variable. The value of this attribute is undefined if the\n symbol is not a variable. The type of this attribute is uint64_t."] + pub const AMD_COMGR_SYMBOL_INFO_SIZE: amd_comgr_symbol_info_s = amd_comgr_symbol_info_s(3); + #[doc = " Indicates whether the symbol is undefined. The type of this attribute is\n bool."] + pub const AMD_COMGR_SYMBOL_INFO_IS_UNDEFINED: amd_comgr_symbol_info_s = + amd_comgr_symbol_info_s(4); + #[doc = " The value of the symbol. The type of this attribute is uint64_t."] + pub const AMD_COMGR_SYMBOL_INFO_VALUE: amd_comgr_symbol_info_s = amd_comgr_symbol_info_s(5); + #[doc = " Marker for last valid symbol info."] + pub const AMD_COMGR_SYMBOL_INFO_LAST: amd_comgr_symbol_info_s = amd_comgr_symbol_info_s(5); +} +#[repr(transparent)] +#[doc = " @brief Machine code object symbol attributes."] +#[derive(Copy, Clone, Hash, PartialEq, Eq)] +pub struct amd_comgr_symbol_info_s(pub ::std::os::raw::c_uint); +#[doc = " @brief Machine code object symbol attributes."] +pub use self::amd_comgr_symbol_info_s as amd_comgr_symbol_info_t; pub struct Comgr3 { __library: ::libloading::Library, pub amd_comgr_get_version: @@ -341,6 +318,27 @@ pub struct Comgr3 { ) -> amd_comgr_status_t, ::libloading::Error, >, + pub amd_comgr_iterate_symbols: Result< + unsafe extern "C" fn( + data: amd_comgr_data_t, + callback: ::std::option::Option< + unsafe extern "C" fn( + symbol: amd_comgr_symbol_t, + user_data: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t, + >, + user_data: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t, + ::libloading::Error, + >, + pub amd_comgr_symbol_get_info: Result< + unsafe extern "C" fn( + symbol: amd_comgr_symbol_t, + attribute: amd_comgr_symbol_info_t, + value: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t, + ::libloading::Error, + >, } impl Comgr3 { pub unsafe fn new

(path: P) -> Result @@ -386,6 +384,12 @@ impl Comgr3 { .get(b"amd_comgr_action_info_set_option_list\0") .map(|sym| *sym); let amd_comgr_do_action = __library.get(b"amd_comgr_do_action\0").map(|sym| *sym); + let amd_comgr_iterate_symbols = __library + .get(b"amd_comgr_iterate_symbols\0") + .map(|sym| *sym); + let amd_comgr_symbol_get_info = __library + .get(b"amd_comgr_symbol_get_info\0") + .map(|sym| *sym); Ok(Comgr3 { __library, amd_comgr_get_version, @@ -403,6 +407,8 @@ impl Comgr3 { amd_comgr_action_info_set_language, amd_comgr_action_info_set_option_list, amd_comgr_do_action, + amd_comgr_iterate_symbols, + amd_comgr_symbol_get_info, }) } #[doc = " @brief Get the version of the code object manager interface\n supported.\n\n An interface is backwards compatible with an implementation with an\n equal major version, and a greater than or equal minor version.\n\n @param[out] major Major version number.\n\n @param[out] minor Minor version number."] @@ -583,4 +589,35 @@ impl Comgr3 { .as_ref() .expect("Expected function, got error."))(kind, info, input, result) } + #[must_use] + #[doc = " @brief Iterate over the symbols of a machine code object.\n\n For a AMD_COMGR_DATA_KIND_RELOCATABLE the symbols in the ELF symtab section\n are iterated. For a AMD_COMGR_DATA_KIND_EXECUTABLE the symbols in the ELF\n dynsymtab are iterated.\n\n @param[in] data The data object to query.\n\n @param[in] callback The function to call for each symbol in the machine code\n data object. The symbol handle is passed in @p symbol and @p user_data is\n passed as @p user_data. If the function returns with a status other than @p\n AMD_COMGR_STATUS_SUCCESS then iteration is stopped.\n\n @param[in] user_data The value to pass to each invocation of @p\n callback. Allows context to be passed into the call back function.\n\n @retval ::AMD_COMGR_STATUS_SUCCESS The function has\n been executed successfully.\n\n @retval ::AMD_COMGR_STATUS_ERROR An error was\n reported by @p callback.\n\n @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p data is an invalid data\n object, or not of kind @p AMD_COMGR_DATA_KIND_RELOCATABLE or\n AMD_COMGR_DATA_KIND_EXECUTABLE. @p callback is NULL.\n\n @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES\n Unable to iterate the data object as out of resources."] + pub unsafe fn amd_comgr_iterate_symbols( + &self, + data: amd_comgr_data_t, + callback: ::std::option::Option< + unsafe extern "C" fn( + symbol: amd_comgr_symbol_t, + user_data: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t, + >, + user_data: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t { + (self + .amd_comgr_iterate_symbols + .as_ref() + .expect("Expected function, got error."))(data, callback, user_data) + } + #[must_use] + #[doc = " @brief Query information about a machine code object symbol.\n\n @param[in] symbol The symbol to query.\n\n @param[in] attribute Attribute to query.\n\n @param[out] value Pointer to an application-allocated buffer where to store\n the value of the attribute. If the buffer passed by the application is not\n large enough to hold the value of attribute, the behavior is undefined. The\n type of value returned is specified by @p amd_comgr_symbol_info_t.\n\n @retval ::AMD_COMGR_STATUS_SUCCESS The function has\n been executed successfully.\n\n @retval ::AMD_COMGR_STATUS_ERROR The @p symbol does not have the requested @p\n attribute.\n\n @retval ::AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT @p symbol is an invalid\n symbol. @p attribute is an invalid value. @p value is NULL.\n\n @retval ::AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES\n Unable to query symbol as out of resources."] + pub unsafe fn amd_comgr_symbol_get_info( + &self, + symbol: amd_comgr_symbol_t, + attribute: amd_comgr_symbol_info_t, + value: *mut ::std::os::raw::c_void, + ) -> amd_comgr_status_t { + (self + .amd_comgr_symbol_get_info + .as_ref() + .expect("Expected function, got error."))(symbol, attribute, value) + } } diff --git a/ptx/lib/zluda_ptx_impl.bc b/ptx/lib/zluda_ptx_impl.bc index 9cabbcc5aedc7feb2e4ca991024733dab35d974e..853b9e152ba2034b0e8e646bb2c4fc6075e64387 100644 GIT binary patch delta 5832 zcmbP}_#%FS3S-qo)oe!7i4*1PuO)11n4#?ONp*%Y1G5yPhGSq?lLA{(AA^V*cbAcf zM-bBz5e_E>=SYDR2LTpGffS8{2JQkPi4|Q2EUpf1PCSPVM3@}g7K$7;;Bl60OVnU( zQaBvYlB99O*v4P5Em6Wz!fPY%VFQuH4igw1(-^uQRHjz!d1#f{rIGl_ddXxHMgjGC z&skGBY|nGt3+}l1d0tV)yyum10UYN)?+L1y_uO`=h7dy~8`Cm|%~_0E9Q9uO9D+iQ zZ9O8Aj3!PJVW-5h82+X2s%xnfi?5g`D?EX7vZe|v0|O%igTn;I1AUs>&5leBj2s{V zg%b=39#7dj8Ce_{U|<5H^QzzsJ{AcU28ITZAV&j_M9{^ir3{P)ATAiE9GKuGyN#8D zfr+7>39Oe%fw?V2^`W5yg9w8F0}}%Sg8+l1!4fI%wTw&$7#bJ^7(m9IXiyA|&*5Y6 zVFw$-z`)?Z#Z`O%M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