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

#include <NOPEncoding.hh>

Inheritance diagram for NOPEncoding:
Inheritance graph
Collaboration diagram for NOPEncoding:
Collaboration graph

Public Member Functions

 NOPEncoding (unsigned int encoding, unsigned int extraBits, SlotField &parent)
 
 NOPEncoding (const ObjectState *state, SlotField &parent)
 
virtual ~NOPEncoding ()
 
SlotFieldparent () const
 
virtual int bitPosition () const
 
virtual ObjectStatesaveState () const
 
- Public Member Functions inherited from Encoding
virtual ~Encoding ()
 
InstructionFieldparent () const
 
unsigned int encoding () const
 
unsigned int extraBits () const
 
virtual int width () const
 

Static Public Attributes

static const std::string OSNAME_NOP_ENCODING = "nop_encoding"
 ObjectState name for NOP encoding. More...
 
- Static Public Attributes inherited from Encoding
static const std::string OSNAME_ENCODING = "encoding"
 ObjectState name for Encoding class. More...
 
static const std::string OSKEY_ENCODING = "encoding"
 ObjectState attribute key for the encoding. More...
 
static const std::string OSKEY_EXTRA_BITS = "extra_bits"
 ObjectState attribute key for the number of extra bits. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Encoding
 Encoding (unsigned int encoding, unsigned int extraBits, InstructionField *parent)
 
 Encoding (const ObjectState *state, InstructionField *parent)
 
void setParent (InstructionField *parent)
 
void setEncoding (unsigned int encoding, unsigned int extraBits)
 

Detailed Description

Represents the encoding for NOP (no operation) in the source field.

Definition at line 44 of file NOPEncoding.hh.

Constructor & Destructor Documentation

◆ NOPEncoding() [1/2]

NOPEncoding::NOPEncoding ( unsigned int  encoding,
unsigned int  extraBits,
SlotField parent 
)

The constructor.

Registers the encoding automatically to the parent src/dst field.

Parameters
encodingThe encoding for inline immediates.
extraBitsThe number of extra bits in the encoding.
parentThe parent src/dst field.
Exceptions
ObjectAlreadyExistsIf the given parent field has a NOP encoding already or if the encoding is ambiguous with some other encoding in the parent field.

Definition at line 55 of file NOPEncoding.cc.

57  : Encoding(encoding, extraBits, NULL) {
59  setParent(&parent);
60 }

References parent(), SlotField::setNoOperationEncoding(), and Encoding::setParent().

Here is the call graph for this function:

◆ NOPEncoding() [2/2]

NOPEncoding::NOPEncoding ( const ObjectState state,
SlotField parent 
)

The constructor.

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

Parameters
stateThe ObjectState instance.
parentThe parent field.
Exceptions
ObjectAlreadyExistsIf the given parent field has a NOP encoding already or if the encoding is ambiguous with some other encoding in the parent field.
ObjectStateLoadingExceptionIf the given ObjectState instance is erroneous.

Definition at line 76 of file NOPEncoding.cc.

77  : Encoding(state, NULL) {
78  const string procName = "NOPEncoding::NOPEncoding";
79 
80  if (state->name() != OSNAME_NOP_ENCODING) {
81  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
82  }
83 
85  setParent(&parent);
86 }

References ObjectState::name(), OSNAME_NOP_ENCODING, parent(), SlotField::setNoOperationEncoding(), and Encoding::setParent().

Here is the call graph for this function:

◆ ~NOPEncoding()

NOPEncoding::~NOPEncoding ( )
virtual

The destructor.

Definition at line 91 of file NOPEncoding.cc.

91  {
92  SlotField* oldParent = parent();
93  assert(oldParent != NULL);
94  setParent(NULL);
95  oldParent->unsetNoOperationEncoding();
96 }

References assert, parent(), Encoding::setParent(), and SlotField::unsetNoOperationEncoding().

Here is the call graph for this function:

Member Function Documentation

◆ bitPosition()

int NOPEncoding::bitPosition ( ) const
virtual

Returns the position of the encoding within the source field.

Returns
The position of the encoding.

Implements Encoding.

Definition at line 123 of file NOPEncoding.cc.

123  {
124  if (parent()->componentIDPosition() == BinaryEncoding::LEFT) {
125  return parent()->width() - parent()->extraBits() - width();
126  } else {
127  return 0;
128  }
129 }

References InstructionField::extraBits(), BinaryEncoding::LEFT, parent(), Encoding::width(), and SlotField::width().

Here is the call graph for this function:

◆ parent()

SlotField * NOPEncoding::parent ( ) const

Returns the parent source field.

Returns
The parent.

Definition at line 105 of file NOPEncoding.cc.

105  {
107  if (parent != NULL) {
108  SlotField* sField = dynamic_cast<SlotField*>(parent);
109  assert(sField != NULL);
110  return sField;
111  } else {
112  return NULL;
113  }
114 }

References assert, and Encoding::parent().

Referenced by bitPosition(), NOPEncoding(), SlotField::setNoOperationEncoding(), and ~NOPEncoding().

Here is the call graph for this function:

◆ saveState()

ObjectState * NOPEncoding::saveState ( ) const
virtual

Saves the state of the object to an ObjectState instance.

Returns
The newly created ObjectState instance.

Reimplemented from Encoding.

Definition at line 138 of file NOPEncoding.cc.

138  {
139  ObjectState* state = Encoding::saveState();
141  return state;
142 }

References OSNAME_NOP_ENCODING, Encoding::saveState(), and ObjectState::setName().

Here is the call graph for this function:

Member Data Documentation

◆ OSNAME_NOP_ENCODING

const std::string NOPEncoding::OSNAME_NOP_ENCODING = "nop_encoding"
static

The documentation for this class was generated from the following files:
ObjectStateLoadingException
Definition: Exception.hh:551
Encoding::setParent
void setParent(InstructionField *parent)
Definition: Encoding.cc:155
Encoding::parent
InstructionField * parent() const
Definition: Encoding.cc:97
ObjectState
Definition: ObjectState.hh:59
ObjectState::setName
void setName(const std::string &name)
InstructionField
Definition: InstructionField.hh:43
SlotField::setNoOperationEncoding
void setNoOperationEncoding(NOPEncoding &encoding)
Definition: SlotField.cc:234
assert
#define assert(condition)
Definition: Application.hh:86
NOPEncoding::parent
SlotField * parent() const
Definition: NOPEncoding.cc:105
Encoding::width
virtual int width() const
Definition: Encoding.cc:130
BinaryEncoding::LEFT
@ LEFT
Definition: BinaryEncoding.hh:64
SlotField::width
virtual int width() const
Definition: SlotField.cc:307
Encoding::encoding
unsigned int encoding() const
Definition: Encoding.cc:108
SlotField::unsetNoOperationEncoding
void unsetNoOperationEncoding()
Definition: SlotField.cc:253
ObjectState::name
std::string name() const
Encoding::saveState
virtual ObjectState * saveState() const
Definition: Encoding.cc:141
InstructionField::extraBits
int extraBits() const
Definition: InstructionField.cc:229
Encoding::Encoding
Encoding(unsigned int encoding, unsigned int extraBits, InstructionField *parent)
Definition: Encoding.cc:53
SlotField
Definition: SlotField.hh:58
NOPEncoding::OSNAME_NOP_ENCODING
static const std::string OSNAME_NOP_ENCODING
ObjectState name for NOP encoding.
Definition: NOPEncoding.hh:57
Encoding::extraBits
unsigned int extraBits() const
Definition: Encoding.cc:119