OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TTAProgram::TerminalRegister Class Reference

#include <TerminalRegister.hh>

Inheritance diagram for TTAProgram::TerminalRegister:
Inheritance graph
Collaboration diagram for TTAProgram::TerminalRegister:
Collaboration graph

Public Member Functions

 TerminalRegister (const TTAMachine::Port &port, int index)
 
virtual ~TerminalRegister ()
 Copying is allowed. More...
 
virtual bool isImmediateRegister () const
 
virtual bool isGPR () const
 
virtual bool isUniversalMachineRegister () const
 
virtual const TTAMachine::RegisterFileregisterFile () const
 
virtual const TTAMachine::ImmediateUnitimmediateUnit () const
 
virtual int index () const
 
virtual const TTAMachine::Portport () const
 
virtual void setIndex (int index)
 
virtual Terminalcopy () const
 
virtual bool equals (const Terminal &other) const
 
virtual TCEString toString () const
 
- Public Member Functions inherited from TTAProgram::Terminal
 Terminal ()
 
virtual ~Terminal ()
 
virtual bool isImmediate () const
 
virtual bool isAddress () const
 
virtual bool isInstructionAddress () const
 
virtual bool isFUPort () const
 
virtual bool isRA () const
 
virtual bool isBasicBlockReference () const
 
virtual bool isProgramOperationReference () const
 
virtual bool isCodeSymbolReference () const
 
virtual SimValue value () const
 
virtual Address address () const
 
virtual const InstructionReferenceinstructionReference () const
 
virtual InstructionReferenceinstructionReference ()
 
virtual const TTAMachine::FunctionUnitfunctionUnit () const
 
virtual const BasicBlockbasicBlock () const
 
virtual bool isOpcodeSetting () const
 
virtual bool isTriggering () const
 
virtual Operationoperation () const
 
virtual OperationhintOperation () const
 
virtual int operationIndex () const
 
virtual void setInstructionReference (InstructionReference ref)
 
bool operator== (const Terminal &other) const
 

Private Member Functions

TerminalRegisteroperator= (const TerminalRegister &)
 Assignment not allowed. More...
 

Private Attributes

const TTAMachine::Unitunit_
 Unit of the terminal. More...
 
const TTAMachine::Portport_
 Port of the unit. More...
 
short index_
 Index of the register of the register file or immediate unit. More...
 
bool isImmUnit_
 Unit type flag: true if immediate unit, false if register file. More...
 

Detailed Description

Represents a reference to registers from general-purpose register files and immediate units.

These types of terminals are characterised by the fact that multiple, functionally identical registers are accessed through the same port. Registers are identified by an index.

Definition at line 53 of file TerminalRegister.hh.

Constructor & Destructor Documentation

◆ TerminalRegister()

TTAProgram::TerminalRegister::TerminalRegister ( const TTAMachine::Port port,
int  index 
)

The constructor.

Parameters
unitThe register file.
portThe port of the register file.
indexRegister identifier.

Definition at line 50 of file TerminalRegister.cc.

51  : unit_(*port.parentUnit()), port_(port), index_(index), isImmUnit_(false) {
52  if (dynamic_cast<const ImmediateUnit*>(&unit_) != NULL) {
53  isImmUnit_ = true;
54  } else if (dynamic_cast<const RegisterFile*>(&unit_) == NULL) {
55  throw InvalidData(
56  __FILE__, __LINE__, "TerminalRegister::TerminalRegister()",
57  "Unit of the terminal has invalid type");
58  }
59 }

References isImmUnit_, and unit_.

Referenced by copy().

◆ ~TerminalRegister()

TTAProgram::TerminalRegister::~TerminalRegister ( )
virtual

Copying is allowed.

The destructor.

Definition at line 64 of file TerminalRegister.cc.

64  {
65 }

Member Function Documentation

◆ copy()

Terminal * TTAProgram::TerminalRegister::copy ( ) const
virtual

Creates an exact copy of the terminal and returns it.

Returns
A copy of the terminal.

Implements TTAProgram::Terminal.

Definition at line 147 of file TerminalRegister.cc.

147  {
148  return new TerminalRegister(port_, index_);
149 }

References index_, port_, and TerminalRegister().

Referenced by RegisterCopyAdder::addConnectionRegisterCopies(), and RegisterCopyAdder::addConnectionRegisterCopiesImmediate().

Here is the call graph for this function:

◆ equals()

bool TTAProgram::TerminalRegister::equals ( const Terminal other) const
virtual

Checks if terminals are equal.

Parameters
otherTerminal to compare.
Returns
true if terminals are equal.

Implements TTAProgram::Terminal.

Definition at line 158 of file TerminalRegister.cc.

