From f9c8a80fd18dcf1d507b0e3fbf9901d410da393f Mon Sep 17 00:00:00 2001 From: Isaac David Date: Fri, 13 Dec 2024 21:23:51 +0000 Subject: [PATCH] [vuop_gen] move logic for viext --- arches/isa_json/gen_uarch_rv64v_json.py | 1 + core/Inst.hpp | 33 ------------------- core/InstGenerator.cpp | 17 ---------- core/VectorUopGenerator.cpp | 21 ++++++++++++- core/VectorUopGenerator.hpp | 42 +++++++++++++++++++++++-- 5 files changed, 60 insertions(+), 54 deletions(-) diff --git a/arches/isa_json/gen_uarch_rv64v_json.py b/arches/isa_json/gen_uarch_rv64v_json.py index 8f861fde..e7fcf6a3 100755 --- a/arches/isa_json/gen_uarch_rv64v_json.py +++ b/arches/isa_json/gen_uarch_rv64v_json.py @@ -186,6 +186,7 @@ "vwmaccus.vx" : {"pipe" : "vmul", "uop_gen" : "MAC_WIDE", "latency" : 3}, # Vector Integer Arithmetic Instructions: Vector Integer Merge Instructions +# FIXME: Requires Mavis fix to include vector mask "vmerge.vvm" : {"pipe" : "vint", "uop_gen" : "ELEMENTWISE", "latency" : 1}, "vmerge.vxm" : {"pipe" : "vint", "uop_gen" : "ELEMENTWISE", "latency" : 1}, "vmerge.vim" : {"pipe" : "vint", "uop_gen" : "ELEMENTWISE", "latency" : 1}, diff --git a/core/Inst.hpp b/core/Inst.hpp index c5324af6..0b3bff93 100644 --- a/core/Inst.hpp +++ b/core/Inst.hpp @@ -24,7 +24,6 @@ #include #include #include -#include namespace olympia { @@ -77,22 +76,6 @@ namespace olympia Reg data_reg_; }; - class Modifier - { - public: - Modifier(std::string name, uint32_t value) : name_{name}, data_{value} {} - - std::string getName() const { return name_; } - - uint32_t getValue() const { return data_; } - - void setValue(uint32_t newValue) { data_ = newValue; } - - private: - std::string name_; - uint32_t data_; - }; - // Used by Mavis using PtrType = sparta::SpartaSharedPointer; @@ -439,20 +422,6 @@ namespace olympia return ss.str(); } - void addModifier(std::string name, uint32_t value) { modifiers_.emplace_back(name, value); } - - std::optional getModifier(std::string name) - { - for (auto & m : modifiers_) - { - if (m.getName() == name) - { - return m.getValue(); - } - } - return {}; - } - private: mavis::OpcodeInfo::PtrType opcode_info_; InstArchInfo::PtrType inst_arch_info_; @@ -507,8 +476,6 @@ namespace olympia RegisterBitMaskArray store_data_mask_; RenameData rename_data; static const std::unordered_map status2String; - - std::vector modifiers_; }; using InstPtr = Inst::PtrType; diff --git a/core/InstGenerator.cpp b/core/InstGenerator.cpp index acb04e37..9ce6004e 100644 --- a/core/InstGenerator.cpp +++ b/core/InstGenerator.cpp @@ -134,23 +134,6 @@ namespace olympia mavis::ExtractorDirectOpInfoList ex_info(mnemonic, srcs, dests); inst = mavis_facade_->makeInstDirectly(ex_info, clk); } - if (inst->getUopGenType() == InstArchInfo::UopGenType::INT_EXT) - { - auto modifier = mnemonic.substr(mnemonic.find(".") + 1); - - if (modifier == "vf2") - { - inst->addModifier("viext", 2); - } - else if (modifier == "vf4") - { - inst->addModifier("viext", 4); - } - else if (modifier == "vf8") - { - inst->addModifier("viext", 8); - } - } if (jinst.find("vaddr") != jinst.end()) { diff --git a/core/VectorUopGenerator.cpp b/core/VectorUopGenerator.cpp index 14da49bd..7787544f 100644 --- a/core/VectorUopGenerator.cpp +++ b/core/VectorUopGenerator.cpp @@ -144,6 +144,25 @@ namespace olympia sparta_assert(uop_gen_type != InstArchInfo::UopGenType::NONE, "Inst: " << current_inst_ << " uop gen type is none"); + if (uop_gen_type == InstArchInfo::UopGenType::INT_EXT) + { + auto mnemonic = inst->getMnemonic(); + auto modifier = mnemonic.substr(mnemonic.find(".") + 1); + + if (modifier == "vf2") + { + addModifier("viext", 2); + } + else if (modifier == "vf4") + { + addModifier("viext", 4); + } + else if (modifier == "vf8") + { + addModifier("viext", 8); + } + } + // Number of vector elements processed by each uop const VectorConfigPtr & vector_config = inst->getVectorConfig(); const uint64_t num_elems_per_uop = VectorConfig::VLEN / vector_config->getSEW(); @@ -237,7 +256,7 @@ namespace olympia } else if constexpr (Type == InstArchInfo::UopGenType::INT_EXT) { - auto ext = current_inst_->getModifier("viext"); + auto ext = getModifier("viext"); if (!ext) { throw sparta::SpartaException("Modifier at current instruction doesnt exist."); diff --git a/core/VectorUopGenerator.hpp b/core/VectorUopGenerator.hpp index 41b3cdfc..07032f9d 100644 --- a/core/VectorUopGenerator.hpp +++ b/core/VectorUopGenerator.hpp @@ -10,6 +10,8 @@ #include "FlushManager.hpp" #include "MavisUnit.hpp" +#include + namespace olympia { @@ -20,6 +22,22 @@ namespace olympia class VectorUopGenerator : public sparta::Unit { public: + class Modifier + { + public: + Modifier(std::string name, uint32_t value) : name_{name}, data_{value} {} + + std::string getName() const { return name_; } + + uint32_t getValue() const { return data_; } + + void setValue(uint32_t newValue) { data_ = newValue; } + + private: + std::string name_; + uint32_t data_; + }; + //! \brief Parameters for VectorUopGenerator model class VectorUopGeneratorParameterSet : public sparta::ParameterSet { @@ -46,8 +64,7 @@ namespace olympia const InstPtr generateUop(); - template - const InstPtr generateUops(); + template const InstPtr generateUops(); uint64_t getNumUopsRemaining() const { return num_uops_to_generate_; } @@ -65,6 +82,7 @@ namespace olympia // TODO: Use Sparta ValidValue InstPtr current_inst_ = nullptr; + std::vector current_inst_modifiers_; // UopGenFunctionMapType::iterator current_uop_gen_function_; sparta::Counter vuops_generated_; @@ -75,11 +93,29 @@ namespace olympia void reset_() { current_inst_ = nullptr; + current_inst_modifiers_.clear(); num_uops_generated_ = 0; num_uops_to_generate_ = 0; } - friend class VectorUopGeneratorTester; + void addModifier(const std::string & name, uint32_t value) + { + current_inst_modifiers_.emplace_back(name, value); + } + + std::optional getModifier(const std::string & name) + { + for (auto & m : current_inst_modifiers_) + { + if (m.getName() == name) + { + return m.getValue(); + } + } + return {}; + } + + friend class VectorUopGeneratorTester; }; class VectorUopGeneratorTester;