Skip to content

Commit 7fd51cc

Browse files
update Hip documentation
1 parent 73f219f commit 7fd51cc

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

clang/docs/HIPSupport.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,42 @@ Example Usage
286286
basePtr->virtualFunction(); // Allowed since obj is constructed in device code
287287
}
288288

289+
Alias Attribute Support
290+
=======================
291+
292+
Clang supports alias attributes in HIP code, allowing creation of alternative names for functions and variables.
293+
- Aliases work with ``__host__``, ``__device__``, and ``__host__ __device__`` functions and variables.
294+
- The alias attribute uses the syntax ``__attribute__((alias("target_name")))``. Both weak and strong aliases are supported.
295+
- Outside of ``extern "C"``, the alias target must use the mangled name of the aliasee
296+
297+
Example Usage
298+
-------------
299+
300+
.. code-block:: c++
301+
302+
extern "C" {
303+
// Host function alias
304+
int __HostFunc(void) { return 0; }
305+
int HostFunc(void) __attribute__((weak, alias("__HostFunc")));
306+
307+
// Device function alias
308+
__device__ int __DeviceFunc(void) { return 1; }
309+
__device__ int DeviceFunc(void) __attribute__((weak, alias("__DeviceFunc")));
310+
311+
// Host-device function alias
312+
__host__ __device__ int __BothFunc(void) { return 2; }
313+
__host__ __device__ int BothFunc(void) __attribute__((alias("__BothFunc")));
314+
315+
// Variable alias
316+
int __host_var = 3;
317+
extern int __attribute__((weak, alias("__host_var"))) host_var;
318+
}
319+
// Mangled / overload alias
320+
__host__ __device__ float __Four(float f) { return 2.0f * f; }
321+
__host__ __device__ int Four(void) __attribute__((weak, alias("_Z6__Fourv")));
322+
__host__ __device__ float Four(float f) __attribute__((weak, alias("_Z6__Fourf")));
323+
324+
289325
Host and Device Attributes of Default Destructors
290326
===================================================
291327

0 commit comments

Comments
 (0)