diff --git a/src/isa/isainfo.h b/src/isa/isainfo.h index e84a7753..0b82c805 100644 --- a/src/isa/isainfo.h +++ b/src/isa/isainfo.h @@ -141,6 +141,9 @@ class ISAInfoBase { */ virtual QString elfSupportsFlags(unsigned flags) const = 0; + /// The name of the base extension for this ISA + virtual QString baseExtension() const = 0; + /** * @brief supportedExtensions/enabledExtensions * An ISA may have a set of (optional) extensions which may be diff --git a/src/isa/mipsisainfo_common.h b/src/isa/mipsisainfo_common.h index 6ab815b0..cb6db27a 100644 --- a/src/isa/mipsisainfo_common.h +++ b/src/isa/mipsisainfo_common.h @@ -229,6 +229,8 @@ class MIPS_ISAInfoBase : public ISAInfoBase { return QString(); } + QString baseExtension() const override { return "I"; } + const QStringList &supportedExtensions() const override { return m_supportedExtensions; } diff --git a/src/isa/rvisainfo_common.h b/src/isa/rvisainfo_common.h index 7b55f306..9ddaf36d 100644 --- a/src/isa/rvisainfo_common.h +++ b/src/isa/rvisainfo_common.h @@ -208,6 +208,8 @@ class RV_ISAInfoBase : public ISAInfoBase { return QString(); } + QString baseExtension() const override { return "I"; } + const QStringList &supportedExtensions() const override { return m_supportedExtensions; } diff --git a/src/sliderulestab.cpp b/src/sliderulestab.cpp index a5bf5e83..1d01aa63 100644 --- a/src/sliderulestab.cpp +++ b/src/sliderulestab.cpp @@ -17,22 +17,29 @@ SliderulesTab::SliderulesTab(QToolBar *toolbar, QWidget *parent) } connect(ProcessorHandler::get(), &ProcessorHandler::processorChanged, this, - &SliderulesTab::isaChanged); + &SliderulesTab::processorChanged); connect(ui->isaSelector, &QComboBox::currentIndexChanged, this, &SliderulesTab::updateRegWidthSelector); connect(ui->regWidthSelector, &QComboBox::currentIndexChanged, this, &SliderulesTab::isaSelectorChanged); connect(ui->isaSelector, &QComboBox::currentIndexChanged, this, &SliderulesTab::isaSelectorChanged); + connect(ui->mainExtensionSelector, &QComboBox::currentIndexChanged, this, + &SliderulesTab::isaSelectorChanged); updateISASelector(true); } void SliderulesTab::isaSelectorChanged() { - ui->encodingTable->updateISA(ui->regWidthSelector->currentText()); + auto isa = ui->encodingTable->model->isa; + auto exts = QStringList(); + auto text = ui->mainExtensionSelector->currentText(); + if (!text.isEmpty() && isa->supportsExtension(text)) + exts = QStringList() << text; + ui->encodingTable->updateISA(ui->regWidthSelector->currentText(), exts); } -void SliderulesTab::isaChanged() { updateISASelector(); } +void SliderulesTab::processorChanged() { updateISASelector(); } void SliderulesTab::updateISASelector(bool forceUpdate) { if (auto isaId = ProcessorHandler::currentISA()->isaID(); @@ -58,6 +65,13 @@ void SliderulesTab::updateRegWidthSelector() { } } + auto isa = ui->encodingTable->model->isa; + ui->mainExtensionSelector->clear(); + ui->mainExtensionSelector->addItem(isa->baseExtension()); + for (const auto &ext : isa->supportedExtensions()) { + ui->mainExtensionSelector->addItem(ext); + } + emit ui->regWidthSelector->currentIndexChanged( static_cast(m_selectedISA)); } @@ -69,7 +83,7 @@ EncodingModel::EncodingModel( const std::shared_ptr instructions, const std::shared_ptr pseudoInstructions, QObject *parent) - : QAbstractTableModel(parent), m_isa(isa), m_instructions(instructions), + : QAbstractTableModel(parent), isa(isa), m_instructions(instructions), m_pseudoInstructions(pseudoInstructions) { // Map instructions to their row index size_t row = 0; @@ -210,10 +224,11 @@ void EncodingView::processorChanged() { updateView(); } -void EncodingView::updateISA(const QString &isaName) { +void EncodingView::updateISA(const QString &isaName, + const QStringList &extensions) { for (const auto &isa : ISANames) { if (isa.second == isaName) { - updateModel(ISAConstructors.at(isa.first)(QStringList())); + updateModel(ISAConstructors.at(isa.first)(extensions)); updateView(); return; } @@ -221,11 +236,11 @@ void EncodingView::updateISA(const QString &isaName) { } void EncodingView::updateModel(std::shared_ptr isa) { - if (!m_model || !m_model->m_isa->eq(isa.get(), isa->enabledExtensions())) { - m_model = std::make_unique( + if (!model || !model->isa->eq(isa.get(), isa->enabledExtensions())) { + model = std::make_unique( isa, std::make_shared(isa->instructions()), std::make_shared(isa->pseudoInstructions())); - setModel(m_model.get()); + setModel(model.get()); } } @@ -240,7 +255,7 @@ void EncodingView::updateView() { horizontalHeader()->setSectionResizeMode(EncodingModel::DESCRIPTION, QHeaderView::ResizeMode::Stretch); clearSpans(); - for (const auto &pair : m_model->m_rowInstrMap) { + for (const auto &pair : model->m_rowInstrMap) { int row = static_cast(pair.first); const auto &instr = pair.second; size_t fieldIdx = 0; diff --git a/src/sliderulestab.h b/src/sliderulestab.h index 90022921..11a550e7 100644 --- a/src/sliderulestab.h +++ b/src/sliderulestab.h @@ -49,12 +49,13 @@ class EncodingModel : public QAbstractTableModel { virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + const std::shared_ptr isa; + protected: friend class EncodingView; size_t m_rows; - const std::shared_ptr m_isa; const std::shared_ptr m_instructions; const std::shared_ptr m_pseudoInstructions; @@ -66,7 +67,10 @@ class EncodingView : public QTableView { public: EncodingView(QWidget *parent = nullptr); - void updateISA(const QString &isaName); + void updateISA(const QString &isaName, + const QStringList &extensions = QStringList()); + + std::unique_ptr model; public slots: void processorChanged(); @@ -74,8 +78,6 @@ public slots: protected: void updateModel(std::shared_ptr isa); void updateView(); - - std::unique_ptr m_model; }; struct DecodingModel : public QAbstractTableModel { @@ -109,7 +111,7 @@ class SliderulesTab : public RipesTab { ~SliderulesTab(); public slots: - void isaChanged(); + void processorChanged(); void isaSelectorChanged(); private slots: diff --git a/src/sliderulestab.ui b/src/sliderulestab.ui index 6bc830b7..8be54653 100644 --- a/src/sliderulestab.ui +++ b/src/sliderulestab.ui @@ -112,6 +112,20 @@ + + + + + + Main Extension + + + + + + + +