158  {
159  try {
160  if (isImmediateRegister()) {
161  return (other.isImmediateRegister() &&
162  index() == other.index() &&
163  immediateUnit().name() == other.immediateUnit().name());
164  }
165  if (isGPR()) {
166  return (other.isGPR() &&
167  index() == other.index() &&
168  registerFile().name() == other.registerFile().name());
169  }
170  return false;
171  } catch (const WrongSubclass&) {
172  // the method should throw this when called for wrong type,
173  // thus the objects cannot be equal
174  return false;
175  }
176 }

References immediateUnit(), TTAProgram::Terminal::immediateUnit(), index(), TTAProgram::Terminal::index(), isGPR(), TTAProgram::Terminal::isGPR(), isImmediateRegister(), TTAProgram::Terminal::isImmediateRegister(), TTAMachine::Component::name(), registerFile(), and TTAProgram::Terminal::registerFile().

Referenced by ControlFlowGraph::createJumps().

Here is the call graph for this function:

◆ immediateUnit()

const ImmediateUnit & TTAProgram::TerminalRegister::immediateUnit ( ) const
virtual

Returns the immediate unit of the long immediate register.

Applicable only if the unit of the terminal is an instance of ImmediateUnit.

Returns
The immediate unit of the long immediate register.
Exceptions
WrongSubclassif the unit of the terminal is not an instance of ImmediateUnit.

Reimplemented from TTAProgram::Terminal.

Definition at line 99 of file TerminalRegister.cc.

99  {
100  if (isImmUnit_ == true) {
101  return static_cast<const ImmediateUnit&>(unit_);
102  } else {
103  throw WrongSubclass(
104  __FILE__, __LINE__, "TerminalRegister::immediateUnit()",
105  "Unit of the terminal is not of type ImmediateUnit");
106  }
107 }

References isImmUnit_, and unit_.

Referenced by equals().

◆ index()

virtual int TTAProgram::TerminalRegister::index ( ) const
virtual

Return the index of the register (either a long immediate or a general-purpose register).

Returns
The index of the register.
Exceptions
WrongSubclassif the terminal is not an instance of TerminalRegister.

Reimplemented from TTAProgram::Terminal.

Referenced by llvm::LLVMTCEBuilder::createGuard(), equals(), setIndex(), toString(), CopyingDelaySlotFiller::writesRegister(), and SimpleIfConverter::writesRegister().

◆ isGPR()

virtual bool TTAProgram::TerminalRegister::isGPR ( ) const
virtual

Tells whether the terminal is a general-purpose register.

Returns
True if the terminal is a general-purpose register.

Reimplemented from TTAProgram::Terminal.

Referenced by ControlFlowGraph::createJumps(), and equals().

◆ isImmediateRegister()

virtual bool TTAProgram::TerminalRegister::isImmediateRegister ( ) const
virtual

Tells whether the terminal is a long immediate register.

Returns
True if the terminal is a long immediate register.

Reimplemented from TTAProgram::Terminal.

Referenced by ControlFlowGraph::createJumps(), and equals().

◆ isUniversalMachineRegister()

bool TTAProgram::TerminalRegister::isUniversalMachineRegister ( ) const
virtual

Tells whether the terminal is a reg in UniversalMachine

Returns
True if the terminal is a register in universalmachine, ie. not in any real machine. This practically means the register is unallocated and meant to be bypassed.

Reimplemented from TTAProgram::Terminal.

Definition at line 198 of file TerminalRegister.cc.

198  {
199  return (dynamic_cast<const UnboundedRegisterFile*>(&unit_) != NULL);
200 }

References unit_.

◆ operator=()

TerminalRegister& TTAProgram::TerminalRegister::operator= ( const TerminalRegister )
private

Assignment not allowed.

◆ port()

const Port & TTAProgram::TerminalRegister::port ( ) const
virtual

Return the port.

Returns
The port of the unit of the terminal.
Exceptions
WrongSubclassnever.

Reimplemented from TTAProgram::Terminal.

Definition at line 116 of file TerminalRegister.cc.

116  {
117  return port_;
118 }

References port_.

◆ registerFile()

const RegisterFile & TTAProgram::TerminalRegister::registerFile ( ) const
virtual

Returns the register file of the general-purpose register.

Applicable only if the unit of the terminal is an instance of RegisterFile.

Returns
The register file of the general-purpose register.
Exceptions
WrongSubclassif the unit of the terminal is not an instance of RegisterFile.

Reimplemented from TTAProgram::Terminal.

Definition at line 78 of file TerminalRegister.cc.

78  {
79  if (isImmUnit_ == false) {
80  return static_cast<const RegisterFile&>(unit_);
81  } else {
82  throw WrongSubclass(
83  __FILE__, __LINE__, "TerminalRegister::registerFile()",
84  "Unit of the terminal is not of type RegisterFile");
85  }
86 }

References isImmUnit_, and unit_.

