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

#include <LongImmediateRegisterState.hh>

Inheritance diagram for LongImmediateRegisterState:
Inheritance graph
Collaboration diagram for LongImmediateRegisterState:
Collaboration graph

Public Member Functions

 LongImmediateRegisterState (LongImmediateUnitState *parent, int index, int width, bool signExtend)
 
virtual ~LongImmediateRegisterState ()
 
virtual void setValue (const SimValue &value)
 
virtual const SimValuevalue () const
 
- Public Member Functions inherited from StateData
 StateData ()
 
virtual ~StateData ()
 
- Public Member Functions inherited from WritableState
 WritableState ()
 
virtual ~WritableState ()
 
- Public Member Functions inherited from ReadableState
 ReadableState ()
 
virtual ~ReadableState ()
 

Private Member Functions

 LongImmediateRegisterState (const LongImmediateRegisterState &)
 Copying not allowed. More...
 
LongImmediateRegisterStateoperator= (const LongImmediateRegisterState &)
 Assignment not allowed. More...
 

Private Attributes

LongImmediateUnitStateparent_
 Parent unit of the register state. More...
 
int index_
 Index of the register. More...
 
int width_
 The bit width of the register (needed only while extending). More...
 
bool signExtend_
 True in case the written values should be sign extended. More...
 

Detailed Description

Represents a register of a long immediate unit.

Definition at line 47 of file LongImmediateRegisterState.hh.

Constructor & Destructor Documentation

◆ LongImmediateRegisterState() [1/2]

LongImmediateRegisterState::LongImmediateRegisterState ( LongImmediateUnitState parent,
int  index,
int  width,
bool  signExtend 
)

Constructor.

Parameters
parentParent unit of the register.
indexIndex of the register.
widthThe bit width of the register.
signExtendTrue in case written value should be sign extended (default is zero extension).

Definition at line 49 of file LongImmediateRegisterState.cc.

50  :
51  StateData(), parent_(parent), index_(index), width_(width),
52  signExtend_(signExtend) {
53 }

◆ ~LongImmediateRegisterState()

LongImmediateRegisterState::~LongImmediateRegisterState ( )
virtual

Destructor.

Definition at line 58 of file LongImmediateRegisterState.cc.

58  {
59 }

◆ LongImmediateRegisterState() [2/2]

LongImmediateRegisterState::LongImmediateRegisterState ( const LongImmediateRegisterState )
private

Copying not allowed.

Member Function Documentation

◆ operator=()

LongImmediateRegisterState& LongImmediateRegisterState::operator= ( const LongImmediateRegisterState )
private

Assignment not allowed.

◆ setValue()

void LongImmediateRegisterState::setValue ( const SimValue value)
virtual

Sets the value of the register.

Also extends the value if it's narrower than the register width.

Parameters
valueNew value.

Implements WritableState.

Definition at line 69 of file LongImmediateRegisterState.cc.

69  {
70  // The value is extended in case it's smaller than WORD_BITWIDTH,
71  // which is the width of (int) otherwise we won't extend, as it's
72  // probably a double. In the future when we support 64 bit or larger
73  // integers, this check is not needed.
74  if (value.width() < width_) {
75  SimValue newValue(width_);
76  int ext = width_ - value.width();
77 
78  if (signExtend_) {
79  SLongWord toBeExtended = value.sLongWordValue();
80  newValue = ((long)(toBeExtended << ext) >> ext);
81  } else {
82  // @todo: this might not be needed, we could assume the top bits
83  // to be zero already
84  ULongWord toBeExtended = value.uLongWordValue();
85  newValue = ((toBeExtended << ext) >> ext);
86  }
87  parent_->setRegisterValue(index_, newValue);
88  } else {
90  }
91 }

References index_, parent_, LongImmediateUnitState::setRegisterValue(), signExtend_, SimValue::sLongWordValue(), SimValue::uLongWordValue(), value(), SimValue::width(), and width_.

Referenced by LongImmUpdateAction::execute().

Here is the call graph for this function:

◆ value()

const SimValue & LongImmediateRegisterState::value ( ) const
virtual

Returns the register value.

Returns
Register value.

Implements ReadableState.

Definition at line 99 of file LongImmediateRegisterState.cc.

99  {
100  return parent_->registerValue(index_);
101 }

References index_, parent_, and LongImmediateUnitState::registerValue().

Referenced by ProximRegisterWindow::loadImmediateUnit(), and setValue().

Here is the call graph for this function:

Member Data Documentation

◆ index_

int LongImmediateRegisterState::index_
private

Index of the register.

Definition at line 68 of file LongImmediateRegisterState.hh.

Referenced by setValue(), and value().

◆ parent_

LongImmediateUnitState* LongImmediateRegisterState::parent_
private

Parent unit of the register state.

Definition at line 66 of file LongImmediateRegisterState.hh.

Referenced by setValue(), and value().

◆ signExtend_

bool LongImmediateRegisterState::signExtend_
private

True in case the written values should be sign extended.

Definition at line 72 of file LongImmediateRegisterState.hh.

Referenced by setValue().

◆ width_

int LongImmediateRegisterState::width_
private

The bit width of the register (needed only while extending).

Definition at line 70 of file LongImmediateRegisterState.hh.

Referenced by setValue().


The documentation for this class was generated from the following files:
SimValue::sLongWordValue
SLongWord sLongWordValue() const
Definition: SimValue.cc:997
LongImmediateUnitState::setRegisterValue
virtual void setRegisterValue(int index, const SimValue &value)
Definition: LongImmediateUnitState.cc:114
SimValue
Definition: SimValue.hh:96
LongImmediateRegisterState::parent_
LongImmediateUnitState * parent_
Parent unit of the register state.
Definition: LongImmediateRegisterState.hh:66
LongImmediateRegisterState::signExtend_
bool signExtend_
True in case the written values should be sign extended.
Definition: LongImmediateRegisterState.hh:72
SimValue::uLongWordValue
ULongWord uLongWordValue() const
Definition: SimValue.cc:1027
SimValue::width
int width() const
Definition: SimValue.cc:103
StateData::StateData
StateData()
Definition: StateData.cc:38
ULongWord
unsigned long ULongWord
Definition: BaseType.hh:51
LongImmediateRegisterState::width_
int width_
The bit width of the register (needed only while extending).
Definition: LongImmediateRegisterState.hh:70
LongImmediateUnitState::registerValue
virtual SimValue & registerValue(int index)
Definition: LongImmediateUnitState.cc:98
SLongWord
long SLongWord
Definition: BaseType.hh:52
LongImmediateRegisterState::index_
int index_
Index of the register.
Definition: LongImmediateRegisterState.hh:68
LongImmediateRegisterState::value
virtual const SimValue & value() const
Definition: LongImmediateRegisterState.cc:99