OpenASIP
2.0
|
#include <BEMGenerator.hh>
Public Member Functions | |
BEMGenerator (const TTAMachine::Machine &machine) | |
virtual | ~BEMGenerator () |
BinaryEncoding * | generate () |
Private Types | |
typedef std::map< const TTAMachine::Socket *, SocketCodeTable * > | SCTableMap |
Map type for storing Socket - SocketCodeTable pairs. More... | |
typedef std::pair< unsigned int, unsigned int > | Encoding |
Typedef for encoding (first = encoding, second = extra bits). More... | |
Static Private Member Functions | |
static int | socketCount (const TTAMachine::Bus &bus, TTAMachine::Socket::Direction direction) |
static TTAMachine::Socket & | socket (int index, const TTAMachine::Bus &bus, TTAMachine::Socket::Direction direction) |
static bool | needsSocketCodeTable (const TTAMachine::Socket &socket) |
static bool | haveEqualConnections (const TTAMachine::Socket &socket1, const TTAMachine::Socket &socket2) |
static int | sourceBridgeCount (const TTAMachine::Bus &bus) |
static TTAMachine::Bridge & | sourceBridge (int index, const TTAMachine::Bus &bus) |
static bool | hasUnconditionalGuard (const TTAMachine::Bus &bus) |
static int | requiredIndexWidth (const TTAMachine::BaseRegisterFile ®File) |
static void | calculateEncodings (const std::multiset< int > &oppositeFieldWidths, bool leftAlignment, std::multiset< Encoding > &encodings) |
static void | addExtraBits (std::multiset< Encoding > &encodings, int bitCount) |
Private Attributes | |
const TTAMachine::Machine * | machine_ |
The machine for which the BEM is generated. More... | |
SCTableMap | scTableMap_ |
A map which tells which socket code table belongs to a socket. More... | |
Generates a binary encoding map for the given machine.
Definition at line 61 of file BEMGenerator.hh.
|
private |
Typedef for encoding (first = encoding, second = extra bits).
Definition at line 72 of file BEMGenerator.hh.
|
private |
Map type for storing Socket - SocketCodeTable pairs.
Definition at line 70 of file BEMGenerator.hh.
BEMGenerator::BEMGenerator | ( | const TTAMachine::Machine & | machine | ) |
The constructor.
machine | The machine for which the binary encoding map will be generated. |
Definition at line 86 of file BEMGenerator.cc.
|
virtual |
|
private |
Adds encodings for the given destination field.
field | The destination field. |
Definition at line 521 of file BEMGenerator.cc.
References assert, TTAMachine::Machine::busNavigator(), calculateEncodings(), AssocTools::containsKey(), TTAMachine::Bus::guard(), TTAMachine::Bus::guardCount(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Guard::isInverted(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, MoveSlot::name(), TTAMachine::Component::name(), SlotField::parent(), SocketEncoding::setSocketCodes(), socket(), socketCodeTable(), socketCodeWidthsForBus(), socketCount(), and SocketCodeTable::width().
|
private |
Adds guard encodings to the given guard field.
field | The guard field. |
Definition at line 691 of file BEMGenerator.cc.
References assert, TTAMachine::Machine::busNavigator(), TTAMachine::Bus::guard(), TTAMachine::Bus::guardCount(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Guard::isInverted(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::Port::name(), MoveSlot::name(), TTAMachine::Component::name(), GuardField::parent(), TTAMachine::BaseFUPort::parentUnit(), TTAMachine::PortGuard::port(), TTAMachine::RegisterGuard::registerFile(), and TTAMachine::RegisterGuard::registerIndex().
|
private |
Adds the encoding for instruction templates to the given immediate control field.
field | The immediate control field. |
Definition at line 505 of file BEMGenerator.cc.
References ImmediateControlField::addTemplateEncoding(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, and TTAMachine::Component::name().
Referenced by addSubfields(), and addTopLevelFields().
|
private |
Adds encodings for the given source field.
field | The source field. |
Definition at line 594 of file BEMGenerator.cc.
References assert, TTAMachine::Machine::busNavigator(), calculateEncodings(), AssocTools::containsKey(), TTAMachine::Bus::guard(), TTAMachine::Bus::guardCount(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Bus::immediateWidth(), TTAMachine::Guard::isInverted(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, MoveSlot::name(), TTAMachine::Component::name(), SlotField::parent(), SocketEncoding::setSocketCodes(), socket(), socketCodeTable(), socketCodeWidthsForBus(), socketCount(), sourceBridge(), sourceBridgeCount(), and SocketCodeTable::width().
|
staticprivate |
Adds the given number of extra bits to the encodings in the given set.
encodings | The encodings. |
bitLength | The number of bits. |
Definition at line 1269 of file BEMGenerator.cc.
Referenced by calculateEncodings().
|
private |
Adds the long immediate destination register fields to the given binary encoding map.
bem | The binary encoding map. |
Definition at line 363 of file BEMGenerator.cc.
References LImmDstRegisterField::addDestination(), MathTools::bitLength(), AssocTools::containsKey(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::immediateUnitNavigator(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::InstructionTemplate::isOneOfDestinations(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::Component::name(), and TTAMachine::BaseRegisterFile::numberOfRegisters().
Referenced by addTopLevelFields().
|
private |
Adds the port codes to the given socket code table.
table | The socket code table. |
socket | The socket that will refer to the table. |
Definition at line 887 of file BEMGenerator.cc.
References assert, calculateEncodings(), AssocTools::containsKey(), TTAMachine::Socket::direction(), TTAMachine::BaseFUPort::isOpcodeSetting(), TTAMachine::HWOperation::name(), TTAMachine::Port::name(), TTAMachine::Component::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::Port::parentUnit(), TTAMachine::Socket::port(), TTAMachine::Socket::portCount(), requiredIndexWidth(), and socket().
Referenced by addSocketCodeTables().
|
private |
Adds a RISC-V format to the binary encoding map
format | The operation triggered format |
bem | The binary encoding |
Definition at line 198 of file BEMGenerator.cc.
References InstructionFormat::addOperation(), assert, MapTools::containsKey(), TTAMachine::Component::name(), TTAMachine::OperationTriggeredFormat::operations(), riscvBTypeOperations, riscvITypeOperations, riscvJTypeOperations, riscvRTypeOperations, riscvSTypeOperations, and riscvUTypeOperations.
Referenced by addTopLevelFields().
|
private |
Adds the socket code tables to the given binary encoding map.
bem | The binary encoding map. |
Definition at line 125 of file BEMGenerator.cc.
References addPortCodes(), assignSocketCodeTable(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::Component::name(), needsSocketCodeTable(), socket(), TTAMachine::Machine::socketNavigator(), and suitableSocketCodeTable().
Referenced by generate().
|
private |
Adds subfields to the given move slot.
slot | The move slot. |
Definition at line 462 of file BEMGenerator.cc.
References addEncodings(), assert, TTAMachine::Machine::busNavigator(), InstructionField::extraBits(), TTAMachine::Bus::guardCount(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::Navigator< ComponentType >::item(), BinaryEncoding::LEFT, machine_, maxLongImmSlotWidth(), MoveSlot::name(), InstructionField::setExtraBits(), and MoveSlot::width().
Referenced by generate().
|
private |
Adds the top-level fields to the given binary encoding map.
bem | The binary encoding to be modified. |
Definition at line 150 of file BEMGenerator.cc.
References addEncodings(), addLongImmDstRegisterFields(), addRiscvFormat(), TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::immediateSlotNavigator(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::Component::name(), TTAMachine::Machine::operationTriggeredFormatNavigator(), and TTAMachine::ImmediateSlot::width().
Referenced by generate().
|
private |
Assigns the given socket code table for the given socket.
socket | The socket. |
table | The socket code table. |
Definition at line 770 of file BEMGenerator.cc.
References assert, MapTools::containsKey(), scTableMap_, and socket().
Referenced by addSocketCodeTables().
|
staticprivate |
Calculates unambiguous encodings when the encodings have opposite fields of the given widths.
Minimizes both the total width of the field and the width of the encodings. Currently supports only left aligment of encodings.
oppositeFieldWidths | Widths of the opposite fields. |
alignment | Tells whether the encodings are aligned to left (true) or right (false). |
encoding | The encodings are added here. |
Definition at line 1197 of file BEMGenerator.cc.
References addExtraBits(), assert, and MathTools::bitLength().
Referenced by addEncodings(), and addPortCodes().
BinaryEncoding * BEMGenerator::generate | ( | ) |
Generates the binary encoding map.
Definition at line 104 of file BEMGenerator.cc.
References addSocketCodeTables(), addSubfields(), addTopLevelFields(), BinaryEncoding::moveSlot(), and BinaryEncoding::moveSlotCount().
Referenced by ProGe::ProGeUI::generateProcessor(), llvm::LLVMTCERISCVIntrinsicsLowering::LLVMTCERISCVIntrinsicsLowering(), ProcessorImplementationWindow::loadICDecoderPlugin(), RemoteController::loadIMemImage(), main(), GenerateProcessorDialog::onOK(), and MachineCanvas::updateMachine().
|
staticprivate |
Tells whether the given bus has an unconditional guard.
bus | The bus. |
Definition at line 1156 of file BEMGenerator.cc.
References TTAMachine::Bus::guard(), and TTAMachine::Bus::guardCount().
|
staticprivate |
Checks whether the given sockets have equal port connections.
socket1 | The first socket. |
socket2 | The second socket. |
Definition at line 1067 of file BEMGenerator.cc.
References TTAMachine::Socket::port(), and TTAMachine::Socket::portCount().
Referenced by suitableSocketCodeTable().
|
private |
Returns the width of the longest long immediate template being encoded in a slot given as parameter.
slot | Move slot where to check if it's used to store long immediates. |
Definition at line 1295 of file BEMGenerator.cc.
References TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, MoveSlot::name(), TTAMachine::InstructionTemplate::slot(), TTAMachine::TemplateSlot::slot(), TTAMachine::InstructionTemplate::slotCount(), and TTAMachine::TemplateSlot::width().
Referenced by addSubfields().
|
staticprivate |
Tells whether the given socket needs a socket code table.
Definition at line 851 of file BEMGenerator.cc.
References TTAMachine::FUPort::isOpcodeSetting(), TTAMachine::BaseRegisterFile::numberOfRegisters(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::BaseFUPort::parentUnit(), TTAMachine::RFPort::parentUnit(), TTAMachine::Socket::port(), TTAMachine::Socket::portCount(), and socket().
Referenced by addSocketCodeTables().
|
staticprivate |
Returns the number of bits needed to identify a register in the given register file.
regFile | The register file. |
Definition at line 1175 of file BEMGenerator.cc.
References MathTools::bitLength(), and TTAMachine::BaseRegisterFile::numberOfRegisters().
Referenced by addPortCodes().
|
staticprivate |
By the given index, returns a socket that is attached to the given bus and has the given direction.
index | The index. |
bus | The bus. |
direction | Direction of the sockets being returned. |
Definition at line 817 of file BEMGenerator.cc.
References assert, TTAMachine::Segment::connection(), TTAMachine::Segment::connectionCount(), ContainerTools::containsValue(), TTAMachine::Socket::direction(), TTAMachine::Bus::segment(), and TTAMachine::Bus::segmentCount().
Referenced by addEncodings(), addPortCodes(), addSocketCodeTables(), assignSocketCodeTable(), needsSocketCodeTable(), socketCodeTable(), socketCodeWidthsForBus(), socketCount(), and suitableSocketCodeTable().
|
private |
Returns the socket code table that is assigned to the given socket.
socket | The socket. |
Definition at line 732 of file BEMGenerator.cc.
References MapTools::containsKey(), scTableMap_, and socket().
Referenced by addEncodings(), and socketCodeWidthsForBus().
|
private |
Returns a multiset containing the socket code widths for sockets of the given direction that are connected to the given bus.
bus | The bus. |
socket | The direction. |
Definition at line 1039 of file BEMGenerator.cc.
References socket(), socketCodeTable(), socketCount(), and SocketCodeTable::width().
Referenced by addEncodings().
|
staticprivate |
Returns the number of sockets of the given direction connected to the given bus.
bus | The bus. |
direction | The direction |
Definition at line 788 of file BEMGenerator.cc.
References TTAMachine::Segment::connection(), TTAMachine::Segment::connectionCount(), TTAMachine::Socket::direction(), TTAMachine::Bus::segment(), TTAMachine::Bus::segmentCount(), and socket().
Referenced by addEncodings(), and socketCodeWidthsForBus().
|
staticprivate |
By the given index returns a source bridge for the given bus.
index | The index (0 or 1). |
bus | The bus. |
Definition at line 1124 of file BEMGenerator.cc.
References assert, TTAMachine::Machine::bridgeNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Bridge::destinationBus(), TTAMachine::Machine::Navigator< ComponentType >::item(), and TTAMachine::Component::machine().
Referenced by addEncodings().
|
staticprivate |
Tells how many source bridges the given bus has.
bus | The bus. |
Definition at line 1097 of file BEMGenerator.cc.
References assert, TTAMachine::Machine::bridgeNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Bridge::destinationBus(), TTAMachine::Machine::Navigator< ComponentType >::item(), and TTAMachine::Component::machine().
Referenced by addEncodings().
|
private |
Finds a suitable socket code table from the socket code table map for the given socket.
Returns NULL if there is no suitable socket code table.
socket | The socket. |
Definition at line 751 of file BEMGenerator.cc.
References haveEqualConnections(), scTableMap_, and socket().
Referenced by addSocketCodeTables().
|
private |
The machine for which the BEM is generated.
Definition at line 128 of file BEMGenerator.hh.
Referenced by addEncodings(), addLongImmDstRegisterFields(), addSocketCodeTables(), addSubfields(), addTopLevelFields(), and maxLongImmSlotWidth().
|
private |
A map which tells which socket code table belongs to a socket.
Definition at line 130 of file BEMGenerator.hh.
Referenced by assignSocketCodeTable(), socketCodeTable(), and suitableSocketCodeTable().