Referenced by llvm::LLVMTCEBuilder::createGuard(), equals(), toString(), CopyingDelaySlotFiller::writesRegister(), and SimpleIfConverter::writesRegister().

◆ setIndex()

void TTAProgram::TerminalRegister::setIndex ( int  index)
virtual

Change the register of the register file to the given index.

Parameters
indexThe new register index.
Exceptions
OutOfRangeif index is not smaller than the size of the register file or immediate unit it belongs to.

Reimplemented from TTAProgram::Terminal.

Definition at line 128 of file TerminalRegister.cc.

128  {
129  const BaseRegisterFile& reg =
130  dynamic_cast<const BaseRegisterFile&>(unit_);
131 
132  if (index < reg.numberOfRegisters()) {
133  index_ = index;
134  } else {
135  throw OutOfRange(
136  __FILE__, __LINE__, "TerminalRegister::setIndex()",
137  "Index out of range.");
138  }
139 }

References index(), index_, TTAMachine::BaseRegisterFile::numberOfRegisters(), and unit_.

Here is the call graph for this function:

◆ toString()

TCEString TTAProgram::TerminalRegister::toString ( ) const
virtual

Implements TTAProgram::Terminal.

Definition at line 179 of file TerminalRegister.cc.

179  {
180  if (isImmUnit_ == false) {
181  DisassemblyRegister disasm(registerFile().name(), index());
182  return disasm.toString();
183  } else {
184  TCEString res = unit_.name();
185  res << "." << index_;
186  return res;
187  }
188 }

References index(), index_, isImmUnit_, TTAMachine::Component::name(), registerFile(), DisassemblyRegister::toString(), and unit_.

Here is the call graph for this function:

Member Data Documentation

◆ index_

short TTAProgram::TerminalRegister::index_
private

Index of the register of the register file or immediate unit.

Definition at line 86 of file TerminalRegister.hh.

Referenced by copy(), setIndex(), and toString().

◆ isImmUnit_

bool TTAProgram::TerminalRegister::isImmUnit_
private

Unit type flag: true if immediate unit, false if register file.

Definition at line 88 of file TerminalRegister.hh.

Referenced by immediateUnit(), registerFile(), TerminalRegister(), and toString().

◆ port_

const TTAMachine::Port& TTAProgram::TerminalRegister::port_
private

Port of the unit.

Definition at line 84 of file TerminalRegister.hh.

Referenced by copy(), and port().

◆ unit_

const TTAMachine::Unit& TTAProgram::TerminalRegister::unit_
private

Unit of the terminal.

Definition at line 82 of file TerminalRegister.hh.

Referenced by immediateUnit(), isUniversalMachineRegister(), registerFile(), setIndex(), TerminalRegister(), and toString().


The documentation for this class was generated from the following files:
TTAProgram::TerminalRegister::isGPR
virtual bool isGPR() const
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
UnboundedRegisterFile
Definition: UnboundedRegisterFile.hh:43
OutOfRange
Definition: Exception.hh:320
TTAProgram::TerminalRegister::isImmediateRegister
virtual bool isImmediateRegister() const
TTAProgram::TerminalRegister::immediateUnit
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
Definition: TerminalRegister.cc:99
TTAProgram::TerminalRegister::TerminalRegister
TerminalRegister(const TTAMachine::Port &port, int index)
Definition: TerminalRegister.cc:50
TTAProgram::TerminalRegister::index
virtual int index() const
TTAProgram::TerminalRegister::unit_
const TTAMachine::Unit & unit_
Unit of the terminal.
Definition: TerminalRegister.hh:82
TTAMachine::BaseRegisterFile::numberOfRegisters
virtual int numberOfRegisters() const
TTAMachine::BaseRegisterFile
Definition: BaseRegisterFile.hh:48
TTAProgram::TerminalRegister::port
virtual const TTAMachine::Port & port() const
Definition: TerminalRegister.cc:116
InvalidData
Definition: Exception.hh:149
WrongSubclass
Definition: Exception.hh:336
TTAProgram::TerminalRegister::isImmUnit_
bool isImmUnit_
Unit type flag: true if immediate unit, false if register file.
Definition: TerminalRegister.hh:88
TTAProgram::TerminalRegister::port_
const TTAMachine::Port & port_
Port of the unit.
Definition: TerminalRegister.hh:84
TTAProgram::TerminalRegister::registerFile
virtual const TTAMachine::RegisterFile & registerFile() const
Definition: TerminalRegister.cc:78
TCEString
Definition: TCEString.hh:53
DisassemblyRegister
Definition: DisassemblyRegister.hh:51
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
TTAProgram::TerminalRegister::index_
short index_
Index of the register of the register file or immediate unit.
Definition: TerminalRegister.hh:86
TTAMachine::Port::parentUnit
Unit * parentUnit() const
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50