OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
- Static Public Attributes inherited from Encoding
static const std::string OSNAME_ENCODING = "encoding"
 ObjectState name for Encoding class.
 
static const std::string OSKEY_ENCODING = "encoding"
 ObjectState attribute key for the encoding.
 
static const std::string OSKEY_EXTRA_BITS = "extra_bits"
 ObjectState attribute key for the number of extra bits.
 

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) {
60}
unsigned int extraBits() const
Definition Encoding.cc:119
void setParent(InstructionField *parent)
Definition Encoding.cc:155
unsigned int encoding() const
Definition Encoding.cc:108
SlotField * parent() const
void setNoOperationEncoding(NOPEncoding &encoding)
Definition SlotField.cc:234

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
86}
static const std::string OSNAME_NOP_ENCODING
ObjectState name for NOP encoding.
std::string name() const

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}
#define assert(condition)
void unsetNoOperationEncoding()
Definition SlotField.cc:253

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}
virtual int width() const
Definition Encoding.cc:130
virtual int width() const
Definition SlotField.cc:307

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}
InstructionField * parent() const
Definition Encoding.cc:97

References assert, Encoding::parent(), and parent().

Referenced by bitPosition(), NOPEncoding(), NOPEncoding(), parent(), 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 {
141 return state;
142}
virtual ObjectState * saveState() const
Definition Encoding.cc:141
void setName(const std::string &name)

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: