OpenASIP  2.0
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
CodeCompressorPlugin Class Referenceabstract

#include <CodeCompressorPlugin.hh>

Inheritance diagram for CodeCompressorPlugin:
Inheritance graph
Collaboration diagram for CodeCompressorPlugin:
Collaboration graph

Classes

struct  Parameter
 Parameter struct. More...
 

Public Types

typedef std::vector< ParameterParameterTable
 Table for passing plugin parameters. More...
 

Public Member Functions

virtual ~CodeCompressorPlugin ()
 
void setParameters (ParameterTable parameters)
 
void setPrograms (std::map< std::string, TPEF::Binary * > &programs)
 
void setMachine (const TTAMachine::Machine &machine)
 
void setBEM (const BinaryEncoding &bem)
 
const BinaryEncodingbinaryEncoding () const
 
const TTAMachine::Machinemachine () const
 
virtual InstructionBitVectorcompress (const std::string &program)=0
 
virtual void generateDecompressor (std::ostream &stream, TCEString entityStr)=0
 
virtual void printDescription (std::ostream &stream)=0
 
unsigned int memoryAddress (const TTAProgram::Instruction &instruction) const
 
TTAProgram::ProgramcurrentProgram () const
 
int imemMauWidth () const
 
InstructionBitVectorbemInstructionBits (const TTAProgram::Instruction &)
 

Protected Types

typedef std::map< std::string, TPEF::Binary * > TPEFMap
 Map type for handling programs. More...
 

Protected Member Functions

 CodeCompressorPlugin ()
 
InstructionBitVectorbemBits (const TTAProgram::Program &program)
 
int moveSlotCount () const
 
int moveSlotWidth (int index) const
 
int firstMoveSlotIndex () const
 
void startNewProgram (const std::string &programName)
 
void addInstruction (const TTAProgram::Instruction &instruction, InstructionBitVector *bits)
 
void setInstructionToStartAtBeginningOfMAU (const TTAProgram::Instruction &instruction)
 
void setAllInstructionsToStartAtBeginningOfMAU ()
 
InstructionBitVectorprogramBits () const
 
bool hasParameter (const std::string &paramName) const
 
std::string parameterValue (const std::string &paramName) const
 
void setImemWidth (int mau, int widthInMaus=1)
 
int numberOfPrograms () const
 
TPEFMap::const_iterator programElement (int index) const
 
std::string indentation (int level)
 

Private Types

typedef std::set< const TTAProgram::Instruction * > InstructionSet
 Set type for Instructions. More...
 
typedef std::set< const TTAProgram::Immediate * > ImmediateSet
 Set type for Immediates. More...
 
typedef std::set< const TTAProgram::Terminal * > TerminalSet
 Set type for Terminals. More...
 
typedef std::map< const TTAProgram::Immediate *, const TTAProgram::Instruction * > RelocMap
 Map type that maps Immediates to the Instructions they are referring to. More...
 
typedef std::map< const TTAProgram::Immediate *, std::vector< IndexBound > > IndexTable
 Map type that maps Immediates to a vector of indexes. More...
 
typedef std::map< const TTAProgram::Instruction *, unsigned int > InstructionAddressMap
 Map type for addresses of instructions. More...
 

Private Member Functions

void addBitsForICField (const ImmediateControlField &icField, const TTAProgram::Instruction &instruction, BitVector &bitVector) const
 
void addBitsForMoveSlot (const MoveSlot &slot, const TTAProgram::Instruction &instruction, InstructionBitVector &bitVector)
 
void addBitsForSourceField (const SourceField &srcField, const TTAProgram::Move &move, InstructionBitVector &bitVector) const
 
void addBitsForImmediateSlot (const ImmediateSlotField &immSlot, const TTAProgram::Instruction &instruction, BitVector &bitVector)
 
void addBitsForDstRegisterField (const LImmDstRegisterField &field, const TTAProgram::Instruction &instruction, BitVector &bitVector)
 
std::string instructionTemplate (const TTAProgram::Instruction &instruction) const
 
bool startsAtBeginningOfMAU (const TTAProgram::Instruction &instruction) const
 
unsigned int nextAddressablePositionFrom (unsigned int position) const
 
void encodeLongImmediate (const std::string &slotName, int slotWidth, const TTAProgram::Instruction &instruction, BitVector &bitVector)
 
void encodeMove (const MoveSlot &slot, const TTAProgram::Instruction &instruction, InstructionBitVector &bitVector) const
 
void encodeImmediateTerminal (const SourceField &field, const TTAProgram::Terminal &terminal, InstructionBitVector &bitVector) const
 
void initializeRelocations ()
 
TTAProgram::TerminalimmediateTerminal (const TPEF::CodeSection &codeSection, unsigned int elementIndex, const TPEF::ImmediateElement &immElem, const TTAProgram::Instruction &instruction) const
 
TTAProgram::ImmediateprogramImmediate (const TPEF::ImmediateElement &immElem, const TTAProgram::Instruction &instruction) const
 

Static Private Member Functions

static void addBitsForDestinationField (const DestinationField &dstField, const TTAProgram::Move &move, BitVector &bitVector)
 
static void addBitsForGuardField (const GuardField &guardField, const TTAProgram::Move &move, BitVector &bitVector)
 
static void encodeNOP (const MoveSlot &slot, BitVector &bitVector)
 
static void encodeIUTerminal (const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector)
 
static void encodeRFTerminal (const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector)
 
static void encodeFUTerminal (const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector)
 
static void encodeSlotField (const SlotField &field, const BitVector &componentIDBits, const BitVector &socketCodeBits, BitVector &BitVector)
 
static BitVector socketCodeBits (const SocketCodeTable &socketCodes, const PortCode &portCode, unsigned int registerIndex)
 
static void addBits (unsigned int number, int leftmostBit, int rightmostBit, BitVector &bitVector)
 

Private Attributes

TPEFMap tpefPrograms_
 Programs run in the machine. More...
 
TPEF::BinarycurrentTPEF_
 The current TPEF. More...
 
TTAProgram::ProgramcurrentPOM_
 The current program in POM. More...
 
std::string currentProgram_
 The current program. More...
 
const BinaryEncodingbem_
 The binary encoding map. More...
 
const TTAMachine::Machinemachine_
 The machine. More...
 
ParameterTable parameters_
 Parameters for the plugin. More...
 
InstructionBitVectorprogramBits_
 The bits of the program. More...
 
bool allStartsAtBeginningOfMAU_
 Tells whether all the instructions starts at the beginning of MAU. More...
 
int mau_
 The size of the minimum addressable unit. More...
 
int addressSpaceOffset_
 The offset of the instruction memory (the address of the first instruction). More...
 
InstructionSet instructionsAtBeginningOfMAU_
 Set of instructions that start at the beginning of MAU. More...
 
ImmediateSet immediatesToRelocate_
 Set of (long) immediates that refer to an instruction. More...
 
TerminalSet terminalsToRelocate_
 Set of (short) immediate terminals that refer to an instruction. More...
 
RelocMap relocMap_
 Contains information to which instructions the immediates are referring to. More...
 
IndexTable indexTable_
 A table of indexes used when encoding long immediates. More...
 
InstructionAddressMap instructionAddresses_
 Contains the addresses of instructions. More...
 

Detailed Description

The base class for different code compressors.

Definition at line 84 of file CodeCompressorPlugin.hh.

Member Typedef Documentation

◆ ImmediateSet

Set type for Immediates.

Definition at line 174 of file CodeCompressorPlugin.hh.

◆ IndexTable

typedef std::map<const TTAProgram::Immediate*, std::vector<IndexBound> > CodeCompressorPlugin::IndexTable
private

Map type that maps Immediates to a vector of indexes.

Definition at line 183 of file CodeCompressorPlugin.hh.

◆ InstructionAddressMap

typedef std::map<const TTAProgram::Instruction*, unsigned int> CodeCompressorPlugin::InstructionAddressMap
private

Map type for addresses of instructions.

Definition at line 186 of file CodeCompressorPlugin.hh.

◆ InstructionSet

Set type for Instructions.

Definition at line 172 of file CodeCompressorPlugin.hh.

◆ ParameterTable

Table for passing plugin parameters.

Definition at line 94 of file CodeCompressorPlugin.hh.

◆ RelocMap

Map type that maps Immediates to the Instructions they are referring to.

Definition at line 180 of file CodeCompressorPlugin.hh.

◆ TerminalSet

typedef std::set<const TTAProgram::Terminal*> CodeCompressorPlugin::TerminalSet
private

Set type for Terminals.

Definition at line 176 of file CodeCompressorPlugin.hh.

◆ TPEFMap

typedef std::map<std::string, TPEF::Binary*> CodeCompressorPlugin::TPEFMap
protected

Map type for handling programs.

Definition at line 138 of file CodeCompressorPlugin.hh.

Constructor & Destructor Documentation

◆ ~CodeCompressorPlugin()

CodeCompressorPlugin::~CodeCompressorPlugin ( )
virtual

The destructor.

Definition at line 117 of file CodeCompressorPlugin.cc.

117  {
118  if (currentPOM_ != NULL) {
119  delete currentPOM_;
120  }
121  if (programBits_ != NULL) {
122  delete programBits_;
123  }
124 }

References currentPOM_, and programBits_.

◆ CodeCompressorPlugin()

CodeCompressorPlugin::CodeCompressorPlugin ( )
protected

The constructor.

Definition at line 104 of file CodeCompressorPlugin.cc.

Member Function Documentation

◆ addBits()

void CodeCompressorPlugin::addBits ( unsigned int  number,
int  leftmostBit,
int  rightmostBit,
BitVector bitVector 
)
staticprivate

Adds the bits of the given number to the given bit vector.

The bits added are determined by leftmostBit and rightmostBit parameters.

Parameters
numberThe number.
leftmostThe leftmost bit of the number which is added to the bit vector.
rightmostThe rightmost bit of the number which is added to the bit vector.
bitVectorThe bit vector to which the bits are added.

Definition at line 1688 of file CodeCompressorPlugin.cc.

1692  {
1693 
1694  for (int i = leftmostBit; i >= rightmostBit; i--) {
1695  bitVector.push_back(MathTools::bit(number, i));
1696  }
1697 }

References MathTools::bit().

Referenced by encodeLongImmediate().

Here is the call graph for this function:

◆ addBitsForDestinationField()

void CodeCompressorPlugin::addBitsForDestinationField ( const DestinationField dstField,
const TTAProgram::Move move,
BitVector bitVector 
)
staticprivate

Adds bits for a destination field to the given bit vector.

Parameters
dstFieldThe destination field that determines the encoding rules.
moveThe move that is being encoded.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 800 of file CodeCompressorPlugin.cc.

802  {
803  assert(move.bus().name() == dstField.parent()->name());
804  Terminal& destination = move.destination();
805 
806  if (destination.isGPR()) {
807  encodeRFTerminal(dstField, destination, bitVector);
808  } else if (destination.isFUPort()) {
809  encodeFUTerminal(dstField, destination, bitVector);
810  } else {
811  assert(false);
812  }
813 }

