OpenASIP  2.0
OperationPimpl.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file OperationPimpl.cc
26  *
27  * Definition of OperationPimpl (private implementation) class.
28  *
29  * @author Viljami Korhonen 2008 (viljami.korhonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include "OperationPimpl.hh"
34 #include "Operation.hh"
35 #include "OperationBehavior.hh"
36 #include "OperationDAG.hh"
37 #include "OperationDAGConverter.hh"
38 #include "SequenceTools.hh"
39 #include "ContainerTools.hh"
40 #include "StringTools.hh"
41 #include "Application.hh"
42 #include "OperationPool.hh"
43 #include "TCEString.hh"
44 #include "OperationPimpl.hh"
45 #include "ObjectState.hh"
46 
47 // -----------
48 /// @todo These two lines can be removed after C++11 features can be used in
49 /// the source code, since it has native support for initializing std::map.
50 #include "boost/assign.hpp"
51 using namespace boost::assign;
52 // -----------
53 
54 using std::set;
55 using std::vector;
56 using std::string;
57 
58 
59 /**
60  * Constructor.
61  *
62  * @param name The name of the Operation.
63  * @param behavior The behavior of the Operation.
64  */
66  const TCEString& name,
67  OperationBehavior& behavior) :
68  behavior_(&behavior), name_(StringTools::stringToUpper(name)),
69  description_(""),
70  inputs_(0), outputs_(0), readsMemory_(false), writesMemory_(false),
71  canTrap_(false), hasSideEffects_(false), isClocked_(false),
72  controlFlowOperation_(false), isCall_(false), isBranch_(false) {
73 }
74 
75 /**
76  * Destructor.
77  *
78  * Operands are destroyed.
79  */
81  clear();
82 }
83 
84 /**
85  * Clears the operation.
86  */
87 void
89 
90  for (int i = 0; i < dagCount(); i++) {
91  if (!dags_[i].dag->isNull()) {
92  delete dags_[i].dag;
93  }
94  }
95  dags_.clear();
96 
99  inputOperands_.clear();
100  outputOperands_.clear();
101  affects_.clear();
102  affectedBy_.clear();
103  name_ = "";
104  inputs_ = 0;
105  outputs_ = 0;
106  readsMemory_ = false;
107  writesMemory_ = false;
108  canTrap_ = false;
109  hasSideEffects_ = false;
110  controlFlowOperation_ = false;
111  isBranch_ = false;
112  isCall_ = false;
113 }
114 
115 /**
116  * Returns the name of the Operation.
117  *
118  * @return The name of the Operation.
119  */
120 TCEString
122  return name_;
123 }
124 
125 /**
126  * Returns the description of the Operation.
127  *
128  * @return The description of the Operation.
129  */
130 TCEString
132  return description_;
133 }
134 
135 /**
136  * Creates new DAG and adds it's code for operation.
137  *
138  * @param code Source code written in DAG language.
139  */
141  OperationDAGInfo newDag;
142  newDag.code = code;
143  newDag.dag = &OperationDAG::null;
144  newDag.compilationFailed = false;
145  dags_.push_back(newDag);
146 }
147 
148 /**
149  * Removes DAG of given index from operation.
150  *
151  * @param index Index of dag to delete.
152  */
153 void
155  DAGContainer::iterator i = dags_.begin() + index;
156 
157  if (!i->dag->isNull()) {
158  delete i->dag;
159  i->dag = &OperationDAG::null;
160  }
161 
162  dags_.erase(i);
163 }
164 
165 
166 /**
167  * Returns number of DAGs stored for operation.
168  *
169  * @return Number of DAGs stored for operation.
170  */
171 int
173  return dags_.size();
174 }
175 
176 /**
177  * Returns an operation DAG for operation.
178  *
179  * Compiles DAG from code to object if necessary.
180  *
181  * @param index Index of returned DAG.
182  * @return Requested operation DAG or OperationDAG::null
183  * if DAG is not valid.
184  */
185 OperationDAG&
186 OperationPimpl::dag(int index) const {
187 
188  // if dag is not up to date, try to compile it, if compilation failed and
189  // dag code has not been changed don't try to compile again
190  if (dags_[index].dag->isNull() && !dags_[index].compilationFailed) {
191 
192  try {
193  dags_[index].dag =
194  OperationDAGConverter::createDAG(*this, dags_[index].code);
195  dags_[index].compilationFailed = false;
196  dags_[index].error = "";
197 
198  } catch (const IllegalParameters &e) {
199  dags_[index].dag = &OperationDAG::null;
200  dags_[index].error = e.errorMessage();
201  dags_[index].compilationFailed = true;
202 
203  } catch (const Exception &e) {
204  dags_[index].dag = &OperationDAG::null;
205  dags_[index].error = "UNEXPECTED ERROR: " + e.errorMessage();
206  dags_[index].compilationFailed = true;
207  }
208  }
209 
210  return *dags_[index].dag;
211 }
212 
213 /**
214  * Returns source code of DAG.
215  *
216  * @param index Index of DAG whose source code is requested.
217  * @return The source code set for DAG.
218  */
219 TCEString
220 OperationPimpl::dagCode(int index) const {
221  return dags_[index].code;
222 }
223 
224 /**
225  * Set new source code for DAG and automatically tries to compile
226  * latest version to object.
227  *
228  * @param index Index of DAG whose source code is updated.
229  * @param code New source code in DAG Osal Language.
230  */
231 void
232 OperationPimpl::setDagCode(int index, const TCEString& code) {
233  dags_[index].code = code;
234  if (!dags_[index].dag->isNull()) {
235  delete dags_[index].dag;
236  dags_[index].dag = &OperationDAG::null;
237  }
238  dags_[index].compilationFailed = false;
239 }
240 
241 /**
242  * Error message if DAG source code could not be compiled.
243  *
244  * @param index Index of DAG whose error is returned.
245  * @return Error message, empty string if DAG was compiles successfully.
246  */
247 TCEString
248 OperationPimpl::dagError(int index) const {
249  return dags_[index].error;
250 }
251 
252 /**
253  * Returns true if Operation can trap.
254  *
255  * @return True if Operation can trap, false otherwise.
256  */
257 bool
259  return canTrap_;
260 }
261 
262 /**
263  * Return true if operation has side effects.
264  *
265  * @return True if Operation has side effects, false otherwise.
266  */
267 bool
269  return hasSideEffects_;
270 }
271 
272 /**
273  * Returns true if the operation is clocked.
274  *
275  * @return True if the operation is clocked.
276  */
277 bool
279  return isClocked_;
280 }
281 
282 /**
283  * Return true if the operation can change control flow.
284  *
285  * Branches and calls of different type have this property set.
286  *
287  * @return True if Operation is a control flow operation.
288  */
289 bool
291  return controlFlowOperation_;
292 }
293 
294 /**
295  * Return true if the operation is call.
296  *
297  * Calls of different type have this property set.
298  *
299  * @return True if Operation is a call operation.
300  */
301 bool
303  return isCall_;
304 }
305 /**
306  * Return true if the operation is branch.
307  *
308  * Branches of different type have this property set.
309  *
310  * @return True if Operation is a branch operation.
311  */
312 bool
314  return isBranch_;
315 }
316 
317 /**
318  * Sets the behavior for operation.
319  *
320  * @param behavior Behavior for an operation.
321  */
322 void
324  behavior_ = &behavior;
325 }
326 
327 /**
328  * Returns the behavior of Operation.
329  *
330  * @return The behavior of Operation.
331  */
334  return *behavior_;
335 }
336 
337 /**
338  * Returns the number of operations that affect this operation.
339  *
340  * @return The number of operations that affect this operation.
341  */
342 int
344  return affects_.size();
345 }
346 
347 /**
348  * Returns the number of operations affected by this operation.
349  *
350  * @return The number of operations affected by this operation.
351  */
352 int
354  return affectedBy_.size();
355 }
356 
357 /**
358  * Returns the name of the operation this operation affects.
359  *
360  * @param i The index of the operation.
361  * @return The name of the operation.
362  */
363 TCEString
364 OperationPimpl::affects(unsigned int i) const {
365 
366  if (i >= affects_.size()) {
367  string method = "OperationPimpl::affects()";
368  string msg = "Index out of range.";
369  throw OutOfRange(__FILE__, __LINE__, method, msg);
370  }
371 
372  set<string>::const_iterator it = affects_.begin();
373  unsigned int count = 0;
374  while (count < i) {
375  it++;
376  count++;
377  }
378  return *it;
379 }
380 
381 /**
382  * Returns the name of the operation that is affected by this operation.
383  *
384  * @param i The index of the operation.
385  * @exception OutOfRange If index is illegal.
386  * @return The name of the operation.
387  */
388 TCEString
389 OperationPimpl::affectedBy(unsigned int i) const {
390 
391  if (i >= affectedBy_.size()) {
392  string method = "OperationPimpl::affectedBy()";
393  string msg = "Index out of range.";
394  throw OutOfRange(__FILE__, __LINE__, method, msg);
395  }
396 
397  set<string>::const_iterator it = affectedBy_.begin();
398  unsigned int count = 0;
399  while (count < i) {
400  it++;
401  count++;
402  }
403  return *it;
404 }
405 
406 /**
407  * Returns true if Operation depends on the given operation.
408  *
409  * @param op The Operation being investigated.
410  * @return True if Operation depends on the given operation, false otherwise.
411  */
412 bool
414  set<string>::const_iterator it = affects_.find(op.name());
415  if (it != affects_.end()) {
416  return true;
417  } else {
418  it = affectedBy_.find(op.name());
419  if (it != affectedBy_.end()) {
420  return true;
421  }
422  }
423 
424  return false;
425 }
426 
427 /**
428  * Returns true if Operands can be swapped.
429  *
430  * @param id1 Id of the first Operand.
431  * @param id2 Id of the second Operand.
432  * @return True, if Operands can be swapped, false otherwise.
433  */
434 bool
435 OperationPimpl::canSwap(int id1, int id2) const {
436 
437  Operand& op1 = fetchOperand(id1);
438  Operand& op2 = fetchOperand(id2);
439 
440  if (&op1 == &NullOperand::instance() ||
441  &op2 == &NullOperand::instance()) {
442  return false;
443  }
444  return op1.canSwap(op2);
445 }
446 
447 /**
448  * Loads the Operation from ObjectState object.
449  *
450  * @param state The state of the Operation.
451  */
452 void
454 
455  clear();
456 
457  string method = "OperationPimpl::loadState()";
458 
459  try {
462 
464 
467 
476 
477  for (int i = 0; i < state->childCount(); i++) {
478  ObjectState* child = state->child(i);
479 
480  if (child->name() == Operation::OPRN_IN) {
481  Operand* operand = new Operand(true);
482  operand->loadState(child);
483  if (operand->index() < 1 || operand->index() > inputs_) {
484  string msg = "Input operand index illegal";
485  throw Exception(__FILE__, __LINE__, method, msg);
486  }
488 
489  } else if (child->name() == Operation::OPRN_OUT) {
490  Operand* operand = new Operand(false);
491  operand->loadState(child);
492  if (operand->index() <= inputs_ ||
493  operand->index() > inputs_ + outputs_) {
494  string msg = "Output operand index illegal";
495  throw Exception(__FILE__, __LINE__, method, msg);
496  }
498 
499  } else if (child->name() == Operation::OPRN_AFFECTS) {
500  for (int j = 0; j < child->childCount(); j++) {
501  ObjectState* affects = child->child(j);
502  affects_.insert(
504  affects->stringAttribute(Operation::OPRN_NAME)));
505  }
506 
507  } else if (child->name() == Operation::OPRN_AFFECTED_BY) {
508  for (int j = 0; j < child->childCount(); j++) {
509  ObjectState* affectedBy = child->child(j);
510  affectedBy_.insert(
512  affectedBy->stringAttribute(Operation::OPRN_NAME)));
513  }
514 
515  } else if (child->name() == Operation::OPRN_TRIGGER) {
516  addDag(child->stringValue());
517 
518  } else {
519  // no other childs should be possible
520  string msg = "Unknown child: " + child->name();
521  throw Exception(__FILE__, __LINE__, method, msg);
522  }
523  }
524 
525  // TODO: check can-swap operands and verify that they are created
526  // properly
527 
528  // add operands that are not defined in XML nor can-swap..
529  for (int i = 1; i <= inputs_; ++i) {
530  if (&operand(i) == &NullOperand::instance()) {
531  Operand* operand = new Operand(true, i, Operand::SINT_WORD);
533  }
534  }
535 
536  for (int i = 1 + inputs_; i <= inputs_ + outputs_; ++i) {
537  if (&operand(i) == &NullOperand::instance()) {
538  Operand* operand = new Operand(true, i, Operand::SINT_WORD);
540  }
541  }
542 
543  } catch (const Exception& e) {
544  string msg = "Problems loading Operation: " + e.errorMessage();
545  ObjectStateLoadingException error(__FILE__, __LINE__, method, msg);
546  error.setCause(e);
547  throw error;
548  }
549 }
550 
551 /**
552  * Saves the state of the Operation in ObjectState object.
553  *
554  * @return The state of the Operation.
555  */
558 
564 
573 
574  if (affectedBy_.size() > 0) {
576  set<string>::const_iterator it = affectedBy_.begin();
577  while (it != affectedBy_.end()) {
578  ObjectState* affectedByChild = new ObjectState(Operation::OPRN_OPERATION);
579  affectedByChild->setAttribute(Operation::OPRN_NAME, *it);
580  affectedBy->addChild(affectedByChild);
581  it++;
582  }
583  root->addChild(affectedBy);
584  }
585 
586  if (affects_.size() > 0) {
588  set<string>::const_iterator it = affects_.begin();
589  while (it != affects_.end()) {
591  affectsChild->setAttribute(Operation::OPRN_NAME, *it);
592  affects->addChild(affectsChild);
593  it++;
594  }
595  root->addChild(affects);
596  }
597 
598  for (unsigned int i = 0; i < inputOperands_.size(); i++) {
599  ObjectState* operand = inputOperands_[i]->saveState();
600  operand->setName(Operation::OPRN_IN);
601  root->addChild(operand);
602  }
603 
604  for (unsigned int i = 0; i < outputOperands_.size(); i++) {
605  ObjectState* operand = outputOperands_[i]->saveState();
606  operand->setName(Operation::OPRN_OUT);
607  root->addChild(operand);
608  }
609 
610  for (int i = 0; i < dagCount(); i++) {
612  trigger->setValue(dagCode(i));
613  root->addChild(trigger);
614  }
615 
616  return root;
617 }
618 
619 void
621  inputOperands_.push_back(operand);
622  inputs_ = inputOperands_.size();
623 }
624 
625 void
627  outputOperands_.push_back(operand);
628  outputs_ = outputOperands_.size();
629 }
630 
631 /**
632  * Returns the output Operand with the given index.
633  *
634  * This method can be used to traverse the list of output operands
635  * (the max index is numberOfOutput() - 1).
636  *
637  * @param index The index of Operand.
638  */
639 Operand&
640 OperationPimpl::output(int index) const {
641  return *outputOperands_.at(index);
642 }
643 
644 /**
645  * Returns the Operand with the given id if found, otherwise null Operand.
646  *
647  * @note This method is used to fetch operands with their 'id', the number
648  * which identifies it to the programmer. That is, output ids start from
649  * the last input id + 1, etc.
650  *
651  * @param id The id of Operand.
652  * @return Operand if found, null Operand otherwise.
653  */
654 Operand&
655 OperationPimpl::operand(int id) const {
656  assert(id != 0);
658  if (&op == &NullOperand::instance()) {
659  return fetchOperand(id, outputOperands_);
660  }
661  return op;
662 }
663 
664 /**
665  * Returns an operand with a certain id if it exists.
666  *
667  * If operand is not found, a null operand is returned.
668  *
669  * @param id The id of an operand.
670  * @param ops Vector where operand is searched.
671  * @return Operand with a certain id.
672  */
673 Operand&
674 OperationPimpl::fetchOperand(int id, const std::vector<Operand*>& ops) const {
675  assert(id != 0);
676 
677  for (std::vector<Operand*>::const_iterator i = ops.begin(); i != ops.end();
678  ++i) {
679  if ((*i)->index() == id) {
680  return **i;
681  }
682  }
683 
684  return NullOperand::instance();
685 }
686 
687 /**
688  * Returns an operand with a certain id if it exists.
689  *
690  * If operand is not found, NullOperand is returned.
691  *
692  * @param id Id of the operand.
693  * @return Operand with a certain id.
694  */
695 Operand&
697  assert(id != 0);
698 
699  for (unsigned int i = 0; i < inputOperands_.size(); i++) {
700  if (inputOperands_[i]->index() == id) {
701  return *inputOperands_[i];
702  }
703  }
704 
705  for (unsigned int i = 0; i < outputOperands_.size(); i++) {
706  if (outputOperands_[i]->index() == id) {
707  return *outputOperands_[i];
708  }
709  }
710 
711  return NullOperand::instance();
712 }
713 
714 /**
715  * Inserts operand to the right place.
716  *
717  * Operands are inserted according to their indexes.
718  *
719  * @param operand Operand to be inserted.
720  * @param ops Vector in which operand is inserted.
721  */
722 void
723 OperationPimpl::insertOperand(Operand* operand, std::vector<Operand*>& ops) {
724 
725  vector<Operand*>::iterator it = ops.begin();
726  bool inserted = false;
727  while (it != ops.end()) {
728  if ((*it)->index() > operand->index()) {
729  inserted = true;
730  ops.insert(it, operand);
731  break;
732  }
733  it++;
734  }
735  if (!inserted) {
736  ops.push_back(operand);
737  }
738 }
739 
740 /**
741  * Simulates the process of starting execution of an operation.
742  *
743  * @param io The input and output operands.
744  * @param context The operation context.
745  * @return True, if all values could be computed, false otherwise.
746  * @exception Exception Depends on the operation behavior.
747  *
748  */
749 bool
751  SimValue** io,
752  OperationContext& context) const {
753 
754  return behavior_->simulateTrigger(io, context);
755 }
756 
757 /**
758  * Creates an instance of operation state for this operation and adds it to
759  * the operation context.
760  *
761  * @param context The operation context to add the state in.
762  */
763 void
765  behavior_->createState(context);
766 }
767 
768 /**
769  * Deletes an instance of operation state for this operation from the
770  * operation context.
771  *
772  * @param context The operation context to delete the state from.
773  */
774 void
776  behavior_->deleteState(context);
777 }
778 
779 /**
780  * Returns true if this operation has behavior, or dag which is
781  * simulateable (doesn't contain infinite recursion loop).
782  *
783  * @return True if this operation has behavior, or dag which is
784  */
785 bool
787  return behavior_->canBeSimulated();
788 }
789 
790 
791 std::string
793  switch (type) {
794  case Operand::SINT_WORD:
795  return "i32";
796  case Operand::UINT_WORD:
797  return "i32";
799  return "f16";
800  case Operand::FLOAT_WORD:
801  return "f32";
803  return "f64";
804  case Operand::SLONG_WORD:
805  case Operand::ULONG_WORD:
806  return "i64";
807  default:
808  return "Unknown";
809  }
810 }
811 
812 /**
813  * Name of emulation function which is called if the operation is emulated
814  * in program.
815  *
816  * @return Name of emulation function of the instruction.
817  */
818 TCEString
820  std::string functionName;
821 
822  functionName = "__emulate_" + std::string(name()) +
825 
826  for (int i = 1; i <= numberOfInputs(); i++) {
827  Operand& oper = operand(i);
828  functionName += "_" + llvmOperandType(oper.type());
829  }
830 
831  for (int i = 1; i <= numberOfOutputs(); i++) {
832  Operand& oper = operand(numberOfInputs() + i);
833  functionName += "_" + llvmOperandType(oper.type());
834  }
835 
836  return functionName;
837 }
838 
839 /**
840  * Sets property of operation indicating that the operation is changing
841  * control flow.
842  */
843 void
845  controlFlowOperation_ = setting;
846 }
847 
848 /**
849  * Sets property of operation indicating that the operation is function call.
850  */
851 void
852 OperationPimpl::setCall(bool setting) {
853  isCall_ = setting;
854 }
855 
856 /**
857  * Sets property of operation indicating that the operation is branch changing
858  * control flow.
859  */
860 void
862  isBranch_ = setting;
863 }
864 
865 /**
866  * Specifies if operation reads memory.
867  */
868 void
870  readsMemory_ = setting;
871 }
872 
873 /**
874  * Specifies if operation writes memory.
875  */
876 void
878  writesMemory_ = setting;
879 }
Operand
Definition: Operand.hh:52
OperationPimpl::~OperationPimpl
~OperationPimpl()
Definition: OperationPimpl.cc:80
OperationPimpl::affects_
std::set< std::string > affects_
Operations that affects this Operation.
Definition: OperationPimpl.hh:180
OperationPimpl::hasSideEffects
bool hasSideEffects() const
Definition: OperationPimpl.cc:268
OperationPimpl::setBranch
void setBranch(bool setting)
Definition: OperationPimpl.cc:861
OperationBehavior::canBeSimulated
virtual bool canBeSimulated() const
Definition: OperationBehavior.cc:162
OperationPimpl::name
TCEString name() const
Definition: OperationPimpl.cc:121
OperationPimpl::dagError
TCEString dagError(int index) const
Definition: OperationPimpl.cc:248
OperationPimpl::affectedByCount
int affectedByCount() const
Definition: OperationPimpl.cc:353
OperationDAG::isNull
bool isNull() const
Definition: OperationDAG.hh:48
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
OperationPimpl::loadState
void loadState(const ObjectState *state)
Definition: OperationPimpl.cc:453
OperationPimpl::clear
void clear()
Definition: OperationPimpl.cc:88
Operand::OperandType
OperandType
Definition: Operand.hh:58
Operand::HALF_FLOAT_WORD
@ HALF_FLOAT_WORD
Definition: Operand.hh:63
ObjectStateLoadingException
Definition: Exception.hh:551
OperationPimpl::addInput
void addInput(Operand *operand)
Definition: OperationPimpl.cc:620
OperationPimpl::OperationPimpl
OperationPimpl()
Operation::OPRN_IN
static const char * OPRN_IN
Object state name for input operand.
Definition: Operation.hh:91
OperationDAGConverter.hh
OperationPimpl::OperationDAGInfo::dag
OperationDAG * dag
DAG presentation of code. set to NullOperationDAG if could not be created.
Definition: OperationPimpl.hh:142
OperationContext
Definition: OperationContext.hh:56
OperationPimpl::isCall
bool isCall() const
Definition: OperationPimpl.cc:302
OutOfRange
Definition: Exception.hh:320
OperationPimpl::isControlFlowOperation
bool isControlFlowOperation() const
Definition: OperationPimpl.cc:290
SequenceTools.hh
OperationPimpl::isClocked
bool isClocked() const
Definition: OperationPimpl.cc:278
OperationPimpl::canTrap
bool canTrap() const
Definition: OperationPimpl.cc:258
OperationPimpl::setCall
void setCall(bool setting)
Definition: OperationPimpl.cc:852
Operand::UINT_WORD
@ UINT_WORD
Definition: Operand.hh:60
OperationPimpl::inputs_
int inputs_
The number of inputs of the Operation.
Definition: OperationPimpl.hh:164
Operation::OPRN_NAME
static const char * OPRN_NAME
Object state name for name.
Definition: Operation.hh:67
Exception::setCause
void setCause(const Exception &cause)
Definition: Exception.cc:75
ObjectState
Definition: ObjectState.hh:59
NullOperand::instance
static NullOperand & instance()
Operation::OPRN_AFFECTS
static const char * OPRN_AFFECTS
Object state name for affects.
Definition: Operation.hh:87
OperationDAG::null
static OperationDAG null
Definition: OperationDAG.hh:47
OperationPimpl::addOutput
void addOutput(Operand *operand)
Definition: OperationPimpl.cc:626
OperationPimpl::affectedBy_
std::set< std::string > affectedBy_
Operations that are affected by this Operation.
Definition: OperationPimpl.hh:182
OperationPimpl::emulationFunctionName
TCEString emulationFunctionName() const
Definition: OperationPimpl.cc:819
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
OperationPimpl::canTrap_
bool canTrap_
Flag indicating if Operation can trap.
Definition: OperationPimpl.hh:172
Operation::OPRN_AFFECTED_BY
static const char * OPRN_AFFECTED_BY
Object state name for affected by.
Definition: Operation.hh:89
Conversion::toString
static std::string toString(const T &source)
OperationBehavior::createState
virtual void createState(OperationContext &context) const
Definition: OperationBehavior.cc:127
SimValue
Definition: SimValue.hh:96
OperationPimpl::outputs_
int outputs_
The number of outputs of the Operation.
Definition: OperationPimpl.hh:166
OperationPimpl::name_
std::string name_
Name of the Operation.
Definition: OperationPimpl.hh:157
OperationPimpl::dagCode
TCEString dagCode(int index) const
Definition: OperationPimpl.cc:220
OperationBehavior::simulateTrigger
virtual bool simulateTrigger(SimValue **io, OperationContext &context) const =0
Definition: OperationBehavior.cc:83
TCEString.hh
StringTools::stringToUpper
static std::string stringToUpper(const std::string &source)
Definition: StringTools.cc:143
OperationPimpl::dagCount
int dagCount() const
Definition: OperationPimpl.cc:172
OperationPimpl::outputOperands_
std::vector< Operand * > outputOperands_
Output Operands of the Operation.
Definition: OperationPimpl.hh:186
StringTools.hh
OperationPimpl::numberOfOutputs
int numberOfOutputs() const
assert
#define assert(condition)
Definition: Application.hh:86
Operation::OPRN_CONTROL_FLOW
static const char * OPRN_CONTROL_FLOW
Object state name for control flow property.
Definition: Operation.hh:81
OperationPimpl::OperationDAGInfo
Definition: OperationPimpl.hh:133
OperationPimpl::setControlFlowOperation
void setControlFlowOperation(bool setting)
Definition: OperationPimpl.cc:844
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
OperationPimpl::isClocked_
bool isClocked_
Flag indicating if Operation is clocked and needs AdvanceClock.
Definition: OperationPimpl.hh:176
Operation::OPRN_DESCRIPTION
static const char * OPRN_DESCRIPTION
Object state name for description.
Definition: Operation.hh:69
OperationPimpl::saveState
ObjectState * saveState() const
Definition: OperationPimpl.cc:557
IllegalParameters
Definition: Exception.hh:113
OperationPimpl::setBehavior
void setBehavior(OperationBehavior &behavior)
Definition: OperationPimpl.cc:323
Operation::OPRN_TRAP
static const char * OPRN_TRAP
Object state name for trap.
Definition: Operation.hh:75
Operation::OPRN_TRIGGER
static const char * OPRN_TRIGGER
Object state name for trigger semantics.
Definition: Operation.hh:95
Operand::canSwap
virtual bool canSwap(const Operand &op) const
Definition: Operand.cc:372
OperationPimpl::output
Operand & output(int index) const
Definition: OperationPimpl.cc:640
Operand::SLONG_WORD
@ SLONG_WORD
Definition: Operand.hh:66
OperationPimpl::OperationDAGInfo::code
std::string code
Source code for creating DAG for operation.
Definition: OperationPimpl.hh:135
OperationDAG.hh
Application.hh
OperationDAG
Definition: OperationDAG.hh:43
Operation::OPRN_OPERATION
static const char * OPRN_OPERATION
Object state name for operation.
Definition: Operation.hh:65
Operation::OPRN_CLOCKED
static const char * OPRN_CLOCKED
Object state name for clockedness.
Definition: Operation.hh:79
ObjectState.hh
Operand::FLOAT_WORD
@ FLOAT_WORD
Definition: Operand.hh:61
Operation::OPRN_ISCALL
static const char * OPRN_ISCALL
Object state name for call property.
Definition: Operation.hh:97
Operand::index
virtual int index() const
Definition: Operand.cc:135
llvmOperandType
std::string llvmOperandType(Operand::OperandType type)
Definition: OperationPimpl.cc:792
OperationPimpl::writesMemory_
bool writesMemory_
Flag indicating if Operation writes to memory.
Definition: OperationPimpl.hh:170
ObjectState::child
ObjectState * child(int index) const
Definition: ObjectState.cc:471
OperationPimpl::simulateTrigger
bool simulateTrigger(SimValue **, OperationContext &context) const
Definition: OperationPimpl.cc:750
ObjectState::addChild
void addChild(ObjectState *child)
Definition: ObjectState.cc:376
Operation.hh
OperationPimpl::affects
TCEString affects(unsigned int i) const
Definition: OperationPimpl.cc:364
OperationPimpl::setReadsMemory
void setReadsMemory(bool setting)
Definition: OperationPimpl.cc:869
Operation::OPRN_WRITES_MEMORY
static const char * OPRN_WRITES_MEMORY
Object state name for writes memory.
Definition: Operation.hh:85
ObjectState::childCount
int childCount() const
OperationPimpl::operand
Operand & operand(int id) const
Definition: OperationPimpl.cc:655
StringTools
Definition: StringTools.hh:44
OperationPimpl.hh
Operand::SINT_WORD
@ SINT_WORD
Definition: Operand.hh:59
Operation::OPRN_READS_MEMORY
static const char * OPRN_READS_MEMORY
Object state name for reads memory.
Definition: Operation.hh:83
Exception
Definition: Exception.hh:54
OperationPimpl::createState
void createState(OperationContext &context) const
Definition: OperationPimpl.cc:764
Operand::ULONG_WORD
@ ULONG_WORD
Definition: Operand.hh:67
ObjectState::name
std::string name() const
OperationPimpl::behavior
OperationBehavior & behavior() const
Definition: OperationPimpl.cc:333
Operation
Definition: Operation.hh:59
Operation::OPRN_OUT
static const char * OPRN_OUT
Object state name for output operand.
Definition: Operation.hh:93
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
Operation::OPRN_INPUTS
static const char * OPRN_INPUTS
Object state name for inputs.
Definition: Operation.hh:71
OperationPimpl::dags_
DAGContainer dags_
Table of DAGs and their source codes of an operation.
Definition: OperationPimpl.hh:161
OperationPimpl::insertOperand
void insertOperand(Operand *operand, std::vector< Operand * > &ops)
Definition: OperationPimpl.cc:723
Operation::OPRN_SIDE_EFFECTS
static const char * OPRN_SIDE_EFFECTS
Object state name for side effects.
Definition: Operation.hh:77
Operand::DOUBLE_WORD
@ DOUBLE_WORD
Definition: Operand.hh:62
OperationBehavior.hh
OperationBehavior
Definition: OperationBehavior.hh:53
Operand::type
virtual OperandType type() const
Definition: Operand.cc:165
false
find Finds info of the inner loops in the false
Definition: InnerLoopFinder.cc:81
OperationBehavior::deleteState
virtual void deleteState(OperationContext &context) const
Definition: OperationBehavior.cc:141
TCEString
Definition: TCEString.hh:53
ObjectState::boolAttribute
bool boolAttribute(const std::string &name) const
Definition: ObjectState.cc:338
OperationPimpl::fetchOperand
Operand & fetchOperand(int id, const std::vector< Operand * > &ops) const
Definition: OperationPimpl.cc:674
OperationPimpl::behavior_
OperationBehavior * behavior_
The behavior of the Operation.
Definition: OperationPimpl.hh:155
OperationPimpl::removeDag
void removeDag(int index)
Definition: OperationPimpl.cc:154
OperationPimpl::isBranch_
bool isBranch_
Flag indicating if Operation is branch changing control flow.
Definition: OperationPimpl.hh:190
ObjectState::stringValue
std::string stringValue() const
OperationPimpl::inputOperands_
std::vector< Operand * > inputOperands_
Input Operands of the Operation.
Definition: OperationPimpl.hh:184
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
OperationPimpl::dependsOn
bool dependsOn(const Operation &op) const
Definition: OperationPimpl.cc:413
OperationPimpl::dag
OperationDAG & dag(int index) const
Definition: OperationPimpl.cc:186
OperationPimpl::canSwap
bool canSwap(int id1, int id2) const
Definition: OperationPimpl.cc:435
OperationPimpl::affectedBy
TCEString affectedBy(unsigned int i) const
Definition: OperationPimpl.cc:389
OperationPimpl::OperationDAGInfo::compilationFailed
bool compilationFailed
If code was already tried to compile and it did not succeed.
Definition: OperationPimpl.hh:139
OperationPimpl::affectsCount
int affectsCount() const
Definition: OperationPimpl.cc:343
OperationPimpl::readsMemory_
bool readsMemory_
Flag indicating if Operation reads from memory.
Definition: OperationPimpl.hh:168
OperationPimpl::canBeSimulated
bool canBeSimulated() const
Definition: OperationPimpl.cc:786
OperationPimpl::description_
std::string description_
Description of the Operation.
Definition: OperationPimpl.hh:159
OperationPimpl::isBranch
bool isBranch() const
Definition: OperationPimpl.cc:313
OperationPimpl::hasSideEffects_
bool hasSideEffects_
Flag indicating if Operation has side effects.
Definition: OperationPimpl.hh:174
OperationPimpl::addDag
void addDag(const TCEString &code)
Definition: OperationPimpl.cc:140
OperationPool.hh
ObjectState::setValue
void setValue(const std::string &value)
Operation::OPRN_ISBRANCH
static const char * OPRN_ISBRANCH
Object state name for branch property.
Definition: Operation.hh:99
Operation::OPRN_OUTPUTS
static const char * OPRN_OUTPUTS
Object state name for outputs.
Definition: Operation.hh:73
OperationPimpl::controlFlowOperation_
bool controlFlowOperation_
Flag indicating if the Operation can change program flow.
Definition: OperationPimpl.hh:178
OperationPimpl::description
TCEString description() const
Definition: OperationPimpl.cc:131
OperationPimpl::setWritesMemory
void setWritesMemory(bool setting)
Definition: OperationPimpl.cc:877
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100
OperationDAGConverter::createDAG
static OperationDAG * createDAG(const OperationPimpl &operation, std::string sourceCode)
Definition: OperationDAGConverter.cc:61
Operand::loadState
virtual void loadState(const ObjectState *state)
Definition: Operand.cc:383
OperationPimpl::deleteState
void deleteState(OperationContext &context) const
Definition: OperationPimpl.cc:775
ContainerTools.hh
OperationPimpl::isCall_
bool isCall_
Flag indicating if Operation is call.
Definition: OperationPimpl.hh:188
OperationPimpl::setDagCode
void setDagCode(int index, const TCEString &code)
Definition: OperationPimpl.cc:232
OperationPimpl::numberOfInputs
int numberOfInputs() const