mangle.h File Reference


Detailed Description

Some macros to mangle index/value type-specific names.

To allow users to build a library in multiple precisions, we use the preprocessor macros defined in this file to mangle type and routine names. This header essentially helps simulate a hack-ish C++ template facility.

In order for name mangling to work, the following compile-time macros need to be defined:

At a minimum, the user must define IND_TAG_CHAR and VAL_TAG_CHAR, from which this header will select default expansions for the other macros.

#include <math.h>

Go to the source code of this file.

Mangler for type ID numbers for the default scalar types.

#define MANGLE_CONCAT0(a, b)   a ## b
 Direct concatenation of input arguments.
#define MANGLE_CONCAT(a, b)   MANGLE_CONCAT0(a, b)
 Macro-expanded concatenation of input arguments.
#define OSKI_IND_ID   MANGLE_CONCAT(OSKI_SCALIND_, IND_TYPE_ID)
 Type ID for the default scalar integer index type.
#define OSKI_VAL_ID   MANGLE_CONCAT(OSKI_SCALVAL_, VAL_TYPE_ID)
 Type ID for the default scalar non-zero value type.

Typed value constants.

#define TVAL_ZERO   MANGLE_(TVAL_ZERO)
#define TVAL_ONE   MANGLE_(TVAL_ONE)
#define TVAL_NEG_ONE   MANGLE_(TVAL_NEG_ONE)
#define TVAL_IMAG   MANGLE_(TVAL_IMAG)
#define TVAL_NEG_IMAG   MANGLE_(TVAL_NEG_IMAG)
const oski_value_t TVAL_ZERO
const oski_value_t TVAL_ONE
const oski_value_t TVAL_NEG_ONE
const oski_value_t TVAL_IMAG
const oski_value_t TVAL_NEG_IMAG

Defines

#define INC_OSKI_MANGLE_H
 oski/mangle.h has been included.
#define IS_VAL_COMPLEX   ((VAL_TAG_CHAR=='c') || (VAL_TAG_CHAR=='z'))
 Returns 1 if the current default value type is complex.
#define IS_VALPREC_SINGLE   ((VAL_TAG_CHAR=='s') || (VAL_TAG_CHAR=='c'))
 Returns 1 if the current default value type is single precision.
#define IS_VALPREC_DOUBLE   ((VAL_TAG_CHAR=='d') || (VAL_TAG_CHAR=='z'))
 Returns 1 if the current default value type is single precision.
#define VAL_EPS   1e-7
 Default machine epsilon.
#define VAL_ZERO   (0.0)
 Numerical zero.
#define VAL_ONE   (1.0)
 Numerical one.
#define VAL_NEG_ONE   (-1.0)
 Numerical negative one.
#define IS_REAL_ZERO(x)   ((x) == VAL_ZERO)
 Returns 1 <==> x == 0.0.
#define IS_VAL_ZERO(x)   ((x) == VAL_ZERO)
 Returns 1 <==> x == 0.0.
#define IS_VAL_ONE(x)   ((x) == VAL_ONE)
 Returns 1 <==> x == 1.0.
#define IS_VAL_NEG_ONE(x)   ((x) == VAL_NEG_ONE)
 Returns 1 <==> x == -1.0.
#define VAL_ABS(x)   fabs(x)
 Returns $|x|$ as a double-precision value.
#define VAL_SET_ZERO(x)   (x) = 0.0
 Sets x to 0.
#define VAL_SET_ONE(x)   (x) = 1.0
 Sets x to 1.
#define VAL_CONJ(x)
 Conjugates x, i.e., $x \leftarrow \bar{x}$.
#define VAL_ASSIGN(y, x)   (y) = (x)
 Set $y \leftarrow x$, where $x, y$ are real variables.
#define VAL_ASSIGN_CONJ(y, x)   VAL_ASSIGN(y, x)
 Set $y \leftarrow \bar{x}$, where $x, y$ are real variables.
#define VAL_ASSIGN_NEG(y, x)   (y) = -(x)
 Set $y \leftarrow -x$, where $x, y$ are real variables.
#define VAL_ASSIGN_NEG_CONJ(y, x)   VAL_ASSIGN_NEG(y, x)
 Set $y \leftarrow -\bar{x}$, where $x, y$ are real variables.
#define MAKE_VAL_COMPLEX(x, y)   (x)
 Make an initializer record (ignores imaginary part).
