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

#include <AnnotatedInstructionElement.hh>

Inheritance diagram for TTAProgram::AnnotatedInstructionElement:
Inheritance graph
Collaboration diagram for TTAProgram::AnnotatedInstructionElement:
Collaboration graph

Public Member Functions

 AnnotatedInstructionElement ()
 
 ~AnnotatedInstructionElement ()
 
void addAnnotation (const ProgramAnnotation &annotation)
 
void setAnnotation (const ProgramAnnotation &annotation)
 
ProgramAnnotation annotation (int index, ProgramAnnotation::Id id=ProgramAnnotation::ANN_UNDEF_ID) const
 
int annotationCount (ProgramAnnotation::Id id=ProgramAnnotation::ANN_UNDEF_ID) const
 
void removeAnnotations (ProgramAnnotation::Id id=ProgramAnnotation::ANN_UNDEF_ID)
 
bool hasAnnotations (ProgramAnnotation::Id id=ProgramAnnotation::ANN_UNDEF_ID) const
 
bool hasAnnotation (ProgramAnnotation::Id id, const TCEString &data) const
 
void copyAnnotationsFrom (const AnnotatedInstructionElement &other)
 

Private Types

typedef std::multimap< ProgramAnnotation::Id, ProgramAnnotationAnnotationIndex
 a type for the container of the annotations More...
 

Private Attributes

AnnotationIndex annotations_
 container for annotations More...
 

Detailed Description

AnnotatedInstructionElements provide an interface for the classes that can be attached an instruction annotation.

Basically the TerminalImmediate and Move inherit this to provide such capabilities.

Definition at line 53 of file AnnotatedInstructionElement.hh.

Member Typedef Documentation

◆ AnnotationIndex

a type for the container of the annotations

Definition at line 76 of file AnnotatedInstructionElement.hh.

Constructor & Destructor Documentation

◆ AnnotatedInstructionElement()

TTAProgram::AnnotatedInstructionElement::AnnotatedInstructionElement ( )

Constructor.

Definition at line 48 of file AnnotatedInstructionElement.cc.

48  {
49 }

◆ ~AnnotatedInstructionElement()

TTAProgram::AnnotatedInstructionElement::~AnnotatedInstructionElement ( )

Destructor.

Definition at line 54 of file AnnotatedInstructionElement.cc.

54  {
55 }

Member Function Documentation

◆ addAnnotation()

void TTAProgram::AnnotatedInstructionElement::addAnnotation ( const ProgramAnnotation annotation)

◆ annotation()

ProgramAnnotation TTAProgram::AnnotatedInstructionElement::annotation ( int  index,
ProgramAnnotation::Id  id = ProgramAnnotation::ANN_UNDEF_ID 
) const

Returns the annotation at the given index (and id).

Parameters
indexThe index of the annotation.
idThe id of the annotation (optional).
Exceptions
OutOfRangeIf the index is out of range.

Definition at line 100 of file AnnotatedInstructionElement.cc.

101  {
102  std::pair<AnnotationIndex::const_iterator,
103  AnnotationIndex::const_iterator> range(
104  annotations_.end(), annotations_.end());
105 
107  // set the iterators to point to the set of elements with the given id
108  range = annotations_.equal_range(id);
109  else
110  // go through all elements
111  range = std::make_pair(annotations_.begin(), annotations_.end());
112 
113  AnnotationIndex::const_iterator i = range.first;
114  for (int counter = 0; counter < index; ++counter) {
115  ++i;
116  if (i == annotations_.end())
117  break;
118  }
119 
120  if (i == annotations_.end())
121  throw OutOfRange(__FILE__, __LINE__, __func__);
122 
123  return (*i).second;
124 }

References __func__, TTAProgram::ProgramAnnotation::ANN_UNDEF_ID, and annotations_.

Referenced by MachineConnectivityCheck::addAnnotatedFUs(), addAnnotation(), PRegionAliasAnalyzer::analyze(), BFOptimization::assign(), TTAProgram::Move::copy(), llvm::LLVMTCEBuilder::copyFUAnnotations(), ControlFlowGraph::createBlock(), TTAProgram::ProgramWriter::createCodeSection(), DataDependenceGraphBuilder::findStaticRegisters(), DataDependenceGraphBuilder::isAlwaysDifferentFU(), DataDependenceGraphBuilder::memoryCategory(), DataDependenceGraph::mergeAndKeepSource(), DataDependenceGraph::mergeAndKeepUser(), setAnnotation(), TTAProgram::Move::sourceFileName(), and TTAProgram::Move::sourceLineNumber().

◆ annotationCount()

int TTAProgram::AnnotatedInstructionElement::annotationCount ( ProgramAnnotation::Id  id = ProgramAnnotation::ANN_UNDEF_ID) const

Returns the count of annotations (with the given id).

Parameters
idThe id of the annotations to count (optional).
Returns
The count of annotations (with the given id).

Definition at line 133 of file AnnotatedInstructionElement.cc.

133  {
135  return static_cast<int>(annotations_.count(id));
136  else
137  return static_cast<int>(annotations_.size());
138 }

References TTAProgram::ProgramAnnotation::ANN_UNDEF_ID, and annotations_.

Referenced by MachineConnectivityCheck::addAnnotatedFUs(), BFOptimization::assign(), TTAProgram::Move::copy(), llvm::LLVMTCEBuilder::copyFUAnnotations(), TTAProgram::ProgramWriter::createCodeSection(), DataDependenceGraphBuilder::findStaticRegisters(), BFOptimization::hasAmbiguousResources(), hasAnnotations(), DataDependenceGraphBuilder::memoryCategory(), and TTAProgram::Move::sourceLineNumber().

