Resource.xcc

Benoit Dupont de Dinechin (Benoit.Dupont-de-Dinechin@st.com).

Copyright 2002 - 2007 STMicroelectronics. Copyright 1995 - 1998 Commissariat a l'Energie Atomique.

This program is free software; you can redistribute it and/or modify it under the terms of either (at your option): the GNU General Public License (GPL) version 2; the GNU Lesser General Public License (LGPL) version 2.1; any later version of these licences as published by the Free Software Foundation.

Pack a vector of Resource__ units in a word.

union ResourceVector_ {
  uint8_t UNITS[sizeof(uint64_t)/sizeof(uint8_t)];
  uint64_t PACKED;
};
typedef union ResourceVector_ ResourceVector_, *ResourceVector;
typedef const union ResourceVector_ *const_ResourceVector;
typedef union ResourceVector_ *restrict restrict_ResourceVector;
#define ResourceVector_UNITS(this) ((this)->UNITS)
#define ResourceVector_PACKED(this) ((this)->PACKED)
#define ResourceVector__PACKED(this) (&(this)->PACKED)
ResourceVector_clear— Clear this ResourceVector.
#ifdef NSIMDIZE
void
ResourceVector_clear(ResourceVector this);
#else
static inline void
ResourceVector_clear(ResourceVector this) {
  *ResourceVector__PACKED(this) = 0;
}
#endif//NSIMDIZE
ResourceVector_accumulate— Accumulate that ResourceVector to this ResourceVector.
#ifdef NSIMDIZE
void
ResourceVector_accumulate(ResourceVector this, const_ResourceVector that);
#else
static inline void
ResourceVector_accumulate(ResourceVector this, const_ResourceVector that)
{
  *ResourceVector__PACKED(this) += ResourceVector_PACKED(that);
}
#endif//NSIMDIZE
ResourceVector_accept— True if this + increase <= limit.
#ifdef NSIMDIZE
bool
ResourceVector_accept(const_ResourceVector this,
                      const_ResourceVector increase,
                      const_ResourceVector limit);
#else
static inline bool
ResourceVector_accept(const_ResourceVector this,
                      const_ResourceVector increase,
                      const_ResourceVector limit)
{
  uint64_t mask = 0x8080808080808080ULL;
  uint64_t x = ResourceVector_PACKED(limit);
  uint64_t y = ResourceVector_PACKED(this) + ResourceVector_PACKED(increase);
  x |= mask;                    // Set high bit of each unit.
  x -= y;                       // Carry does not propagate across units.
  x &= mask;                        // Grab high bits after substract.
  return x == mask;             // High bit change means this + increase > limit.
}
#endif//NSIMDIZE
ResourceVector_maxMerge— Max-merge that ResourceVector into this ResourceVector.
Return
true if the merge changed this else false.
#ifdef NSIMDIZE
bool
ResourceVector_maxMerge(ResourceVector this, const_ResourceVector that);
#else
static inline bool
ResourceVector_maxMerge(ResourceVector this, const_ResourceVector that)
{
  uint64_t mask = 0x8080808080808080ULL;
  uint64_t x = ResourceVector_PACKED(that);
  uint64_t y = ResourceVector_PACKED(this);
  uint64_t z = x, t = 0;
  z |= mask;                    // Set high bit of each unit.
  z -= y;                       // Carry does not propagate across units.
  z ^= mask;                    // z = (that - this).
  t = mask & z;                     // Grab the sign bits of (that - this).
  t = (t << 1) - (t >> 7);  // All ones if (that < this) else all zeros.
  z &= ~t;                  // z = MAX(that - this, 0).
  y += z;                       // y = MAX(that, this).
  *ResourceVector__PACKED(this) = y;
  return z != 0;
}
#endif//NSIMDIZE
ResourceTable— Maintains the Resource state for Instruction scheduling.

Each VECTORS element is the resource usage for a date (modulo ResourceTable_CLP2HORIZON). The dates considered are never earlier than the ResourceTable WINDOWSTART.

struct ResourceTable_ {
  //@args       Processor processor, int windowSize
  uint8_t WINDOWSIZE;
  uint16_t CLP2HORIZON;
  int16_t WINDOWSTART;
  const_ResourceVector AVAILABILITY;
  //@access VECTORS     (ResourceVector_ *)((ResourceTable)(this) + 1)
};
Resource_name_— Names for the Resource enumeration.
extern const char *
Resource_name_(Resource this);
extern const char *
Resource_name(Resource this);
Resource_availability— This Resource availability units for a Processor.
int
Resource_availability(Resource this, Processor processor);