OpenASIP  2.0
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
TTAMachine::RegisterGuard Class Reference

#include <Guard.hh>

Inheritance diagram for TTAMachine::RegisterGuard:
Inheritance graph
Collaboration diagram for TTAMachine::RegisterGuard:
Collaboration graph

Public Member Functions

 RegisterGuard (bool inverted, const RegisterFile &regFile, unsigned int registerIndex, Bus *parentBus)
 
 RegisterGuard (const ObjectState *state, Bus &parentBus)
 
virtual ~RegisterGuard ()
 
bool isOpposite (const Guard &guard) const
 
bool isEqual (const Guard &guard) const
 
const RegisterFileregisterFile () const
 
int registerIndex () const
 
virtual void copyTo (Bus &parentBus) const
 
ObjectStatesaveState () const
 
void loadState (const ObjectState *state)
 
- Public Member Functions inherited from TTAMachine::Guard
virtual ~Guard ()
 
virtual BusparentBus () const
 
virtual void setParentBus (Bus *parentBus)
 
virtual bool isInverted () const
 
virtual bool isMoreRestrictive (const Guard &guard) const
 
virtual bool isLessRestrictive (const Guard &guard) const
 
virtual bool isDisjoint (const Guard &guard) const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Static Public Attributes

static const std::string OSNAME_REGISTER_GUARD = "registerguard"
 ObjectState name for RegisterGuard. More...
 
static const std::string OSKEY_REGFILE = "regfile"
 ObjectState attribute key for register file name. More...
 
static const std::string OSKEY_INDEX = "index"
 ObjectState attribute key for register index. More...
 
- Static Public Attributes inherited from TTAMachine::Guard
static const std::string OSNAME_GUARD = "guard"
 ObjectState name for guard. More...
 
static const std::string OSKEY_INVERTED = "inverted"
 ObjectState attribute key for inverted feature. More...
 

Private Attributes

const RegisterFileregFile_
 RegisterFile from which the condition term is taken. More...
 
int registerIndex_
 Index of the register from which the condition term is taken. More...
 

Additional Inherited Members

- Protected Member Functions inherited from TTAMachine::Guard
 Guard (bool inverted, Bus *parentBus)
 
 Guard (const ObjectState *state, Bus &parentBus)
 
- Protected Member Functions inherited from TTAMachine::SubComponent
 SubComponent ()
 
virtual ~SubComponent ()
 
- Protected Member Functions inherited from TTAMachine::MachinePart
 MachinePart ()
 
virtual ~MachinePart ()
 

Detailed Description

Guard where the condition term is taken from the value of a register (from a RegisterFile).

Definition at line 137 of file Guard.hh.

Constructor & Destructor Documentation

◆ RegisterGuard() [1/2]

TTAMachine::RegisterGuard::RegisterGuard ( bool  inverted,
const RegisterFile regFile,
unsigned int  registerIndex,
Bus parentBus 
)

Constructor.

Parameters
invertedIndicates whether the condition term is inverted.
regFileRegisterFile from which the condition term is taken.
registerIndexIndex of the register from which the condition term is taken.
parentBusParent bus component of the guard.
Exceptions
IllegalRegistrationIf the given register file is not registered to the same machine as the parent bus of the guard.
ComponentAlreadyExistsIf the parent bus already has an equal guard.
OutOfRangeIf the given register file does not have a register by the given register index.
InvalidDataIf local + global guard latency would be zero.

Definition at line 393 of file Guard.cc.

396  : Guard(inverted, parentBus),
397  regFile_(&regFile),
399  if (parentBus) {
400  parentBus->ensureRegistration(regFile);
401  }
402  if ((unsigned)regFile.numberOfRegisters() <= registerIndex) {
403  string procName = "RegisterGuard::RegisterGuard";
404  throw OutOfRange(__FILE__, __LINE__, procName);
405  }
406 
407  if (parentBus) {
408  // make sure global + local guard latency > 0
409  Machine* mach = parentBus->machine();
410  ControlUnit* gcu = mach->controlUnit();
411  if (gcu != NULL && gcu->globalGuardLatency() == 0 &&
412  regFile.guardLatency() == 0) {
413  MOMTextGenerator textGen;
414  boost::format text = textGen.text(
416  throw InvalidData(__FILE__, __LINE__, __func__, text.str());
417  }
418  parentBus->addGuard(*this);
419  }
420 }

References __func__, TTAMachine::Bus::addGuard(), TTAMachine::Machine::controlUnit(), TTAMachine::Component::ensureRegistration(), TTAMachine::ControlUnit::globalGuardLatency(), TTAMachine::RegisterFile::guardLatency(), TTAMachine::Component::machine(), TTAMachine::BaseRegisterFile::numberOfRegisters(), TTAMachine::Guard::parentBus(), registerIndex(), Texts::TextGenerator::text(), and MOMTextGenerator::TXT_INVALID_GUARD_LATENCY.

Referenced by copyTo().

Here is the call graph for this function:

◆ RegisterGuard() [2/2]

TTAMachine::RegisterGuard::RegisterGuard ( const ObjectState state,
Bus parentBus 
)

Constructor.

Creates a skeleton object without references to other machine parts. Loads its state from the given ObjectState instance. This constructor should be used by Bus::loadStateWithoutReferences only. Do not use this constructor.

Parameters
stateThe ObjectState instance.
parentBusParent bus of the guard.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid or if the reference to the register cannot be resolved.

Definition at line 436 of file Guard.cc.

437  : Guard(state, parentBus) {
438  loadState(state);
439  try {
440  parentBus.addGuard(*this);
441  } catch (const ComponentAlreadyExists&) {
442  const string procName = "RegisterGuard::RegisterGuard";
443  MOMTextGenerator textGen;
444  format errorMsg = textGen.text(
446  errorMsg % registerIndex() % registerFile()->name() %
447  parentBus.name();
449  __FILE__, __LINE__, procName, errorMsg.str());
450  }
451 }

References TTAMachine::Bus::addGuard(), loadState(), TTAMachine::Component::name(), TTAMachine::Guard::parentBus(), registerFile(), registerIndex(), Texts::TextGenerator::text(), and MOMTextGenerator::TXT_EQUAL_REGISTER_GUARDS.

Here is the call graph for this function:

◆ ~RegisterGuard()

TTAMachine::RegisterGuard::~RegisterGuard ( )
virtual

Destructor.

Definition at line 456 of file Guard.cc.

456  {
457 }

Member Function Documentation

◆ copyTo()

virtual void TTAMachine::RegisterGuard::copyTo ( Bus parentBus) const
inlinevirtual

Implements TTAMachine::Guard.

Definition at line 149 of file Guard.hh.

149  {
150  new RegisterGuard(
152  &parentBus);
153  }

References TTAMachine::Guard::isInverted(), TTAMachine::Guard::parentBus(), regFile_, RegisterGuard(), and registerIndex_.

Here is the call graph for this function:

◆ isEqual()

bool TTAMachine::RegisterGuard::isEqual ( const Guard guard) const
virtual

Returns true if the guard is equal with the given guard.

Parameters
guardThe other guard.
Returns
True if the guard is equal with the given guard.

Implements TTAMachine::Guard.

Definition at line 467 of file Guard.cc.

467  {
468  const RegisterGuard* regGuard =
469  dynamic_cast<const RegisterGuard*>(&guard);
470  if (regGuard == NULL) {
471  return false;
472  } else {
473  if (registerFile() == regGuard->registerFile() &&
474  registerIndex() == regGuard->registerIndex() &&
475  isInverted() == regGuard->isInverted()) {
476  return true;
477  } else {
478  return false;
479  }
480  }
481 }

References TTAMachine::Guard::isInverted(), registerFile(), and registerIndex().

Here is the call graph for this function:

◆ isOpposite()