◆ copyAnnotationsFrom()

void TTAProgram::AnnotatedInstructionElement::copyAnnotationsFrom ( const AnnotatedInstructionElement other)

Copies annotations from another annotated element.

Possible old annotations are deleted.

Definition at line 193 of file AnnotatedInstructionElement.cc.

194  {
195  annotations_ = other.annotations_;
196 }

References annotations_.

Referenced by TTAProgram::Instruction::copy().

◆ hasAnnotation()

bool TTAProgram::AnnotatedInstructionElement::hasAnnotation ( ProgramAnnotation::Id  id,
const TCEString data 
) const

Returns true in case there's at least one annotation with the given id and the given data.

Definition at line 174 of file AnnotatedInstructionElement.cc.

175  {
176 
177  auto range = annotations_.equal_range(id);
178  for (auto i = range.first; i != range.second; i++) {
179  if (i->second.stringValue() == data) {
180  return true;
181  }
182  }
183  return false;
184 }

References annotations_.

Referenced by RegisterCopyAdder::isAllowedUnit(), DataDependenceGraphBuilder::isAlwaysDifferentFU(), and ProgramOperation::isLegalFU().

◆ hasAnnotations()

bool TTAProgram::AnnotatedInstructionElement::hasAnnotations ( ProgramAnnotation::Id  id = ProgramAnnotation::ANN_UNDEF_ID) const

◆ removeAnnotations()

void TTAProgram::AnnotatedInstructionElement::removeAnnotations ( ProgramAnnotation::Id  id = ProgramAnnotation::ANN_UNDEF_ID)

Removes all annotations (with the given id).

Parameters
idThe id of the annotations to remove (optional).

Definition at line 146 of file AnnotatedInstructionElement.cc.

146  {
147 
149  annotations_.clear();
150  }
151  AnnotationIndex::iterator i = annotations_.find(id);
152  while (i != annotations_.end()) {
153  annotations_.erase(i);
154  i = annotations_.find(id);
155  }
156 }

References TTAProgram::ProgramAnnotation::ANN_UNDEF_ID, and annotations_.

Referenced by BFOptimization::setPrologDstFUAnno(), BFOptimization::setPrologSrcFUAnno(), BFUpdateMoveOnBypass::undoOnlyMe(), BFCopyRegWithOp::undoSplit(), DataDependenceGraph::unMergeUser(), BF2Scheduler::unreservePreallocatedFUs(), BasicBlockScheduler::unschedule(), and SequentialScheduler::unschedule().

◆ setAnnotation()

void TTAProgram::AnnotatedInstructionElement::setAnnotation ( const ProgramAnnotation annotation)

Sets an annotation to the instruction element as the sole annotation of that type.

Removes all annotations with the same type before adding the annotation.

Parameters
annotationThe annotation to set.

Definition at line 79 of file AnnotatedInstructionElement.cc.

80  {
81 
82  // hmm.. does multimap::erase(key) remove *all* elements with the given
83  // key, or just first found?
84  // multimap::erase(key) returns the number of elements removed as
85  // size_type, so it erases all matching elements
86  annotations_.erase(annotation.id());
87  annotations_.insert(
88  std::pair<ProgramAnnotation::Id, ProgramAnnotation>(
90 }

References annotation(), annotations_, and TTAProgram::ProgramAnnotation::id().

Referenced by RegisterCopyAdder::addConnectionRegisterCopies(), RegisterCopyAdder::addConnectionRegisterCopiesImmediate(), llvm::LLVMTCEBuilder::debugDataToAnnotations(), MoveNodeDuplicator::duplicateMove(), BFRegCopy::operator()(), SequentialScheduler::scheduleMove(), BasicBlockScheduler::scheduleMove(), BUBasicBlockScheduler::scheduleMove(), BFOptimization::setPrologDstFUAnno(), BFOptimization::setPrologSrcFUAnno(), and CopyingDelaySlotFiller::updateJumpsAndCfg().

Here is the call graph for this function:

Member Data Documentation

◆ annotations_

AnnotationIndex TTAProgram::AnnotatedInstructionElement::annotations_
private

The documentation for this class was generated from the following files:
OutOfRange
Definition: Exception.hh:320
TTAProgram::ProgramAnnotation::ANN_UNDEF_ID
@ ANN_UNDEF_ID
an illegal annotation ID (the id is only 24 bits, this has more meaningful bits)
Definition: ProgramAnnotation.hh:202
TTAProgram::AnnotatedInstructionElement::annotations_
AnnotationIndex annotations_
container for annotations
Definition: AnnotatedInstructionElement.hh:79
TTAProgram::ProgramAnnotation::id
ProgramAnnotation::Id id() const
Definition: ProgramAnnotation.cc:111
__func__
#define __func__
Definition: Application.hh:67
TTAProgram::AnnotatedInstructionElement::annotation
ProgramAnnotation annotation(int index, ProgramAnnotation::Id id=ProgramAnnotation::ANN_UNDEF_ID) const
Definition: AnnotatedInstructionElement.cc:100
TTAProgram::AnnotatedInstructionElement::annotationCount
int annotationCount(ProgramAnnotation::Id id=ProgramAnnotation::ANN_UNDEF_ID) const
Definition: AnnotatedInstructionElement.cc:133