OpenASIP  2.0
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
GPRGuardEncoding Class Reference

#include <GPRGuardEncoding.hh>

Inheritance diagram for GPRGuardEncoding:
Inheritance graph
Collaboration diagram for GPRGuardEncoding:
Collaboration graph

Public Member Functions

 GPRGuardEncoding (const std::string &regFile, int index, bool inverted, unsigned int encoding, GuardField &parent)
 
 GPRGuardEncoding (const ObjectState *state, GuardField &parent)
 
virtual ~GPRGuardEncoding ()
 
std::string registerFile () const
 
int registerIndex () const
 
virtual ObjectStatesaveState () const
 
- Public Member Functions inherited from GuardEncoding
virtual ~GuardEncoding ()
 
GuardFieldparent () const
 
bool isGuardInverted () const
 
unsigned int encoding () const
 

Static Public Attributes

static const std::string OSNAME_GPR_GUARD_ENCODING
 ObjectState name for GPR guard encoding. More...
 
static const std::string OSKEY_RF_NAME = "rf_name"
 ObjectState attribute key for the name of the register file. More...
 
static const std::string OSKEY_REGISTER_INDEX = "reg_index"
 ObjectState attribute key for register index. More...
 
- Static Public Attributes inherited from GuardEncoding
static const std::string OSNAME_GUARD_ENCODING = "guard_encoding"
 ObjectState name for guard encoding. More...
 
static const std::string OSKEY_INVERTED = "inverted"
 ObjectState attribute key for invert flag. More...
 
static const std::string OSKEY_ENCODING = "encoding"
 ObjectState attribute key for encoding. More...
 

Private Attributes

std::string regFile_
 Name of the register file. More...
 
int index_
 Register index. More...
 

Additional Inherited Members

- Protected Member Functions inherited from GuardEncoding
 GuardEncoding (bool inverted, unsigned int encoding)
 
 GuardEncoding (const ObjectState *state)
 
void setParent (GuardField *parent)
 

Detailed Description

The GPRGuardEncoding class maps a guard expression with general purpose register term to a control code.

Instances of this class are always registered to a guard field.

Definition at line 47 of file GPRGuardEncoding.hh.

Constructor & Destructor Documentation

◆ GPRGuardEncoding() [1/2]

GPRGuardEncoding::GPRGuardEncoding ( const std::string &  regFile,
int  index,
bool  inverted,
unsigned int  encoding,
GuardField parent 
)

The constructor.

Creates a guard encoding and Registers it into the given guard field automatically. The guard expression is identified by the name of register file, the index of the GPR and the "invert" flag, all given as parameters.

Parameters
regFileName of the register file.
indexThe index the GPR.
invertedThe "invert" flag.
encodingThe control code of the guard expression.
parentThe parent guard field.
Exceptions
ObjectAlreadyExistsIf the guard expression is already encoded in the parent field, or if the given control code is already assigned to another guard expression.

Definition at line 63 of file GPRGuardEncoding.cc.

66  : GuardEncoding(inverted, encoding), regFile_(regFile), index_(index) {
67  parent.addGuardEncoding(*this);
68  setParent(&parent);
69 }

References GuardField::addGuardEncoding(), GuardEncoding::parent(), and GuardEncoding::setParent().

Here is the call graph for this function:

◆ GPRGuardEncoding() [2/2]

GPRGuardEncoding::GPRGuardEncoding ( const ObjectState state,
GuardField parent 
)

The constructor.

Loads the state of the object from the given ObjectState instance.

Parameters
stateThe ObjectState instance.
parentThe parent guard field.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.
ObjectAlreadyExistsIf the guard expression is already encoded in the parent field, or if the given control code is already assigned to another guard expression.

Definition at line 85 of file GPRGuardEncoding.cc.

86  : GuardEncoding(state), regFile_(""), index_(0) {
87  const string procName = "GPRGuardEncoding::GPRGuardEncoding";
88 
89  if (state->name() != OSNAME_GPR_GUARD_ENCODING) {
90  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
91  }
92 
93  try {
96  } catch (const Exception& exception) {
98  __FILE__, __LINE__, procName, exception.errorMessage());
99  }
100 
101  parent.addGuardEncoding(*this);
102  setParent(&parent);
103 }

References GuardField::addGuardEncoding(), Exception::errorMessage(), index_, ObjectState::intAttribute(), ObjectState::name(), OSKEY_REGISTER_INDEX, OSKEY_RF_NAME, OSNAME_GPR_GUARD_ENCODING, GuardEncoding::parent(), regFile_, GuardEncoding::setParent(), and ObjectState::stringAttribute().

Here is the call graph for this function:

◆ ~GPRGuardEncoding()

GPRGuardEncoding::~GPRGuardEncoding ( )
virtual

The destructor.

Definition at line 108 of file GPRGuardEncoding.cc.

108  {
109  GuardField* parent = this->parent();
110  setParent(NULL);
111  parent->removeGuardEncoding(*this);
112 }

References GuardEncoding::parent(), GuardField::removeGuardEncoding(), and GuardEncoding::setParent().

Here is the call graph for this function:

Member Function Documentation

◆ registerFile()

std::string GPRGuardEncoding::registerFile ( ) const

Returns the name of the register file that contains the GPR of this guard expression.

Returns
The name of the register file.

Definition at line 122 of file GPRGuardEncoding.cc.

122  {
123  return regFile_;
124 }

References regFile_.