bool TTAMachine::RegisterGuard::isOpposite ( const Guard guard) const
virtual

Returns true if the guard is opposite with the given guard, ie. always if one is executed, another is not executed.

Parameters
guardThe other guard.
Returns
True if the guard is opposite with the given guard.

Implements TTAMachine::Guard.

Definition at line 491 of file Guard.cc.

491  {
492  const RegisterGuard* regGuard =
493  dynamic_cast<const RegisterGuard*>(&guard);
494  if (regGuard == NULL) {
495  return false;
496  } else {
497  if (registerFile() == regGuard->registerFile() &&
498  registerIndex() == regGuard->registerIndex() &&
499  isInverted() != regGuard->isInverted()) {
500  return true;
501  } else {
502  return false;
503  }
504  }
505 }

References TTAMachine::Guard::isInverted(), registerFile(), and registerIndex().

Here is the call graph for this function:

◆ loadState()

void TTAMachine::RegisterGuard::loadState ( const ObjectState state)
virtual

Loads its state from the given ObjectState instance.

Parameters
stateThe ObjectState instance.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid or if the reference to the register file cannot be resolved.

Reimplemented from TTAMachine::Guard.

Definition at line 535 of file Guard.cc.

535  {
536  string procName = "RegisterGuard::loadState";
537  MOMTextGenerator textGenerator;
538 
539  if (state->name() != OSNAME_REGISTER_GUARD) {
540  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
541  }
542 
543  if (!parentBus()->isRegistered()) {
544  format text = textGenerator.text(MOMTextGenerator::
545  TXT_GUARD_REF_LOAD_ERR);
546  text % parentBus()->name();
547  throw ObjectStateLoadingException(__FILE__, __LINE__, procName,
548  text.str());
549  }
550 
551  Guard::loadState(state);
552 
553  try {
554  string regFileName = state->stringAttribute(OSKEY_REGFILE);
555  int regIndex = state->intAttribute(OSKEY_INDEX);
556 
557  Machine* mach = parentBus()->machine();
559  mach->registerFileNavigator();
560  if (regNav.hasItem(regFileName)) {
561  RegisterFile* regFile = regNav.item(regFileName);
562 
563  // check local + global guard latency > 0
564  ControlUnit* gcu = mach->controlUnit();
565  if (regFile->guardLatency() == 0 && gcu != NULL &&
566  gcu->globalGuardLatency() == 0) {
567  format text = textGenerator.text(
570  __FILE__, __LINE__, __func__, text.str());
571  }
572 
573  if (regFile->numberOfRegisters() > regIndex) {
574  regFile_ = regFile;
575  registerIndex_ = regIndex;
576  } else {
577  format text = textGenerator.text(
579  text % parentBus()->name() % Conversion::toString(regIndex)
580  % regFileName %
581  Conversion::toString(regFile->numberOfRegisters());
582  throw ObjectStateLoadingException(__FILE__, __LINE__,
583  procName, text.str());
584  }
585  } else {
586  format text = textGenerator.text(MOMTextGenerator::
587  TXT_GUARD_REF_LOAD_ERR_RF);
588  text % parentBus()->name() % regFileName;
589  throw ObjectStateLoadingException(__FILE__, __LINE__, procName,
590  text.str());
591  }
592  } catch (Exception& e) {
593  throw ObjectStateLoadingException(__FILE__, __LINE__, procName,
594  e.errorMessage());
595  }
596 }

References __func__, TTAMachine::Machine::controlUnit(), Exception::errorMessage(), TTAMachine::ControlUnit::globalGuardLatency(), TTAMachine::RegisterFile::guardLatency(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), ObjectState::intAttribute(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Guard::loadState(), TTAMachine::Component::machine(), ObjectState::name(), TTAMachine::Component::name(), TTAMachine::BaseRegisterFile::numberOfRegisters(), OSKEY_INDEX, OSKEY_REGFILE, OSNAME_REGISTER_GUARD, TTAMachine::Guard::parentBus(), regFile_, TTAMachine::Machine::registerFileNavigator(), registerIndex_, ObjectState::stringAttribute(), Texts::TextGenerator::text(), Conversion::toString(), MOMTextGenerator::TXT_GUARD_REF_LOAD_ERR_REGISTER, and MOMTextGenerator::TXT_INVALID_GUARD_LATENCY.

Referenced by RegisterGuard().

Here is the call graph for this function:

◆ registerFile()

const RegisterFile* TTAMachine::RegisterGuard::registerFile ( ) const

Referenced by CodeCompressorPlugin::addBitsForGuardField(), BEMGenerator::addEncodings(), ResourceConstraintAnalyzer::analyzeRegisterAntideps(), TDGen::analyzeRegisters(), MachineStateBuilder::buildMachineState(), UtilizationStats::calculateForInstruction(), SimpleIfConverter::canConvert(), ProgrammabilityValidator::checkBooleanRegister(), BEMValidator::checkGuardField(), CompiledSimCodeGenerator::CompiledSimCodeGenerator(), DefaultDecoderGenerator::completeDecoderBlock(), DataDependenceGraphBuilder::constructIndividualFromInlineAsmBB(), DefaultDecoderGenerator::containsSimilarGuard(), TTAProgram::ProgramWriter::createCodeSection(), POMDisassembler::createGuard(), llvm::LLVMTCEBuilder::createGuard(), TTAProgram::CodeGenerator::createInverseGuard(), ProgramDependenceGraph::createJump(), TTAMachine::RegisterFile::deleteGuards(), DataDependenceGraph::destRenamed(), CopyingDelaySlotFiller::fillDelaySlots(), findBooleanGuard(), TTAProgram::TPEFProgramFactory::findGuard(), DefaultDecoderGenerator::findGuard(), RegisterQuantityCheck::findGuardRegisters(), RegisterRenamer::findGuardRegisters(), ProgrammabilityValidator::findRegisterGuard(), RegisterCopyAdder::findTempRegisters(), DataDependenceGraph::firstRegisterCycle(), DataDependenceGraph::fixInterBBAntiEdges(), CompiledSimCodeGenerator::generateGuardCondition(), CompiledSimCodeGenerator::generateGuardRead(), TTAProgram::Move::guardLatency(), CompiledSimCodeGenerator::guardPipelineTopSymbol(), DefaultDecoderGenerator::guardPortName(), DataDependenceGraph::guardRenamed(), MachineConnectivityCheck::hasBothGuards(), MachineConnectivityCheck::hasConditionalMoves(), TTAMachine::ControlUnit::hasLocalGuardLatencyOfZero(), isEqual(), isOpposite(), TTAMachine::RegisterFile::isUsedAsGuard(), DataDependenceGraph::lastRegisterCycle(), DataDependenceGraph::lastScheduledRegisterGuardReads(), ListCompareFunction(), MachineInfo::longestGuardLatency(), RFGuardDialog::onOK(), DataDependenceGraphBuilder::processGuard(), MachineResourceManager::registerFileIndexReference(), RegisterGuard(), RegisterRenamer::renameLiveRange(), HDB::RFArchitecture::RFArchitecture(), MachineResourceManager::rFPortOrFUIndexReference(), DataDependenceGraph::sanityCheck(), SequentialScheduler::scheduleMove(), BFRenameLiveRange::setGuard(), MachineInfo::supportsBoolRegisterGuardedJumps(), PostpassOperandSharer::tryRemoveOperandWrite(), and BusDialog::updateGuardLists().

◆ registerIndex()

int TTAMachine::RegisterGuard::registerIndex ( ) const

Referenced by CodeCompressorPlugin::addBitsForGuardField(), BEMGenerator::addEncodings(), TDGen::analyzeRegisters(), MachineStateBuilder::buildMachineState(), UtilizationStats::calculateForInstruction(), SimpleIfConverter::canConvert(), ProgrammabilityValidator::checkBooleanRegister(), BEMValidator::checkGuardField(), CompiledSimCodeGenerator::CompiledSimCodeGenerator(), DefaultDecoderGenerator::completeDecoderBlock(), DataDependenceGraphBuilder::constructIndividualFromInlineAsmBB(), DefaultDecoderGenerator::containsSimilarGuard(), TTAProgram::ProgramWriter::createCodeSection(), POMDisassembler::createGuard(), llvm::LLVMTCEBuilder::createGuard(), TTAProgram::CodeGenerator::createInverseGuard(), ProgramDependenceGraph::createJump(), TTAMachine::RegisterFile::deleteGuards(), DataDependenceGraph::destRenamed(), CopyingDelaySlotFiller::fillDelaySlots(), TTAProgram::TPEFProgramFactory::findGuard(), DefaultDecoderGenerator::findGuard(), RegisterQuantityCheck::findGuardRegisters(), RegisterRenamer::findGuardRegisters(), ProgrammabilityValidator::findRegisterGuard(), RegisterCopyAdder::findTempRegisters(), DataDependenceGraph::firstRegisterCycle(), DataDependenceGraph::fixInterBBAntiEdges(), CompiledSimCodeGenerator::generateGuardCondition(), CompiledSimCodeGenerator::generateGuardRead(), CompiledSimCodeGenerator::guardPipelineTopSymbol(), DefaultDecoderGenerator::guardPortName(), DataDependenceGraph::guardRenamed(), MachineConnectivityCheck::hasBothGuards(), MachineConnectivityCheck::hasConditionalMoves(), isEqual(), isOpposite(), DataDependenceGraph::lastRegisterCycle(), DataDependenceGraph::lastScheduledRegisterGuardReads(), ListCompareFunction(), DataDependenceGraphBuilder::processGuard(), MachineResourceManager::registerFileIndexReference(), RegisterGuard(), RegisterRenamer::renameLiveRange(), MachineResourceManager::rFPortOrFUIndexReference(), BFRenameLiveRange::setGuard(), PostpassOperandSharer::tryRemoveOperandWrite(), and BusDialog::updateGuardLists().

◆ saveState()

ObjectState * TTAMachine::RegisterGuard::saveState ( ) const
virtual

Saves the contents to an ObjectState object.

Returns
The created ObjectState object..

Reimplemented from TTAMachine::Guard.

Definition at line 514 of file Guard.cc.

514  {
515 
516  ObjectState* guardState = Guard::saveState();
517  guardState->setName(OSNAME_REGISTER_GUARD);
518  guardState->setAttribute(OSKEY_REGFILE, regFile_->name());
520 
521  return guardState;
522 }

References TTAMachine::Component::name(), OSKEY_INDEX, OSKEY_REGFILE, OSNAME_REGISTER_GUARD, regFile_, registerIndex_, TTAMachine::Guard::saveState(), ObjectState::setAttribute(), and ObjectState::setName().

Here is the call graph for this function:

Member Data Documentation

◆ OSKEY_INDEX

const string TTAMachine::RegisterGuard::OSKEY_INDEX = "index"
static

ObjectState attribute key for register index.

Definition at line 163 of file Guard.hh.

Referenced by loadState(), and saveState().

◆ OSKEY_REGFILE

const string TTAMachine::RegisterGuard::OSKEY_REGFILE = "regfile"
static

ObjectState attribute key for register file name.

Definition at line 161 of file Guard.hh.

Referenced by loadState(), and saveState().

◆ OSNAME_REGISTER_GUARD

const string TTAMachine::RegisterGuard::OSNAME_REGISTER_GUARD = "registerguard"
static

ObjectState name for RegisterGuard.

Definition at line 159 of file Guard.hh.

Referenced by TTAMachine::Bus::loadState(), loadState(), and saveState().

◆ regFile_

const RegisterFile* TTAMachine::RegisterGuard::regFile_
private

RegisterFile from which the condition term is taken.

Definition at line 167 of file Guard.hh.

Referenced by copyTo(), loadState(), and saveState().

◆ registerIndex_

int TTAMachine::RegisterGuard::registerIndex_
private

Index of the register from which the condition term is taken.

Definition at line 169 of file Guard.hh.

Referenced by copyTo(), loadState(), and saveState().


The documentation for this class was generated from the following files:
TTAMachine::Guard::saveState
virtual ObjectState * saveState() const
Definition: Guard.cc:149
MOMTextGenerator::TXT_INVALID_GUARD_LATENCY
@ TXT_INVALID_GUARD_LATENCY
Definition: MOMTextGenerator.hh:87
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
TTAMachine::RegisterGuard::OSNAME_REGISTER_GUARD
static const std::string OSNAME_REGISTER_GUARD
ObjectState name for RegisterGuard.
Definition: Guard.hh:159
TTAMachine::RegisterGuard::registerIndex
int registerIndex() const
ObjectStateLoadingException
Definition: Exception.hh:551
TTAMachine::Component::ensureRegistration
virtual void ensureRegistration(const Component &component) const
Definition: MachinePart.cc:163
OutOfRange
Definition: Exception.hh:320
ObjectState
Definition: ObjectState.hh:59
TTAMachine::Bus::addGuard
void addGuard(Guard &guard)
Definition: Bus.cc:410
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
ObjectState::setName
void setName(const std::string &name)
Conversion::toString
static std::string toString(const T &source)
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
TTAMachine::Machine::RegisterFileNavigator
Navigator< RegisterFile > RegisterFileNavigator
Navigator type for RegisterFileNavigator.
Definition: Machine.hh:227
InvalidData
Definition: Exception.hh:149
TTAMachine::RegisterGuard::loadState
void loadState(const ObjectState *state)
Definition: Guard.cc:535
__func__
#define __func__
Definition: Application.hh:67
MOMTextGenerator::TXT_EQUAL_REGISTER_GUARDS
@ TXT_EQUAL_REGISTER_GUARDS
Definition: MOMTextGenerator.hh:53
TTAMachine::Guard::Guard
Guard(bool inverted, Bus *parentBus)
Definition: Guard.cc:64
Exception
Definition: Exception.hh:54
TTAMachine::RegisterGuard::registerIndex_
int registerIndex_
Index of the register from which the condition term is taken.
Definition: Guard.hh:169
ObjectState::name
std::string name() const
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
TTAMachine::RegisterGuard::RegisterGuard
RegisterGuard(bool inverted, const RegisterFile &regFile, unsigned int registerIndex, Bus *parentBus)
Definition: Guard.cc:393
TTAMachine::RegisterGuard::OSKEY_REGFILE
static const std::string OSKEY_REGFILE
ObjectState attribute key for register file name.
Definition: Guard.hh:161
TTAMachine::Guard::parentBus
virtual Bus * parentBus() const
TTAMachine::Guard::isInverted
virtual bool isInverted() const
TTAMachine::Component::machine
virtual Machine * machine() const
MOMTextGenerator
Definition: MOMTextGenerator.hh:40
TTAMachine::Guard::loadState
virtual void loadState(const ObjectState *state)
Definition: Guard.cc:164
ComponentAlreadyExists
Definition: Exception.hh:510
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
TTAMachine::RegisterGuard::OSKEY_INDEX
static const std::string OSKEY_INDEX
ObjectState attribute key for register index.
Definition: Guard.hh:163
MOMTextGenerator::TXT_GUARD_REF_LOAD_ERR_REGISTER
@ TXT_GUARD_REF_LOAD_ERR_REGISTER
Definition: MOMTextGenerator.hh:51
TTAMachine::RegisterGuard::registerFile
const RegisterFile * registerFile() const
TTAMachine::RegisterGuard::regFile_
const RegisterFile * regFile_
RegisterFile from which the condition term is taken.
Definition: Guard.hh:167
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100