Commit bfe8ba34 authored by Michael Beck's avatar Michael Beck
Browse files

More inlining functions

[r3087]
parent ac7a8d6d
......@@ -224,12 +224,15 @@ INLINE ir_mode *get_modeANY(void) { ANNOUNCE(); return mode_ANY; }
INLINE ir_mode *get_modeBAD(void) { ANNOUNCE(); return mode_BAD; }
ir_mode *get_modeP_mach(void) { ANNOUNCE(); return mode_P_mach; }
void set_modeP_mach(ir_mode *p) {
ir_mode *(get_modeP_mach)(void) {
ANNOUNCE();
assert(mode_is_reference(p));
mode_P_mach = p;
}
return __get_modeP_mach();
}
void (set_modeP_mach)(ir_mode *p) {
ANNOUNCE();
__set_modeP_mach(p);
}
/**
* Registers a new mode if not defined yet, else returns
......@@ -355,17 +358,17 @@ ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsi
/* Functions for the direct access to all attributes od a ir_mode */
modecode
get_mode_modecode(const ir_mode *mode)
(get_mode_modecode)(const ir_mode *mode)
{
ANNOUNCE();
return mode->code;
return __get_mode_modecode(mode);
}
ident *
get_mode_ident(const ir_mode *mode)
(get_mode_ident)(const ir_mode *mode)
{
ANNOUNCE();
return mode->name;
return __get_mode_ident(mode);
}
const char *
......@@ -376,44 +379,44 @@ get_mode_name(const ir_mode *mode)
}
mode_sort
get_mode_sort(const ir_mode* mode)
(get_mode_sort)(const ir_mode* mode)
{
ANNOUNCE();
return mode->sort;
return __get_mode_sort(mode);
}
INLINE int
get_mode_size_bits(const ir_mode *mode)
int
(get_mode_size_bits)(const ir_mode *mode)
{
ANNOUNCE();
return mode->size;
return __get_mode_size_bits(mode);
}
int get_mode_size_bytes(const ir_mode *mode) {
int size = get_mode_size_bits(mode);
int
(get_mode_size_bytes)(const ir_mode *mode) {
ANNOUNCE();
if ((size & 7) != 0) return -1;
return size >> 3;
return __get_mode_size_bytes(mode);
}
int
get_mode_align (const ir_mode *mode)
(get_mode_align)(const ir_mode *mode)
{
ANNOUNCE();
return mode->align;
return __get_mode_align(mode);
}
int
get_mode_sign (const ir_mode *mode)
(get_mode_sign)(const ir_mode *mode)
{
ANNOUNCE();
return mode->sign;
return __get_mode_sign(mode);
}
int get_mode_arithmetic (const ir_mode *mode)
int
(get_mode_arithmetic)(const ir_mode *mode)
{
ANNOUNCE();
return mode->arithmetic;
return get_mode_arithmetic(mode);
}
......@@ -421,24 +424,27 @@ int get_mode_arithmetic (const ir_mode *mode)
* whether shift applies modulo to value of bits to shift. Asserts
* if mode is not irms_int_number.
*/
unsigned int get_mode_modulo_shift(const ir_mode *mode) {
return mode->modulo_shift;
unsigned int
(get_mode_modulo_shift)(const ir_mode *mode) {
return __get_mode_modulo_shift(mode);
}
unsigned int get_mode_vector_elems(const ir_mode *mode) {
return mode->vector_elem;
unsigned int
(get_mode_vector_elems)(const ir_mode *mode) {
return __get_mode_vector_elems(mode);
}
void *get_mode_link(const ir_mode *mode)
void *
(get_mode_link)(const ir_mode *mode)
{
ANNOUNCE();
return mode->link;
return __get_mode_link(mode);
}
void set_mode_link(ir_mode *mode, void *l)
void
(set_mode_link)(ir_mode *mode, void *l)
{
mode->link=l;
return;
__set_mode_link(mode, l);
}
tarval *
......@@ -516,158 +522,78 @@ is_mode (void *thing) {
return 0;
}
/* Functions to check, whether a modecode is signed, float, int, num, data,
datab or dataM. For more exact definitions read the corresponding pages
in the firm documentation or the followingenumeration
The set of "float" is defined as:
---------------------------------
float = {irm_F, irm_D, irm_E}
The set of "int" is defined as:
-------------------------------
int = {irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu}
The set of "num" is defined as:
-------------------------------
num = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
irm_Is, irm_Iu, irm_Ls, irm_Lu}
= {float || int}
The set of "data" is defined as:
-------------------------------
data = {irm_F, irm_D, irm_E irm_Bs, irm_Bu, irm_Hs, irm_Hu,
irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P}
= {num || irm_C || irm_U || irm_P}
The set of "datab" is defined as:
---------------------------------
datab = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_b}
= {data || irm_b }
The set of "dataM" is defined as:
---------------------------------
dataM = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_M}
= {data || irm_M}
*/
#ifdef MODE_ACCESS_DEFINES
# undef mode_is_signed
# undef mode_is_float
# undef mode_is_int
# undef mode_is_num
# undef mode_is_numP
# undef mode_is_data
# undef mode_is_datab
# undef mode_is_dataM
#endif
int
mode_is_signed (const ir_mode *mode)
{
(mode_is_signed)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return mode->sign;
return __mode_is_signed(mode);
}
int
mode_is_float (const ir_mode *mode)
{
(mode_is_float)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return (get_mode_sort(mode) == irms_float_number);
return __mode_is_float(mode);
}
int
mode_is_int (const ir_mode *mode)
{
(mode_is_int)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return (get_mode_sort(mode) == irms_int_number);
return __mode_is_int(mode);
}
int mode_is_character (const ir_mode *mode)
{
int
(mode_is_character)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return (get_mode_sort(mode) == irms_character);
return __mode_is_character(mode);
}
int mode_is_reference (const ir_mode *mode)
{
int
(mode_is_reference)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return (get_mode_sort(mode) == irms_reference);
return __mode_is_reference(mode);
}
int
mode_is_num (const ir_mode *mode)
{
(mode_is_num)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return (mode_is_int(mode) || mode_is_float(mode));
return __mode_is_num(mode);
}
int
mode_is_numP (const ir_mode *mode)
{
(mode_is_numP)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return (mode_is_int(mode) || mode_is_float(mode) || mode_is_reference(mode));
return __mode_is_numP(mode);
}
int
mode_is_data (const ir_mode *mode)
{
(mode_is_data)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return (mode_is_num(mode) || get_mode_sort(mode) == irms_character || get_mode_sort(mode) == irms_reference);
return __mode_is_data(mode);
}
int
mode_is_datab (const ir_mode *mode)
{
(mode_is_datab)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return (mode_is_data(mode) || get_mode_sort(mode) == irms_internal_boolean);
return __mode_is_datab(mode);
}
int
mode_is_dataM (const ir_mode *mode)
{
(mode_is_dataM)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return (mode_is_data(mode) || get_mode_modecode(mode) == irm_M);
return __mode_is_dataM(mode);
}
int
mode_is_float_vector (const ir_mode *mode)
{
(mode_is_float_vector)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return (get_mode_sort(mode) == irms_float_number) && (get_mode_vector_elems(mode) > 1);
return __mode_is_float_vector(mode);
}
int
mode_is_int_vector (const ir_mode *mode)
{
(mode_is_int_vector)(const ir_mode *mode) {
ANNOUNCE();
assert(mode);
return (get_mode_sort(mode) == irms_int_number) && (get_mode_vector_elems(mode) > 1);
}
#ifdef MODE_ACCESS_DEFINES
# define mode_is_signed(mode) (mode)->sign
# define mode_is_float(mode) ((mode)->sort == irms_float_number)
# define mode_is_int(mode) ((mode)->sort == irms_int_number)
# define mode_is_num(mode) (((mode)->sort == irms_float_number) || ((mode)->sort == irms_int_number))
# define mode_is_data(mode) (((mode)->sort == irms_float_number) || ((mode)->sort == irms_int_number) || ((mode)->sort == irms_character) || ((mode)->sort == irms_reference))
# define mode_is_datab(mode) (((mode)->sort == irms_float_number) || ((mode)->sort == irms_int_number) || ((mode)->sort == irms_character) || ((mode)->sort == irms_reference) || ((mode)->sort == irms_internal_boolean))
# define mode_is_dataM(mode) (((mode)->sort == irms_float_number) || ((mode)->sort == irms_int_number) || ((mode)->sort == irms_character) || ((mode)->sort == irms_reference) || ((mode)->code == irm_M))
# define mode_is_float_vector(mode) (((mode)->sort == irms_float_number) && ((mode)->vector_elem > 1))
# define mode_is_int_vector(mode) (((mode)->sort == irms_int_number) && ((mode)->vector_elem > 1))
#endif
return __mode_is_int_vector(mode);
}
/* Returns true if sm can be converted to lm without loss. */
int
smaller_mode(const ir_mode *sm, const ir_mode *lm)
......
......@@ -50,4 +50,194 @@ struct ir_mode {
const void *tv_priv; /**< tarval module will save private data here */
};
/* ------------------------------- *
* inline functions *
* ------------------------------- */
extern ir_mode *mode_P_mach;
static INLINE ir_mode *
__get_modeP_mach(void) { return mode_P_mach; }
static INLINE void
__set_modeP_mach(ir_mode *p) {
assert(mode_is_reference(p));
mode_P_mach = p;
}
static INLINE modecode
__get_mode_modecode(const ir_mode *mode) { return mode->code; }
static INLINE ident *
__get_mode_ident(const ir_mode *mode) { return mode->name; }
static INLINE mode_sort
__get_mode_sort(const ir_mode* mode) { return mode->sort; }
static INLINE int
__get_mode_size_bits(const ir_mode *mode) { return mode->size; }
static INLINE int
__get_mode_size_bytes(const ir_mode *mode) {
int size = __get_mode_size_bits(mode);
if ((size & 7) != 0) return -1;
return size >> 3;
}
static INLINE int
__get_mode_align(const ir_mode *mode) { return mode->align; }
static INLINE int
__get_mode_sign(const ir_mode *mode) { return mode->sign; }
static INLINE int
__get_mode_arithmetic(const ir_mode *mode) { return mode->arithmetic; }
static INLINE unsigned int
__get_mode_modulo_shift(const ir_mode *mode) { return mode->modulo_shift; }
static INLINE unsigned int
__get_mode_vector_elems(const ir_mode *mode) { return mode->vector_elem; }
static INLINE void *
__get_mode_link(const ir_mode *mode) { return mode->link; }
static INLINE void
__set_mode_link(ir_mode *mode, void *l) { mode->link = l; }
/* Functions to check, whether a modecode is signed, float, int, num, data,
datab or dataM. For more exact definitions read the corresponding pages
in the firm documentation or the followingenumeration
The set of "float" is defined as:
---------------------------------
float = {irm_F, irm_D, irm_E}
The set of "int" is defined as:
-------------------------------
int = {irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu}
The set of "num" is defined as:
-------------------------------
num = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
irm_Is, irm_Iu, irm_Ls, irm_Lu}
= {float || int}
The set of "data" is defined as:
-------------------------------
data = {irm_F, irm_D, irm_E irm_Bs, irm_Bu, irm_Hs, irm_Hu,
irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P}
= {num || irm_C || irm_U || irm_P}
The set of "datab" is defined as:
---------------------------------
datab = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_b}
= {data || irm_b }
The set of "dataM" is defined as:
---------------------------------
dataM = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_M}
= {data || irm_M}
*/
static INLINE int
__mode_is_signed(const ir_mode *mode) {
assert(mode);
return mode->sign;
}
static INLINE int
__mode_is_float(const ir_mode *mode) {
assert(mode);
return (__get_mode_sort(mode) == irms_float_number);
}
static INLINE int
__mode_is_int(const ir_mode *mode) {
assert(mode);
return (__get_mode_sort(mode) == irms_int_number);
}
static INLINE int
__mode_is_character(const ir_mode *mode) {
assert(mode);
return (__get_mode_sort(mode) == irms_character);
}
static INLINE int
__mode_is_reference(const ir_mode *mode) {
assert(mode);
return (__get_mode_sort(mode) == irms_reference);
}
static INLINE int
__mode_is_num(const ir_mode *mode) {
assert(mode);
return (__mode_is_int(mode) || __mode_is_float(mode));
}
static INLINE int
__mode_is_numP(const ir_mode *mode) {
assert(mode);
return (__mode_is_int(mode) || __mode_is_float(mode) || __mode_is_reference(mode));
}
static INLINE int
__mode_is_data(const ir_mode *mode) {
assert(mode);
return (__mode_is_num(mode) || __get_mode_sort(mode) == irms_character || __get_mode_sort(mode) == irms_reference);
}
static INLINE int
__mode_is_datab(const ir_mode *mode) {
assert(mode);
return (__mode_is_data(mode) || __get_mode_sort(mode) == irms_internal_boolean);
}
static INLINE int
__mode_is_dataM(const ir_mode *mode) {
assert(mode);
return (__mode_is_data(mode) || __get_mode_modecode(mode) == irm_M);
}
static INLINE int
__mode_is_float_vector(const ir_mode *mode) {
assert(mode);
return (__get_mode_sort(mode) == irms_float_number) && (__get_mode_vector_elems(mode) > 1);
}
static INLINE int
__mode_is_int_vector(const ir_mode *mode) {
assert(mode);
return (__get_mode_sort(mode) == irms_int_number) && (__get_mode_vector_elems(mode) > 1);
}
#define get_modeP_mach() __get_modeP_mach()
#define set_modeP_mach(p) __set_modeP_mach(p)
#define get_mode_modecode(mode) __get_mode_modecode(mode)
#define get_mode_ident(mode) __get_mode_ident(mode)
#define get_mode_sort(mode) __get_mode_sort(mode)
#define get_mode_size_bits(mode) __get_mode_size_bits(mode)
#define get_mode_size_bytes(mode) __get_mode_size_bytes(mode)
#define get_mode_align(mode) __get_mode_align(mode)
#define get_mode_sign(mode) __get_mode_sign(mode)
#define get_mode_arithmetic(mode) __get_mode_arithmetic(mode)
#define get_mode_modulo_shift(mode) __get_mode_modulo_shift(mode)
#define get_mode_vector_elems(mode) __get_mode_vector_elems(mode)
#define get_mode_link(mode) __get_mode_link(mode)
#define set_mode_link(mode, l) __set_mode_link(mode, l)
#define mode_is_signed(mode) __mode_is_signed(mode)
#define mode_is_float(mode) __mode_is_float(mode)
#define mode_is_int(mode) __mode_is_int(mode)
#define mode_is_character(mode) __mode_is_character(mode)
#define mode_is_reference(mode) __mode_is_reference(mode)
#define mode_is_num(mode) __mode_is_num(mode)
#define mode_is_numP(mode) __mode_is_numP(mode)
#define mode_is_data(mode) __mode_is_data(mode)
#define mode_is_datab(mode) __mode_is_datab(mode)
#define mode_is_dataM(mode) __mode_is_dataM(mode)
#define mode_is_float_vector(mode) __mode_is_float_vector(mode)
#define mode_is_int_vector(mode) __mode_is_int_vector(mode)
#endif /* _IRMODE_T_H_ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment