simX floating-point fixes and refactoring
This commit is contained in:
101
simX/instr.h
101
simX/instr.h
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include "trace.h"
|
||||
|
||||
namespace vortex {
|
||||
|
||||
@@ -20,12 +19,7 @@ enum Opcode {
|
||||
JALR_INST = 0x67,
|
||||
SYS_INST = 0x73,
|
||||
FENCE = 0x0f,
|
||||
PJ_INST = 0x7b,
|
||||
GPGPU = 0x6b,
|
||||
VSET_ARITH= 0x57,
|
||||
VL = 0x7,
|
||||
VS = 0x27,
|
||||
// F-Extension
|
||||
// F Extension
|
||||
FL = 0x7,
|
||||
FS = 0x27,
|
||||
FCI = 0x53,
|
||||
@@ -33,6 +27,12 @@ enum Opcode {
|
||||
FMSUB = 0x47,
|
||||
FMNMSUB = 0x4b,
|
||||
FMNMADD = 0x4f,
|
||||
// Vector Extension
|
||||
VSET = 0x57,
|
||||
VL = 0x7,
|
||||
VS = 0x27,
|
||||
// GPGPU Extension
|
||||
GPGPU = 0x6b,
|
||||
};
|
||||
|
||||
enum InstType {
|
||||
@@ -51,34 +51,27 @@ class Instr {
|
||||
public:
|
||||
Instr()
|
||||
: opcode_(Opcode::NOP)
|
||||
, nRsrc_(0)
|
||||
, hasImmSrc_(false)
|
||||
, hasRDest_(false)
|
||||
, is_iDest_(false)
|
||||
, is_FpDest_(false)
|
||||
, is_VDest_(false)
|
||||
, is_FpSrc_(0)
|
||||
, is_VSrc_(0)
|
||||
, func2_(0)
|
||||
, num_rsrcs_(0)
|
||||
, has_imm_(false)
|
||||
, rdest_(0)
|
||||
, func3_(0)
|
||||
, func7_(0)
|
||||
{}
|
||||
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &, Instr &);
|
||||
, func7_(0) {
|
||||
for (int i = 0; i < MAX_REG_SOURCES; ++i) {
|
||||
rsrc_type_[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Setters used to "craft" the instruction. */
|
||||
void setOpcode(Opcode opcode) { opcode_ = opcode; }
|
||||
void setDestReg(int destReg) { hasRDest_ = true; is_iDest_ = true; rdest_ = destReg; }
|
||||
void setSrcReg(int srcReg) { rsrc_[nRsrc_++] = srcReg; }
|
||||
void setDestFReg(int destReg) { hasRDest_ = true; is_FpDest_ = true; rdest_ = destReg; }
|
||||
void setSrcFReg(int srcReg) { is_FpSrc_ |= (1 << nRsrc_); rsrc_[nRsrc_++] = srcReg; }
|
||||
void setDestVReg(int destReg) { hasRDest_ = true; is_VDest_ = true; rdest_ = destReg; }
|
||||
void setSrcVReg(int srcReg) { is_VSrc_ |= (1 << nRsrc_); rsrc_[nRsrc_++] = srcReg; }
|
||||
void setDestReg(int destReg) { rdest_type_ = 1; rdest_ = destReg; }
|
||||
void setSrcReg(int srcReg) { rsrc_type_[num_rsrcs_] = 1; rsrc_[num_rsrcs_++] = srcReg; }
|
||||
void setDestFReg(int destReg) { rdest_type_ = 2; rdest_ = destReg; }
|
||||
void setSrcFReg(int srcReg) { rsrc_type_[num_rsrcs_] = 2; rsrc_[num_rsrcs_++] = srcReg; }
|
||||
void setDestVReg(int destReg) { rdest_type_ = 3; rdest_ = destReg; }
|
||||
void setSrcVReg(int srcReg) { rsrc_type_[num_rsrcs_] = 3; rsrc_[num_rsrcs_++] = srcReg; }
|
||||
void setFunc3(Word func3) { func3_ = func3; }
|
||||
void setFunc7(Word func7) { func7_ = func7; }
|
||||
void setSrcImm(Word srcImm) { hasImmSrc_ = true; immsrc_ = srcImm; }
|
||||
void setVsetImm(Word vset_imm) { if (vset_imm) vsetImm_ = true; else vsetImm_ = false; }
|
||||
void setImm(Word imm) { has_imm_ = true; imm_ = imm; }
|
||||
void setVlsWidth(Word width) { vlsWidth_ = width; }
|
||||
void setVmop(Word mop) { vMop_ = mop; }
|
||||
void setVnf(Word nf) { vNf_ = nf; }
|
||||
@@ -94,29 +87,22 @@ public:
|
||||
Word getFunc3() const { return func3_; }
|
||||
Word getFunc6() const { return func6_; }
|
||||
Word getFunc7() const { return func7_; }
|
||||
int getNRSrc() const { return nRsrc_; }
|
||||
int getNRSrc() const { return num_rsrcs_; }
|
||||
int getRSrc(int i) const { return rsrc_[i]; }
|
||||
bool hasRDest() const { return hasRDest_; }
|
||||
int getRDest() const { return rdest_; }
|
||||
bool hasImm() const { return hasImmSrc_; }
|
||||
Word getImm() const { return immsrc_; }
|
||||
bool getVsetImm() const { return vsetImm_; }
|
||||
int getRSType(int i) const { return rsrc_type_[i]; }
|
||||
int getRDest() const { return rdest_; }
|
||||
int getRDType() const { return rdest_type_; }
|
||||
bool hasImm() const { return has_imm_; }
|
||||
Word getImm() const { return imm_; }
|
||||
Word getVlsWidth() const { return vlsWidth_; }
|
||||
Word getVmop() const { return vMop_; }
|
||||
Word getvNf() const { return vNf_; }
|
||||
bool getVmask() const { return vmask_; }
|
||||
Word getVmask() const { return vmask_; }
|
||||
Word getVs3() const { return vs3_; }
|
||||
Word getVlmul() const { return vlmul_; }
|
||||
Word getVsew() const { return vsew_; }
|
||||
Word getVediv() const { return vediv_; }
|
||||
|
||||
bool is_iDest() const { return is_iDest_; }
|
||||
bool is_FpDest() const { return is_FpDest_; }
|
||||
bool is_FpSrc(int i) const { return (is_FpSrc_ >> i) & 0x1; }
|
||||
|
||||
bool is_VDest() const { return is_VDest_; }
|
||||
bool is_VSrc(int i) const { return (is_VSrc_ >> i) & 0x1; }
|
||||
|
||||
private:
|
||||
|
||||
enum {
|
||||
@@ -124,24 +110,21 @@ private:
|
||||
};
|
||||
|
||||
Opcode opcode_;
|
||||
int nRsrc_;
|
||||
bool hasImmSrc_;
|
||||
bool hasRDest_;
|
||||
bool is_iDest_;
|
||||
bool is_FpDest_;
|
||||
bool is_VDest_;
|
||||
int is_FpSrc_;
|
||||
int is_VSrc_;
|
||||
Word immsrc_;
|
||||
Word func2_;
|
||||
int num_rsrcs_;
|
||||
bool has_imm_;
|
||||
int rdest_type_;
|
||||
int isrc_mask_;
|
||||
int fsrc_mask_;
|
||||
int vsrc_mask_;
|
||||
Word imm_;
|
||||
int rsrc_type_[MAX_REG_SOURCES];
|
||||
int rsrc_[MAX_REG_SOURCES];
|
||||
int rdest_;
|
||||
Word func3_;
|
||||
Word func7_;
|
||||
int rsrc_[MAX_REG_SOURCES];
|
||||
int rdest_;
|
||||
|
||||
//Vector
|
||||
bool vsetImm_;
|
||||
bool vmask_;
|
||||
Word vmask_;
|
||||
Word vlsWidth_;
|
||||
Word vMop_;
|
||||
Word vNf_;
|
||||
@@ -150,8 +133,8 @@ private:
|
||||
Word vsew_;
|
||||
Word vediv_;
|
||||
Word func6_;
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &, const Instr&);
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &, Instr &);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user