Referenced by GuardField::addGuardEncoding(), DefaultDecoderGenerator::findGuard(), GuardField::gprGuardEncoding(), GuardField::hasGPRGuardEncoding(), printGuardFieldEncodings(), and saveState().

◆ registerIndex()

int GPRGuardEncoding::registerIndex ( ) const

Returns the index of the GPR of this guard expression.

Returns
The index of the GPR.

Definition at line 133 of file GPRGuardEncoding.cc.

133  {
134  return index_;
135 }

References index_.

Referenced by GuardField::addGuardEncoding(), DefaultDecoderGenerator::findGuard(), GuardField::gprGuardEncoding(), GuardField::hasGPRGuardEncoding(), printGuardFieldEncodings(), and saveState().

◆ saveState()

ObjectState * GPRGuardEncoding::saveState ( ) const
virtual

Saves the state of the object to an ObjectState instance.

Returns
The newly created ObjectState instance.

Reimplemented from GuardEncoding.

Definition at line 144 of file GPRGuardEncoding.cc.

144  {
149  return state;
150 }

References OSKEY_REGISTER_INDEX, OSKEY_RF_NAME, OSNAME_GPR_GUARD_ENCODING, registerFile(), registerIndex(), GuardEncoding::saveState(), ObjectState::setAttribute(), and ObjectState::setName().

Referenced by GuardField::saveState().

Here is the call graph for this function:

Member Data Documentation

◆ index_

int GPRGuardEncoding::index_
private

Register index.

Definition at line 71 of file GPRGuardEncoding.hh.

Referenced by GPRGuardEncoding(), and registerIndex().

◆ OSKEY_REGISTER_INDEX

const std::string GPRGuardEncoding::OSKEY_REGISTER_INDEX = "reg_index"
static

ObjectState attribute key for register index.

Definition at line 65 of file GPRGuardEncoding.hh.

Referenced by GPRGuardEncoding(), BEMSerializer::guardFieldToFile(), BEMSerializer::guardFieldToOM(), and saveState().

◆ OSKEY_RF_NAME

const std::string GPRGuardEncoding::OSKEY_RF_NAME = "rf_name"
static

ObjectState attribute key for the name of the register file.

Definition at line 63 of file GPRGuardEncoding.hh.

Referenced by GPRGuardEncoding(), BEMSerializer::guardFieldToFile(), BEMSerializer::guardFieldToOM(), and saveState().

◆ OSNAME_GPR_GUARD_ENCODING

const std::string GPRGuardEncoding::OSNAME_GPR_GUARD_ENCODING
static
Initial value:
=
"gpr_guard_enc"

ObjectState name for GPR guard encoding.

Definition at line 61 of file GPRGuardEncoding.hh.

Referenced by GPRGuardEncoding(), BEMSerializer::guardFieldToFile(), BEMSerializer::guardFieldToOM(), GuardField::loadState(), and saveState().

◆ regFile_

std::string GPRGuardEncoding::regFile_
private

Name of the register file.

Definition at line 69 of file GPRGuardEncoding.hh.

Referenced by GPRGuardEncoding(), and registerFile().


The documentation for this class was generated from the following files:
GPRGuardEncoding::index_
int index_
Register index.
Definition: GPRGuardEncoding.hh:71
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
ObjectStateLoadingException
Definition: Exception.hh:551
GPRGuardEncoding::registerFile
std::string registerFile() const
Definition: GPRGuardEncoding.cc:122
GPRGuardEncoding::OSKEY_REGISTER_INDEX
static const std::string OSKEY_REGISTER_INDEX
ObjectState attribute key for register index.
Definition: GPRGuardEncoding.hh:65
ObjectState
Definition: ObjectState.hh:59
GuardField
Definition: GuardField.hh:55
ObjectState::setName
void setName(const std::string &name)
GuardField::addGuardEncoding
void addGuardEncoding(GPRGuardEncoding &encoding)
Definition: GuardField.cc:141
GPRGuardEncoding::regFile_
std::string regFile_
Name of the register file.
Definition: GPRGuardEncoding.hh:69
GuardEncoding::setParent
void setParent(GuardField *parent)
Definition: GuardEncoding.cc:137
Exception
Definition: Exception.hh:54
GuardEncoding::encoding
unsigned int encoding() const
Definition: GuardEncoding.cc:112
ObjectState::name
std::string name() const
GuardEncoding::GuardEncoding
GuardEncoding(bool inverted, unsigned int encoding)
Definition: GuardEncoding.cc:51
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
GPRGuardEncoding::OSKEY_RF_NAME
static const std::string OSKEY_RF_NAME
ObjectState attribute key for the name of the register file.
Definition: GPRGuardEncoding.hh:63
GuardField::removeGuardEncoding
void removeGuardEncoding(GPRGuardEncoding &encoding)
Definition: GuardField.cc:163
GPRGuardEncoding::OSNAME_GPR_GUARD_ENCODING
static const std::string OSNAME_GPR_GUARD_ENCODING
ObjectState name for GPR guard encoding.
Definition: GPRGuardEncoding.hh:61
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
GPRGuardEncoding::registerIndex
int registerIndex() const
Definition: GPRGuardEncoding.cc:133
GuardEncoding::saveState
virtual ObjectState * saveState() const
Definition: GuardEncoding.cc:123
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100
GuardEncoding::parent
GuardField * parent() const
Definition: GuardEncoding.cc:90