Skip to content

Commit

Permalink
[vuop_gen] move logic for viext
Browse files Browse the repository at this point in the history
  • Loading branch information
orion160 committed Dec 13, 2024
1 parent 64d9cf6 commit f9c8a80
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 54 deletions.
1 change: 1 addition & 0 deletions arches/isa_json/gen_uarch_rv64v_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
33 changes: 0 additions & 33 deletions core/Inst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <unordered_map>
#include <variant>
#include <sstream>
#include <optional>

namespace olympia
{
Expand Down Expand Up @@ -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<Inst>;

Expand Down Expand Up @@ -439,20 +422,6 @@ namespace olympia
return ss.str();
}

void addModifier(std::string name, uint32_t value) { modifiers_.emplace_back(name, value); }

std::optional<uint32_t> 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_;
Expand Down Expand Up @@ -507,8 +476,6 @@ namespace olympia
RegisterBitMaskArray store_data_mask_;
RenameData rename_data;
static const std::unordered_map<Inst::Status, std::string> status2String;

std::vector<Modifier> modifiers_;
};

using InstPtr = Inst::PtrType;
Expand Down
17 changes: 0 additions & 17 deletions core/InstGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
21 changes: 20 additions & 1 deletion core/VectorUopGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.");
Expand Down
42 changes: 39 additions & 3 deletions core/VectorUopGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "FlushManager.hpp"
#include "MavisUnit.hpp"

#include <optional>

namespace olympia
{

Expand All @@ -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
{
Expand All @@ -46,8 +64,7 @@ namespace olympia

const InstPtr generateUop();

template <InstArchInfo::UopGenType Type>
const InstPtr generateUops();
template <InstArchInfo::UopGenType Type> const InstPtr generateUops();

uint64_t getNumUopsRemaining() const { return num_uops_to_generate_; }

Expand All @@ -65,6 +82,7 @@ namespace olympia

// TODO: Use Sparta ValidValue
InstPtr current_inst_ = nullptr;
std::vector<Modifier> current_inst_modifiers_;
// UopGenFunctionMapType::iterator current_uop_gen_function_;

sparta::Counter vuops_generated_;
Expand All @@ -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<uint32_t> getModifier(const std::string & name)
{
for (auto & m : current_inst_modifiers_)
{
if (m.getName() == name)
{
return m.getValue();
}
}
return {};
}

friend class VectorUopGeneratorTester;
};

class VectorUopGeneratorTester;
Expand Down

0 comments on commit f9c8a80

Please sign in to comment.