OpenASIP  2.0
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
OperationPoolPimpl Class Reference

#include <OperationPoolPimpl.hh>

Collaboration diagram for OperationPoolPimpl:
Collaboration graph

Public Member Functions

 ~OperationPoolPimpl ()
 
Operationoperation (const char *name)
 
OperationIndexindex ()
 
bool sharesState (const Operation &op)
 

Static Public Member Functions

static void cleanupCache ()
 
static void setLLVMTargetInstrInfo (const llvm::MCInstrInfo *tid)
 

Private Types

typedef std::map< std::string, Operation * > OperationTable
 Container for operations indexed by their names. More...
 

Private Member Functions

 OperationPoolPimpl ()
 
 OperationPoolPimpl (const OperationPoolPimpl &)
 Copying not allowed. More...
 
OperationPoolPimploperator= (const OperationPoolPimpl &)
 Assignment not allowed. More...
 
OperationloadFromLLVM (const llvm::MCInstrDesc &tid)
 

Private Attributes

OperationSerializer serializer_
 

Static Private Attributes

static OperationBehaviorLoaderloader_
 Operation pool uses this to load behavior models of the operations. More...
 
static OperationIndexindex_
 Indexed table used to find out which operation module contains the given operation. More...
 
static OperationTable operationCache_
 Contains all operations that have been already requested by the client. More...
 
static std::vector< OperationBehaviorProxy * > proxies_
 Contains all operation behavior proxies. More...
 
static const llvm::MCInstrInfo * llvmTargetInstrInfo_
 If this is set, OSAL data is loaded from the TargetInstrInfo instead of .opp XML files. Used when calling the TCE scheduler from non-TTA LLVM targets. More...
 

Friends

class OperationPool
 

Detailed Description

A private implementation class for OperationPool

Definition at line 53 of file OperationPoolPimpl.hh.

Member Typedef Documentation

◆ OperationTable

typedef std::map<std::string, Operation*> OperationPoolPimpl::OperationTable
private

Container for operations indexed by their names.

Definition at line 71 of file OperationPoolPimpl.hh.

Constructor & Destructor Documentation

◆ ~OperationPoolPimpl()

OperationPoolPimpl::~OperationPoolPimpl ( )

The destructor

Definition at line 90 of file OperationPoolPimpl.cc.

90  {
91 }

◆ OperationPoolPimpl() [1/2]

OperationPoolPimpl::OperationPoolPimpl ( )
private

The constructor

Definition at line 75 of file OperationPoolPimpl.cc.

75  {
76  // if this is a first created instance of OperationPool,
77  // initialize the OperationIndex instance with the search paths
78  if (index_ == NULL) {
79  index_ = new OperationIndex();
80  vector<string> paths = Environment::osalPaths();
81  for (unsigned int i = 0; i < paths.size(); i++) {
82  index_->addPath(paths[i]);
83  }
84  }
85 }

References OperationIndex::addPath(), index_, and Environment::osalPaths().

Here is the call graph for this function:

◆ OperationPoolPimpl() [2/2]

OperationPoolPimpl::OperationPoolPimpl ( const OperationPoolPimpl )
private

Copying not allowed.

Member Function Documentation

◆ cleanupCache()

void OperationPoolPimpl::cleanupCache ( )
static

Cleans up the static Operation cache.

Deletes also the Operation instances, so be sure you are not using them after calling this!

Definition at line 100 of file OperationPoolPimpl.cc.

100  {
102  delete index_;
103  index_ = NULL;
104 }

References AssocTools::deleteAllValues(), index_, and operationCache_.

Referenced by OperationPool::cleanupCache().

Here is the call graph for this function:

◆ index()

OperationIndex & OperationPoolPimpl::index ( )

Returns the operation index of operation pool.

Returns
The operation index.

Definition at line 213 of file OperationPoolPimpl.cc.

213  {
214  assert(index_ != NULL);
215  return *index_;
216 }

References assert, and index_.

Referenced by OperationPool::index().

◆ loadFromLLVM()

Operation * OperationPoolPimpl::loadFromLLVM ( const llvm::MCInstrDesc &  tid)
private

Loads an OSAL Operation from LLVM TargetInstrDesc.

Used for avoiding the need for .xml OSAL databases when TCE scheduler is called directly for non-TTA LLVM targets.

Definition at line 164 of file OperationPoolPimpl.cc.

