OpenASIP 2.2
Loading...
Searching...
No Matches
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}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
static std::string stringToUpper(const std::string &source)
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
const std::string & name() const
ComponentType * item(int index) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380

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}
void generateHeader(std::ostream &stream, const TTAMachine::Machine &machine)
std::string errorMessage() const
Definition Exception.cc:123
static Machine * loadFromADF(const std::string &adfFileName)
Definition Machine.cc:899

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:
57 return "int";
58 break;
60 return "unsigned";
61 break;
63 return"float";
64 break;
66 return "double";
67 break;
68 }
69 return "unsigned"; // a good guess ;)
70}
virtual OperandType type() const
Definition Operand.cc:165
@ FLOAT_WORD
Definition Operand.hh:61
@ SINT_WORD
Definition Operand.hh:59
@ DOUBLE_WORD
Definition Operand.hh:62
@ UINT_WORD
Definition Operand.hh:60

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

Here is the call graph for this function: