OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 

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.
 

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

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

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}
InstructionBitVector * programBits_
The bits of the program.
TTAProgram::Program * currentPOM_
The current program in POM.

References currentPOM_, and programBits_.

◆ CodeCompressorPlugin()

CodeCompressorPlugin::CodeCompressorPlugin ( )
protected

The constructor.

Definition at line 104 of file CodeCompressorPlugin.cc.

104 :
105 tpefPrograms_(), currentTPEF_(NULL), currentPOM_(NULL),
106 currentProgram_(), bem_(NULL), machine_(NULL),
111}
IndexTable indexTable_
A table of indexes used when encoding long immediates.
int addressSpaceOffset_
The offset of the instruction memory (the address of the first instruction).
const TTAMachine::Machine * machine_
The machine.
InstructionSet instructionsAtBeginningOfMAU_
Set of instructions that start at the beginning of MAU.
ImmediateSet immediatesToRelocate_
Set of (long) immediates that refer to an instruction.
TPEF::Binary * currentTPEF_
The current TPEF.
bool allStartsAtBeginningOfMAU_
Tells whether all the instructions starts at the beginning of MAU.
RelocMap relocMap_
Contains information to which instructions the immediates are referring to.
const BinaryEncoding * bem_
The binary encoding map.
int mau_
The size of the minimum addressable unit.
ParameterTable parameters_
Parameters for the plugin.
InstructionAddressMap instructionAddresses_
Contains the addresses of instructions.
std::string currentProgram_
The current program.
TPEFMap tpefPrograms_
Programs run in the machine.
TerminalSet terminalsToRelocate_
Set of (short) immediate terminals that refer to an instruction.

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}
static bool bit(ULongWord integer, unsigned int index)

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}
#define assert(condition)
static void encodeFUTerminal(const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector)
static void encodeRFTerminal(const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector)
std::string name() const
Definition MoveSlot.cc:136
MoveSlot * parent() const
Definition SlotField.cc:98
virtual TCEString name() const
Terminal & destination() const
Definition Move.cc:323
const TTAMachine::Bus & bus() const
Definition Move.cc:373
virtual bool isGPR() const
Definition Terminal.cc:107
virtual bool isFUPort() const
Definition Terminal.cc:118

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}
#define __func__
void pushBack(long long unsigned int integer, int size)
Definition BitVector.cc:94
std::string instructionTemplate(const TTAProgram::Instruction &instruction) const
std::string errorMessage() const
Definition Exception.cc:123
virtual int width() const
std::string immediateUnit(const std::string &instructionTemplate) const
virtual int numberOfRegisters() const
const Terminal & destination() const
Definition Immediate.cc:92
Immediate & immediate(int i) const
virtual int index() const
Definition Terminal.cc:274
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
Definition Terminal.cc:240

References __func__, TTAProgram::Immediate::destination(), Exception::errorMessage(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::Terminal::immediateUnit(), LImmDstRegisterField::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}
unsigned int encoding() const
FUGuardEncoding & fuGuardEncoding(int index) const
GPRGuardEncoding & gprGuardEncoding(int index) const
virtual int width() const
MoveSlot * parent() const
static NullFUGuardEncoding & instance()
static NullGPRGuardEncoding & instance()
static NullUnconditionalGuardEncoding & instance()
virtual bool isInverted() const
FUPort * port() const
Unit * parentUnit() const
virtual std::string name() const
Definition Port.cc:141
const RegisterFile * registerFile() const
const TTAMachine::Guard & guard() const
Definition MoveGuard.cc:86
MoveGuard & guard() const
Definition Move.cc:345
bool isUnconditional() const
Definition Move.cc:154
virtual boost::format text(int textId)

References assert, GuardEncoding::encoding(), GuardField::fuGuardEncoding(), GuardField::gprGuardEncoding(), TTAProgram::Move::guard(), TTAProgram::MoveGuard::guard(), NullFUGuardEncoding::instance(), NullGPRGuardEncoding::instance(), NullUnconditionalGuardEncoding::instance(), TTAMachine::Guard::isInverted(), TTAProgram::Move::isUnconditional(), MoveSlot::name(), TTAMachine::Component::name(), TTAMachine::Port::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}
unsigned int templateEncoding(const std::string &name) const

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}
const TTAMachine::Machine & machine() const
void encodeLongImmediate(const std::string &slotName, int slotWidth, const TTAProgram::Instruction &instruction, BitVector &bitVector)
virtual int width() const
std::string name() const
virtual bool usesSlot(const std::string &slotName) const
ComponentType * item(int index) const
bool hasItem(const std::string &name) const
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
Definition Machine.cc:428

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}
void encodeMove(const MoveSlot &slot, const TTAProgram::Instruction &instruction, InstructionBitVector &bitVector) const
virtual int width() const
Definition MoveSlot.cc:406
virtual BusNavigator busNavigator() const
Definition Machine.cc:356

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}
static void encodeIUTerminal(const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector)
void encodeImmediateTerminal(const SourceField &field, const TTAProgram::Terminal &terminal, InstructionBitVector &bitVector) const
virtual int width() const
Terminal & source() const
Definition Move.cc:302
virtual bool isImmediateRegister() const
Definition Terminal.cc:97
virtual bool isImmediate() const
Definition Terminal.cc:63

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_);
413 std::pair<const Instruction*, unsigned int>(
414 &instruction, memoryAddress));
415}
unsigned int memoryAddress(const TTAProgram::Instruction &instruction) const
bool startsAtBeginningOfMAU(const TTAProgram::Instruction &instruction) const
unsigned int nextAddressablePositionFrom(unsigned int position) const
void markInstructionStartingPoint(unsigned int position)
void pushBack(const InstructionBitVector &bits)
void fixInstructionAddress(const TTAProgram::Instruction &instruction, unsigned int address)

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

