OpenASIP  2.0
Functions
ExtensionGen.cc File Reference
#include <iostream>
#include <fstream>
#include <set>
#include <assert.h>
#include <boost/format.hpp>
#include "OperationPool.hh"
#include "Operation.hh"
#include "Conversion.hh"
#include "OperationIndex.hh"
#include "Operand.hh"
#include "Machine.hh"
#include "StringTools.hh"
#include "HWOperation.hh"
Include dependency graph for ExtensionGen.cc:

Go to the source code of this file.

Functions

std::string operandTypeCString (const Operand &operand)
 
void generateHeader (std::ostream &stream, const TTAMachine::Machine &machine)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ generateHeader()

void generateHeader ( std::ostream &  stream,
const TTAMachine::Machine machine 
)

Writes the macros that can be written to the tceoclext.h header file to stdout.

Following macros are produced for all operations found in the given machine (for example, in case of ADDSUB):

#define cl_TCE_ADDSUB #define clADDSUBTCE _TCE_ADDSUB

Thus, it's possible to figure out whether ADDSUB is implemented in the machine using the first define and actually call the ADDSUB with the latter.

Definition at line 86 of file ExtensionGen.cc.

86  {
87  std::set<std::string> opNames;
88 
91 
92  for (int i = 0; i < fuNav.count(); i++) {
93  const TTAMachine::FunctionUnit* fu = fuNav.item(i);
94  for (int o = 0; o < fu->operationCount(); o++) {
95  const std::string opName = fu->operation(o)->name();
96  opNames.insert(StringTools::stringToUpper(opName));
97  }
98  }
99  stream
100  << "// automatically generated by tceoclextgen" << std::endl
101  << std::endl;
102 
103  for (std::set<std::string>::const_iterator i = opNames.begin();
104  i != opNames.end(); ++i) {
105  std::string name = (*i);
106  stream
107  << (boost::format(
108  "#define cl_TCE_%s\n"
109  "#define cl%sTCE _TCE_%s\n\n")
110  % name % name % name).str();
111  }
112 }

References TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine, TTAMachine::HWOperation::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), and StringTools::stringToUpper().

Referenced by main().

Here is the call graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 114 of file ExtensionGen.cc.

114  {
115 
116  if (argc != 2) {
117  std::cout << "Usage: tceoclextgen ADF" << std::endl;
118  return EXIT_FAILURE;
119  }
120 
121  try {
124  generateHeader(std::cout, *machine);
125 
126  delete machine; machine = NULL;
127  } catch (const Exception& e) {
128  std::cerr << e.errorMessage() << std::endl;
129  return EXIT_FAILURE;
130  }
131  return EXIT_SUCCESS;
132 }

References Exception::errorMessage(), generateHeader(), TTAMachine::Machine::loadFromADF(), and machine.

Here is the call graph for this function:

◆ operandTypeCString()

std::string operandTypeCString ( const Operand operand)

Generates OpenCL C extension functions and definitions for the (custom) operations in the given ADF.

Author
Pekka Jääskeläinen 2009 (pjaaskel-no.spam-cs.tut.fi)
Note
rating: red Returns a C type string for the given operand type.

Definition at line 53 of file ExtensionGen.cc.

53  {
54  switch (operand.type()) {
55  default:
56  case Operand::SINT_WORD:
57  return "int";
58  break;
59  case Operand::UINT_WORD:
60  return "unsigned";
61  break;
63  return"float";
64  break;
66  return "double";
67  break;
68  }
69  return "unsigned"; // a good guess ;)
70 }

References Operand::DOUBLE_WORD, Operand::FLOAT_WORD, Operand::SINT_WORD, Operand::type(), and Operand::UINT_WORD.

Here is the call graph for this function:
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
Operand::UINT_WORD
@ UINT_WORD
Definition: Operand.hh:60
TTAMachine::Machine::Navigator::count
int count() const
StringTools::stringToUpper
static std::string stringToUpper(const std::string &source)
Definition: StringTools.cc:143
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
Operand::FLOAT_WORD
@ FLOAT_WORD
Definition: Operand.hh:61
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
Operand::SINT_WORD
@ SINT_WORD
Definition: Operand.hh:59
Exception
Definition: Exception.hh:54
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
Operand::DOUBLE_WORD
@ DOUBLE_WORD
Definition: Operand.hh:62
Operand::type
virtual OperandType type() const
Definition: Operand.cc:165
generateHeader
void generateHeader(std::ostream &stream, const TTAMachine::Machine &machine)
Definition: ExtensionGen.cc:86
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAMachine::Machine
Definition: Machine.hh:73
TTAMachine::Machine::loadFromADF
static Machine * loadFromADF(const std::string &adfFileName)
Definition: Machine.cc:905