numba_dpex.core.utils.itanium_mangler

Itanium CXX ABI Mangler

Reference: https://itanium-cxx-abi.github.io/cxx-abi/abi.html

The basics of the mangling scheme.

We are hijacking the CXX mangling scheme for our use. We map Python modules into CXX namespace. A module1.submodule2.foo is mapped to module1::submodule2::foo. For parameterized numba types, we treat them as templated types; for example, array(int64, 1d, C) becomes an array<int64, 1, C>.

All mangled names are prefixed with “_Z”. It is followed by the name of the entity. A name contains one or more identifiers. Each identifier is encoded as “<num of char><name>”. If the name is namespaced and, therefore, has multiple identifiers, the entire name is encoded as “N<name>E”.

For functions, arguments types follow. There are condensed encodings for basic built-in types; e.g. “i” for int, “f” for float. For other types, the previously mentioned name encoding should be used.

For templated types, the template parameters are encoded immediately after the name. If it is namespaced, it should be within the ‘N’ ‘E’ marker. Template parameters are encoded in “I<params>E”, where each parameter is encoded using the mentioned name encoding scheme. Template parameters can contain literal values like the ‘1’ in the array type shown earlier. There is special encoding scheme for them to avoid leading digits.

Overview

Function

mangle_type_or_value(typ)

Mangle type parameter and arbitrary value.

mangle_ext(ident, argtys, *None, abi_tags)

Mangle identifier with Numba type objects and abi-tags.

mangle_abi_tag(abi_tag)

-

mangle_identifier(ident, template_params, *None, abi_tags, uid)

Mangle the identifier with optional template parameters and abi_tags.

mangle_type_c(typ)

Mangle C type name

mangle_type_or_value_numba(typ)

Mangle type parameter and arbitrary value.

mangle_templated_ident(identifier, parameters)

Mangle templated identifier.

mangle_args_c(argtys)

Mangle sequence of C type names

mangle_args(argtys)

Mangle sequence of Numba type objects and arbitrary values.

mangle_c(ident, argtys)

Mangle identifier with C type names

mangle(ident, argtys, *None, abi_tags, uid)

Mangle identifier with Numba type objects and abi-tags.

prepend_namespace(mangled, ns)

Prepend namespace to mangled name.

Attributes

PREFIX

-

C2CODE

-

N2C

-

mangle_type

-

mangle_value

-

Functions

mangle_type_or_value(typ)

Mangle type parameter and arbitrary value.

This function extends Numba’s magle_type_or_value() to support numba.types.CPointer type, e.g. an int * argument will be mangled to “Pi”. Mangling of extended qualifiers is supported only for address space qualifiers. In which case, the mangling follows the rule defined in Section 5.1.5.1 of the Itanium ABI <https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.qualified-type>``_. For example, an ``int global * argument will be mangeled to “PU3AS1i”.

Parameters:

typ (numba.types, int, str) – Type to mangle

Returns:

The mangled name of the type

Return type:

str

mangle_ext(ident, argtys, *, abi_tags=())

Mangle identifier with Numba type objects and abi-tags.

mangle_abi_tag(abi_tag: str) str
mangle_identifier(ident, template_params='', *, abi_tags=(), uid=None)

Mangle the identifier with optional template parameters and abi_tags.

Note:

This treats ‘.’ as ‘::’ in C++.

mangle_type_c(typ)

Mangle C type name

Parameters:

typ (str) – C type name

mangle_type_or_value_numba(typ)

Mangle type parameter and arbitrary value.

mangle_templated_ident(identifier, parameters)

Mangle templated identifier.

mangle_args_c(argtys)

Mangle sequence of C type names

mangle_args(argtys)

Mangle sequence of Numba type objects and arbitrary values.

mangle_c(ident, argtys)

Mangle identifier with C type names

mangle(ident, argtys, *, abi_tags=(), uid=None)

Mangle identifier with Numba type objects and abi-tags.

prepend_namespace(mangled, ns)

Prepend namespace to mangled name.

Attributes

PREFIX = '_Z'
C2CODE
N2C
mangle_type
mangle_value