Fix incorrect extensions listed in processor selection dialog
MODIFY
src/isa/isainfo.h
src/isa/isainfo.h
#include <QMap>
#include <QSet>
#include <QString>
+#include <memory>
#include <set>
#include "elfio/elf_types.hpp"
@@ -91,6 +92,12 @@ protected:
ISAInfoBase() {}
};
+// Shallow ISA info used to drive ISA construction and UI representation.
+struct ProcessorISAInfo {
+ std::shared_ptr<ISAInfoBase> isa;
+ QStringList supportedExtensions;
+};
+
template <ISA isa>
class ISAInfo : public ISAInfoBase {};

MODIFY
src/isa/rvisainfo_common.h
src/isa/rvisainfo_common.h
@@ -7,7 +7,7 @@ namespace Ripes {
template <unsigned XLEN>
constexpr ISA XLenToRVISA() {
static_assert(XLEN == 32 || XLEN == 64, "Only supports 32- and 64-bit variants");
- if (XLEN == 32) {
+ if constexpr (XLEN == 32) {
return ISA::RV32I;
} else {
return ISA::RV64I;
@@ -110,7 +110,7 @@ public:
flags &= ~flag.first;
if (flags != 0) {
- return "ELF flag '0b" + QString::number(flags, 2) + "' unsupported<br/>";
+ return "ELF flag '0b" + QString::number(flags, 2) + "' unsupported";
}
return QString();
}

MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -28,7 +28,7 @@ ProcessorHandler::ProcessorHandler() {
// Some sanity checking
m_currentID = m_currentID >= ProcessorID::NUM_PROCESSORS ? ProcessorID::RV32_5S : m_currentID;
}
- _selectProcessor(m_currentID, ProcessorRegistry::getDescription(m_currentID).isa()->supportedExtensions(),
+ _selectProcessor(m_currentID, ProcessorRegistry::getDescription(m_currentID).isaInfo().isa->supportedExtensions(),
ProcessorRegistry::getDescription(m_currentID).defaultRegisterVals);
// The m_procStateChangeTimer limits maximum frequency of which the procStateChangedNonRun is emitted.
@@ -250,8 +250,9 @@ void ProcessorHandler::_selectProcessor(const ProcessorID& id, const QStringList
RipesSettings::setValue(RIPES_SETTING_PROCESSOR_ID, id);
// Keep current program if the ISA between the two processors are identical
- const bool keepProgram = m_currentProcessor && (m_currentProcessor->implementsISA()->eq(
- ProcessorRegistry::getDescription(id).isa(), extensions));
+ const bool keepProgram =
+ m_currentProcessor && (m_currentProcessor->implementsISA()->eq(
+ ProcessorRegistry::getDescription(id).isaInfo().isa.get(), extensions));
// Processor initializations
m_currentProcessor = ProcessorRegistry::constructProcessor(m_currentID, extensions);

MODIFY
src/processorregistry.h
src/processorregistry.h
@@ -57,7 +57,7 @@ public:
QString description;
RegisterInitialization defaultRegisterVals;
std::vector<Layout> layouts;
- virtual const ISAInfoBase* isa() const = 0;
+ virtual ProcessorISAInfo isaInfo() const = 0;
virtual std::unique_ptr<RipesProcessor> construct(const QStringList& extensions) = 0;
};
@@ -67,7 +67,7 @@ public:
using ProcInfoBase::ProcInfoBase;
std::unique_ptr<RipesProcessor> construct(const QStringList& extensions) { return std::make_unique<T>(extensions); }
// At this point we force the processor type T to implement a static function identifying its supported ISA.
- const ISAInfoBase* isa() const { return T::supportsISA(); }
+ ProcessorISAInfo isaInfo() const { return T::supportsISA(); }
};
class ProcessorRegistry {

MODIFY
src/processors/RISC-V/rv5s/rv5s.h
src/processors/RISC-V/rv5s/rv5s.h
@@ -494,9 +494,8 @@ public:
m_syscallExitCycle = -1;
}
- static const ISAInfoBase* supportsISA() {
- static auto s_isa = ISAInfo<XLenToRVISA<XLEN>()>(QStringList{"M"});
- return &s_isa;
+ static ProcessorISAInfo supportsISA() {
+ return ProcessorISAInfo{std::make_shared<ISAInfo<XLenToRVISA<XLEN>()>>(QStringList()), {"M", "C"}};
}
const ISAInfoBase* implementsISA() const override { return m_enabledISA.get(); }

MODIFY
src/processors/RISC-V/rv5s_no_fw/rv5s_no_fw.h
src/processors/RISC-V/rv5s_no_fw/rv5s_no_fw.h
@@ -470,9 +470,8 @@ public:
m_syscallExitCycle = -1;
}
- static const ISAInfoBase* supportsISA() {
- static auto s_isa = ISAInfo<XLenToRVISA<XLEN>()>(QStringList{"M"});
- return &s_isa;
+ static ProcessorISAInfo supportsISA() {
+ return ProcessorISAInfo{std::make_shared<ISAInfo<XLenToRVISA<XLEN>()>>(QStringList()), {"M"}};
}
const ISAInfoBase* implementsISA() const override { return m_enabledISA.get(); }

MODIFY
src/processors/RISC-V/rv5s_no_fw_hz/rv5s_no_fw_hz.h
src/processors/RISC-V/rv5s_no_fw_hz/rv5s_no_fw_hz.h
@@ -420,9 +420,8 @@ public:
m_syscallExitCycle = -1;
}
- static const ISAInfoBase* supportsISA() {
- static auto s_isa = ISAInfo<XLenToRVISA<XLEN>()>(QStringList{"M"});
- return &s_isa;
+ static ProcessorISAInfo supportsISA() {
+ return ProcessorISAInfo{std::make_shared<ISAInfo<XLenToRVISA<XLEN>()>>(QStringList()), {"M"}};
}
const ISAInfoBase* implementsISA() const override { return m_enabledISA.get(); };

MODIFY
src/processors/RISC-V/rv5s_no_hz/rv5s_no_hz.h
src/processors/RISC-V/rv5s_no_hz/rv5s_no_hz.h
@@ -453,9 +453,8 @@ public:
m_syscallExitCycle = -1;
}
- static const ISAInfoBase* supportsISA() {
- static auto s_isa = ISAInfo<XLenToRVISA<XLEN>()>(QStringList{"M"});
- return &s_isa;
+ static ProcessorISAInfo supportsISA() {
+ return ProcessorISAInfo{std::make_shared<ISAInfo<XLenToRVISA<XLEN>()>>(QStringList()), {"M"}};
}
const ISAInfoBase* implementsISA() const override { return m_enabledISA.get(); };

MODIFY
src/processors/RISC-V/rv6s_dual/rv6s_dual.h
src/processors/RISC-V/rv6s_dual/rv6s_dual.h
@@ -834,9 +834,8 @@ public:
m_syscallExitCycle = -1;
}
- static const ISAInfoBase* supportsISA() {
- static auto s_isa = ISAInfo<XLenToRVISA<XLEN>()>(QStringList{"M"});
- return &s_isa;
+ static ProcessorISAInfo supportsISA() {
+ return ProcessorISAInfo{std::make_shared<ISAInfo<XLenToRVISA<XLEN>()>>(QStringList()), {"M", "C"}};
}
const ISAInfoBase* implementsISA() const override { return m_enabledISA.get(); };

MODIFY
src/processors/RISC-V/rvss/rvss.h
src/processors/RISC-V/rvss/rvss.h
@@ -219,9 +219,8 @@ public:
m_finished = false;
}
- static const ISAInfoBase* supportsISA() {
- static auto s_isa = ISAInfo<XLenToRVISA<XLEN>()>(QStringList{"M", "C"});
- return &s_isa;
+ static ProcessorISAInfo supportsISA() {
+ return ProcessorISAInfo{std::make_shared<ISAInfo<XLenToRVISA<XLEN>()>>(QStringList()), {"M", "C"}};
}
const ISAInfoBase* implementsISA() const override { return m_enabledISA.get(); }
const std::set<RegisterFileType> registerFiles() const override {

MODIFY
src/processorselectiondialog.cpp
src/processorselectiondialog.cpp
@@ -42,16 +42,16 @@ ProcessorSelectionDialog::ProcessorSelectionDialog(QWidget* parent)
processorItem->setFont(ProcessorColumn, font);
selectedItem = processorItem;
}
- const QString& isaFamily = ISAFamilyNames.at(desc.second->isa()->isaID());
+ const QString& isaFamily = ISAFamilyNames.at(desc.second->isaInfo().isa->isaID());
QTreeWidgetItem* familyItem = isaFamilyItems.at(isaFamily);
auto& regWidthItemsForISA = isaFamilyRegWidthItems.at(familyItem);
- auto isaRegWidthItem = regWidthItemsForISA.find(desc.second->isa()->bits());
+ auto isaRegWidthItem = regWidthItemsForISA.find(desc.second->isaInfo().isa->bits());
if (isaRegWidthItem == regWidthItemsForISA.end()) {
// Create reg width item
- auto* widthItem = new QTreeWidgetItem({QString::number(desc.second->isa()->bits()) + "-bit"});
+ auto* widthItem = new QTreeWidgetItem({QString::number(desc.second->isaInfo().isa->bits()) + "-bit"});
widthItem->setFlags(widthItem->flags() & ~(Qt::ItemIsSelectable));
- regWidthItemsForISA[desc.second->isa()->bits()] = widthItem;
- isaRegWidthItem = regWidthItemsForISA.find(desc.second->isa()->bits());
+ regWidthItemsForISA[desc.second->isaInfo().isa->bits()] = widthItem;
+ isaRegWidthItem = regWidthItemsForISA.find(desc.second->isaInfo().isa->bits());
familyItem->insertChild(familyItem->childCount(), widthItem);
}
isaRegWidthItem->second->insertChild(isaRegWidthItem->second->childCount(), processorItem);
@@ -69,7 +69,7 @@ ProcessorSelectionDialog::ProcessorSelectionDialog(QWidget* parent)
// Initialize extensions for processors; default to all available extensions
for (const auto& desc : ProcessorRegistry::getAvailableProcessors()) {
- m_selectedExtensionsForID[desc.second->id] = desc.second->isa()->supportedExtensions();
+ m_selectedExtensionsForID[desc.second->id] = desc.second->isaInfo().supportedExtensions;
}
m_selectedExtensionsForID[ProcessorHandler::getID()] = ProcessorHandler::currentISA()->enabledExtensions();
@@ -123,7 +123,7 @@ void ProcessorSelectionDialog::selectionChanged(QTreeWidgetItem* current, QTreeW
// Update information widgets with the current processor info
m_selectedID = id;
m_ui->name->setText(desc->name);
- m_ui->ISA->setText(desc->isa()->name());
+ m_ui->ISA->setText(desc->isaInfo().isa->name());
m_ui->description->setPlainText(desc->description);
m_ui->regInitWidget->processorSelectionChanged(id);
@@ -140,7 +140,7 @@ void ProcessorSelectionDialog::selectionChanged(QTreeWidgetItem* current, QTreeW
delete item;
}
- for (const auto& ext : desc->isa()->supportedExtensions()) {
+ for (const auto& ext : desc->isaInfo().supportedExtensions) {
auto chkbox = new QCheckBox(ext);
m_ui->extensions->addWidget(chkbox);
if (m_selectedExtensionsForID[desc->id].contains(ext)) {

MODIFY
src/registerinitializationwidget.cpp
src/registerinitializationwidget.cpp
@@ -22,12 +22,12 @@ void RegisterSelectionComboBox::showPopup() {
if (count())
clear();
- const auto& isa = ProcessorRegistry::getAvailableProcessors().at(m_parent->m_currentID)->isa();
+ const auto& procisa = ProcessorRegistry::getAvailableProcessors().at(m_parent->m_currentID)->isaInfo();
const auto& initializations = m_parent->m_initializations.at(m_parent->m_currentID);
std::set<unsigned> regOptions;
- for (unsigned i = 0; i < isa->regCnt(); ++i) {
- if (!isa->regIsReadOnly(i)) {
+ for (unsigned i = 0; i < procisa.isa->regCnt(); ++i) {
+ if (!procisa.isa->regIsReadOnly(i)) {
regOptions.insert(i);
}
}
@@ -37,7 +37,7 @@ void RegisterSelectionComboBox::showPopup() {
}
for (const auto& i : regOptions) {
- addItem(isa->regName(i) + " (" + isa->regAlias(i) + ")", i);
+ addItem(procisa.isa->regName(i) + " (" + procisa.isa->regAlias(i) + ")", i);
}
QComboBox::showPopup();
}
@@ -91,14 +91,14 @@ void RegisterInitializationWidget::updateAddButtonState() {
}
int RegisterInitializationWidget::getNonInitializedRegIdx() {
- const auto& currentISA = ProcessorRegistry::getAvailableProcessors().at(m_currentID)->isa();
+ const auto& currentISA = ProcessorRegistry::getAvailableProcessors().at(m_currentID)->isaInfo();
const auto& currentInitForProc = m_initializations.at(m_currentID);
unsigned id = 0;
- while (currentInitForProc.count(id) || currentISA->regIsReadOnly(id)) {
+ while (currentInitForProc.count(id) || currentISA.isa->regIsReadOnly(id)) {
id++;
}
- return id < currentISA->regCnt() ? id : -1;
+ return id < currentISA.isa->regCnt() ? id : -1;
}
RegisterInitializationWidget::RegInitWidgets* RegisterInitializationWidget::addRegisterInitialization(unsigned regIdx) {
@@ -109,7 +109,7 @@ RegisterInitializationWidget::RegInitWidgets* RegisterInitializationWidget::addR
}
const auto& regLayout = m_ui->regInitLayout;
- const auto& isa = ProcessorRegistry::getAvailableProcessors().at(m_currentID)->isa();
+ const auto& procisa = ProcessorRegistry::getAvailableProcessors().at(m_currentID)->isaInfo();
auto& w = m_currentRegInitWidgets.emplace_back(std::make_unique<RegInitWidgets>());
auto* w_ptr = w.get();
@@ -118,7 +118,7 @@ RegisterInitializationWidget::RegInitWidgets* RegisterInitializationWidget::addR
w->value = new QLineEdit(this);
w->remove = new QPushButton(this);
- w->name->addItem(isa->regName(regIdx) + " (" + isa->regAlias(regIdx) + ")", regIdx);
+ w->name->addItem(procisa.isa->regName(regIdx) + " (" + procisa.isa->regAlias(regIdx) + ")", regIdx);
connect(w->name, &RegisterSelectionComboBox::regIndexChanged, [this, w_ptr](int oldIdx, int newIdx) {
m_initializations.at(m_currentID).erase(oldIdx);

Fix incorrect extensions listed in processor selection dialog