#define VAL_SCALE(x, alpha)   (x) *= (alpha)
 Compute $x *= \alpha$, where $x, \alpha$ are real numbers.
#define VAL_SCALE_CONJ(x, alpha)   VAL_SCALE(x, alpha)
 Compute $x *= \bar{\alpha}$, where $x, \alpha$ are real numbers.
#define VAL_MAC(y, alpha, x)   (y) += (alpha) * (x)
 Compute $y += \alpha\cdot x$ (multiply-accumulate), where $x, \alpha, y$ are all real numbers.
#define VAL_MAC_CONJ(y, alpha, x)   VAL_MAC(y, alpha, x)
 Compute $y += \bar{\alpha}\cdot x$ (multiply-accumulate), where $x, \alpha, y$ are all real numbers.
#define VAL_MSUB(y, alpha, x)   (y) -= (alpha) * (x)
 Compute $y -= \alpha\cdot x$ (multiply-subtract), where $x, \alpha, y$ are all real numbers.
#define VAL_MSUB_CONJ(y, alpha, x)   VAL_MSUB(y, alpha, x)
 Compute $y -= \bar{\alpha}\cdot x$ (multiply-subtract), where $x, \alpha, y$ are all real numbers.
#define VAL_DEC(x, a)   (x) -= (a)
 Compute $x -= a$ (decrease/decrement), where $x, a$ are real numbers.
#define VAL_DEC_CONJ(x, a)   VAL_DEC(x, a)
 Compute $x -= \bar{a}$ (decrease/decrement), where $x, a$ are real numbers.
#define VAL_INC(x, a)   (x) += (a)
 Compute $x += a$ (increase/increment), where $x, a$ are real numbers.
#define VAL_INC_CONJ(x, a)   VAL_INC(x, a)
 Compute $x += \bar{a}$ (increase/increment), where $x, a$ are real numbers.
#define VAL_MUL(z, x, y)   (z) = (x) * (y)
 Computes $z \leftarrow x\cdot y$, where $x, y, z$ are real, unaliased variables.
#define VAL_MUL_CONJ(z, x, y)   VAL_MUL(z, x, y)
 Computes $z \leftarrow \bar{x}\cdot y$, where $x, y, z$ are real, unaliased variables.
#define VAL_TRIAD(z, y, alpha, x)   (z) = (y) + (alpha) * (x)
 Compute $z = y + alpha*x$ (triad), where $z, y, x, \alpha$ are all real numbers.
#define VAL_TRIAD_CONJ(z, y, alpha, x)   VAL_TRIAD(z, y, alpha, x)
 Compute $z = y + \bar{alpha}*x$ (triad), where $z, y, x, \alpha$ are all real numbers.
#define VAL_DIVEQ(x, a)   (x) /= (a)
 Compute $x /= \alpha$, where $x$ and $\alpha$ are real.
#define VAL_DIVEQ_CONJ(x, a)   VAL_DIVEQ(x, a)
 Compute $x /= \bar{\alpha}$, where $x$ and $\alpha$ are real.
#define VAL_INV(y, x)   (y) = 1.0/(x)
 Computes $y \leftarrow \frac{1}{x}$, where $x, y$ are real.
#define MAKE_VAL_REAL(x)   MAKE_VAL_COMPLEX((x), VAL_ZERO)
 Make a complex initializer record.
#define MAKE_VAL_GENERAL   MAKE_VAL_COMPLEX(-9, -9)
 A dummy value to represent a "general" value.
#define CATEGORIZE_VAL(alpha)
 Returns $\alpha$ if $\alpha \in \{-1, 0, 1\}$, or a constant value (see MAKE_VAL_GENERAL) otherwise.
#define MAKETYPENAME0(base, ind, val)   base ## _T ## ind ## val
 Makes a type-mangled name, [BASE]_T[IND][VAL].
#define MAKETYPENAME1(base, ind, val)   MAKETYPENAME0(base, ind, val)
 Name mangling helper macro.
#define MAKEMODNAME0(mod, base, ind, val)   mod ## _T ## ind ## val ## _LTX_ ## base
 Makes a type-mangled shared library module routine name, [MOD]_T[IND][VAL]_LTX_[BASE].
#define MAKEMODNAME1(mod, base, ind, val)   MAKEMODNAME0(mod, base, ind, val)
 Name mangling helper macro.
#define MANGLE_(base)   MAKETYPENAME1(base, IND_TAG, VAL_TAG)
 Mangle a base type name.
