OpenASIP  2.0
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
Encoding Class Referenceabstract

#include <Encoding.hh>

Inheritance diagram for Encoding:
Inheritance graph
Collaboration diagram for Encoding:
Collaboration graph

Public Member Functions

virtual ~Encoding ()
 
InstructionFieldparent () const
 
unsigned int encoding () const
 
unsigned int extraBits () const
 
virtual int width () const
 
virtual int bitPosition () const =0
 
virtual ObjectStatesaveState () const
 

Static Public Attributes

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...
 

Protected Member Functions

 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)
 

Private Attributes

unsigned int encoding_
 The encoding. More...
 
unsigned int extraBits_
 The number of extra bits. More...
 
InstructionFieldparent_
 The parent instruction field. More...
 

Detailed Description

Represents an encoding of a source of destination within a move slot. This is a base class for different encodings.

Definition at line 46 of file Encoding.hh.

Constructor & Destructor Documentation

◆ ~Encoding()

Encoding::~Encoding ( )
virtual

The destructor.

Definition at line 87 of file Encoding.cc.

87  {
88 }

◆ Encoding() [1/2]

Encoding::Encoding ( unsigned int  encoding,
unsigned int  extraBits,
InstructionField parent 
)
protected

The constructor.

Parameters
encodingThe encoding.
extraBitsThe number of extra bits.
parentThe parent pointer.

Definition at line 53 of file Encoding.cc.

◆ Encoding() [2/2]

Encoding::Encoding ( const ObjectState state,
InstructionField parent 
)
protected

The constructor.

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

Parameters
stateThe ObjectState instance.
parentThe parent pointer.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.

Definition at line 71 of file Encoding.cc.

72  : encoding_(0), extraBits_(0), parent_(parent) {
73  const string procName = "Encoding::Encoding";
74 
75  try {
78  } catch (const Exception& exception) {
80  __FILE__, __LINE__, procName, exception.errorMessage());
81  }
82 }

References encoding_, Exception::errorMessage(), extraBits_, ObjectState::intAttribute(), OSKEY_ENCODING, and OSKEY_EXTRA_BITS.

Here is the call graph for this function:

Member Function Documentation

◆ bitPosition()

virtual int Encoding::bitPosition ( ) const
pure virtual

Returns the position of the encoding within the parent field.

Implemented in SocketEncoding, ImmediateEncoding, BridgeEncoding, and NOPEncoding.

◆ encoding()

unsigned int Encoding::encoding ( ) const

◆ extraBits()

unsigned int Encoding::extraBits ( ) const

Returns the number of extra zero bits in the encoding.

Returns
The number of extra bits.

Definition at line 119 of file Encoding.cc.

119  {
120  return extraBits_;
121 }

References extraBits_.

Referenced by SourceField::addBridgeEncoding(), SlotField::addSocketEncoding(), BEMTester::canAddComponentEncoding(), saveState(), SocketEncoding::setEncoding(), setEncoding(), SourceField::setImmediateEncoding(), SlotField::setNoOperationEncoding(), SocketEncoding::socketIDWidth(), and width().

◆ parent()

InstructionField * Encoding::parent ( ) const

Returns the parent instruction field.

Returns
The parent instruction field.

Definition at line 97 of file Encoding.cc.

97  {
98  return parent_;
99 }

References parent_.

Referenced by NOPEncoding::parent(), ImmediateEncoding::parent(), BridgeEncoding::parent(), SocketEncoding::parent(), and setParent().

◆ saveState()

ObjectState * Encoding::saveState ( ) const
virtual

Saves the state of the object to an ObjectState instance.

Returns
The newly created ObjectState instance.

Reimplemented in SocketEncoding, ImmediateEncoding, BridgeEncoding, and NOPEncoding.

Definition at line 141 of file Encoding.cc.

141  {
145  return state;
146 }

References encoding(), extraBits(), OSKEY_ENCODING, OSKEY_EXTRA_BITS, OSNAME_ENCODING, and ObjectState::setAttribute().

Referenced by NOPEncoding::saveState(), BridgeEncoding::saveState(), ImmediateEncoding::saveState(), and SocketEncoding::saveState().

Here is the call graph for this function:

◆ setEncoding()

void Encoding::setEncoding ( unsigned int  encoding,
unsigned int  extraBits 
)
protected

Sets the encoding

Definition at line 163 of file Encoding.cc.

163  {
166 }

References encoding(), encoding_, extraBits(), and extraBits_.

Referenced by SocketEncoding::setEncoding().

Here is the call graph for this function:

◆ setParent()

void Encoding::setParent ( InstructionField parent)
protected

◆ width()

int Encoding::width ( ) const
virtual

Returns the bit width required by the encoding.

Returns
The bit width.

Reimplemented in SocketEncoding, and ImmediateEncoding.

Definition at line 130 of file Encoding.cc.

130  {
132 }

References MathTools::bitLength(), encoding(), and extraBits().

Referenced by NOPEncoding::bitPosition(), BridgeEncoding::bitPosition(), BEMTester::canAddComponentEncoding(), CodeCompressorPlugin::encodeNOP(), ImmediateEncoding::encodingWidth(), printSlotFieldEncodings(), printSourceFieldEncodings(), SourceField::width(), and SlotField::width().

Here is the call graph for this function:

Member Data Documentation

◆ encoding_

unsigned int Encoding::encoding_
private

The encoding.

Definition at line 81 of file Encoding.hh.

Referenced by encoding(), Encoding(), and setEncoding().

◆ extraBits_

unsigned int Encoding::extraBits_
private

The number of extra bits.

Definition at line 83 of file Encoding.hh.

Referenced by Encoding(), extraBits(), and setEncoding().

◆ OSKEY_ENCODING

const std::string Encoding::OSKEY_ENCODING = "encoding"
static

◆ OSKEY_EXTRA_BITS

const std::string Encoding::OSKEY_EXTRA_BITS = "extra_bits"
static

◆ OSNAME_ENCODING

const std::string Encoding::OSNAME_ENCODING = "encoding"
static

ObjectState name for Encoding class.

Definition at line 64 of file Encoding.hh.

Referenced by saveState().

◆ parent_

InstructionField* Encoding::parent_
private

The parent instruction field.

Definition at line 85 of file Encoding.hh.

Referenced by parent(), and setParent().


The documentation for this class was generated from the following files:
Encoding::OSNAME_ENCODING
static const std::string OSNAME_ENCODING
ObjectState name for Encoding class.
Definition: Encoding.hh:64
ObjectStateLoadingException
Definition: Exception.hh:551
Encoding::parent
InstructionField * parent() const
Definition: Encoding.cc:97
ObjectState
Definition: ObjectState.hh:59
Encoding::OSKEY_ENCODING
static const std::string OSKEY_ENCODING
ObjectState attribute key for the encoding.
Definition: Encoding.hh:66
Encoding::encoding
unsigned int encoding() const
Definition: Encoding.cc:108
Exception
Definition: Exception.hh:54
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
Encoding::OSKEY_EXTRA_BITS
static const std::string OSKEY_EXTRA_BITS
ObjectState attribute key for the number of extra bits.
Definition: Encoding.hh:68
Encoding::parent_
InstructionField * parent_
The parent instruction field.
Definition: Encoding.hh:85
Encoding::encoding_
unsigned int encoding_
The encoding.
Definition: Encoding.hh:81
MathTools::bitLength
static unsigned int bitLength(long unsigned int number)
Encoding::extraBits_
unsigned int extraBits_
The number of extra bits.
Definition: Encoding.hh:83
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
Encoding::extraBits
unsigned int extraBits() const
Definition: Encoding.cc:119
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100