OpenASIP 2.2
Loading...
Searching...
No Matches
Classes | Functions
DictionaryTool.cc File Reference
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "ADFSerializer.hh"
#include "Application.hh"
#include "Machine.hh"
#include "ProgrammabilityValidator.hh"
#include "ProgrammabilityValidatorResults.hh"
#include "CmdLineOptions.hh"
#include "Exception.hh"
#include "Binary.hh"
#include "TPEFWriter.hh"
#include "TPEFProgramFactory.hh"
#include "ProgramWriter.hh"
#include "BinaryStream.hh"
#include "MoveElement.hh"
#include "tce_config.h"
Include dependency graph for DictionaryTool.cc:

Go to the source code of this file.

Classes

class  DictionaryToolCmdLineOptions
 

Functions

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

Detailed Description

DictionaryTool main application.

Author
Jari M�ntyneva 2006 (jari.mantyneva-no.spam-tut.fi)
Note
rating: red

Definition in file DictionaryTool.cc.

Function Documentation

◆ main()

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

The dictionary_tool main function.

Definition at line 162 of file DictionaryTool.cc.

162 {
163
165
166 try {
167 options.parse(argv, argc);
168 } catch (ParserStopRequest const&) {
169 return EXIT_SUCCESS;
170 } catch (const IllegalCommandLine& e) {
171 cerr << e.errorMessage() << endl;
172 return EXIT_FAILURE;
173 }
174
175 if (options.numberOfArguments() == 0) {
177 return EXIT_SUCCESS;
178 } else if (options.numberOfArguments() > 1) {
179 cerr << "Illegal number of arguments" << endl;
180 return EXIT_FAILURE;
181 }
182
183 string adfFileName = options.argument(1);
184
185 ADFSerializer adfSerializer;
186 adfSerializer.setSourceFile(adfFileName);
187
189
190 try {
191 mach = adfSerializer.readMachine();
192 } catch (...) {
193 cout.flush();
194 cerr << "Error opening ADF file:" << endl
195 << "- Is the filename correct?" << endl
196 << "- Is the machine legal?" << endl;
197 return EXIT_FAILURE;
198 }
199
200 ProgrammabilityValidator* validator;
201
202 try {
203 validator = new ProgrammabilityValidator(*mach);
204 } catch (IllegalMachine& e) {
205 cerr << e.errorMessage() << endl;
206 return EXIT_FAILURE;
207 }
208
209 ProgrammabilityValidatorResults booleanResults;
210 validator->checkBooleanRegister(booleanResults);
211 if (booleanResults.errorCount() != 0) {
212 for (int i = 0; i < booleanResults.errorCount(); i++) {
214 booleanResults.error(i);
215
216 cerr << error.second << endl;
217 }
218 cerr << "Execution stopped." << endl;
219 return EXIT_SUCCESS;
220 }
221
222 bool gcrError = false;
223
225 TPEF::Binary* binaryProgram = NULL;
226 try {
227 binaryProgram = validator->profile(results);
228 } catch (NotAvailable& e) {
229 cerr << e.errorMessage() << endl;
230 cerr << "Check that all operations are found in OSAL." << endl;
231 cerr << "Create new ones with OSEd." << endl;
232 cerr << "Execution stopped." << endl;
233 return EXIT_FAILURE;
234 } catch (InstanceNotFound& e) {
235 cerr << e.errorMessage() << endl;
236 }
237
238 if (options.writeBinary()) {
239 string outputFile = adfFileName.append("_profiled.tpef");
240 BinaryStream tpefOut(outputFile);
241 TPEFWriter::instance().writeBinary(tpefOut, binaryProgram);
242 }
243
244 if (!options.doNotPrintErrors()) {
245 for (int i = 0; i < results.errorCount(); i++) {
247 if (error.first ==
249 OPERATION_MISSING_FROM_THE_PRIMITIVE_OPERATION_SET) {
250 if (options.printPrimitive()) {
251 cerr << error.second << endl;
252 }
253 }
254 else if (error.first ==
256 GLOBAL_CONNECTION_REGISTER_NOT_FOUND) {
257 if (options.printGlobalRegister()) {
258 gcrError = true;
259 cerr << error.second << endl;
260 }
261 }
262 else if (error.first ==
264 MISSING_CONNECTION) {
265 if (options.printMissingConnections()) {
266 cerr << error.second << endl;
267 }
268 }
269 else {
270 cerr << error.second << endl;
271 }
272 }
273 }
274
275 if (options.printGlobalRegister() && !gcrError) {
276 cout << "* The global connection register in the machine is: "
277 << validator->findGlobalConnectionRegister()->name()
278 << endl;
279 }
280
281 if (options.printConnections()) {
282 validator->printConnections();
283 }
284
285 if (options.printRFConnections()) {
286 validator->printRegisterConnections();
287 }
288
289 return EXIT_SUCCESS;
290}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
TTAMachine::Machine * readMachine()
void parse(char *argv[], int argc)
virtual std::string argument(int index) const
virtual int numberOfArguments() const
std::string errorMessage() const
Definition Exception.cc:123
virtual void printHelp() const
std::pair< ProgrammabilityValidator::ErrorCode, std::string > Error
Typedef for an error (error code + error message).
bool checkBooleanRegister(ProgrammabilityValidatorResults &results)
const RegisterFile * findGlobalConnectionRegister()
TPEF::Binary * profile(ProgrammabilityValidatorResults &results)
void writeBinary(BinaryStream &stream, const Binary *bin) const
static const BinaryWriter & instance()
Definition TPEFWriter.cc:70
virtual TCEString name() const
void setSourceFile(const std::string &fileName)

References CmdLineParser::argument(), ProgrammabilityValidator::checkBooleanRegister(), ProgrammabilityValidatorResults::error(), ProgrammabilityValidatorResults::errorCount(), Exception::errorMessage(), ProgrammabilityValidator::findGlobalConnectionRegister(), TPEF::TPEFWriter::instance(), TTAMachine::Component::name(), CmdLineParser::numberOfArguments(), options, CmdLineOptions::parse(), ProgrammabilityValidator::printConnections(), MachInfoCmdLineOptions::printHelp(), ProgrammabilityValidator::printRegisterConnections(), ProgrammabilityValidator::profile(), ADFSerializer::readMachine(), XMLSerializer::setSourceFile(), and TPEF::BinaryWriter::writeBinary().

Here is the call graph for this function: