Back to index

cell-binutils  2.17cvs20070401
Functions
cgen-bitset.c File Reference
#include "libiberty.h"
#include "opcode/cgen-bitset.h"
#include <string.h>

Go to the source code of this file.

Functions

CGEN_BITSETcgen_bitset_create (unsigned bit_count)
void cgen_bitset_init (CGEN_BITSET *mask, unsigned bit_count)
void cgen_bitset_clear (CGEN_BITSET *mask)
void cgen_bitset_add (CGEN_BITSET *mask, unsigned bit_num)
void cgen_bitset_set (CGEN_BITSET *mask, unsigned bit_num)
int cgen_bitset_contains (CGEN_BITSET *mask, unsigned bit_num)
int cgen_bitset_compare (CGEN_BITSET *mask1, CGEN_BITSET *mask2)
int cgen_bitset_intersect_p (CGEN_BITSET *mask1, CGEN_BITSET *mask2)
CGEN_BITSETcgen_bitset_copy (CGEN_BITSET *mask)
void cgen_bitset_union (CGEN_BITSET *mask1, CGEN_BITSET *mask2, CGEN_BITSET *result)

Function Documentation

void cgen_bitset_add ( CGEN_BITSET mask,
unsigned  bit_num 
)

Definition at line 66 of file cgen-bitset.c.

{
  int byte_ix, bit_ix;
  int bit_mask;

  if (! mask)
    return;
  byte_ix = bit_num / 8;
  bit_ix = bit_num % 8;
  bit_mask = 1 << (7 - bit_ix);
  mask->bits[byte_ix] |= bit_mask;
}

Here is the caller graph for this function:

void cgen_bitset_clear ( CGEN_BITSET mask)

Definition at line 52 of file cgen-bitset.c.

{
  unsigned i;

  if (! mask)
    return;

  for (i = 0; i < mask->length; ++i)
    mask->bits[i] = 0;
}

Here is the caller graph for this function:

int cgen_bitset_compare ( CGEN_BITSET mask1,
CGEN_BITSET mask2 
)

Definition at line 112 of file cgen-bitset.c.

{
  if (mask1 == mask2)
    return 0;
  if (! mask1 || ! mask2)
    return 1;
  if (mask1->length != mask2->length)
    return 1;
  return memcmp (mask1->bits, mask2->bits, mask1->length);
}

Here is the caller graph for this function:

int cgen_bitset_contains ( CGEN_BITSET mask,
unsigned  bit_num 
)

Definition at line 94 of file cgen-bitset.c.

{
  int byte_ix, bit_ix;
  int bit_mask;

  if (! mask)
    return 1; /* No bit restrictions.  */

  byte_ix = bit_num / 8;
  bit_ix = 7 - (bit_num % 8);
  bit_mask = 1 << bit_ix;
  return (mask->bits[byte_ix] & bit_mask) >> bit_ix;
}

Here is the caller graph for this function:

Definition at line 147 of file cgen-bitset.c.

{
  CGEN_BITSET* newmask;

  if (! mask)
    return NULL;
  newmask = cgen_bitset_create ((mask->length * 8) - 1);
  memcpy (newmask->bits, mask->bits, mask->length);
  return newmask;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 30 of file cgen-bitset.c.

{
  CGEN_BITSET * mask = xmalloc (sizeof (* mask));
  cgen_bitset_init (mask, bit_count);
  return mask;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cgen_bitset_init ( CGEN_BITSET mask,
unsigned  bit_count 
)

Definition at line 40 of file cgen-bitset.c.

{
  if (! mask)
    return;
  mask->length = (bit_count / 8) + 1;
  mask->bits = xmalloc (mask->length);
  cgen_bitset_clear (mask);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int cgen_bitset_intersect_p ( CGEN_BITSET mask1,
CGEN_BITSET mask2 
)

Definition at line 127 of file cgen-bitset.c.

{
  unsigned i, limit;

  if (mask1 == mask2)
    return 1;
  if (! mask1 || ! mask2)
    return 0;
  limit = mask1->length < mask2->length ? mask1->length : mask2->length;

  for (i = 0; i < limit; ++i)
    if ((mask1->bits[i] & mask2->bits[i]))
      return 1;

  return 0;
}

Here is the caller graph for this function:

void cgen_bitset_set ( CGEN_BITSET mask,
unsigned  bit_num 
)

Definition at line 82 of file cgen-bitset.c.

{
  if (! mask)
    return;
  cgen_bitset_clear (mask);
  cgen_bitset_add (mask, bit_num);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cgen_bitset_union ( CGEN_BITSET mask1,
CGEN_BITSET mask2,
CGEN_BITSET result 
)

Definition at line 161 of file cgen-bitset.c.

{
  unsigned i;

  if (! mask1 || ! mask2 || ! result
      || mask1->length != mask2->length
      || mask1->length != result->length)
    return;

  for (i = 0; i < result->length; ++i)
    result->bits[i] = mask1->bits[i] | mask2->bits[i];
}

Here is the caller graph for this function: