Skip to content

Commit

Permalink
[vuop_gen]
Browse files Browse the repository at this point in the history
  • Loading branch information
orion160 committed Dec 8, 2024
1 parent f126c04 commit f8613ef
Show file tree
Hide file tree
Showing 18 changed files with 594 additions and 101 deletions.
15 changes: 6 additions & 9 deletions arches/isa_json/gen_uarch_rv64v_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@
"vwsub.wv" : {"pipe" : "vint", "uop_gen" : "WIDENING_MIXED", "latency" : 1},
"vwsub.wx" : {"pipe" : "vint", "uop_gen" : "WIDENING_MIXED", "latency" : 1},

# TODO: Vector Integer Arithmetic Instructions: Vector Integer Extension
# FIXME: Requires Mavis fix to support correctly
# "vzext.vf2" : {"pipe" : "vint", "uop_gen" : "ARITH_EXT", "latency" : 1},
# "vsext.vf2" : {"pipe" : "vint", "uop_gen" : "ARITH_EXT", "latency" : 1},
# "vzext.vf4" : {"pipe" : "vint", "uop_gen" : "ARITH_EXT", "latency" : 1},
# "vsext.vf4" : {"pipe" : "vint", "uop_gen" : "ARITH_EXT", "latency" : 1},
# "vzext.vf8" : {"pipe" : "vint", "uop_gen" : "ARITH_EXT", "latency" : 1},
# "vsext.vf8" : {"pipe" : "vint", "uop_gen" : "ARITH_EXT", "latency" : 1},
"vzext.vf2" : {"pipe" : "vint", "uop_gen" : "INT_EXT", "latency" : 1},
"vsext.vf2" : {"pipe" : "vint", "uop_gen" : "INT_EXT", "latency" : 1},
"vzext.vf4" : {"pipe" : "vint", "uop_gen" : "INT_EXT", "latency" : 1},
"vsext.vf4" : {"pipe" : "vint", "uop_gen" : "INT_EXT", "latency" : 1},
"vzext.vf8" : {"pipe" : "vint", "uop_gen" : "INT_EXT", "latency" : 1},
"vsext.vf8" : {"pipe" : "vint", "uop_gen" : "INT_EXT", "latency" : 1},

# Vector Integer Arithmetic Instructions: Vector Integer Add-with-Carry/Subtract-with-Borrow Instructions
# FIXME: Requires Mavis fix to include vector mask
Expand Down Expand Up @@ -188,7 +186,6 @@
"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
36 changes: 18 additions & 18 deletions arches/isa_json/olympia_uarch_rv64v.json
Original file line number Diff line number Diff line change
Expand Up @@ -1735,21 +1735,21 @@
},
{
"mnemonic": "vsext.vf2",
"pipe": "?",
"uop_gen": "NONE",
"latency": 0
"pipe": "vint",
"uop_gen": "INT_EXT",
"latency": 1
},
{
"mnemonic": "vsext.vf4",
"pipe": "?",
"uop_gen": "NONE",
"latency": 0
"pipe": "vint",
"uop_gen": "INT_EXT",
"latency": 1
},
{
"mnemonic": "vsext.vf8",
"pipe": "?",
"uop_gen": "NONE",
"latency": 0
"pipe": "vint",
"uop_gen": "INT_EXT",
"latency": 1
},
{
"mnemonic": "vslide1down.vx",
Expand Down Expand Up @@ -2209,20 +2209,20 @@
},
{
"mnemonic": "vzext.vf2",
"pipe": "?",
"uop_gen": "NONE",
"latency": 0
"pipe": "vint",
"uop_gen": "INT_EXT",
"latency": 1
},
{
"mnemonic": "vzext.vf4",
"pipe": "?",
"uop_gen": "NONE",
"latency": 0
"pipe": "vint",
"uop_gen": "INT_EXT",
"latency": 1
},
{
"mnemonic": "vzext.vf8",
"pipe": "?",
"uop_gen": "NONE",
"latency": 0
"pipe": "vint",
"uop_gen": "INT_EXT",
"latency": 1
}
]
64 changes: 50 additions & 14 deletions core/Inst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
#include "VectorConfig.hpp"
#include "MiscUtils.hpp"

#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <unordered_map>
#include <variant>
#include <sstream>
#include <optional>

namespace olympia
{
Expand Down Expand Up @@ -75,6 +77,22 @@ 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 @@ -221,29 +239,34 @@ namespace olympia
}

const VectorConfigPtr getVectorConfig() const { return vector_config_; }

VectorConfigPtr getVectorConfig() { return vector_config_; }

void setTail(bool has_tail) { has_tail_ = has_tail; }

bool hasTail() const { return has_tail_; }

void setUOpParent(sparta::SpartaWeakPointer<olympia::Inst> & parent_uop)
{
parent_uop_ = parent_uop;
}

sparta::SpartaWeakPointer<olympia::Inst> getUOpParent() { return parent_uop_; }

// Branch instruction was taken (always set for JAL/JALR)
void setTakenBranch(bool taken) { is_taken_branch_ = taken; }

// Is this branch instruction mispredicted?
bool isMispredicted() const { return is_mispredicted_; }
void setMispredicted() { is_mispredicted_ = true; }
bool isMispredicted() const { return is_mispredicted_; }

void setMispredicted() { is_mispredicted_ = true; }

// TBD -- add branch prediction
void setSpeculative(bool spec) { is_speculative_ = spec; }

// Last instruction within the cache block fetched from the ICache
void setLastInFetchBlock(bool last) { last_in_fetch_block_ = last; }

bool isLastInFetchBlock() const { return last_in_fetch_block_; }

// Opcode information
Expand Down Expand Up @@ -271,25 +294,20 @@ namespace olympia
bool hasZeroRegSource() const
{
return std::any_of(getSourceOpInfoList().begin(), getSourceOpInfoList().end(),
[](const mavis::OperandInfo::Element & elem)
{
return elem.field_value == 0;
});
[](const mavis::OperandInfo::Element & elem)
{ return elem.field_value == 0; });
}

bool hasZeroRegDest() const
{
return std::any_of(getDestOpInfoList().begin(), getDestOpInfoList().end(),
[](const mavis::OperandInfo::Element & elem)
{
return elem.field_value == 0;
});
[](const mavis::OperandInfo::Element & elem)
{ return elem.field_value == 0; });
}

uint64_t getImmediate() const
{
sparta_assert(has_immediate_,
"Instruction does not have an immediate!");
sparta_assert(has_immediate_, "Instruction does not have an immediate!");
return opcode_info_->getImmediate();
}

Expand All @@ -298,7 +316,8 @@ namespace olympia
try
{
// If vm bit is 0, masking is enabled
const uint64_t vm_bit = opcode_info_->getSpecialField(mavis::OpcodeInfo::SpecialField::VM);
const uint64_t vm_bit =
opcode_info_->getSpecialField(mavis::OpcodeInfo::SpecialField::VM);
return vm_bit == 0;
}
catch (const mavis::UnsupportedExtractorSpecialFieldID & mavis_exception)
Expand Down Expand Up @@ -344,7 +363,8 @@ namespace olympia

bool isVector() const { return is_vector_; }

void setCoF(const bool &cof) { is_cof_ = cof; }
void setCoF(const bool & cof) { is_cof_ = cof; }

bool isCoF() const { return is_cof_; }

// Rename information
Expand Down Expand Up @@ -419,6 +439,20 @@ 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 @@ -473,6 +507,8 @@ 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
1 change: 1 addition & 0 deletions core/InstArchInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace olympia
{"NARROWING", InstArchInfo::UopGenType::NARROWING},
{"MAC", InstArchInfo::UopGenType::MAC},
{"MAC_WIDE", InstArchInfo::UopGenType::MAC_WIDE},
{"INT_EXT", InstArchInfo::UopGenType::INT_EXT},
{"NONE", InstArchInfo::UopGenType::NONE}
};

Expand Down
1 change: 1 addition & 0 deletions core/InstArchInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace olympia
NARROWING,
MAC,
MAC_WIDE,
INT_EXT,
NONE,
UNKNOWN
};
Expand Down
25 changes: 22 additions & 3 deletions core/InstGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,37 @@ 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())
{
uint64_t vaddr = std::strtoull(jinst["vaddr"].get<std::string>().c_str(), nullptr, 0);
uint64_t vaddr =
std::strtoull(jinst["vaddr"].get<std::string>().c_str(), nullptr, 0);
inst->setTargetVAddr(vaddr);
}

VectorConfigPtr vector_config = inst->getVectorConfig();
if (jinst.find("vtype") != jinst.end())
{
// immediate, so decode from hex
uint64_t vtype = std::strtoull(jinst["vtype"].get<std::string>().c_str(), nullptr, 0);
uint64_t vtype =
std::strtoull(jinst["vtype"].get<std::string>().c_str(), nullptr, 0);
std::string binaryString = std::bitset<32>(vtype).to_string();
uint32_t sew = std::pow(2, std::stoi(binaryString.substr(26, 3), nullptr, 2)) * 8;
uint32_t lmul = std::pow(2, std::stoi(binaryString.substr(29, 3), nullptr, 2));
Expand All @@ -155,7 +174,7 @@ namespace olympia

if (jinst.find("vta") != jinst.end())
{
const bool vta = jinst["vta"].get<uint64_t>() > 0 ? true: false;
const bool vta = jinst["vta"].get<uint64_t>() > 0 ? true : false;
vector_config->setVTA(vta);
}

Expand Down
Loading

0 comments on commit f8613ef

Please sign in to comment.