166  {
167  TCEString opName = llvmTargetInstrInfo_->getName(tid.getOpcode()).str();
169 
170  unsigned outputs = tid.getNumDefs();
171  unsigned inputs = tid.getNumOperands() - outputs;
172 
173  // at least a minimal implicit trigger input
174  // RET of SPU does not include the implicit link register
175  // operand even though it will be generated in the final
176  // assembly to just an absolute jump to it
177  if (inputs == 0)
178  inputs = 1;
179 
180  for (unsigned opr = 0; opr < outputs; ++opr) {
181  Operand* operand =
182  new Operand(false, inputs + opr + 1, Operand::UINT_WORD);
183  op->addOutput(operand);
184  }
185 
186  for (unsigned opr = 0; opr < inputs; ++opr) {
187  Operand* operand = new Operand(true, opr + 1, Operand::UINT_WORD);
188  op->addInput(operand);
189  }
190  if (tid.isCall()) {
191  op->setCall(true);
192  op->setControlFlowOperation(true);
193  }
194  if (tid.isBranch() || tid.isReturn()) {
195  op->setBranch(true);
196  op->setControlFlowOperation(true);
197  }
198  if (tid.mayLoad()) {
199  op->setReadsMemory(true);
200  }
201  if (tid.mayStore()) {
202  op->setWritesMemory(true);
203  }
204  return op;
205 }

References Operation::addInput(), Operation::addOutput(), NullOperationBehavior::instance(), llvmTargetInstrInfo_, Operation::setBranch(), Operation::setCall(), Operation::setControlFlowOperation(), Operation::setReadsMemory(), Operation::setWritesMemory(), and Operand::UINT_WORD.

Referenced by operation().

Here is the call graph for this function:

◆ operation()

Operation & OperationPoolPimpl::operation ( const char *  name)

Looks up an operation identified by its name and returns a reference to it.

The first found operation is returned. If operation is not found, a null operation is returned.

Parameters
nameThe name of the operation.
Returns
The wanted operation.

Definition at line 116 of file OperationPoolPimpl.cc.

116  {
117 
118  OperationTable::iterator it =
120  if (it != operationCache_.end()) {
121  return *((*it).second);
122  }
123 
124  // If llvmTargetInstrInfo_ is set, the scheduler is called
125  // directly from LLVM code gen. Use the TargetInstrDesc as
126  // the source for operation info instead.
127  if (llvmTargetInstrInfo_ != NULL) {
128  for (unsigned opc = 0; opc < llvmTargetInstrInfo_->getNumOpcodes();
129  ++opc) {
130  const llvm::MCInstrDesc& tid = llvmTargetInstrInfo_->get(opc);
131  TCEString operName =
132  TCEString(llvmTargetInstrInfo_->getName(opc).str()).lower();
133  if (operName == TCEString(name).lower()) {
134  Operation* llvmOperation = loadFromLLVM(tid);
135  operationCache_[operName] = llvmOperation;
136  return *llvmOperation;
137  }
138  }
140  TCEString("Did not find info for LLVM operation ") + name);
141  }
142 
143  OperationModule& module = index_->moduleOf(name);
144  if (&module == &NullOperationModule::instance()) {
145  return NullOperation::instance();
146  }
147 
148  Operation* effective = index_->effectiveOperation(name);
149  if (effective != NULL) {
150  operationCache_[StringTools::stringToLower(name)] = effective;
151  return *effective;
152  } else {
153  return NullOperation::instance();
154  }
155 }

References abortWithError, OperationIndex::effectiveOperation(), index_, NullOperationModule::instance(), NullOperation::instance(), llvmTargetInstrInfo_, loadFromLLVM(), TCEString::lower(), OperationIndex::moduleOf(), operationCache_, and StringTools::stringToLower().

Referenced by OperationPool::operation().

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

◆ setLLVMTargetInstrInfo()

static void OperationPoolPimpl::setLLVMTargetInstrInfo ( const llvm::MCInstrInfo *  tid)
inlinestatic

Definition at line 64 of file OperationPoolPimpl.hh.

64  {
66  }

References llvmTargetInstrInfo_.

Referenced by OperationPool::setLLVMTargetInstrInfo().

◆ sharesState()

bool OperationPoolPimpl::sharesState ( const Operation op)

Definition at line 219 of file OperationPoolPimpl.cc.

219  {
220  if (op.affectsCount() > 0 || op.affectedByCount() > 0)
221  return true;
222  for (const auto& entry : operationCache_) {
223  const Operation& other = *entry.second;
224  if (other.dependsOn(op))
225  return true;
226  }
227  return false;
228 }

References Operation::affectedByCount(), Operation::affectsCount(), Operation::dependsOn(), and operationCache_.

Referenced by OperationPool::sharesState().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ OperationPool

friend class OperationPool
friend

Definition at line 55 of file OperationPoolPimpl.hh.

Member Data Documentation

◆ index_

