File instr_jalr.h
File List > projects > simtix > src > simtix > sm > instr_jalr.h
Go to the documentation of this file
#pragma once
#include <cstdint>
#include <vector>
#include "sm/instr.h"
#include "sm/thread.h"
#include "sm/warp.h"
namespace simtix {
class InstrJalr : public Instr {
public:
using Op = void (InstrJalr::*)();
// Implementation of Instr's virtual methods
void Decode() override;
void Issue() override;
void OperandCollect() override;
void Execute() override;
void Commit() override;
void Reset() override;
void Assign(const Instr *other) override;
bool CanIssue() const override;
bool CanExecute() const override { return rs1_data_ready_; }
bool CanCommit() const override { return executed_; }
bool CanRetire() const override { return committed_; }
bool may_change_ctrl_flow() const override { return true; }
// Helper functionos
static inline int64_t DecodeImmItype(uint32_t iword) {
return (int32_t(iword) >> 20);
}
protected:
InstrJalr(Warp *warp, uint32_t iword, uint64_t wpc);
void Reinitialize(Warp *warp, uint32_t iword, uint64_t wpc) override;
int64_t imm_ = 0;
Op op_ = nullptr;
bool rs1_data_ready_ = false;
bool executed_ = false;
bool committed_ = false;
// Register data
std::vector<int64_t> rs1_data_;
int64_t rd_data_;
std::vector<uint64_t> next_pc_;
private:
// Operands defined in this Opcode
void jalr_() {
rd_data_ = wpc_ + 4;
for (Thread *t : active_threads_) {
uint32_t tid = t->tid();
next_pc_[tid] = rs1_data_[tid] + imm_;
}
}
void nop_() {}
template <class InstrType>
friend class InstrPool;
};
} // namespace simtix