References assert, TTAProgram::Move::bus(), TTAProgram::Move::destination(), encodeFUTerminal(), encodeRFTerminal(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isGPR(), MoveSlot::name(), TTAMachine::Component::name(), and SlotField::parent().

Referenced by encodeMove().

Here is the call graph for this function:

◆ addBitsForDstRegisterField()

void CodeCompressorPlugin::addBitsForDstRegisterField ( const LImmDstRegisterField field,
const TTAProgram::Instruction instruction,
BitVector bitVector 
)
private

Adds the bits of the given destination register field to the bit vector.

Parameters
fieldThe long immediate destination register field.
instructionThe instruction.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the instruction or BEM is erroneous.

Definition at line 960 of file CodeCompressorPlugin.cc.

962  {
963  for (int i = 0; i < instruction.immediateCount(); i++) {
964  TTAProgram::Immediate& immediate = instruction.immediate(i);
965  const TTAProgram::Terminal& dstTerminal = immediate.destination();
966  const ImmediateUnit& dstIU = dstTerminal.immediateUnit();
967  if (dstIU.numberOfRegisters() == 1) {
968  continue;
969  }
970  string instructionTemplate = "";
971  try {
972  instructionTemplate = this->instructionTemplate(instruction);
973  } catch (const Exception& e) {
974  throw InvalidData(
975  __FILE__, __LINE__, __func__, e.errorMessage());
976  }
977 
978  string iuName = field.immediateUnit(instructionTemplate);
979  if (dstIU.name() == iuName) {
980  bitVector.pushBack(dstTerminal.index(), field.width());
981  return;
982  }
983  }
984 
985  // the field is not used by this instruction template
986  bitVector.pushBack(0, field.width());
987 }

References __func__, TTAProgram::Immediate::destination(), Exception::errorMessage(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), LImmDstRegisterField::immediateUnit(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::index(), instructionTemplate(), TTAMachine::Component::name(), TTAMachine::BaseRegisterFile::numberOfRegisters(), BitVector::pushBack(), and LImmDstRegisterField::width().

Referenced by bemInstructionBits().

Here is the call graph for this function:

◆ addBitsForGuardField()

void CodeCompressorPlugin::addBitsForGuardField ( const GuardField guardField,
const TTAProgram::Move move,
BitVector bitVector 
)
staticprivate

Adds bits for a guard field to the given bit vector.

Parameters
guardFieldThe guard field that determines the encoding rules.
moveThe move that is being encoded.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 824 of file CodeCompressorPlugin.cc.

826  {
827  unsigned int encodingValue(0);
828  const string procName = "CodeCompressorPlugin::addBitsForGuardField";
829  string busName = guardField.parent()->name();
830 
831  // find the correct encoding value
832  if (move.isUnconditional()) {
833  UnconditionalGuardEncoding& encoding = guardField.
834  unconditionalGuardEncoding(false);
835  if (&encoding == &NullUnconditionalGuardEncoding::instance()) {
836  PIGTextGenerator textGenerator;
837  format text = textGenerator.text(
839  text % busName;
840  throw InvalidData(__FILE__, __LINE__, procName, text.str());
841  }
842  encodingValue = encoding.encoding();
843 
844  } else {
845  const Guard& guard = move.guard().guard();
846  const PortGuard* portGuard = dynamic_cast<const PortGuard*>(&guard);
847  const RegisterGuard* registerGuard =
848  dynamic_cast<const RegisterGuard*>(&guard);
849 
850  if (portGuard != NULL) {
851  const Port& port = *portGuard->port();
852  string portName = port.name();
853  string fuName = port.parentUnit()->name();
854  FUGuardEncoding& encoding = guardField.fuGuardEncoding(
855  fuName, portName, guard.isInverted());
856  if (&encoding == &NullFUGuardEncoding::instance()) {
857  PIGTextGenerator textGenerator;
858  format text = textGenerator.text(
860  if (guard.isInverted()) {
861  text % "inverted" % portName % fuName;
862  } else {
863  text % "non-inverted" % portName % fuName;
864  }
865  throw InvalidData(
866  __FILE__, __LINE__, procName, text.str());
867  }
868  encodingValue = encoding.encoding();
869 
870  } else if (registerGuard != NULL) {
871  string rfName = registerGuard->registerFile()->name();
872  int regIndex = registerGuard->registerIndex();
873  GPRGuardEncoding& encoding = guardField.gprGuardEncoding(
874  rfName, regIndex, guard.isInverted());
875  if (&encoding == &NullGPRGuardEncoding::instance()) {
876  PIGTextGenerator textGenerator;
877  format text = textGenerator.text(
879  if (guard.isInverted()) {
880  text % "inverted" % regIndex % rfName;
881  } else {
882  text % "non-inverted" % regIndex % rfName;
883  }
884  throw InvalidData(
885  __FILE__, __LINE__, procName, text.str());
886  }
887  encodingValue = encoding.encoding();
888 
889  } else {
890  assert(false);
891  }
892  }
893 
894  // push back the encoding value to the bit vector
895  unsigned int oldSize = bitVector.size();
896  bitVector.pushBack(encodingValue, guardField.width());
897  assert(
898  bitVector.size() - oldSize ==
899  static_cast<size_t>(guardField.width()));
900 }

References assert, GuardEncoding::encoding(), GuardField::fuGuardEncoding(), GuardField::gprGuardEncoding(), TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), NullFUGuardEncoding::instance(), NullGPRGuardEncoding::instance(), NullUnconditionalGuardEncoding::instance(), TTAMachine::Guard::isInverted(), TTAProgram::Move::isUnconditional(), TTAMachine::Port::name(), MoveSlot::name(), TTAMachine::Component::name(), GuardField::parent(), TTAMachine::Port::parentUnit(), TTAMachine::PortGuard::port(), BitVector::pushBack(), TTAMachine::RegisterGuard::registerFile(), TTAMachine::RegisterGuard::registerIndex(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_ALWAYS_TRUE_GUARD_ENCODING_MISSING, PIGTextGenerator::TXT_FU_GUARD_ENCODING_MISSING, PIGTextGenerator::TXT_GPR_GUARD_ENCODING_MISSING, and GuardField::width().

Referenced by encodeMove().

Here is the call graph for this function:

◆ addBitsForICField()

void CodeCompressorPlugin::addBitsForICField ( const ImmediateControlField icField,
const TTAProgram::Instruction instruction,
BitVector bitVector 
) const
private

Adds bits for immediate control field to the given bit vector.

Parameters
icFieldThe immediate control field that determines the encoding.
instructionThe instruction that is being encoded.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM or machine is erroneous.

Definition at line 669 of file CodeCompressorPlugin.cc.

671  {
672  string instructionTemplate("");
673 
674  // find the instruction template of the instruction
675  try {
677  this->instructionTemplate(instruction);
678  } catch (const InstanceNotFound& exception) {
679  throw InvalidData(
680  __FILE__, __LINE__, __func__, exception.errorMessage());
681  }
682 
683  // get the encoding
684  int encoding(0);
685  try {
686  encoding = icField.templateEncoding(instructionTemplate);
687  } catch (const InstanceNotFound& exception) {
688  PIGTextGenerator textGenerator;
689  format text = textGenerator.text(
691  text % instructionTemplate;
692  const string procName = "CodeCompressorPlugin::addBitsForICField";
693  throw InvalidData(__FILE__, __LINE__, procName, text.str());
694  }
695 
696  // add the encoding
697  bitVector.pushBack(encoding, icField.width());
698 }

References __func__, Exception::errorMessage(), instructionTemplate(), BitVector::pushBack(), ImmediateControlField::templateEncoding(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_TEMPLATE_ENCODING_MISSING, and ImmediateControlField::width().

Referenced by bemInstructionBits().

Here is the call graph for this function:

◆ addBitsForImmediateSlot()

void CodeCompressorPlugin::addBitsForImmediateSlot ( const ImmediateSlotField immSlot,
const TTAProgram::Instruction instruction,
BitVector bitVector 
)
private

Adds the immediate bits of the given immediate slot to the bit vector.

Parameters
immSlotThe immediate slot.
instructionThe instruction that contains the immediate.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 911 of file CodeCompressorPlugin.cc.

913  {
914  // get the correct instruction template
915  string instructionTemplate = "";
916  try {
918  instruction);
919  } catch (const InstanceNotFound& exception) {
920  if (machine().immediateUnitNavigator().count() == 0) {
921  // if no immediate units, no instruction templates either
922  PIGTextGenerator textGenerator;
923  format text = textGenerator.text(
925  TXT_BEM_DEFINES_IMM_SLOT_THAT_IS_NEVER_USED);
926  const string procName =
927  "CodeCompressorPlugin::addBitsForImmediateSlot";
928  throw InvalidData(__FILE__, __LINE__, procName, text.str());
929  } else {
930  assert(false);
931  }
932  }
933 
936  if (!itNav.hasItem(instructionTemplate)) {
937  assert(false);
938  }
939 
940  // check whether there should be a long immediate on the immediate slot
942  if (iTemp->usesSlot(immSlot.name())) {
944  immSlot.name(), immSlot.width(), instruction, bitVector);
945  } else {
946  // fill the slot with zeros
947  bitVector.pushBack(0, immSlot.width());
948  }
949 }

References assert, encodeLongImmediate(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), instructionTemplate(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine(), ImmediateSlotField::name(), BitVector::pushBack(), Texts::TextGenerator::text(), TTAMachine::InstructionTemplate::usesSlot(), and ImmediateSlotField::width().

Referenced by bemInstructionBits().

Here is the call graph for this function:

◆ addBitsForMoveSlot()

void CodeCompressorPlugin::addBitsForMoveSlot ( const MoveSlot slot,
const TTAProgram::Instruction instruction,
InstructionBitVector bitVector 
)
private

Adds bits for a move slot to the given bit vector.

Parameters
slotThe move slot that determines the encoding.
instructionThe instruction that is being encoded.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 709 of file CodeCompressorPlugin.cc.

711  {
712  // find the correct bus from the machine
713  string busName = slot.name();
715  if (!busNav.hasItem(busName)) {
716  PIGTextGenerator textGenerator;
717  format text = textGenerator.text(
719  text % busName;
720  const string procName = "CodeCompressorPlugin::addBitsForMoveSlot";
721  throw InvalidData(__FILE__, __LINE__, procName, text.str());
722  }
723 
724  Bus* bus = busNav.item(busName);
725 
726  // get the correct instruction template
727  string instructionTemplate = "";
728  try {
730  instruction);
731  } catch (const InstanceNotFound& exception) {
732  if (machine().immediateUnitNavigator().count() == 0) {
733  // if no immediate units, no instruction templates either
734  unsigned int oldSize = bitVector.size();
735  encodeMove(slot, instruction, bitVector);
736  assert(
737  bitVector.size() - oldSize ==
738  static_cast<size_t>(slot.width()));
739  return;
740  } else {
741  assert(false);
742  }
743  }
744 
747  if (!itNav.hasItem(instructionTemplate)) {
748  assert(false);
749  }
750 
751  // check whether there should be a long immediate on the move slot
753  if (iTemp->usesSlot(bus->name())) {
755  bus->name(), slot.width(), instruction, bitVector);
756  } else {
757  encodeMove(slot, instruction, bitVector);
758  }
759 }

References assert, TTAMachine::Machine::busNavigator(), encodeLongImmediate(), encodeMove(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), instructionTemplate(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine(), MoveSlot::name(), TTAMachine::Component::name(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_BEM_DEFINES_SLOT_FOR_NONEXISTING_BUS, TTAMachine::InstructionTemplate::usesSlot(), and MoveSlot::width().

Referenced by bemInstructionBits().

Here is the call graph for this function:

◆ addBitsForSourceField()

void CodeCompressorPlugin::addBitsForSourceField ( const SourceField srcField,
const TTAProgram::Move move,
InstructionBitVector bitVector 
) const
private

Adds bits for a source field to the given bit vector.

Parameters
srcFieldThe source field that determines the encoding rules.
moveThe move that is being encoded.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 770 of file CodeCompressorPlugin.cc.

772  {
773  unsigned int oldSize = bitVector.size();
774  assert(move.bus().name() == srcField.parent()->name());
775  Terminal& source = move.source();
776 
777  if (source.isImmediateRegister()) {
778  encodeIUTerminal(srcField, source, bitVector);
779  } else if (source.isGPR()) {
780  encodeRFTerminal(srcField, source, bitVector);
781  } else if (source.isFUPort()) {
782  encodeFUTerminal(srcField, source, bitVector);
783  } else if (source.isImmediate()) {
784  encodeImmediateTerminal(srcField, source, bitVector);
785  }
786 
787  assert(
788  bitVector.size() - oldSize == static_cast<size_t>(srcField.width()));
789 }

References assert, TTAProgram::Move::bus(), encodeFUTerminal(), encodeImmediateTerminal(), encodeIUTerminal(), encodeRFTerminal(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isGPR(), TTAProgram::Terminal::isImmediate(), TTAProgram::Terminal::isImmediateRegister(), MoveSlot::name(), TTAMachine::Component::name(), SlotField::parent(), TTAProgram::Move::source(), and SourceField::width().

Referenced by encodeMove().

Here is the call graph for this function:

◆ addInstruction()

void CodeCompressorPlugin::addInstruction ( const TTAProgram::Instruction instruction,
InstructionBitVector bits 
)
protected

Adds the given instruction to the program.

Parameters
instructionThe instruction.
bitsThe bits that models the instruction.
Exceptions
InvalidDataIf new program is not started by startNewProgram.
OutOfRangeIf some immediate would become too large to fit in its space due to the address of the instruction being added.

Definition at line 384 of file CodeCompressorPlugin.cc.

385  {
386  if (programBits_ == NULL) {
387  throw InvalidData(__FILE__, __LINE__, __func__);
388  }
389 
390  unsigned int firstFree = programBits_->size();
391  unsigned int instructionPosition = firstFree;
392 
393  if (startsAtBeginningOfMAU(instruction)) {
394  instructionPosition = nextAddressablePositionFrom(firstFree);
395  }
396 
397  // fill the memory from last instruction to this instruction with 0's
398  for (unsigned int i = firstFree; i < instructionPosition; i++) {
399  programBits_->push_back(false);
400  }
401 
402  // add the instruction bits
403  programBits_->pushBack(*bits);
404  delete bits;
405 
406  // mark the instruction starting point
407  programBits_->markInstructionStartingPoint(instructionPosition);
408 
409  unsigned int memoryAddress = addressSpaceOffset_ +
410  (instructionPosition / mau_);
412  instructionAddresses_.insert(
413  std::pair<const Instruction*, unsigned int>(
414  &instruction, memoryAddress));
415 }

References __func__, addressSpaceOffset_, InstructionBitVector::fixInstructionAddress(), instructionAddresses_, InstructionBitVector::markInstructionStartingPoint(), mau_, memoryAddress(), nextAddressablePositionFrom(), programBits_, InstructionBitVector::pushBack(), and startsAtBeginningOfMAU().

Referenced by DEFAULT_Compressor::compress().

Here is the call graph for this function:

◆ bemBits()

InstructionBitVector * CodeCompressorPlugin::bemBits ( const TTAProgram::Program program)
protected

Returns the bit image of the program encoded as the BEM determines.

Parameters
programThe program.
Returns
The program image.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 205 of file CodeCompressorPlugin.cc.

205  {
206  relocMap_.clear();
207  indexTable_.clear();
208 
209  InstructionBitVector* imageBits = new InstructionBitVector();
210  for (int i = 0; i < program.procedureCount(); i++) {
211  Procedure& p = program.procedure(i);
212  for (int j = 0; j < p.instructionCount(); j++) {
213  Instruction& instruction = p.instructionAtIndex(j);
214  InstructionBitVector* bits = bemInstructionBits(instruction);
215  assert(bits->size() == static_cast<size_t>(bem_->width()));
216  imageBits->pushBack(*bits);
217  }
218  }
219  return imageBits;
220 }

References assert, bem_, bemInstructionBits(), indexTable_, TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), program, InstructionBitVector::pushBack(), relocMap_, and BinaryEncoding::width().

Here is the call graph for this function:

◆ bemInstructionBits()

InstructionBitVector * CodeCompressorPlugin::bemInstructionBits ( const TTAProgram::Instruction instruction)

Returns bit vector that represents the given instruction as the BEM determines.

Parameters
instructionThe instruction.
Returns
The newly created bit vector containing the instruction bits.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 454 of file CodeCompressorPlugin.cc.

455  {
456  if (bem_ == NULL) {
457  throw InvalidData(__FILE__, __LINE__, __func__);
458  }
459 
460  InstructionBitVector* instructionBits = new InstructionBitVector();
461 
462  // insert the bits to the vector
463  for (int i = binaryEncoding().childFieldCount() - 1; i >= 0; i--) {
465  ImmediateControlField* icField =
466  dynamic_cast<ImmediateControlField*>(&field);
467  MoveSlot* moveSlot = dynamic_cast<MoveSlot*>(&field);
468  ImmediateSlotField* immField =
469  dynamic_cast<ImmediateSlotField*>(&field);
470  LImmDstRegisterField* dstRegField =
471  dynamic_cast<LImmDstRegisterField*>(&field);
472  unsigned int oldSize = instructionBits->size();
473  if (icField != NULL) {
475  *icField, instruction, *instructionBits);
476  assert(
477  instructionBits->size() - oldSize ==
478  static_cast<size_t>(icField->width()));
479  } else if (moveSlot != NULL) {
481  *moveSlot, instruction, *instructionBits);
482  assert(
483  instructionBits->size() - oldSize ==
484  static_cast<size_t>(moveSlot->width()));
485  } else if (immField != NULL) {
487  *immField, instruction, *instructionBits);
488  assert(instructionBits->size() - oldSize ==
489  static_cast<size_t>(immField->width()));
490  } else if (dstRegField != NULL) {
492  *dstRegField, instruction, *instructionBits);
493  assert(
494  instructionBits->size() - oldSize ==
495  static_cast<size_t>(dstRegField->width()));
496  } else {
497  assert(false);
498  }
499  }
500 
501  // mark the instruction references to the bit vector
502  for (RelocMap::const_iterator iter = relocMap_.begin();
503  iter != relocMap_.end(); iter++) {
504  const Immediate* immediate = (*iter).first;
505  const Instruction* instruction = (*iter).second;
507  vector<IndexBound> indexes = MapTools::valueForKey<
508  vector<IndexBound> >(indexTable_, immediate);
509  instructionBits->startSettingInstructionReference(*instruction);
510  for (vector<IndexBound>::const_iterator iter = indexes.begin();
511  iter != indexes.end(); iter++) {
512  instructionBits->addIndexBoundsForReference(*iter);
513  }
514  }
515 
516  relocMap_.clear();
517  indexTable_.clear();
518 
519  return instructionBits;
520 }

References __func__, addBitsForDstRegisterField(), addBitsForICField(), addBitsForImmediateSlot(), addBitsForMoveSlot(), InstructionBitVector::addIndexBoundsForReference(), assert, bem_, binaryEncoding(), BinaryEncoding::childField(), MapTools::containsKey(), indexTable_, relocMap_, InstructionBitVector::startSettingInstructionReference(), MapTools::valueForKey(), ImmediateSlotField::width(), LImmDstRegisterField::width(), ImmediateControlField::width(), and MoveSlot::width().

Referenced by bemBits(), DEFAULT_Compressor::compress(), ProGe::RV32MicroCodeGenerator::constructBInstructions(), ProGe::RV32MicroCodeGenerator::constructIInstructions(), ProGe::RV32MicroCodeGenerator::constructRInstructions(), ProGe::RV32MicroCodeGenerator::constructSInstructions(), ProGe::RV32MicroCodeGenerator::constructUJInstructions(), and ProGe::RV32MicroCodeGenerator::generateNOP().

Here is the call graph for this function:

◆ binaryEncoding()

const BinaryEncoding & CodeCompressorPlugin::binaryEncoding ( ) const

Returns the binary encoding map.

Returns
The binary encoding map.
Exceptions
NotAvailableIf the BEM is not set.

Definition at line 280 of file CodeCompressorPlugin.cc.

280  {
281  if (bem_ == NULL) {
282  throw NotAvailable(__FILE__, __LINE__, __func__);
283  }
284 
285  return *bem_;
286 }

References __func__, and bem_.

Referenced by bemInstructionBits(), and ProgramImageGenerator::generateProgramImage().

◆ compress()

virtual InstructionBitVector* CodeCompressorPlugin::compress ( const std::string &  program)
pure virtual

Generates bit image of the program.

Returns
The bit image.
Exceptions
InvalidDataIf the BEM is erroneous.

Implemented in MoveSlotDictionary, InstructionDictionary, and DEFAULT_Compressor.

Referenced by ProgramImageGenerator::generateDataImage(), and ProgramImageGenerator::generateProgramImage().

◆ currentProgram()

TTAProgram::Program & CodeCompressorPlugin::currentProgram ( ) const

Returns the program (POM) being processed currently.

Returns
The program.
Exceptions
NotAvailableIf there is no program being processed.

Definition at line 295 of file CodeCompressorPlugin.cc.

295  {
296  if (currentPOM_ == NULL) {
297  throw NotAvailable(__FILE__, __LINE__, __func__);
298  }
299 
300  return *currentPOM_;
301 }

References __func__, and currentPOM_.

Referenced by DEFAULT_Compressor::compress(), ProgramImageGenerator::generateProgramImage(), and ProgramImageGenerator::writeDataSection().

◆ encodeFUTerminal()

void CodeCompressorPlugin::encodeFUTerminal ( const SlotField field,
const TTAProgram::Terminal terminal,
BitVector bitVector 
)
staticprivate

Encodes the given function unit terminal to the given bit vector.

Parameters
fieldThe slot field that determines the encoding rules.
terminalThe terminal to be encoded.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 1418 of file CodeCompressorPlugin.cc.

1420  {
1421  const string procName = "CodeCompressorPlugin::encodeFUTerminal";
1422  assert(terminal.isFUPort());
1423  string fuName = terminal.functionUnit().name();
1424  const Port& port = terminal.port();
1425  string socketName("");
1426 
1427  // find the correct socket
1428  if (dynamic_cast<const SourceField*>(&field) != NULL) {
1429  socketName = port.outputSocket()->name();
1430  } else if (dynamic_cast<const DestinationField*>(&field) != NULL) {
1431  socketName = port.inputSocket()->name();
1432  } else {
1433  assert(false);
1434  }
1435 
1436  if (!field.hasSocketEncoding(socketName)) {
1437  PIGTextGenerator textGenerator;
1438  format text = textGenerator.text(
1440  if (dynamic_cast<const SourceField*>(&field) != NULL) {
1441  text % socketName % "source" % field.parent()->name();
1442  } else {
1443  text % socketName % "destination" % field.parent()->name();
1444  }
1445  throw InvalidData(__FILE__, __LINE__, procName, text.str());
1446  }
1447 
1448  // create encoding for socket ID
1449  SocketEncoding& socketID = field.socketEncoding(socketName);
1450  BitVector socketIDBits;
1451  socketIDBits.pushBack(socketID.encoding(), socketID.socketIDWidth());
1452 
1453  // create encoding for socket code
1455  if (socketID.hasSocketCodes()) {
1456  SocketCodeTable& socketCodes = socketID.socketCodes();
1457  FUPortCode* portCode = NULL;
1458  if (terminal.isOpcodeSetting()) {
1459  if (&terminal.operation() == &NullOperation::instance()) {
1460  const TTAProgram::TerminalFUPort* fuTerm =
1461  dynamic_cast<const TerminalFUPort*>(&terminal);
1462  PIGTextGenerator textGenerator;
1463  format text = textGenerator.text(
1465  text % (fuTerm != NULL ? fuTerm->hwOperation()->name() : "") % fuName;
1466  throw InvalidData(__FILE__, __LINE__, procName, text.str());
1467  }
1468  string opName = terminal.operation().name();
1469  if (!socketCodes.hasFUPortCode(fuName, port.name(), opName)) {
1470  PIGTextGenerator textGenerator;
1471  format text = textGenerator.text(
1473  text % fuName % opName;
1474  throw InvalidData(__FILE__, __LINE__, procName, text.str());
1475  }
1476  portCode = &socketCodes.fuPortCode(fuName, port.name(), opName);
1477 
1478  } else {
1479  if (!socketCodes.hasFUPortCode(fuName, port.name())) {
1480  PIGTextGenerator textGenerator;
1481  format text = textGenerator.text(
1483  text % port.name() % fuName % socketName;
1484  throw InvalidData(__FILE__, __LINE__, procName, text.str());
1485  }
1486  portCode = &socketCodes.fuPortCode(fuName, port.name());
1487  }
1488  socketCodeBits.pushBack(portCode->encoding(), socketCodes.width());
1489  }
1490 
1491  encodeSlotField(field, socketIDBits, socketCodeBits, bitVector);
1492 }

References assert, encodeSlotField(), Encoding::encoding(), PortCode::encoding(), TTAProgram::Terminal::functionUnit(), SocketCodeTable::fuPortCode(), SocketCodeTable::hasFUPortCode(), SocketEncoding::hasSocketCodes(), SlotField::hasSocketEncoding(), TTAProgram::TerminalFUPort::hwOperation(), TTAMachine::Port::inputSocket(), NullOperation::instance(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isOpcodeSetting(), TTAMachine::HWOperation::name(), TTAMachine::Port::name(), MoveSlot::name(), TTAMachine::Component::name(), Operation::name(), TTAProgram::Terminal::operation(), TTAMachine::Port::outputSocket(), SlotField::parent(), TTAProgram::Terminal::port(), BitVector::pushBack(), socketCodeBits(), SocketEncoding::socketCodes(), SlotField::socketEncoding(), SocketEncoding::socketIDWidth(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_FU_OC_PORT_CODE_MISSING, PIGTextGenerator::TXT_FU_PORT_CODE_MISSING, PIGTextGenerator::TXT_OSAL_OC_MISSING, PIGTextGenerator::TXT_SOCKET_ENCODING_MISSING, and SocketCodeTable::width().

Referenced by addBitsForDestinationField(), and addBitsForSourceField().

Here is the call graph for this function:

◆ encodeImmediateTerminal()

void CodeCompressorPlugin::encodeImmediateTerminal ( const SourceField field,
const TTAProgram::Terminal terminal,
InstructionBitVector bitVector 
) const
private

Encodes the given immediate terminal to the given bit vector.

Parameters
fieldThe source field which determines the encoding rules.
terminalThe immediate terminal to be encoded.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 1503 of file CodeCompressorPlugin.cc.

1505  {
1506  assert(terminal.isImmediate());
1507  unsigned int immValue = terminal.value().uIntWordValue();
1508  ImmediateEncoding& encoding = field.immediateEncoding();
1509 
1510  if (&encoding == &NullImmediateEncoding::instance()) {
1511  PIGTextGenerator textGenerator;
1512  format text = textGenerator.text(
1514  text % field.parent()->name();
1515  const string procName =
1516  "CodeCompressorPlugin::encodeImmediateTerminal";
1517  throw InvalidData(__FILE__, __LINE__, procName, text.str());
1518  }
1519 
1520  // create bits for the immediate value
1521  InstructionBitVector immediateBits;
1522  static_cast<BitVector&>(immediateBits).pushBack(
1523  immValue, field.width() - encoding.encodingWidth());
1525  Instruction& referenced = currentPOM_->instructionAt(immValue);
1526  assert(&referenced != &NullInstruction::instance());
1527  immediateBits.startSettingInstructionReference(referenced);
1528  IndexBound simmBound(0, (immediateBits.size()-1));
1529  immediateBits.addIndexBoundsForReference(simmBound);
1530  }
1531 
1532  // encode the source field
1533  unsigned int oldSize = bitVector.size();
1534  if (field.componentIDPosition() == BinaryEncoding::LEFT) {
1535  static_cast<BitVector&>(bitVector).pushBack(
1536  encoding.encoding(), encoding.encodingWidth());
1537  bitVector.pushBack(immediateBits);
1538  } else {
1539  bitVector.pushBack(immediateBits);
1540  static_cast<BitVector&>(bitVector).pushBack(
1541  encoding.encoding(), encoding.encodingWidth());
1542  }
1543  assert(bitVector.size() - oldSize == static_cast<size_t>(field.width()));
1544 }

References InstructionBitVector::addIndexBoundsForReference(), assert, SlotField::componentIDPosition(), AssocTools::containsKey(), currentPOM_, Encoding::encoding(), ImmediateEncoding::encodingWidth(), SourceField::immediateEncoding(), NullImmediateEncoding::instance(), TTAProgram::Program::instructionAt(), TTAProgram::Terminal::isImmediate(), BinaryEncoding::LEFT, MoveSlot::name(), SlotField::parent(), InstructionBitVector::pushBack(), InstructionBitVector::startSettingInstructionReference(), terminalsToRelocate_, Texts::TextGenerator::text(), PIGTextGenerator::TXT_IMMEDIATE_ENCODING_MISSING, SimValue::uIntWordValue(), TTAProgram::Terminal::value(), and SourceField::width().

Referenced by addBitsForSourceField().

Here is the call graph for this function:

◆ encodeIUTerminal()

void CodeCompressorPlugin::encodeIUTerminal ( const SlotField field,
const TTAProgram::Terminal terminal,
BitVector bitVector 
)
staticprivate

Encodes the immediate unit register terminal to the given bit vector.

Parameters
fieldThe slot field that determines the encoding rules.
terminalThe terminal to be encoded.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 1288 of file CodeCompressorPlugin.cc.

1290  {
1291  const string procName = "CodeCompressorPlugin::encodeIUTerminal";
1292  assert(terminal.isImmediateRegister());
1293  string iuName = terminal.immediateUnit().name();
1294  const Port& port = terminal.port();
1295  string socketName("");
1296 
1297  // find the correct socket
1298  if (dynamic_cast<const SourceField*>(&field) != NULL) {
1299  socketName = port.outputSocket()->name();
1300  } else if (dynamic_cast<const DestinationField*>(&field) != NULL) {
1301  socketName = port.inputSocket()->name();
1302  } else {
1303  assert(false);
1304  }
1305 
1306  if (!field.hasSocketEncoding(socketName)) {
1307  PIGTextGenerator textGenerator;
1308  format text = textGenerator.text(
1310  if (dynamic_cast<const SourceField*>(&field) != NULL) {
1311  text % socketName % "source" % field.parent()->name();
1312  } else {
1313  text % socketName % "destination" % field.parent()->name();
1314  }
1315  throw InvalidData(__FILE__, __LINE__, procName, text.str());
1316  }
1317 
1318  // create socket ID encoding
1319  SocketEncoding& socketID = field.socketEncoding(socketName);
1320  BitVector socketIDBits;
1321  socketIDBits.pushBack(socketID.encoding(), socketID.socketIDWidth());
1322 
1323  // create socket code encoding
1325  if (socketID.hasSocketCodes()) {
1326  SocketCodeTable& socketCodes = socketID.socketCodes();
1327  if (!socketCodes.hasIUPortCode(iuName)) {
1328  PIGTextGenerator textGenerator;
1329  format text = textGenerator.text(
1331  text % iuName % socketName % field.parent()->name();
1332  throw InvalidData(__FILE__, __LINE__, procName, text.str());
1333  }
1334 
1335  IUPortCode& portCode = socketCodes.iuPortCode(iuName);
1336  unsigned int registerIndex = terminal.index();
1339  socketCodes, portCode, registerIndex));
1340  }
1341 
1342  encodeSlotField(field, socketIDBits, socketCodeBits, bitVector);
1343 }

References assert, encodeSlotField(), Encoding::encoding(), SocketCodeTable::hasIUPortCode(), SocketEncoding::hasSocketCodes(), SlotField::hasSocketEncoding(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::index(), TTAMachine::Port::inputSocket(), TTAProgram::Terminal::isImmediateRegister(), SocketCodeTable::iuPortCode(), MoveSlot::name(), TTAMachine::Component::name(), TTAMachine::Port::outputSocket(), SlotField::parent(), TTAProgram::Terminal::port(), BitVector::pushBack(), socketCodeBits(), SocketEncoding::socketCodes(), SlotField::socketEncoding(), SocketEncoding::socketIDWidth(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_IU_PORT_CODE_MISSING, and PIGTextGenerator::TXT_SOCKET_ENCODING_MISSING.

Referenced by addBitsForSourceField().

Here is the call graph for this function:

◆ encodeLongImmediate()

void CodeCompressorPlugin::encodeLongImmediate ( const std::string &  slotName,
int  slotWidth,
const TTAProgram::Instruction instruction,
BitVector bitVector 
)
private

Encodes the instruction's long immediate bits that belong to the given (move or immediate) slot to the bit vector.

Parameters
slotNameName of the slot.
widthBit width of the slot.
instructionThe instruction that is being encoded.
bitVectorThe bit vector to which the bits are added.

Definition at line 1066 of file CodeCompressorPlugin.cc.

1070  {
1071 
1072  // find the correct immediate from the instruction
1073  for (int i = 0; i < instruction.immediateCount(); i++) {
1074  Immediate& imm = instruction.immediate(i);
1075  const InstructionTemplate& iTemp = instruction.instructionTemplate();
1076 
1077  if (iTemp.usesSlot(slotName)) {
1078  // correct immediate
1079  ImmediateUnit* dstUnit = iTemp.destinationOfSlot(slotName);
1080 
1081  // find the correct boundary of the long immediate which is to
1082  // be encoded in the given (immediate or move) slot
1083  int rightmostBitToEncode = 0;
1084  for (int i = iTemp.numberOfSlots(*dstUnit) - 1; i >= 0; i--) {
1085  string slotOfImm = iTemp.slotOfDestination(*dstUnit, i);
1086  if (slotOfImm != slotName) {
1087  rightmostBitToEncode += iTemp.supportedWidth(slotOfImm);
1088  } else {
1089  break;
1090  }
1091  }
1092  unsigned int limmSlotWidth = iTemp.supportedWidth(slotName);
1093  int leftmostBitToEncode =
1094  rightmostBitToEncode + limmSlotWidth - 1;
1095  assert(leftmostBitToEncode >= rightmostBitToEncode);
1096  assert(
1097  leftmostBitToEncode - rightmostBitToEncode < slotWidth);
1098 
1099  // need to add zero bits to the move slot if the immediate
1100  // width is smaller than the width of the move slot
1101  int zerosToAdd = slotWidth - (
1102  leftmostBitToEncode - rightmostBitToEncode) - 1;
1103  assert(zerosToAdd >= 0);
1104  for (int i = 0; i < zerosToAdd; i++) {
1105  bitVector.push_back(false);
1106  }
1107 
1108  // push back the immediate value
1109  UIntWord immediateValue = imm.value().value().uIntWordValue();
1110  addBits(
1111  immediateValue, leftmostBitToEncode, rightmostBitToEncode,
1112  bitVector);
1113 
1114  // if the long immediate is address of an instruction, mark it
1115  // to relocMap_ and indexTable_
1117  Instruction& referenced = currentPOM_->instructionAt(
1118  immediateValue);
1119  unsigned int startIndex = bitVector.size() - slotWidth;
1120  unsigned int endIndex = bitVector.size() - 1;
1121  relocMap_.insert(
1122  pair<const Immediate*, const Instruction*>(
1123  &imm, &referenced));
1124  vector<IndexBound> indices;
1125  if (MapTools::containsKey(indexTable_, &imm)) {
1126  indices = MapTools::valueForKey<vector<IndexBound> >(
1127  indexTable_, &imm);
1128  }
1129  IndexBound bounds(startIndex, endIndex, limmSlotWidth,
1130  leftmostBitToEncode, rightmostBitToEncode);
1131  indices.push_back(bounds);
1132  indexTable_[&imm] = indices;
1133  }
1134 
1135  return;
1136  }
1137  }
1138  assert(false);
1139 }

References addBits(), assert, MapTools::containsKey(), AssocTools::containsKey(), currentPOM_, TTAMachine::InstructionTemplate::destinationOfSlot(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), immediatesToRelocate_, indexTable_, TTAProgram::Program::instructionAt(), TTAProgram::Instruction::instructionTemplate(), TTAMachine::InstructionTemplate::numberOfSlots(), relocMap_, TTAMachine::InstructionTemplate::slotOfDestination(), TTAMachine::InstructionTemplate::supportedWidth(), SimValue::uIntWordValue(), TTAMachine::InstructionTemplate::usesSlot(), TTAProgram::TerminalImmediate::value(), and TTAProgram::Immediate::value().

Referenced by addBitsForImmediateSlot(), and addBitsForMoveSlot().

Here is the call graph for this function:

◆ encodeMove()

void CodeCompressorPlugin::encodeMove ( const MoveSlot slot,
const TTAProgram::Instruction instruction,
InstructionBitVector bitVector 
) const
private

Encodes a move to the given bit vector.

Parameters
slotThe move slot that determines the encoding rules.
instructionThe instruction that is being encoded.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 1151 of file CodeCompressorPlugin.cc.

1153  {
1154  string busName = slot.name();
1156  Bus* bus = busNav.item(busName);
1157 
1158  for (int i = 0; i < instruction.moveCount(); i++) {
1159  Move& move = instruction.move(i);
1160  if (&move.bus() == bus) {
1161  // correct move
1162  SourceField& srcField = slot.sourceField();
1163  DestinationField& dstField = slot.destinationField();
1164  GuardField& guardField = slot.guardField();
1165  for (int i = slot.childFieldCount() - 1; i >= 0; i--) {
1166  InstructionField& childField = slot.childField(i);
1167  unsigned int oldSize = bitVector.size();
1168  if (dynamic_cast<GuardField*>(&childField) != NULL) {
1169  addBitsForGuardField(guardField, move, bitVector);
1170  assert(bitVector.size() - oldSize ==
1171  static_cast<size_t>(guardField.width()));
1172  } else if (dynamic_cast<SourceField*>(&childField) != NULL) {
1173  addBitsForSourceField(srcField, move, bitVector);
1174  assert(bitVector.size() - oldSize ==
1175  static_cast<size_t>(srcField.width()));
1176 
1177  } else if (dynamic_cast<DestinationField*>(&childField) !=
1178  NULL) {
1179  addBitsForDestinationField(dstField, move, bitVector);
1180  assert(bitVector.size() - oldSize ==
1181  static_cast<size_t>(dstField.width()));
1182  } else {
1183  assert(false);
1184  }
1185  }
1186  return;
1187  }
1188  }
1189 
1190  // no move on the bus
1191  unsigned int oldSize = bitVector.size();
1192  encodeNOP(slot, bitVector);
1193  assert(bitVector.size() - oldSize == static_cast<size_t>(slot.width()));
1194 }

References addBitsForDestinationField(), addBitsForGuardField(), addBitsForSourceField(), assert, TTAProgram::Move::bus(), TTAMachine::Machine::busNavigator(), MoveSlot::childField(), MoveSlot::childFieldCount(), MoveSlot::destinationField(), encodeNOP(), MoveSlot::guardField(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), MoveSlot::name(), MoveSlot::sourceField(), SourceField::width(), SlotField::width(), MoveSlot::width(), and GuardField::width().

Referenced by addBitsForMoveSlot().

Here is the call graph for this function:

◆ encodeNOP()

void CodeCompressorPlugin::encodeNOP ( const MoveSlot slot,
BitVector bitVector 
)
staticprivate

Encodes a NOP to the given bitVector.

Parameters
slotThe move slot that determines the encoding rules.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM does not define encoding for NOP.

Definition at line 1204 of file CodeCompressorPlugin.cc.

1204  {
1205  for (int i = slot.childFieldCount() - 1; i >= 0; i--) {
1206  InstructionField& childField = slot.childField(i);
1207  GuardField& guardField = slot.guardField();
1208  SourceField& srcField = slot.sourceField();
1209  DestinationField& dstField = slot.destinationField();
1210 
1211  if (&guardField == &childField) {
1212  if ((!srcField.hasNoOperationEncoding() ||
1213  !dstField.hasNoOperationEncoding()) &&
1214  guardField.hasUnconditionalGuardEncoding(true)) {
1215  bitVector.pushBack(
1216  guardField.unconditionalGuardEncoding(true).encoding(),
1217  guardField.width());
1218  } else {
1219  bitVector.pushBack(0, guardField.width());
1220  }
1221 
1222  } else if (&srcField == &childField) {
1223  if (srcField.width() == 0) {
1224  continue;
1225  }
1226 
1227  NOPEncoding& encoding = srcField.noOperationEncoding();
1228  if (&encoding == &NullNOPEncoding::instance() &&
1229  !guardField.hasUnconditionalGuardEncoding(true)) {
1230  PIGTextGenerator textGenerator;
1231  format text = textGenerator.text(
1233  text % slot.name();
1234  const string procName = "CodeCompressorPlugin::encodeNOP";
1235  throw InvalidData(
1236  __FILE__, __LINE__, procName, text.str());
1237  }
1238  if (&encoding == &NullNOPEncoding::instance()) {
1239  bitVector.pushBack(0, srcField.width());
1240  } else {
1241  if (srcField.componentIDPosition() == BinaryEncoding::LEFT) {
1242  bitVector.pushBack(
1243  encoding.encoding(), encoding.width());
1244  bitVector.pushBack(
1245  0, srcField.width() - encoding.width());
1246  } else {
1247  bitVector.pushBack(
1248  encoding.encoding(), srcField.width());
1249  }
1250  }
1251 
1252  } else if (&dstField == &childField) {
1253  if (dstField.width() == 0) {
1254  continue;
1255  }
1256  NOPEncoding& encoding = dstField.noOperationEncoding();
1257  if (&encoding == &NullNOPEncoding::instance() &&
1258  !guardField.hasUnconditionalGuardEncoding(true)) {
1259  PIGTextGenerator textGenerator;
1260  format text = textGenerator.text(
1262  text % slot.name();
1263  throw InvalidData(__FILE__, __LINE__, __func__, text.str());
1264  }
1265  if (&encoding == &NullNOPEncoding::instance()) {
1266  bitVector.pushBack(0, dstField.width());
1267  } else {
1268  if (dstField.componentIDPosition() == BinaryEncoding::LEFT) {
1269  bitVector.pushBack(encoding.encoding(), encoding.width());
1270  bitVector.pushBack(0, dstField.width() - encoding.width());
1271  } else {
1272  bitVector.pushBack(encoding.encoding(), dstField.width());
1273  }
1274  }
1275  }
1276  }
1277 }

References __func__, MoveSlot::childField(), MoveSlot::childFieldCount(), SlotField::componentIDPosition(), MoveSlot::destinationField(), GuardEncoding::encoding(), Encoding::encoding(), MoveSlot::guardField(), SlotField::hasNoOperationEncoding(), GuardField::hasUnconditionalGuardEncoding(), NullNOPEncoding::instance(), BinaryEncoding::LEFT, MoveSlot::name(), SlotField::noOperationEncoding(), BitVector::pushBack(), MoveSlot::sourceField(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_NOP_ENCODING_MISSING, GuardField::unconditionalGuardEncoding(), Encoding::width(), SourceField::width(), SlotField::width(), and GuardField::width().

Referenced by encodeMove().

Here is the call graph for this function:

◆ encodeRFTerminal()

void CodeCompressorPlugin::encodeRFTerminal ( const SlotField field,
const TTAProgram::Terminal terminal,
BitVector bitVector 
)
staticprivate

Encodes the given register file terminal to the given bit vector.

Parameters
fieldThe slot field that determines the encoding rules.
terminalThe terminal to be encoded.
bitVectorThe bit vector to which the bits are added.
Exceptions
InvalidDataIf the BEM is erroneous.

Definition at line 1354 of file CodeCompressorPlugin.cc.

1356  {
1357  const string procName = "CodeCompressorPlugin::encodeRFTerminal";
1358  assert(terminal.isGPR());
1359  string rfName = terminal.registerFile().name();
1360  const Port& port = terminal.port();
1361  string socketName("");
1362 
1363  // find the correct socket
1364  if (dynamic_cast<const SourceField*>(&field) != NULL) {
1365  socketName = port.outputSocket()->name();
1366  } else if (dynamic_cast<const DestinationField*>(&field) != NULL) {
1367  socketName = port.inputSocket()->name();
1368  } else {
1369  assert(false);
1370  }
1371 
1372  if (!field.hasSocketEncoding(socketName)) {
1373  PIGTextGenerator textGenerator;
1374  format text = textGenerator.text(
1376  if (dynamic_cast<const SourceField*>(&field) != NULL) {
1377  text % socketName % "source" % field.parent()->name();
1378  } else {
1379  text % socketName % "destination" % field.parent()->name();
1380  }
1381  throw InvalidData(__FILE__, __LINE__, procName, text.str());
1382  }
1383 
1384  // create encoding for socket ID
1385  SocketEncoding& socketID = field.socketEncoding(socketName);
1386  BitVector socketIDBits;
1387  socketIDBits.pushBack(socketID.encoding(), socketID.socketIDWidth());
1388 
1389  // create encoding for socket code
1391  if (socketID.hasSocketCodes()) {
1392  SocketCodeTable& socketCodes = socketID.socketCodes();
1393  if (!socketCodes.hasRFPortCode(rfName)) {
1394  PIGTextGenerator textGenerator;
1395  format text = textGenerator.text(
1397  text % rfName % socketName % field.parent()->name();
1398  throw InvalidData(__FILE__, __LINE__, procName, text.str());
1399  }
1400  RFPortCode& portCode = socketCodes.rfPortCode(rfName);
1401  unsigned int registerIndex = terminal.index();
1403  socketCodes, portCode, registerIndex);
1404  }
1405 
1406  encodeSlotField(field, socketIDBits, socketCodeBits, bitVector);
1407 }

References assert, encodeSlotField(), Encoding::encoding(), SocketCodeTable::hasRFPortCode(), SocketEncoding::hasSocketCodes(), SlotField::hasSocketEncoding(), TTAProgram::Terminal::index(), TTAMachine::Port::inputSocket(), TTAProgram::Terminal::isGPR(), MoveSlot::name(), TTAMachine::Component::name(), TTAMachine::Port::outputSocket(), SlotField::parent(), TTAProgram::Terminal::port(), BitVector::pushBack(), TTAProgram::Terminal::registerFile(), SocketCodeTable::rfPortCode(), socketCodeBits(), SocketEncoding::socketCodes(), SlotField::socketEncoding(), SocketEncoding::socketIDWidth(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_RF_PORT_CODE_MISSING, and PIGTextGenerator::TXT_SOCKET_ENCODING_MISSING.

Referenced by addBitsForDestinationField(), and addBitsForSourceField().

Here is the call graph for this function:

◆ encodeSlotField()

void CodeCompressorPlugin::encodeSlotField ( const SlotField field,
const BitVector componentIDBits,
const BitVector socketCodeBits,
BitVector bitVector 
)
staticprivate

Encodes the given source or destination field with the given bit vectors.

Parameters
fieldThe source or destination field which determines the encoding order of component ID bits and socket code bits.
componentIDBitsThe encoding for component ID.
socketCodeBitsThe encoding for socket code.
bitVectorThe bit vector to which the bits are added.

Definition at line 1556 of file CodeCompressorPlugin.cc.

1560  {
1561 
1562  unsigned int oldSize = bitVector.size();
1563  unsigned int numberOfZeros = field.width() - componentIDBits.size() -
1564  socketCodeBits.size();
1565 
1566  if (field.componentIDPosition() == BinaryEncoding::LEFT) {
1567  bitVector.pushBack(componentIDBits);
1568  bitVector.pushBack(0, numberOfZeros);
1569  bitVector.pushBack(socketCodeBits);
1570  } else {
1571  bitVector.pushBack(socketCodeBits);
1572  bitVector.pushBack(0, numberOfZeros);
1573  bitVector.pushBack(componentIDBits);
1574  }
1575  assert(bitVector.size() - oldSize == static_cast<size_t>(field.width()));
1576 }

References assert, SlotField::componentIDPosition(), BinaryEncoding::LEFT, BitVector::pushBack(), socketCodeBits(), and SlotField::width().

Referenced by encodeFUTerminal(), encodeIUTerminal(), and encodeRFTerminal().

Here is the call graph for this function:

◆ firstMoveSlotIndex()

int CodeCompressorPlugin::firstMoveSlotIndex ( ) const
protected

Returns the index of first move slot defined in bem

Definition at line 242 of file CodeCompressorPlugin.cc.

242  {
243  int moveSlotIndex = 0;
245  moveSlotIndex = bem_->immediateControlField().width();
246  for (int i = 0; i < bem_->longImmDstRegisterFieldCount(); i++) {
247  moveSlotIndex += bem_->longImmDstRegisterField(i).width();
248  }
249  }
250  return moveSlotIndex;
251 }

References bem_, BinaryEncoding::hasImmediateControlField(), BinaryEncoding::immediateControlField(), BinaryEncoding::longImmDstRegisterField(), BinaryEncoding::longImmDstRegisterFieldCount(), LImmDstRegisterField::width(), and ImmediateControlField::width().

Here is the call graph for this function:

◆ generateDecompressor()

virtual void CodeCompressorPlugin::generateDecompressor ( std::ostream &  stream,
TCEString  entityStr 
)
pure virtual

Generates the HDL code of the decompressor block.

Parameters
streamThe stream to write.

Implemented in InstructionDictionary, MoveSlotDictionary, and DEFAULT_Compressor.

Referenced by ProgramImageGenerator::generateDecompressor().

◆ hasParameter()

bool CodeCompressorPlugin::hasParameter ( const std::string &  paramName) const
protected

Tells whether the plugin has the given parameter defined.

Parameters
paramNameName of the parameter.
Returns
True if the given parameter is defined, otherwise false.

Definition at line 558 of file CodeCompressorPlugin.cc.

558  {
559  for (ParameterTable::const_iterator iter = parameters_.begin();
560  iter != parameters_.end(); iter++) {
561  Parameter param = *iter;
562  if (param.name == paramName) {
563  return true;
564  }
565  }
566  return false;
567 }

References CodeCompressorPlugin::Parameter::name, and parameters_.

◆ imemMauWidth()

int CodeCompressorPlugin::imemMauWidth ( ) const

Returns the mau of instruction memory.

Before compression this is the original width and after compression it returns the compressed instruction width

Returns
mau width

Definition at line 600 of file CodeCompressorPlugin.cc.

600  {
601  return mau_;
602 }

References mau_.

Referenced by ProgramImageGenerator::imemMauWidth().

◆ immediateTerminal()

TTAProgram::Terminal * CodeCompressorPlugin::immediateTerminal ( const TPEF::CodeSection codeSection,
unsigned int  elementIndex,
const TPEF::ImmediateElement immElem,
const TTAProgram::Instruction instruction 
) const
private

Returns the immediate terminal that matches with the given ImmediateElement instance.

Parameters
codeSectionThe code section that contains the immediate element.
elementIndexThe index at which the instruction containing the immediate element starts.
immElemThe immediate element.
instructionThe instruction that contains the immediate terminal.
Returns
The immediate terminal or NULL if there is no such terminal.

Definition at line 1712 of file CodeCompressorPlugin.cc.

1716  {
1717 
1718  if (!immElem.isInline()) {
1719  return NULL;
1720  }
1721 
1722  Byte busIndex = immElem.destinationIndex();
1723  string busName = "";
1724  for (unsigned int i = elementIndex; i < codeSection.elementCount();
1725  i++) {
1726  InstructionElement* element = dynamic_cast<InstructionElement*>(
1727  codeSection.element(i));
1728  if (element->begin() && i > elementIndex) {
1729  assert(false);
1730  }
1731  MoveElement* moveElem = dynamic_cast<MoveElement*>(element);
1732  if (moveElem != NULL &&
1733  moveElem->sourceType() == MoveElement::MF_IMM &&
1734  moveElem->sourceIndex() == busIndex) {
1735  busName = TPEFTools::resourceName(
1736  *currentTPEF_, ResourceElement::MRT_BUS, moveElem->bus());
1737  break;
1738  }
1739  }
1740 
1741  assert(busName != "");
1742 
1743  for (int i = 0; i < instruction.moveCount(); i++) {
1744  Move& move = instruction.move(i);
1745  if (move.bus().name() == busName) {
1746  return &move.source();
1747  }
1748  }
1749 
1750  assert(false);
1751  return NULL;
1752 }

References assert, TPEF::InstructionElement::begin(), TPEF::MoveElement::bus(), TTAProgram::Move::bus(), currentTPEF_, TPEF::ImmediateElement::destinationIndex(), TPEF::CodeSection::element(), TPEF::Section::elementCount(), TPEF::ImmediateElement::isInline(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAMachine::Component::name(), TTAProgram::Move::source(), TPEF::MoveElement::sourceIndex(), and TPEF::MoveElement::sourceType().

Referenced by initializeRelocations().

Here is the call graph for this function:

◆ indentation()

std::string CodeCompressorPlugin::indentation ( int  level)
protected

Returns the indentation string of the given level.

Parameters
levelThe indentation level.

Definition at line 652 of file CodeCompressorPlugin.cc.

652  {
653  string ind;
654  for (int i = 0; i < level; i++) {
655  ind += " ";
656  }
657  return ind;
658 }

◆ initializeRelocations()

void CodeCompressorPlugin::initializeRelocations ( )
private

Initializes the immediatesToRelocate_ and terminalsToRelocate_ members.

Definition at line 1608 of file CodeCompressorPlugin.cc.

1608  {
1609 
1610  typedef std::set<const TPEF::SectionElement*> SectionElemSet;
1611  SectionElemSet toRelocate;
1612  RelocSection* relocSection = NULL;
1613 
1614  // find the correct reloc section from tpef
1615  for (unsigned int sectionIndex = 0;
1616  sectionIndex < currentTPEF_->sectionCount(Section::ST_RELOC);
1617  sectionIndex++) {
1618  relocSection = dynamic_cast<RelocSection*>(
1619  currentTPEF_->section(Section::ST_RELOC, sectionIndex));
1620  Section* codeSection = currentTPEF_->section(Section::ST_CODE, 0);
1621  if (relocSection->referencedSection() == codeSection) {
1622  break;
1623  }
1624  }
1625 
1626  if (relocSection == NULL) {
1627  return;
1628  }
1629 
1630  // collect the section elements that are to be relocated to a set
1631  for (unsigned int i = 0; i < relocSection->elementCount(); i++) {
1632  RelocElement* element = dynamic_cast<RelocElement*>(
1633  relocSection->element(i));
1634  assert(element != NULL);
1635  SectionElement* location = element->location();
1636  SectionElement* destination = element->destination();
1637  assert(dynamic_cast<InstructionElement*>(location) != NULL);
1638  if (dynamic_cast<InstructionElement*>(destination) != NULL){
1639  toRelocate.insert(location);
1640  }
1641  }
1642 
1643  // find the corresponding Immediates and Terminals from POM and add
1644  // them to immediatesToRelocate_ and terminalsToRelocate_ members
1645  CodeSection* codeSection = dynamic_cast<CodeSection*>(
1646  currentTPEF_->section(Section::ST_CODE, 0));
1647  Instruction* instruction = &currentPOM_->firstInstruction();
1648  unsigned int instStart = 0;
1649  for (unsigned int i = 0; i < codeSection->elementCount(); i++) {
1650  InstructionElement* instructionElem =
1651  dynamic_cast<InstructionElement*>(codeSection->element(i));
1652  if (instructionElem->begin() && i > 0) {
1653  instruction = &currentPOM_->nextInstruction(*instruction);
1654  instStart = i;
1655  }
1656  if (AssocTools::containsKey(toRelocate, instructionElem)) {
1657  assert(instructionElem->isImmediate());
1658  ImmediateElement* immElem = dynamic_cast<ImmediateElement*>(
1659  instructionElem);
1660  Terminal* terminal = immediateTerminal(
1661  *codeSection, instStart, *immElem, *instruction);
1662  Immediate* immediate = programImmediate(*immElem, *instruction);
1663  if (terminal != NULL) {
1664  terminalsToRelocate_.insert(terminal);
1665  } else if (immediate != NULL) {
1666  immediatesToRelocate_.insert(immediate);
1667  } else {
1668  assert(false);
1669  }
1670  }
1671  }
1672 }

References assert, TPEF::InstructionElement::begin(), AssocTools::containsKey(), currentPOM_, currentTPEF_, TPEF::RelocElement::destination(), TPEF::CodeSection::element(), TPEF::Section::element(), TPEF::Section::elementCount(), TTAProgram::Program::firstInstruction(), immediatesToRelocate_, immediateTerminal(), TPEF::InstructionElement::isImmediate(), TPEF::RelocElement::location(), TTAProgram::Program::nextInstruction(), programImmediate(), TPEF::RelocSection::referencedSection(), TPEF::Binary::section(), TPEF::Binary::sectionCount(), and terminalsToRelocate_.

Referenced by startNewProgram().

Here is the call graph for this function:

◆ instructionTemplate()

std::string CodeCompressorPlugin::instructionTemplate ( const TTAProgram::Instruction instruction) const
private

Returns the name of the instruction template of the given instruction.

Parameters
instructionThe instruction.
Exceptions
InstanceNotFoundIf the machine does not have such an instruction template.

Definition at line 997 of file CodeCompressorPlugin.cc.

998  {
999  if (instruction.immediateCount() == 0) {
1002  for (int i = 0; i < itNav.count(); i++) {
1003  InstructionTemplate* iTemp = itNav.item(i);
1004  if (iTemp->isEmpty()) {
1005  return iTemp->name();
1006  }
1007  }
1008  const string procName = "CodeCompressorPlugin::instructionTemplate";
1009  PIGTextGenerator textGen;
1010  format text = textGen.text(PIGTextGenerator::TXT_EMPTY_ITEMP_MISSING);
1011  throw InstanceNotFound(__FILE__, __LINE__, procName, text.str());
1012  } else {
1013  return instruction.instructionTemplate().name();
1014  }
1015 }

References TTAMachine::Machine::Navigator< ComponentType >::count(), TTAProgram::Instruction::immediateCount(), TTAProgram::Instruction::instructionTemplate(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::InstructionTemplate::isEmpty(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine(), TTAMachine::Component::name(), Texts::TextGenerator::text(), and PIGTextGenerator::TXT_EMPTY_ITEMP_MISSING.

Referenced by addBitsForDstRegisterField(), addBitsForICField(), addBitsForImmediateSlot(), and addBitsForMoveSlot().

Here is the call graph for this function:

◆ machine()

const Machine & CodeCompressorPlugin::machine ( ) const

Returns the machine.

Returns
The machine.
Exceptions
NotAvailableIf the machine is not set.

Definition at line 310 of file CodeCompressorPlugin.cc.

310  {
311  if (machine_ == NULL) {
312  throw NotAvailable(__FILE__, __LINE__, __func__);
313  }
314 
315  return *machine_;
316 }

References __func__, and machine_.

Referenced by addBitsForImmediateSlot(), addBitsForMoveSlot(), encodeMove(), ProgramImageGenerator::generateDataImage(), ProgramImageGenerator::generateProgramImage(), instructionTemplate(), setMachine(), and ProgramImageGenerator::writeDataSection().

◆ memoryAddress()

unsigned int CodeCompressorPlugin::memoryAddress ( const TTAProgram::Instruction instruction) const

Tells the memory address of the given instruction.

Parameters
instructionThe instruction.
Returns
The memory address.
Exceptions
InstanceNotFoundIf the program does not contain the given instruction.

Definition at line 262 of file CodeCompressorPlugin.cc.

263  {
264  if (!MapTools::containsKey(instructionAddresses_, &instruction)) {
265  const string procName = "CodeCompressorPlugin::memoryAddress";
266  throw InstanceNotFound(__FILE__, __LINE__, procName);
267  } else {
268  return MapTools::valueForKey<unsigned int>(
269  instructionAddresses_, &instruction);
270  }
271 }

References MapTools::containsKey(), and instructionAddresses_.

Referenced by addInstruction(), and ProgramImageGenerator::writeDataSection().

Here is the call graph for this function:

◆ moveSlotCount()

int CodeCompressorPlugin::moveSlotCount ( ) const
protected

Returns the number of move slots

Definition at line 226 of file CodeCompressorPlugin.cc.

226  {
227  return bem_->moveSlotCount();
228 }

References bem_, and BinaryEncoding::moveSlotCount().

Here is the call graph for this function:

◆ moveSlotWidth()

int CodeCompressorPlugin::moveSlotWidth ( int  index) const
protected

Returns the width of the move slot in the given index

Parameters
indexIndex of move slot

Definition at line 235 of file CodeCompressorPlugin.cc.

235  {
236  return bem_->moveSlot(index).width();
237 }

References bem_, BinaryEncoding::moveSlot(), and MoveSlot::width().

Here is the call graph for this function:

◆ nextAddressablePositionFrom()

unsigned int CodeCompressorPlugin::nextAddressablePositionFrom ( unsigned int  position) const
private

Returns the next addressable position in the bit vector calculated from the given position.

Parameters
positionThe position.
Returns
The next addressable position.

Definition at line 1045 of file CodeCompressorPlugin.cc.

1046  {
1047 
1048  if (position % mau_ == 0) {
1049  return position;
1050  } else {
1051  return position + mau_ - (position % mau_);
1052  }
1053 }

References mau_.

Referenced by addInstruction().

◆ numberOfPrograms()

int CodeCompressorPlugin::numberOfPrograms ( ) const
protected

Returns the number of programs to be compressed

Returns
number of programs

Definition at line 623 of file CodeCompressorPlugin.cc.

623  {
624  return tpefPrograms_.size();
625 }

References tpefPrograms_.

◆ parameterValue()

std::string CodeCompressorPlugin::parameterValue ( const std::string &  paramName) const
protected

Returns the value of the given parameter.

Parameters
paramNameName of the parameter.
Returns
The value.
Exceptions
NotAvailableIf the given parameter is not defined.

Definition at line 578 of file CodeCompressorPlugin.cc.

578  {
579  for (ParameterTable::const_iterator iter = parameters_.begin();
580  iter != parameters_.end(); iter++) {
581  Parameter param = *iter;
582  if (param.name == paramName) {
583  return param.value;
584  }
585  }
586 
587  throw NotAvailable(__FILE__, __LINE__, __func__);
588 }

References __func__, CodeCompressorPlugin::Parameter::name, parameters_, and CodeCompressorPlugin::Parameter::value.

◆ printDescription()

virtual void CodeCompressorPlugin::printDescription ( std::ostream &  stream)
pure virtual

Prints description of the plugin to the given stream.

Implemented in InstructionDictionary, MoveSlotDictionary, and DEFAULT_Compressor.

Referenced by ProgramImageGenerator::printCompressorDescription().

◆ programBits()

InstructionBitVector * CodeCompressorPlugin::programBits ( ) const
protected

Returns the bits of the program constructed by calling addInstruction method several times.

This method creates a copy of the constructed bit vector and add extra bits to the end to make sure the length of the vector is divisible by MAU.

Returns
The program bits.

Definition at line 533 of file CodeCompressorPlugin.cc.

533  {
534 
536 
537  // add extra bits to the end if the length of program image is not
538  // divisible by MAU
539  int bitCount = mau_ - (bits->size() % mau_);
540  if (bitCount == mau_) {
541  bitCount = 0;
542  }
543  for (int i = 0; i < bitCount; i++) {
544  bits->push_back(false);
545  }
546 
547  return bits;
548 }

References mau_, and programBits_.

Referenced by DEFAULT_Compressor::compress().

◆ programElement()

CodeCompressorPlugin::TPEFMap::const_iterator CodeCompressorPlugin::programElement ( int  index) const
protected

Returns a const iterator to program map element at the given index

Returns
const iterator to program map element
Exceptions
OutOfRangeIf index is out of range

Definition at line 634 of file CodeCompressorPlugin.cc.

634  {
635  if (index >= static_cast<int>(tpefPrograms_.size())) {
636  string errorMsg("Tried to overindex program map");
637  throw OutOfRange(__FILE__, __LINE__, __func__, errorMsg);
638  }
639  TPEFMap::const_iterator iter = tpefPrograms_.begin();
640  for (int i = 0; i < index; i++) {
641  iter++;
642  }
643  return iter;
644 }

References __func__, and tpefPrograms_.

◆ programImmediate()

TTAProgram::Immediate * CodeCompressorPlugin::programImmediate ( const TPEF::ImmediateElement immElem,
const TTAProgram::Instruction instruction 
) const
private

Returns the immediate in the given instruction that matches with the given immediate element.

Parameters
immElemThe immediate element.
instructionThe instruction.
Returns
The immediate or NULL if there is no such an immediate.

Definition at line 1764 of file CodeCompressorPlugin.cc.

1766  {
1767 
1768  if (immElem.isInline()) {
1769  return NULL;
1770  }
1771 
1772  string dstUnitName = TPEFTools::resourceName(
1773  *currentTPEF_, ResourceElement::MRT_IMM, immElem.destinationUnit());
1774 
1775  for (int i = 0; i < instruction.immediateCount(); i++) {
1776  Immediate& immediate = instruction.immediate(i);
1777  const Terminal& dstTerminal = immediate.destination();
1778  assert(dstTerminal.isImmediateRegister());
1779  const ImmediateUnit& dstUnit = dstTerminal.immediateUnit();
1780  if (dstUnit.name() == dstUnitName) {
1781  return &immediate;
1782  }
1783  }
1784 
1785  assert(false);
1786  return NULL;
1787 }

References assert, currentTPEF_, TTAProgram::Immediate::destination(), TPEF::ImmediateElement::destinationUnit(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::isImmediateRegister(), TPEF::ImmediateElement::isInline(), and TTAMachine::Component::name().

Referenced by initializeRelocations().

Here is the call graph for this function:

◆ setAllInstructionsToStartAtBeginningOfMAU()

void CodeCompressorPlugin::setAllInstructionsToStartAtBeginningOfMAU ( )
protected

Sets all instructions to start at the beginning of MAU.

This method must be called before any instructions are added to the bit vector.

Definition at line 440 of file CodeCompressorPlugin.cc.

440  {
442 }

References allStartsAtBeginningOfMAU_.

Referenced by DEFAULT_Compressor::compress().

◆ setBEM()

void CodeCompressorPlugin::setBEM ( const BinaryEncoding bem)

Sets the binary encoding map.

Parameters
bemThe BEM.

Definition at line 192 of file CodeCompressorPlugin.cc.

192  {
193  bem_ = &bem;
194 }

References bem_.

Referenced by ProgramImageGenerator::loadBEM().

◆ setImemWidth()

void CodeCompressorPlugin::setImemWidth ( int  mau,
int  widthInMaus = 1 
)
protected

Sets the imem width to the given mau * widthInMaus and mau to given mau

Parameters
mauMau of instruction memory
widthInMausMemory width in maus (default = 1)

Definition at line 612 of file CodeCompressorPlugin.cc.

612  {
613  machine_->controlUnit()->addressSpace()->setWidth(mau*widthInMaus);
614  mau_ = mau;
615 }

References TTAMachine::FunctionUnit::addressSpace(), TTAMachine::Machine::controlUnit(), machine_, mau_, and TTAMachine::AddressSpace::setWidth().

Referenced by setMachine().

Here is the call graph for this function:

◆ setInstructionToStartAtBeginningOfMAU()

void CodeCompressorPlugin::setInstructionToStartAtBeginningOfMAU ( const TTAProgram::Instruction instruction)
protected

Sets the given instruction to start at the beginning of MAU.

This method must be called before the instruction is added to the bit vector.

Parameters
instructionThe instruction.

Definition at line 426 of file CodeCompressorPlugin.cc.

427  {
428 
429  instructionsAtBeginningOfMAU_.insert(&instruction);
430 }

References instructionsAtBeginningOfMAU_.

◆ setMachine()

void CodeCompressorPlugin::setMachine ( const TTAMachine::Machine machine)

Sets the machine.

Machine must be set before generating the program image. BEM must be set before calling this

Parameters
machineThe machine.
Exceptions
InvalidDataIf the machine does not have control unit.
InvalidDataIf bem is not set

Definition at line 161 of file CodeCompressorPlugin.cc.

161  {
163  if (gcu == NULL) {
164  string errorMsg = "The machine does not have GCU.";
165  throw InvalidData(__FILE__, __LINE__, __func__, errorMsg);
166  }
167  machine_ = &machine;
168  AddressSpace* iMem = gcu->addressSpace();
169  if (bem_ == NULL) {
170  string errorMsg = "Bem not set!";
171  throw InvalidData(__FILE__, __LINE__, __func__, errorMsg);
172  }
173  mau_ = bem_->width();
174  // For RISCV fix mau to 4
175  if (machine.isRISCVMachine()) {
176  mau_ = 8;
177  setImemWidth(8);
178  // fix machines imem width if adf has wrong value
179  } else if (mau_ != iMem->width()) {
181  }
182  addressSpaceOffset_ = iMem->start();
183 }

References __func__, TTAMachine::FunctionUnit::addressSpace(), addressSpaceOffset_, bem_, TTAMachine::Machine::controlUnit(), TTAMachine::Machine::isRISCVMachine(), machine(), machine_, mau_, setImemWidth(), TTAMachine::AddressSpace::start(), TTAMachine::AddressSpace::width(), and BinaryEncoding::width().

Referenced by ProgramImageGenerator::loadMachine().

Here is the call graph for this function:

◆ setParameters()

void CodeCompressorPlugin::setParameters ( ParameterTable  parameters)

Sets the plugin parameters.

Parameters
parametersThe parameters.

Definition at line 133 of file CodeCompressorPlugin.cc.

133  {
134  parameters_ = parameters;
135 }

References parameters_.

Referenced by ProgramImageGenerator::loadCompressorParameters().

◆ setPrograms()

void CodeCompressorPlugin::setPrograms ( std::map< std::string, TPEF::Binary * > &  programs)

Sets the programs to be executed in the machine.

Parameters
programMap of programs.

Definition at line 144 of file CodeCompressorPlugin.cc.

145  {
146  tpefPrograms_ = programs;
147 }

References tpefPrograms_.

Referenced by ProgramImageGenerator::loadPrograms().

◆ socketCodeBits()

BitVector CodeCompressorPlugin::socketCodeBits ( const SocketCodeTable socketCodes,
const PortCode portCode,
unsigned int  registerIndex 
)
staticprivate

Creates a bit vector that encodes the given register file terminal.

Parameters
socketCodesThe socket code table that contains the port codes.
portCodeThe port code that defines the encoding.
registerIndexThe register index to be encoded.
Returns
Bit vector that contains encoding for the register file terminal.

Definition at line 1588 of file CodeCompressorPlugin.cc.

1591  {
1592 
1593  BitVector bits;
1594  unsigned int encodingWidth = portCode.width() - portCode.indexWidth();
1595  if (portCode.hasEncoding()) {
1596  bits.pushBack(portCode.encoding(), encodingWidth);
1597  }
1598  bits.pushBack(registerIndex, socketCodes.width() - encodingWidth);
1599  assert(bits.size() == static_cast<size_t>(socketCodes.width()));
1600  return bits;
1601 }

References assert, PortCode::encoding(), PortCode::hasEncoding(), PortCode::indexWidth(), BitVector::pushBack(), PortCode::width(), and SocketCodeTable::width().

Referenced by encodeFUTerminal(), encodeIUTerminal(), encodeRFTerminal(), and encodeSlotField().

Here is the call graph for this function:

◆ startNewProgram()

void CodeCompressorPlugin::startNewProgram ( const std::string &  programName)
protected

Starts generating new program image.

This function must be called always before starting to add instructions to the program image.

Parameters
programNameThe program of which to generate the image.
Exceptions
InvalidDataIf the program object model cannot be created.

Definition at line 328 of file CodeCompressorPlugin.cc.

328  {
329  if (programBits_ != NULL) {
330  delete programBits_;
331  programBits_ = NULL;
332  }
333 
334  if (tpefPrograms_.find(programName) == tpefPrograms_.end()) {
335  string errorMsg = "Program " + programName + " not found from "
336  + "compressor plugin";
337  throw InvalidData(__FILE__, __LINE__, __func__, errorMsg);
338  }
339 
340  TPEF::Binary* program = tpefPrograms_.find(programName)->second;
341 
342  if (program == NULL) {
343  string errorMsg = "Program bits for program " + programName
344  + " not found";
345  throw InvalidData(__FILE__, __LINE__, __func__, errorMsg);
346  }
347 
350 
351  if (currentPOM_ != NULL) {
352  delete currentPOM_;
353  currentPOM_ = NULL;
354  }
355 
356  TPEFProgramFactory factory(*program, *machine_);
357  try {
358  currentPOM_ = factory.build();
359  } catch (const Exception& e) {
360  throw InvalidData(__FILE__, __LINE__, __func__, e.errorMessage());
361  }
362 
363  // clear previous relocations
364  if (immediatesToRelocate_.size() != 0) {
365  immediatesToRelocate_.clear();
366  }
367  if (terminalsToRelocate_.size() != 0) {
368  terminalsToRelocate_.clear();
369  }
371 }

References __func__, TTAProgram::TPEFProgramFactory::build(), currentPOM_, currentTPEF_, Exception::errorMessage(), immediatesToRelocate_, initializeRelocations(), machine_, program, programBits_, terminalsToRelocate_, and tpefPrograms_.

Referenced by DEFAULT_Compressor::compress().

Here is the call graph for this function:

◆ startsAtBeginningOfMAU()

bool CodeCompressorPlugin::startsAtBeginningOfMAU ( const TTAProgram::Instruction instruction) const
private

Tells whether the given instruction starts at the beginning of MAU.

Parameters
instructionThe instruction.
Returns
True if the instruction start at the beginning of MAU, otherwise false.

Definition at line 1025 of file CodeCompressorPlugin.cc.

1026  {
1027 
1029  return true;
1030  } else {
1031  return AssocTools::containsKey(
1032  instructionsAtBeginningOfMAU_, &instruction);
1033  }
1034 }

References allStartsAtBeginningOfMAU_, AssocTools::containsKey(), and instructionsAtBeginningOfMAU_.

Referenced by addInstruction().

Here is the call graph for this function:

Member Data Documentation

◆ addressSpaceOffset_

int CodeCompressorPlugin::addressSpaceOffset_
private

The offset of the instruction memory (the address of the first instruction).

Definition at line 283 of file CodeCompressorPlugin.hh.

Referenced by addInstruction(), and setMachine().

◆ allStartsAtBeginningOfMAU_

bool CodeCompressorPlugin::allStartsAtBeginningOfMAU_
private

Tells whether all the instructions starts at the beginning of MAU.

Definition at line 278 of file CodeCompressorPlugin.hh.

Referenced by setAllInstructionsToStartAtBeginningOfMAU(), and startsAtBeginningOfMAU().

◆ bem_

const BinaryEncoding* CodeCompressorPlugin::bem_
private

◆ currentPOM_

TTAProgram::Program* CodeCompressorPlugin::currentPOM_
private

◆ currentProgram_

std::string CodeCompressorPlugin::currentProgram_
private

The current program.

Definition at line 266 of file CodeCompressorPlugin.hh.

◆ currentTPEF_

TPEF::Binary* CodeCompressorPlugin::currentTPEF_
private

◆ immediatesToRelocate_

ImmediateSet CodeCompressorPlugin::immediatesToRelocate_
private

Set of (long) immediates that refer to an instruction.

Definition at line 288 of file CodeCompressorPlugin.hh.

Referenced by encodeLongImmediate(), initializeRelocations(), and startNewProgram().

◆ indexTable_

IndexTable CodeCompressorPlugin::indexTable_
private

A table of indexes used when encoding long immediates.

Definition at line 296 of file CodeCompressorPlugin.hh.

Referenced by bemBits(), bemInstructionBits(), and encodeLongImmediate().

◆ instructionAddresses_

InstructionAddressMap CodeCompressorPlugin::instructionAddresses_
private

Contains the addresses of instructions.

Definition at line 299 of file CodeCompressorPlugin.hh.

Referenced by addInstruction(), and memoryAddress().

◆ instructionsAtBeginningOfMAU_

InstructionSet CodeCompressorPlugin::instructionsAtBeginningOfMAU_
private

Set of instructions that start at the beginning of MAU.

Definition at line 286 of file CodeCompressorPlugin.hh.

Referenced by setInstructionToStartAtBeginningOfMAU(), and startsAtBeginningOfMAU().

◆ machine_

const TTAMachine::Machine* CodeCompressorPlugin::machine_
private

The machine.

Definition at line 271 of file CodeCompressorPlugin.hh.

Referenced by machine(), setImemWidth(), setMachine(), and startNewProgram().

◆ mau_

int CodeCompressorPlugin::mau_
private

The size of the minimum addressable unit.

Definition at line 280 of file CodeCompressorPlugin.hh.

Referenced by addInstruction(), imemMauWidth(), nextAddressablePositionFrom(), programBits(), setImemWidth(), and setMachine().

◆ parameters_

ParameterTable CodeCompressorPlugin::parameters_
private

Parameters for the plugin.

Definition at line 273 of file CodeCompressorPlugin.hh.

Referenced by hasParameter(), parameterValue(), and setParameters().

◆ programBits_

InstructionBitVector* CodeCompressorPlugin::programBits_
private

The bits of the program.

Definition at line 276 of file CodeCompressorPlugin.hh.

Referenced by addInstruction(), programBits(), startNewProgram(), and ~CodeCompressorPlugin().

◆ relocMap_

RelocMap CodeCompressorPlugin::relocMap_
private

Contains information to which instructions the immediates are referring to.

Definition at line 294 of file CodeCompressorPlugin.hh.

Referenced by bemBits(), bemInstructionBits(), and encodeLongImmediate().

◆ terminalsToRelocate_

TerminalSet CodeCompressorPlugin::terminalsToRelocate_
private

Set of (short) immediate terminals that refer to an instruction.

Definition at line 290 of file CodeCompressorPlugin.hh.

Referenced by encodeImmediateTerminal(), initializeRelocations(), and startNewProgram().

◆ tpefPrograms_

TPEFMap CodeCompressorPlugin::tpefPrograms_
private

Programs run in the machine.

Definition at line 260 of file CodeCompressorPlugin.hh.

Referenced by numberOfPrograms(), programElement(), setPrograms(), and startNewProgram().


The documentation for this class was generated from the following files:
NullUnconditionalGuardEncoding::instance
static NullUnconditionalGuardEncoding & instance()
Definition: NullUnconditionalGuardEncoding.cc:64
TPEF::CodeSection::element
virtual InstructionElement * element(Word index) const
Definition: CodeSection.cc:88
TTAMachine::Guard
Definition: Guard.hh:55
CodeCompressorPlugin::instructionAddresses_
InstructionAddressMap instructionAddresses_
Contains the addresses of instructions.
Definition: CodeCompressorPlugin.hh:299
TTAProgram::Terminal::isFUPort
virtual bool isFUPort() const
Definition: Terminal.cc:118
TTAProgram::Immediate::value
TerminalImmediate & value() const
Definition: Immediate.cc:103
UIntWord
Word UIntWord
Definition: BaseType.hh:144
TTAMachine::InstructionTemplate::slotOfDestination
virtual std::string slotOfDestination(const ImmediateUnit &dstUnit, int index) const
Definition: InstructionTemplate.cc:395
SlotField::noOperationEncoding
NOPEncoding & noOperationEncoding() const
Definition: SlotField.cc:281
TTAProgram::Program::firstInstruction
Instruction & firstInstruction() const
Definition: Program.cc:353
TTAMachine::Port::inputSocket
virtual Socket * inputSocket() const
Definition: Port.cc:261
MoveSlot::name
std::string name() const
Definition: MoveSlot.cc:136
CodeCompressorPlugin::socketCodeBits
static BitVector socketCodeBits(const SocketCodeTable &socketCodes, const PortCode &portCode, unsigned int registerIndex)
Definition: CodeCompressorPlugin.cc:1588
InstructionBitVector::addIndexBoundsForReference
void addIndexBoundsForReference(IndexBound bounds)
Definition: InstructionBitVector.cc:179
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
CodeCompressorPlugin::terminalsToRelocate_
TerminalSet terminalsToRelocate_
Set of (short) immediate terminals that refer to an instruction.
Definition: CodeCompressorPlugin.hh:290
TTAProgram::Instruction::move
Move & move(int i) const
Definition: Instruction.cc:193
PIGTextGenerator::TXT_SOCKET_ENCODING_MISSING
@ TXT_SOCKET_ENCODING_MISSING
Definition: PIGTextGenerator.hh:55
TTAMachine::PortGuard::port
FUPort * port() const
DestinationField
Definition: DestinationField.hh:44
MoveSlot
Definition: MoveSlot.hh:60
TTAProgram::Terminal::index
virtual int index() const
Definition: Terminal.cc:274
CodeCompressorPlugin::indexTable_
IndexTable indexTable_
A table of indexes used when encoding long immediates.
Definition: CodeCompressorPlugin.hh:296
TTAMachine::Machine::isRISCVMachine
bool isRISCVMachine() const
Definition: Machine.cc:1063
CodeCompressorPlugin::instructionsAtBeginningOfMAU_
InstructionSet instructionsAtBeginningOfMAU_
Set of instructions that start at the beginning of MAU.
Definition: CodeCompressorPlugin.hh:286
TPEF::ImmediateElement::destinationIndex
Byte destinationIndex() const
CodeCompressorPlugin::tpefPrograms_
TPEFMap tpefPrograms_
Programs run in the machine.
Definition: CodeCompressorPlugin.hh:260
CodeCompressorPlugin::encodeFUTerminal
static void encodeFUTerminal(const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector)
Definition: CodeCompressorPlugin.cc:1418
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
TTAMachine::RegisterGuard::registerIndex
int registerIndex() const
CodeCompressorPlugin::allStartsAtBeginningOfMAU_
bool allStartsAtBeginningOfMAU_
Tells whether all the instructions starts at the beginning of MAU.
Definition: CodeCompressorPlugin.hh:278
GuardField::fuGuardEncoding
FUGuardEncoding & fuGuardEncoding(int index) const
Definition: GuardField.cc:387
TTAProgram::Terminal::registerFile
virtual const TTAMachine::RegisterFile & registerFile() const
Definition: Terminal.cc:225
TPEF::InstructionElement
Definition: InstructionElement.hh:77
BitVector
Definition: BitVector.hh:44
BinaryEncoding::longImmDstRegisterFieldCount
int longImmDstRegisterFieldCount() const
Definition: BinaryEncoding.cc:400
PIGTextGenerator::TXT_OSAL_OC_MISSING
@ TXT_OSAL_OC_MISSING
Definition: PIGTextGenerator.hh:59
TTAProgram::Program::nextInstruction
Instruction & nextInstruction(const Instruction &) const
Definition: Program.cc:403
CodeCompressorPlugin::encodeIUTerminal
static void encodeIUTerminal(const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector)
Definition: CodeCompressorPlugin.cc:1288
TPEF::Binary
Definition: Binary.hh:49
SocketCodeTable::fuPortCode
FUPortCode & fuPortCode(int index) const
Definition: SocketCodeTable.cc:308
AssocTools::containsKey
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
TTAProgram::Instruction
Definition: Instruction.hh:57
InstructionBitVector::startSettingInstructionReference
void startSettingInstructionReference(const TTAProgram::Instruction &instruction)
Definition: InstructionBitVector.cc:160
TTAProgram::Move::isUnconditional
bool isUnconditional() const
Definition: Move.cc:154
SlotField::hasSocketEncoding
bool hasSocketEncoding(const std::string &socket) const
Definition: SlotField.cc:188
OutOfRange
Definition: Exception.hh:320
SocketCodeTable::hasRFPortCode
bool hasRFPortCode(const std::string &regFile) const
Definition: SocketCodeTable.cc:502
TTAMachine::Bus
Definition: Bus.hh:53
CodeCompressorPlugin::parameters_
ParameterTable parameters_
Parameters for the plugin.
Definition: CodeCompressorPlugin.hh:273
TTAProgram::Move::destination
Terminal & destination() const
Definition: Move.cc:323
BinaryEncoding::hasImmediateControlField
bool hasImmediateControlField() const
Definition: BinaryEncoding.cc:334
PIGTextGenerator::TXT_RF_PORT_CODE_MISSING
@ TXT_RF_PORT_CODE_MISSING
Definition: PIGTextGenerator.hh:57
IUPortCode
Definition: IUPortCode.hh:41
TTAProgram::Move::bus
const TTAMachine::Bus & bus() const
Definition: Move.cc:373
CodeCompressorPlugin::initializeRelocations
void initializeRelocations()
Definition: CodeCompressorPlugin.cc:1608
SocketCodeTable::rfPortCode
RFPortCode & rfPortCode(int index) const
Definition: SocketCodeTable.cc:484
RFPortCode
Definition: RFPortCode.hh:44
FUPortCode
Definition: FUPortCode.hh:47
GuardField
Definition: GuardField.hh:55
NullImmediateEncoding::instance
static NullImmediateEncoding & instance()
Definition: NullImmediateEncoding.cc:65
CodeCompressorPlugin::currentPOM_
TTAProgram::Program * currentPOM_
The current program in POM.
Definition: CodeCompressorPlugin.hh:264
CodeCompressorPlugin::encodeImmediateTerminal
void encodeImmediateTerminal(const SourceField &field, const TTAProgram::Terminal &terminal, InstructionBitVector &bitVector) const
Definition: CodeCompressorPlugin.cc:1503
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
TPEF::ImmediateElement
Definition: ImmediateElement.hh:49
TPEF::Binary::section
Section * section(Word index) const
GuardField::unconditionalGuardEncoding
UnconditionalGuardEncoding & unconditionalGuardEncoding(bool inverted) const
Definition: GuardField.cc:490
TPEF::InstructionElement::isImmediate
bool isImmediate() const
TPEF::RelocSection::referencedSection
Section * referencedSection() const
SlotField::hasNoOperationEncoding
bool hasNoOperationEncoding() const
Definition: SlotField.cc:267
TPEF::MoveElement::sourceIndex
HalfWord sourceIndex() const
TPEF::Binary::sectionCount
Word sectionCount() const
Byte
unsigned char Byte
Definition: BaseType.hh:116
TTAMachine::Machine::Navigator::count
int count() const
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
SimValue::uIntWordValue
UIntWord uIntWordValue() const
Definition: SimValue.cc:972
NullNOPEncoding::instance
static NullNOPEncoding & instance()
Definition: NullNOPEncoding.cc:65
FUGuardEncoding
Definition: FUGuardEncoding.hh:47
NullOperation::instance
static NullOperation & instance()
CodeCompressorPlugin::addBitsForGuardField
static void addBitsForGuardField(const GuardField &guardField, const TTAProgram::Move &move, BitVector &bitVector)
Definition: CodeCompressorPlugin.cc:824
SlotField::socketEncoding
SocketEncoding & socketEncoding(int index) const
Definition: SlotField.cc:170
CodeCompressorPlugin::addBits
static void addBits(unsigned int number, int leftmostBit, int rightmostBit, BitVector &bitVector)
Definition: CodeCompressorPlugin.cc:1688
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
TPEF::RelocSection
Definition: RelocSection.hh:47
PIGTextGenerator::TXT_GPR_GUARD_ENCODING_MISSING
@ TXT_GPR_GUARD_ENCODING_MISSING
Definition: PIGTextGenerator.hh:53
NotAvailable
Definition: Exception.hh:728
TPEF::MoveElement::bus
HalfWord bus() const
TPEF::Section
Definition: Section.hh:64
ImmediateSlotField
Definition: ImmediateSlotField.hh:44
InstructionField
Definition: InstructionField.hh:43
SocketCodeTable
Definition: SocketCodeTable.hh:68
TTAMachine::BaseRegisterFile::numberOfRegisters
virtual int numberOfRegisters() const
TTAProgram::Terminal::operation
virtual Operation & operation() const
Definition: Terminal.cc:319
TTAMachine::InstructionTemplate
Definition: InstructionTemplate.hh:49
BitVector::pushBack
void pushBack(long long unsigned int integer, int size)
Definition: BitVector.cc:94
CodeCompressorPlugin::machine
const TTAMachine::Machine & machine() const
Definition: CodeCompressorPlugin.cc:310
CodeCompressorPlugin::addBitsForDestinationField
static void addBitsForDestinationField(const DestinationField &dstField, const TTAProgram::Move &move, BitVector &bitVector)
Definition: CodeCompressorPlugin.cc:800
TTAProgram::TPEFProgramFactory
Definition: TPEFProgramFactory.hh:87
TTAProgram::Immediate::destination
const Terminal & destination() const
Definition: Immediate.cc:92
TPEF::Section::element
SectionElement * element(Word index) const
assert
#define assert(condition)
Definition: Application.hh:86
TTAProgram::TerminalImmediate::value
virtual SimValue value() const
Definition: TerminalImmediate.cc:75
TTAProgram::Program::instructionAt
Instruction & instructionAt(InstructionAddress address) const
Definition: Program.cc:374
CodeCompressorPlugin::addressSpaceOffset_
int addressSpaceOffset_
The offset of the instruction memory (the address of the first instruction).
Definition: CodeCompressorPlugin.hh:283
GuardField::gprGuardEncoding
GPRGuardEncoding & gprGuardEncoding(int index) const
Definition: GuardField.cc:290
TTAMachine::AddressSpace::setWidth
virtual void setWidth(int width)
Definition: AddressSpace.cc:215
Encoding::width
virtual int width() const
Definition: Encoding.cc:130
TTAProgram::Terminal::isImmediateRegister
virtual bool isImmediateRegister() const
Definition: Terminal.cc:97
CodeCompressorPlugin::addBitsForICField
void addBitsForICField(const ImmediateControlField &icField, const TTAProgram::Instruction &instruction, BitVector &bitVector) const
Definition: CodeCompressorPlugin.cc:669
PIGTextGenerator::TXT_IU_PORT_CODE_MISSING
@ TXT_IU_PORT_CODE_MISSING
Definition: PIGTextGenerator.hh:56
TTAProgram::Immediate
Definition: Immediate.hh:54
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
IndexBound
Definition: IndexBound.hh:40
ImmediateControlField
Definition: ImmediateControlField.hh:57
TTAMachine::InstructionTemplate::numberOfSlots
virtual int numberOfSlots(const ImmediateUnit &dstUnit) const
Definition: InstructionTemplate.cc:367
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
ImmediateControlField::width
virtual int width() const
Definition: ImmediateControlField.cc:243
InvalidData
Definition: Exception.hh:149
CodeCompressorPlugin::programImmediate
TTAProgram::Immediate * programImmediate(const TPEF::ImmediateElement &immElem, const TTAProgram::Instruction &instruction) const
Definition: CodeCompressorPlugin.cc:1764
PortCode::indexWidth
int indexWidth() const
Definition: PortCode.cc:215
PortCode::width
int width() const
Definition: PortCode.cc:188
MoveSlot::guardField
GuardField & guardField() const
Definition: MoveSlot.cc:215
TTAProgram::CodeSnippet::instructionCount
virtual int instructionCount() const
Definition: CodeSnippet.cc:205
TTAMachine::ControlUnit
Definition: ControlUnit.hh:50
PIGTextGenerator::TXT_BEM_DEFINES_SLOT_FOR_NONEXISTING_BUS
@ TXT_BEM_DEFINES_SLOT_FOR_NONEXISTING_BUS
Definition: PIGTextGenerator.hh:49
PIGTextGenerator::TXT_FU_PORT_CODE_MISSING
@ TXT_FU_PORT_CODE_MISSING
Definition: PIGTextGenerator.hh:60
CodeCompressorPlugin::currentProgram_
std::string currentProgram_
The current program.
Definition: CodeCompressorPlugin.hh:266
TTAMachine::RegisterGuard
Definition: Guard.hh:137
NullGPRGuardEncoding::instance
static NullGPRGuardEncoding & instance()
Definition: NullGPRGuardEncoding.cc:64
TTAMachine::Port
Definition: Port.hh:54
SourceField::immediateEncoding
ImmediateEncoding & immediateEncoding() const
Definition: SourceField.cc:293
CodeCompressorPlugin::bemInstructionBits
InstructionBitVector * bemInstructionBits(const TTAProgram::Instruction &)
Definition: CodeCompressorPlugin.cc:454
GuardField::parent
MoveSlot * parent() const
Definition: GuardField.cc:117
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
SocketCodeTable::iuPortCode
IUPortCode & iuPortCode(int index) const
Definition: SocketCodeTable.cc:600
BinaryEncoding::width
virtual int width(const TCEString &templateName) const
Definition: BinaryEncoding.cc:768
TTAProgram::Move::guard
MoveGuard & guard() const
Definition: Move.cc:345
CodeCompressorPlugin::programBits_
InstructionBitVector * programBits_
The bits of the program.
Definition: CodeCompressorPlugin.hh:276
TPEF::MoveElement
Definition: MoveElement.hh:47
TPEF::RelocElement::destination
SectionElement * destination() const
BinaryEncoding::LEFT
@ LEFT
Definition: BinaryEncoding.hh:64
TPEF::SectionElement
Definition: SectionElement.hh:44
__func__
#define __func__
Definition: Application.hh:67
LImmDstRegisterField::immediateUnit
std::string immediateUnit(const std::string &instructionTemplate) const
Definition: LImmDstRegisterField.cc:197
SlotField::width
virtual int width() const
Definition: SlotField.cc:307
PIGTextGenerator
Definition: PIGTextGenerator.hh:41
CodeCompressorPlugin::encodeLongImmediate
void encodeLongImmediate(const std::string &slotName, int slotWidth, const TTAProgram::Instruction &instruction, BitVector &bitVector)
Definition: CodeCompressorPlugin.cc:1066
TPEF::InstructionElement::begin
bool begin() const
TTAProgram::Terminal::isGPR
virtual bool isGPR() const
Definition: Terminal.cc:107
SocketEncoding::hasSocketCodes
bool hasSocketCodes() const
Definition: SocketEncoding.cc:177
TTAProgram::Terminal::value
virtual SimValue value() const
Definition: Terminal.cc:178
SocketCodeTable::hasFUPortCode
bool hasFUPortCode(const std::string &fu, const std::string &port) const
Definition: SocketCodeTable.cc:326
TTAProgram::Terminal::immediateUnit
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
Definition: Terminal.cc:240
SourceField::width
virtual int width() const
Definition: SourceField.cc:308
TTAMachine::InstructionTemplate::supportedWidth
virtual int supportedWidth() const
Definition: InstructionTemplate.cc:427
Encoding::encoding
unsigned int encoding() const
Definition: Encoding.cc:108
GuardField::hasUnconditionalGuardEncoding
bool hasUnconditionalGuardEncoding(bool inverted) const
Definition: GuardField.cc:471
TTAProgram::Move
Definition: Move.hh:55
SlotField::componentIDPosition
BinaryEncoding::Position componentIDPosition() const
Definition: SlotField.cc:296
LImmDstRegisterField::width
virtual int width() const
Definition: LImmDstRegisterField.cc:213
Exception
Definition: Exception.hh:54
SocketCodeTable::hasIUPortCode
bool hasIUPortCode(const std::string &immediateUnit) const
Definition: SocketCodeTable.cc:618
GuardEncoding::encoding
unsigned int encoding() const
Definition: GuardEncoding.cc:112
CodeCompressorPlugin::instructionTemplate
std::string instructionTemplate(const TTAProgram::Instruction &instruction) const
Definition: CodeCompressorPlugin.cc:997
CodeCompressorPlugin::mau_
int mau_
The size of the minimum addressable unit.
Definition: CodeCompressorPlugin.hh:280
MoveSlot::width
virtual int width() const
Definition: MoveSlot.cc:406
MoveSlot::sourceField
SourceField & sourceField() const
Definition: MoveSlot.cc:277
TPEF::CodeSection
Definition: CodeSection.hh:44
CodeCompressorPlugin::currentTPEF_
TPEF::Binary * currentTPEF_
The current TPEF.
Definition: CodeCompressorPlugin.hh:262
ImmediateSlotField::width
virtual int width() const
Definition: ImmediateSlotField.cc:167
CodeCompressorPlugin::bem_
const BinaryEncoding * bem_
The binary encoding map.
Definition: CodeCompressorPlugin.hh:269
NOPEncoding
Definition: NOPEncoding.hh:44
CodeCompressorPlugin::addBitsForMoveSlot
void addBitsForMoveSlot(const MoveSlot &slot, const TTAProgram::Instruction &instruction, InstructionBitVector &bitVector)
Definition: CodeCompressorPlugin.cc:709
InstructionBitVector::fixInstructionAddress
void fixInstructionAddress(const TTAProgram::Instruction &instruction, unsigned int address)
Definition: InstructionBitVector.cc:199
TPEF::RelocElement
Definition: RelocElement.hh:51
TTAProgram::Instruction::immediate
Immediate & immediate(int i) const
Definition: Instruction.cc:285
PIGTextGenerator::TXT_EMPTY_ITEMP_MISSING
@ TXT_EMPTY_ITEMP_MISSING
Definition: PIGTextGenerator.hh:48
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
TTAProgram::Terminal::isOpcodeSetting
virtual bool isOpcodeSetting() const
Definition: Terminal.cc:285
CodeCompressorPlugin::addBitsForImmediateSlot
void addBitsForImmediateSlot(const ImmediateSlotField &immSlot, const TTAProgram::Instruction &instruction, BitVector &bitVector)
Definition: CodeCompressorPlugin.cc:911
CodeCompressorPlugin::nextAddressablePositionFrom
unsigned int nextAddressablePositionFrom(unsigned int position) const
Definition: CodeCompressorPlugin.cc:1045
CodeCompressorPlugin::memoryAddress
unsigned int memoryAddress(const TTAProgram::Instruction &instruction) const
Definition: CodeCompressorPlugin.cc:262
TTAProgram::TerminalFUPort
Definition: TerminalFUPort.hh:56
CodeCompressorPlugin::immediatesToRelocate_
ImmediateSet immediatesToRelocate_
Set of (long) immediates that refer to an instruction.
Definition: CodeCompressorPlugin.hh:288
TTAProgram::Instruction::instructionTemplate
const TTAMachine::InstructionTemplate & instructionTemplate() const
Definition: Instruction.cc:523
MathTools::bit
static bool bit(ULongWord integer, unsigned int index)
PIGTextGenerator::TXT_IMMEDIATE_ENCODING_MISSING
@ TXT_IMMEDIATE_ENCODING_MISSING
Definition: PIGTextGenerator.hh:61
TTAProgram::Terminal::functionUnit
virtual const TTAMachine::FunctionUnit & functionUnit() const
Definition: Terminal.cc:251
TTAMachine::AddressSpace::width
virtual int width() const
Definition: AddressSpace.cc:155
CodeCompressorPlugin::relocMap_
RelocMap relocMap_
Contains information to which instructions the immediates are referring to.
Definition: CodeCompressorPlugin.hh:294
NullFUGuardEncoding::instance
static NullFUGuardEncoding & instance()
Definition: NullFUGuardEncoding.cc:64
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
ImmediateSlotField::name
std::string name() const
Definition: ImmediateSlotField.cc:123
ImmediateEncoding::encodingWidth
int encodingWidth() const
Definition: ImmediateEncoding.cc:155
SocketEncoding::socketIDWidth
int socketIDWidth() const
Definition: SocketEncoding.cc:264
CodeCompressorPlugin::addBitsForSourceField
void addBitsForSourceField(const SourceField &srcField, const TTAProgram::Move &move, InstructionBitVector &bitVector) const
Definition: CodeCompressorPlugin.cc:770
TTAMachine::Guard::isInverted
virtual bool isInverted() const
CodeCompressorPlugin::encodeNOP
static void encodeNOP(const MoveSlot &slot, BitVector &bitVector)
Definition: CodeCompressorPlugin.cc:1204
CodeCompressorPlugin::machine_
const TTAMachine::Machine * machine_
The machine.
Definition: CodeCompressorPlugin.hh:271
MapTools::valueForKey
static ValueType valueForKey(const MapType &aMap, const KeyType &aKey)
MoveSlot::childField
virtual InstructionField & childField(int position) const
Definition: MoveSlot.cc:380
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
PIGTextGenerator::TXT_FU_OC_PORT_CODE_MISSING
@ TXT_FU_OC_PORT_CODE_MISSING
Definition: PIGTextGenerator.hh:58
CodeCompressorPlugin::encodeMove
void encodeMove(const MoveSlot &slot, const TTAProgram::Instruction &instruction, InstructionBitVector &bitVector) const
Definition: CodeCompressorPlugin.cc:1151
TTAProgram::Instruction::immediateCount
int immediateCount() const
Definition: Instruction.cc:267
TTAProgram::TerminalFUPort::hwOperation
virtual const TTAMachine::HWOperation * hwOperation() const
Definition: TerminalFUPort.cc:379
TTAMachine::Machine::busNavigator
virtual BusNavigator busNavigator() const
Definition: Machine.cc:356
TTAMachine::InstructionTemplate::isEmpty
virtual bool isEmpty() const
Definition: InstructionTemplate.cc:494
LImmDstRegisterField
Definition: LImmDstRegisterField.hh:47
InstructionBitVector::markInstructionStartingPoint
void markInstructionStartingPoint(unsigned int position)
Definition: InstructionBitVector.cc:224
TTAMachine::Port::outputSocket
virtual Socket * outputSocket() const
Definition: Port.cc:281
PIGTextGenerator::TXT_NOP_ENCODING_MISSING
@ TXT_NOP_ENCODING_MISSING
Definition: PIGTextGenerator.hh:54
TTAProgram::Terminal
Definition: Terminal.hh:60
BinaryEncoding::immediateControlField
ImmediateControlField & immediateControlField() const
Definition: BinaryEncoding.cc:348
TTAProgram::CodeSnippet::instructionAtIndex
virtual Instruction & instructionAtIndex(int index) const
Definition: CodeSnippet.cc:285
BinaryEncoding::moveSlot
MoveSlot & moveSlot(int index) const
Definition: BinaryEncoding.cc:121
TTAProgram::Move::source
Terminal & source() const
Definition: Move.cc:302
PortCode::hasEncoding
bool hasEncoding() const
Definition: PortCode.cc:151
BinaryEncoding::childField
virtual InstructionField & childField(int position) const
Definition: BinaryEncoding.cc:704
TPEF::ImmediateElement::destinationUnit
Byte destinationUnit() const
TTAProgram::Terminal::port
virtual const TTAMachine::Port & port() const
Definition: Terminal.cc:378
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
MoveSlot::destinationField
DestinationField & destinationField() const
Definition: MoveSlot.cc:341
TTAMachine::PortGuard
Definition: Guard.hh:99
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
ImmediateControlField::templateEncoding
unsigned int templateEncoding(const std::string &name) const
Definition: ImmediateControlField.cc:182
CodeCompressorPlugin::encodeSlotField
static void encodeSlotField(const SlotField &field, const BitVector &componentIDBits, const BitVector &socketCodeBits, BitVector &BitVector)
Definition: CodeCompressorPlugin.cc:1556
TPEF::MoveElement::sourceType
FieldType sourceType() const
TTAProgram::MoveGuard::guard
const TTAMachine::Guard & guard() const
Definition: MoveGuard.cc:86
CodeCompressorPlugin::startsAtBeginningOfMAU
bool startsAtBeginningOfMAU(const TTAProgram::Instruction &instruction) const
Definition: CodeCompressorPlugin.cc:1025
ImmediateEncoding
Definition: ImmediateEncoding.hh:44
TPEF::RelocElement::location
SectionElement * location() const
CodeCompressorPlugin::binaryEncoding
const BinaryEncoding & binaryEncoding() const
Definition: CodeCompressorPlugin.cc:280
BinaryEncoding::moveSlotCount
int moveSlotCount() const
Definition: BinaryEncoding.cc:104
TTAProgram::Terminal::isImmediate
virtual bool isImmediate() const
Definition: Terminal.cc:63
SocketEncoding::socketCodes
SocketCodeTable & socketCodes() const
Definition: SocketEncoding.cc:191
SocketEncoding
Definition: SocketEncoding.hh:51
GPRGuardEncoding
Definition: GPRGuardEncoding.hh:47
SlotField::parent
MoveSlot * parent() const
Definition: SlotField.cc:98
TTAMachine::Machine::instructionTemplateNavigator
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
Definition: Machine.cc:428
PortCode::encoding
unsigned int encoding() const
Definition: PortCode.cc:164
InstructionBitVector::pushBack
void pushBack(const InstructionBitVector &bits)
Definition: InstructionBitVector.cc:102
BinaryEncoding::longImmDstRegisterField
LImmDstRegisterField & longImmDstRegisterField(int index) const
Definition: BinaryEncoding.cc:415
TTAMachine::RegisterGuard::registerFile
const RegisterFile * registerFile() const
UnconditionalGuardEncoding
Definition: UnconditionalGuardEncoding.hh:47
TTAMachine::AddressSpace::start
virtual ULongWord start() const
Definition: AddressSpace.cc:166
TTAProgram::Procedure
Definition: Procedure.hh:55
CodeCompressorPlugin::encodeRFTerminal
static void encodeRFTerminal(const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector)
Definition: CodeCompressorPlugin.cc:1354
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
SocketCodeTable::width
int width() const
Definition: SocketCodeTable.cc:200
CodeCompressorPlugin::immediateTerminal
TTAProgram::Terminal * immediateTerminal(const TPEF::CodeSection &codeSection, unsigned int elementIndex, const TPEF::ImmediateElement &immElem, const TTAProgram::Instruction &instruction) const
Definition: CodeCompressorPlugin.cc:1712
MoveSlot::childFieldCount
virtual int childFieldCount() const
Definition: MoveSlot.cc:357
PIGTextGenerator::TXT_TEMPLATE_ENCODING_MISSING
@ TXT_TEMPLATE_ENCODING_MISSING
Definition: PIGTextGenerator.hh:47
TPEF::ImmediateElement::isInline
bool isInline() const
TTAProgram::Instruction::moveCount
int moveCount() const
Definition: Instruction.cc:176
TTAMachine::InstructionTemplate::usesSlot
virtual bool usesSlot(const std::string &slotName) const
Definition: InstructionTemplate.cc:265
GuardField::width
virtual int width() const
Definition: GuardField.cc:533
InstanceNotFound
Definition: Exception.hh:304
CodeCompressorPlugin::setImemWidth
void setImemWidth(int mau, int widthInMaus=1)
Definition: CodeCompressorPlugin.cc:612
TPEF::Section::elementCount
Word elementCount() const
CodeCompressorPlugin::addBitsForDstRegisterField
void addBitsForDstRegisterField(const LImmDstRegisterField &field, const TTAProgram::Instruction &instruction, BitVector &bitVector)
Definition: CodeCompressorPlugin.cc:960
TTAMachine::InstructionTemplate::destinationOfSlot
virtual ImmediateUnit * destinationOfSlot(const std::string &slotName) const
Definition: InstructionTemplate.cc:346
InstructionBitVector
Definition: InstructionBitVector.hh:50
TTAMachine::Port::parentUnit
Unit * parentUnit() const
SourceField
Definition: SourceField.hh:48
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50
PIGTextGenerator::TXT_FU_GUARD_ENCODING_MISSING
@ TXT_FU_GUARD_ENCODING_MISSING
Definition: PIGTextGenerator.hh:52
PIGTextGenerator::TXT_ALWAYS_TRUE_GUARD_ENCODING_MISSING
@ TXT_ALWAYS_TRUE_GUARD_ENCODING_MISSING
Definition: PIGTextGenerator.hh:51