OperationIndex * OperationPoolPimpl::index_
staticprivate

Indexed table used to find out which operation module contains the given operation.

Definition at line 82 of file OperationPoolPimpl.hh.

Referenced by cleanupCache(), index(), operation(), and OperationPoolPimpl().

◆ llvmTargetInstrInfo_

const llvm::MCInstrInfo * OperationPoolPimpl::llvmTargetInstrInfo_
staticprivate

If this is set, OSAL data is loaded from the TargetInstrInfo instead of .opp XML files. Used when calling the TCE scheduler from non-TTA LLVM targets.

Definition at line 93 of file OperationPoolPimpl.hh.

Referenced by loadFromLLVM(), operation(), and setLLVMTargetInstrInfo().

◆ loader_

OperationBehaviorLoader* OperationPoolPimpl::loader_
staticprivate

Operation pool uses this to load behavior models of the operations.

Definition at line 79 of file OperationPoolPimpl.hh.

◆ operationCache_

OperationPoolPimpl::OperationTable OperationPoolPimpl::operationCache_
staticprivate

Contains all operations that have been already requested by the client.

Definition at line 87 of file OperationPoolPimpl.hh.

Referenced by cleanupCache(), operation(), and sharesState().

◆ proxies_

std::vector<OperationBehaviorProxy*> OperationPoolPimpl::proxies_
staticprivate

Contains all operation behavior proxies.

Definition at line 89 of file OperationPoolPimpl.hh.

◆ serializer_

OperationSerializer OperationPoolPimpl::serializer_
private

Definition at line 84 of file OperationPoolPimpl.hh.


The documentation for this class was generated from the following files:
Operand
Definition: Operand.hh:52
Operation::affectedByCount
virtual int affectedByCount() const
Definition: Operation.cc:416
OperationIndex::addPath
void addPath(const std::string &path)
Definition: OperationIndex.cc:82
Operation::setReadsMemory
virtual void setReadsMemory(bool setting)
Definition: Operation.cc:631
TCEString::lower
TCEString lower() const
Definition: TCEString.cc:78
Operation::addOutput
virtual void addOutput(Operand *operand)
Definition: Operation.cc:513
Operand::UINT_WORD
@ UINT_WORD
Definition: Operand.hh:60
Operation::dependsOn
virtual bool dependsOn(const Operation &op) const
Definition: Operation.cc:458
NullOperation::instance
static NullOperation & instance()
assert
#define assert(condition)
Definition: Application.hh:86
Operation::setCall
virtual void setCall(bool setting)
Definition: Operation.cc:359
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
OperationPoolPimpl::operationCache_
static OperationTable operationCache_
Contains all operations that have been already requested by the client.
Definition: OperationPoolPimpl.hh:87
Operation::setControlFlowOperation
virtual void setControlFlowOperation(bool setting)
Definition: Operation.cc:335
OperationPoolPimpl::index_
static OperationIndex * index_
Indexed table used to find out which operation module contains the given operation.
Definition: OperationPoolPimpl.hh:82
Environment::osalPaths
static std::vector< std::string > osalPaths()
Definition: Environment.cc:519
Operation
Definition: Operation.hh:59
OperationPoolPimpl::llvmTargetInstrInfo_
static const llvm::MCInstrInfo * llvmTargetInstrInfo_
If this is set, OSAL data is loaded from the TargetInstrInfo instead of .opp XML files....
Definition: OperationPoolPimpl.hh:93
NullOperationBehavior::instance
static NullOperationBehavior & instance()
Definition: OperationBehavior.hh:95
OperationPoolPimpl::loadFromLLVM
Operation * loadFromLLVM(const llvm::MCInstrDesc &tid)
Definition: OperationPoolPimpl.cc:164
Operation::addInput
virtual void addInput(Operand *operand)
Definition: Operation.cc:508
OperationModule
Definition: OperationModule.hh:46
OperationIndex::effectiveOperation
Operation * effectiveOperation(const TCEString &name)
Definition: OperationIndex.cc:454
TCEString
Definition: TCEString.hh:53
OperationIndex
Definition: OperationIndex.hh:58
Operation::setWritesMemory
virtual void setWritesMemory(bool setting)
Definition: Operation.cc:639
NullOperationModule::instance
static NullOperationModule & instance()
AssocTools::deleteAllValues
static void deleteAllValues(ContainerType &aMap)
Operation::affectsCount
virtual int affectsCount() const
Definition: Operation.cc:402
OperationIndex::moduleOf
OperationModule & moduleOf(const std::string &name)
Definition: OperationIndex.cc:315
Operation::setBranch
virtual void setBranch(bool setting)
Definition: Operation.cc:368
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160