#define MANGLE_MOD_(base)   MAKEMODNAME1(MOD_NAME, base, IND_TAG, VAL_TAG)
 Mangle a module routine name.
#define OSKI_MAKENAME_FUNCPT(name)   oski_ ## name ## _funcpt
 Make a function pointer type name of the form, oski_[name]_funcpt.
#define oski_index_t   IND_T
#define oski_value_t   VAL_T


Define Documentation

#define CATEGORIZE_VAL alpha   ) 
 

Value:

( \
        (IS_VAL_ONE(alpha) || IS_VAL_ZERO(alpha) || IS_VAL_NEG_ONE(alpha)) \
            ? (alpha) : MAKE_VAL_GENERAL \
    )
Returns $\alpha$ if $\alpha \in \{-1, 0, 1\}$, or a constant value (see MAKE_VAL_GENERAL) otherwise.

#define IS_VAL_COMPLEX   ((VAL_TAG_CHAR=='c') || (VAL_TAG_CHAR=='z'))
 

Returns 1 if the current default value type is complex.

This implementation simply checks the currently defined VAL_TAG macro to see if it is 'c' or 'z'.

#define MAKE_VAL_GENERAL   MAKE_VAL_COMPLEX(-9, -9)
 

A dummy value to represent a "general" value.

This is used in trace representation.

#define MAKEMODNAME0 mod,
base,
ind,
val   )     mod ## _T ## ind ## val ## _LTX_ ## base
 

Makes a type-mangled shared library module routine name, [MOD]_T[IND][VAL]_LTX_[BASE].

This macro immediately concatenates its arguments to make a static-compatible module routine name of the form

[mod]_T[ind][val]_LTX_[base]

This naming convention allows the LTDL-based module loader to find methods dynamically.

#define MAKEMODNAME1 mod,
base,
ind,
val   )     MAKEMODNAME0(mod, base, ind, val)
 

Name mangling helper macro.

This macro immediately calls MAKEMODNAME0 with the same arguments. Since mod, base, ind, and/or val will often be macros themselves, this intermediate macro provides a way to force the C preprocessor to expand the macro arguments before concatenation.

#define MAKETYPENAME0 base,
ind,
val   )     base ## _T ## ind ## val
 

Makes a type-mangled name, [BASE]_T[IND][VAL].

Parameters:
[in] base Base type name.
[in] ind Type abbreviation for the integer index type.
[in] val Type abbreviation for the non-zero value type.
Returns:
The mangled name, [base]_T[ind][val].
This routine directly concatenates its arguments into the form indicated. If the caller wishes to use macro arguments for any of base, ind, and val, and have those arguments expanded before concatenation, then she should call MAKETYPENAME1 instead.
See also:
MANGLE_, MAKETYPENAME1

#define MAKETYPENAME1 base,
ind,
val   )     MAKETYPENAME0(base, ind, val)
 

Name mangling helper macro.

This macro immediately calls MAKETYPENAME0 with the same arguments. Since base, ind, and/or val will often be macros themselves, this intermediate macro provides a way to force the C preprocessor to expand the macro arguments before concatenation.

See also:
MAKETYPENAME0, MANGLE_

#define MANGLE_ base   )     MAKETYPENAME1(base, IND_TAG, VAL_TAG)
 

Mangle a base type name.

Parameters:
[in] base Base type name.
This macro mangles the type name, base, using the currently instantiated (defined) scalar types, through the compile-time macros IND_TAG and VAL_TAG.

Note:
The described behavior above applies to this macro only when the compile-time macro DO_NAME_MANGLING is defined.
Precondition:
The compile-time macros IND_TAG and VAL_TAG must be defined.
See also:
MAKETYPENAME0, MAKETYPENAME1

#define MANGLE_CONCAT a,
 )     MANGLE_CONCAT0(a, b)
 

Macro-expanded concatenation of input arguments.

This macro serves as an intermediate step to ensure that the input arguments, a and b, will be expanded if they are themselves macros.

#define MANGLE_MOD_ base   )     MAKEMODNAME1(MOD_NAME, base, IND_TAG, VAL_TAG)
 

Mangle a module routine name.

Parameters:
[in] base Base routine name.
This macro mangles the routine name, base, using the currently instantiated module name macro, MOD_NAME.

Precondition:
The compile-time macro MOD_NAME must be defined.


Generated on Wed Sep 19 16:41:22 2007 for BeBOP Optimized Sparse Kernel Interface Library by  doxygen 1.4.6