OpenASIP  2.0
DefaultCompressor.hh
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 DefaultCompressor.hh
26  *
27  * Declaration and implementation of DefaultCompressor class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include "CodeCompressor.hh"
34 #include "Program.hh"
35 #include "NullInstruction.hh"
36 #include "TCEString.hh"
37 
40 
42 public:
44 
45  virtual InstructionBitVector*
46  compress(const std::string& programName) {
47  try {
48  startNewProgram(programName);
50  Instruction* instruction = &currentProgram().firstInstruction();
51  while (instruction != &NullInstruction::instance()) {
52  InstructionBitVector* instructionBits = bemInstructionBits(
53  *instruction);
54  addInstruction(*instruction, instructionBits);
55  instruction =
56  &currentProgram().nextInstruction(*instruction);
57  }
58 
59  return programBits();
60  } catch (const Exception& e) {
61  throw InvalidData(
62  __FILE__, __LINE__, __func__, e.errorMessage());
63  }
64  }
65 
66  virtual void
67  printDescription(std::ostream& stream) {
68  stream << "Does not compress instructions at all." << std::endl;
69  }
70 
71  virtual void
72  generateDecompressor(std::ostream&, TCEString) {}
73 };
74 
TTAProgram::Program::firstInstruction
Instruction & firstInstruction() const
Definition: Program.cc:353
TTAProgram::NullInstruction
Definition: NullInstruction.hh:45
TTAProgram::Program::nextInstruction
Instruction & nextInstruction(const Instruction &) const
Definition: Program.cc:403
TTAProgram::Instruction
Definition: Instruction.hh:57
DEFAULT_Compressor::printDescription
virtual void printDescription(std::ostream &stream)
Definition: DefaultCompressor.hh:67
CodeCompressor.hh
CodeCompressorPlugin::addInstruction
void addInstruction(const TTAProgram::Instruction &instruction, InstructionBitVector *bits)
Definition: CodeCompressorPlugin.cc:384
TCEString.hh
InvalidData
Definition: Exception.hh:149
CodeCompressorPlugin::bemInstructionBits
InstructionBitVector * bemInstructionBits(const TTAProgram::Instruction &)
Definition: CodeCompressorPlugin.cc:454
DEFAULT_Compressor::DEFAULT_Compressor
DEFAULT_Compressor()
Definition: DefaultCompressor.hh:43
NullInstruction.hh
__func__
#define __func__
Definition: Application.hh:67
CodeCompressorPlugin::startNewProgram
void startNewProgram(const std::string &programName)
Definition: CodeCompressorPlugin.cc:328
DEFAULT_Compressor::compress
virtual InstructionBitVector * compress(const std::string &programName)
Definition: DefaultCompressor.hh:46
Exception
Definition: Exception.hh:54
CodeCompressorPlugin::currentProgram
TTAProgram::Program & currentProgram() const
Definition: CodeCompressorPlugin.cc:295
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
DEFAULT_Compressor
Definition: DefaultCompressor.hh:41
Program.hh
EXPORT_CODE_COMPRESSOR
#define EXPORT_CODE_COMPRESSOR(PLUGIN_NAME__)
Definition: CodeCompressor.hh:42
CodeCompressorPlugin
Definition: CodeCompressorPlugin.hh:84
TCEString
Definition: TCEString.hh:53
DEFAULT_Compressor::generateDecompressor
virtual void generateDecompressor(std::ostream &, TCEString)
Definition: DefaultCompressor.hh:72
CodeCompressorPlugin::setAllInstructionsToStartAtBeginningOfMAU
void setAllInstructionsToStartAtBeginningOfMAU()
Definition: CodeCompressorPlugin.cc:440
CodeCompressorPlugin::programBits
InstructionBitVector * programBits() const
Definition: CodeCompressorPlugin.cc:533
InstructionBitVector
Definition: InstructionBitVector.hh:50