Referenced by InstructionDictionary::addInstructions(), MoveSlotDictionary::addInstructions(), and 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
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}
find Finds info of the inner loops in the program
virtual int width(const TCEString &templateName) const
InstructionBitVector * bemInstructionBits(const TTAProgram::Instruction &)
virtual int instructionCount() const
virtual Instruction & instructionAtIndex(int index) const

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

Referenced by InstructionDictionary::addInstructions(), and MoveSlotDictionary::addInstructions().

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}
virtual InstructionField & childField(int position) const
void addBitsForDstRegisterField(const LImmDstRegisterField &field, const TTAProgram::Instruction &instruction, BitVector &bitVector)
void addBitsForMoveSlot(const MoveSlot &slot, const TTAProgram::Instruction &instruction, InstructionBitVector &bitVector)
const BinaryEncoding & binaryEncoding() const
void addBitsForImmediateSlot(const ImmediateSlotField &immSlot, const TTAProgram::Instruction &instruction, BitVector &bitVector)
void addBitsForICField(const ImmediateControlField &icField, const TTAProgram::Instruction &instruction, BitVector &bitVector) const
void startSettingInstructionReference(const TTAProgram::Instruction &instruction)
void addIndexBoundsForReference(IndexBound bounds)
static ValueType valueForKey(const MapType &aMap, const KeyType &aKey)
static bool containsKey(const MapType &aMap, const KeyType &aKey)

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

Referenced by InstructionDictionary::addInstructions(), MoveSlotDictionary::addInstructions(), bemBits(), DEFAULT_Compressor::compress(), ProGe::RV32MicroCodeGenerator::constructBInstructions(), ProGe::RV32MicroCodeGenerator::constructIInstructions(), ProGe::RV32MicroCodeGenerator::constructR1Instructions(), ProGe::RV32MicroCodeGenerator::constructR1RInstructions(), ProGe::RV32MicroCodeGenerator::constructRInstructions(), ProGe::RV32MicroCodeGenerator::constructSInstructions(), ProGe::RV32MicroCodeGenerator::constructUJInstructions(), ProGe::RV32MicroCodeGenerator::generateNOP(), InstructionDictionary::updateDictionary(), and MoveSlotDictionary::updateDictionary().

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(), InstructionDictionary::createDictionary(), InstructionDictionary::generateDecompressor(), ProgramImageGenerator::generateProgramImage(), and MoveSlotDictionary::printDetails().

◆ 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 InstructionDictionary, DEFAULT_Compressor, and MoveSlotDictionary.

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 InstructionDictionary::addInstructions(), MoveSlotDictionary::addInstructions(), DEFAULT_Compressor::compress(), InstructionDictionary::createDictionary(), MoveSlotDictionary::createDictionary(), 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}
static BitVector socketCodeBits(const SocketCodeTable &socketCodes, const PortCode &portCode, unsigned int registerIndex)
static void encodeSlotField(const SlotField &field, const BitVector &componentIDBits, const BitVector &socketCodeBits, BitVector &BitVector)
unsigned int encoding() const
Definition Encoding.cc:108
static NullOperation & instance()
virtual TCEString name() const
Definition Operation.cc:93
unsigned int encoding() const
Definition PortCode.cc:164
bool hasSocketEncoding(const std::string &socket) const
Definition SlotField.cc:188
SocketEncoding & socketEncoding(int index) const
Definition SlotField.cc:170
FUPortCode & fuPortCode(int index) const
bool hasFUPortCode(const std::string &fu, const std::string &port) const
SocketCodeTable & socketCodes() const
bool hasSocketCodes() const
int socketIDWidth() const
const std::string & name() const
virtual Socket * outputSocket() const
Definition Port.cc:281
virtual Socket * inputSocket() const
Definition Port.cc:261
virtual const TTAMachine::HWOperation * hwOperation() const
virtual const TTAMachine::FunctionUnit & functionUnit() const
Definition Terminal.cc:251
virtual bool isOpcodeSetting() const
Definition Terminal.cc:285
virtual Operation & operation() const
Definition Terminal.cc:319
virtual const TTAMachine::Port & port() const
Definition Terminal.cc:378

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(), MoveSlot::name(), TTAMachine::HWOperation::name(), TTAMachine::Component::name(), TTAMachine::Port::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();
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}
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
static NullImmediateEncoding & instance()
UIntWord uIntWordValue() const
Definition SimValue.cc:972
BinaryEncoding::Position componentIDPosition() const
Definition SlotField.cc:296
ImmediateEncoding & immediateEncoding() const
static NullInstruction & instance()
Instruction & instructionAt(InstructionAddress address) const
Definition Program.cc:374
virtual SimValue value() const
Definition Terminal.cc:178

