]> git.lizzy.rs Git - rust.git/blob - src/test/assembly/nvptx-safe-naming.rs
Rollup merge of #59529 - DevQps:improve-rem-docs, r=cuviper
[rust.git] / src / test / assembly / nvptx-safe-naming.rs
1 // assembly-output: ptx-linker
2 // compile-flags: --crate-type cdylib
3 // only-nvptx64
4
5 #![feature(abi_ptx)]
6 #![no_std]
7
8 // aux-build: breakpoint-panic-handler.rs
9 extern crate breakpoint_panic_handler;
10
11 // Verify function name doesn't contain unacceaptable characters.
12 // CHECK: .func (.param .b32 func_retval0) [[IMPL_FN:[a-zA-Z0-9$_]+square[a-zA-Z0-9$_]+]](
13
14 // CHECK-LABEL: .visible .entry top_kernel(
15 #[no_mangle]
16 pub unsafe extern "ptx-kernel" fn top_kernel(a: *const u32, b: *mut u32) {
17     // CHECK:      call.uni (retval0),
18     // CHECK-NEXT: [[IMPL_FN]]
19     *b = deep::private::MyStruct::new(*a).square();
20 }
21
22 pub mod deep {
23     pub mod private {
24         pub struct MyStruct<T>(T);
25
26         impl MyStruct<u32> {
27             pub fn new(a: u32) -> Self {
28                 MyStruct(a)
29             }
30
31             #[inline(never)]
32             pub fn square(&self) -> u32 {
33                 self.0.wrapping_mul(self.0)
34             }
35         }
36     }
37 }