References InstructionBitVector::addIndexBoundsForReference(), assert, SlotField::componentIDPosition(), AssocTools::containsKey(), currentPOM_, Encoding::encoding(), ImmediateEncoding::encodingWidth(), SourceField::immediateEncoding(), NullImmediateEncoding::instance(), TTAProgram::NullInstruction::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}
bool hasIUPortCode(const std::string &immediateUnit) const
IUPortCode & iuPortCode(int index) const

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;
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}
Word UIntWord
Definition BaseType.hh:144
static void addBits(unsigned int number, int leftmostBit, int rightmostBit, BitVector &bitVector)
static KeyType keyForValue(const MapType &aMap, const ValueType &aValue)
virtual ImmediateUnit * destinationOfSlot(const std::string &slotName) const
virtual int numberOfSlots(const ImmediateUnit &dstUnit) const
virtual std::string slotOfDestination(const ImmediateUnit &dstUnit, int index) const
TerminalImmediate & value() const
Definition Immediate.cc:103
const TTAMachine::InstructionTemplate & instructionTemplate() const
virtual SimValue value() const

References addBits(), assert, AssocTools::containsKey(), MapTools::containsKey(), currentPOM_, TTAMachine::InstructionTemplate::destinationOfSlot(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), immediatesToRelocate_, indexTable_, TTAProgram::Program::instructionAt(), TTAProgram::Instruction::instructionTemplate(), MapTools::keyForValue(), TTAMachine::InstructionTemplate::numberOfSlots(), relocMap_, TTAMachine::InstructionTemplate::slotOfDestination(), TTAMachine::InstructionTemplate::supportedWidth(), SimValue::uIntWordValue(), TTAMachine::InstructionTemplate::usesSlot(), TTAProgram::Immediate::value(), and TTAProgram::TerminalImmediate::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}
void addBitsForSourceField(const SourceField &srcField, const TTAProgram::Move &move, InstructionBitVector &bitVector) const
static void addBitsForDestinationField(const DestinationField &dstField, const TTAProgram::Move &move, BitVector &bitVector)
static void encodeNOP(const MoveSlot &slot, BitVector &bitVector)
static void addBitsForGuardField(const GuardField &guardField, const TTAProgram::Move &move, BitVector &bitVector)
SourceField & sourceField() const
Definition MoveSlot.cc:277
virtual InstructionField & childField(int position) const
Definition MoveSlot.cc:380
DestinationField & destinationField() const
Definition MoveSlot.cc:341
GuardField & guardField() const
Definition MoveSlot.cc:215
virtual int childFieldCount() const
Definition MoveSlot.cc:357
virtual int width() const
Definition SlotField.cc:307
Move & move(int i) const

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(), GuardField::width(), MoveSlot::width(), SlotField::width(), and SourceField::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}
virtual int width() const
Definition Encoding.cc:130
bool hasUnconditionalGuardEncoding(bool inverted) const
UnconditionalGuardEncoding & unconditionalGuardEncoding(bool inverted) const
static NullNOPEncoding & instance()
bool hasNoOperationEncoding() const
Definition SlotField.cc:267
NOPEncoding & noOperationEncoding() const
Definition SlotField.cc:281

References __func__, MoveSlot::childField(), MoveSlot::childFieldCount(), SlotField::componentIDPosition(), MoveSlot::destinationField(), Encoding::encoding(), GuardEncoding::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(), GuardField::width(), SlotField::width(), and SourceField::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}
RFPortCode & rfPortCode(int index) const
bool hasRFPortCode(const std::string &regFile) const
virtual const TTAMachine::RegisterFile & registerFile() const
Definition Terminal.cc:225

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
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}
ImmediateControlField & immediateControlField() const
LImmDstRegisterField & longImmDstRegisterField(int index) const
int longImmDstRegisterFieldCount() const
bool hasImmediateControlField() const

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

Referenced by MoveSlotDictionary::addInstructions(), MoveSlotDictionary::compress(), MoveSlotDictionary::evaluateMoveSlotBoundaries(), MoveSlotDictionary::generateDecompressorBody(), MoveSlotDictionary::generateDecompressorSignals(), and MoveSlotDictionary::updateDictionary().

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 DEFAULT_Compressor, InstructionDictionary, and MoveSlotDictionary.

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_.

Referenced by InstructionDictionary::compress().

◆ 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(
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}
unsigned char Byte
Definition BaseType.hh:116
virtual InstructionElement * element(Word index) const
Byte destinationIndex() const
HalfWord bus() const
HalfWord sourceIndex() const
FieldType sourceType() const
@ MF_IMM
Immediate.
@ MRT_BUS
Transport bus.
Word elementCount() const
std::string resourceName(ResourceElement::ResourceType type, HalfWord resourceId) const
Definition TPEFTools.cc:84

References assert, TPEF::InstructionElement::begin(), TTAProgram::Move::bus(), TPEF::MoveElement::bus(), currentTPEF_, TPEF::ImmediateElement::destinationIndex(), TPEF::CodeSection::element(), TPEF::Section::elementCount(), TPEF::ImmediateElement::isInline(), TPEF::MoveElement::MF_IMM, TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TPEF::ResourceElement::MRT_BUS, TTAMachine::Component::name(), TPEF::TPEFTools::resourceName(), 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}

Referenced by InstructionDictionary::generateDecompressor(), MoveSlotDictionary::generateDecompressorBody(), MoveSlotDictionary::generateDecompressorEntity(), MoveSlotDictionary::generateDecompressorProcess(), MoveSlotDictionary::generateDecompressorSignals(), and MoveSlotDictionary::generateDictionaryVhdl().

◆ 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;
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*>(
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}
TTAProgram::Immediate * programImmediate(const TPEF::ImmediateElement &immElem, const TTAProgram::Instruction &instruction) const
TTAProgram::Terminal * immediateTerminal(const TPEF::CodeSection &codeSection, unsigned int elementIndex, const TPEF::ImmediateElement &immElem, const TTAProgram::Instruction &instruction) const
Word sectionCount() const
Section * section(Word index) const
SectionElement * destination() const
SectionElement * location() const
Section * referencedSection() const
@ ST_CODE
Text section.
Definition Section.hh:79
@ ST_RELOC
Relocation section.
Definition Section.hh:74
SectionElement * element(Word index) const
Instruction & nextInstruction(const Instruction &) const
Definition Program.cc:403
Instruction & firstInstruction() const
Definition Program.cc:353

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(), TPEF::Section::ST_CODE, TPEF::Section::ST_RELOC, 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(), InstructionDictionary::compress(), 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 {
269 instructionAddresses_, &instruction);
270 }
271}

References MapTools::containsKey(), instructionAddresses_, and MapTools::keyForValue().

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

Here is the call graph for this function:

◆ moveSlotCount()

int CodeCompressorPlugin::moveSlotCount ( ) const
protected

◆ 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}
MoveSlot & moveSlot(int index) const

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

Referenced by MoveSlotDictionary::addInstructions(), MoveSlotDictionary::generateDecompressorSignals(), MoveSlotDictionary::generateDictionaryVhdl(), and MoveSlotDictionary::updateDictionary().

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_.

Referenced by InstructionDictionary::createDictionary(), and MoveSlotDictionary::createDictionary().

◆ 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.

Referenced by InstructionDictionary::compress().

◆ 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 InstructionDictionary::compress(), DEFAULT_Compressor::compress(), and MoveSlotDictionary::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_.

Referenced by InstructionDictionary::createDictionary(), and MoveSlotDictionary::createDictionary().

◆ 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(
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}
Byte destinationUnit() const
@ MRT_IMM
Immediate unit.

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

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 InstructionDictionary::compress(), DEFAULT_Compressor::compress(), MoveSlotDictionary::compress(), InstructionDictionary::createDictionary(), and MoveSlotDictionary::createDictionary().

◆ 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}
virtual void setWidth(int width)
virtual AddressSpace * addressSpace() const
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345

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

Referenced by InstructionDictionary::compress(), MoveSlotDictionary::compress(), and 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}
void setImemWidth(int mau, int widthInMaus=1)
virtual int width() const
virtual ULongWord start() const
bool isRISCVMachine() const
Definition Machine.cc:1057

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}
bool hasEncoding() const
Definition PortCode.cc:151
int indexWidth() const
Definition PortCode.cc:215
int width() const
Definition PortCode.cc:188

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
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 InstructionDictionary::compress(), DEFAULT_Compressor::compress(), MoveSlotDictionary::compress(), InstructionDictionary::createDictionary(), and MoveSlotDictionary::createDictionary().

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 {
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: