simX refactoring
This commit is contained in:
44
simX/instr.h
44
simX/instr.h
@@ -52,9 +52,12 @@ public:
|
||||
Instr()
|
||||
: opcode_(Opcode::NOP)
|
||||
, nRsrc_(0)
|
||||
, nPsrc_(0)
|
||||
, hasImmSrc_(false)
|
||||
, hasRDest_(false)
|
||||
, is_FpDest_(false)
|
||||
, is_VDest_(false)
|
||||
, is_FpSrc_(0)
|
||||
, is_VSrc_(0)
|
||||
, func2_(0)
|
||||
, func3_(0)
|
||||
, func7_(0)
|
||||
@@ -65,20 +68,24 @@ public:
|
||||
|
||||
/* Setters used to "craft" the instruction. */
|
||||
void setOpcode(Opcode opcode) { opcode_ = opcode; }
|
||||
void setDestReg(RegNum destReg) { hasRDest_ = true; rdest_ = destReg; }
|
||||
void setSrcReg(RegNum srcReg) { rsrc_[nRsrc_++] = srcReg; }
|
||||
void setDestReg(int destReg) { hasRDest_ = 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 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 setVsetImm(Word vset_imm) { if (vset_imm) vsetImm_ = true; else vsetImm_ = false; }
|
||||
void setVlsWidth(Word width) { vlsWidth_ = width; }
|
||||
void setVmop(Word mop) { vMop_ = mop; }
|
||||
void setVnf(Word nf) { vNf_ = nf; }
|
||||
void setVmask(Word mask) { vmask_ = mask; }
|
||||
void setVs3(Word vs) { vs3_ = vs; }
|
||||
void setVlmul(Word lmul);
|
||||
void setVsew(Word sew);
|
||||
void setVediv(Word ediv);
|
||||
void setVlmul(Word lmul) { vlmul_ = 1 << lmul; }
|
||||
void setVsew(Word sew) { vsew_ = 1 << (3+sew); }
|
||||
void setVediv(Word ediv) { vediv_ = 1 << ediv; }
|
||||
void setFunc6(Word func6) { func6_ = func6; }
|
||||
|
||||
/* Getters used by encoders. */
|
||||
@@ -86,10 +93,10 @@ public:
|
||||
Word getFunc3() const { return func3_; }
|
||||
Word getFunc6() const { return func6_; }
|
||||
Word getFunc7() const { return func7_; }
|
||||
RegNum getNRSrc() const { return nRsrc_; }
|
||||
RegNum getRSrc(RegNum i) const { return rsrc_[i]; }
|
||||
int getNRSrc() const { return nRsrc_; }
|
||||
int getRSrc(int i) const { return rsrc_[i]; }
|
||||
bool hasRDest() const { return hasRDest_; }
|
||||
RegNum getRDest() const { return rdest_; }
|
||||
int getRDest() const { return rdest_; }
|
||||
bool hasImm() const { return hasImmSrc_; }
|
||||
Word getImm() const { return immsrc_; }
|
||||
bool getVsetImm() const { return vsetImm_; }
|
||||
@@ -102,6 +109,12 @@ public:
|
||||
Word getVsew() const { return vsew_; }
|
||||
Word getVediv() const { return vediv_; }
|
||||
|
||||
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 {
|
||||
@@ -110,15 +123,18 @@ private:
|
||||
|
||||
Opcode opcode_;
|
||||
int nRsrc_;
|
||||
int nPsrc_;
|
||||
bool hasImmSrc_;
|
||||
bool hasRDest_;
|
||||
bool hasRDest_;
|
||||
bool is_FpDest_;
|
||||
bool is_VDest_;
|
||||
int is_FpSrc_;
|
||||
int is_VSrc_;
|
||||
Word immsrc_;
|
||||
Word func2_;
|
||||
Word func3_;
|
||||
Word func7_;
|
||||
RegNum rsrc_[MAX_REG_SOURCES];
|
||||
RegNum rdest_;
|
||||
int rsrc_[MAX_REG_SOURCES];
|
||||
int rdest_;
|
||||
|
||||
//Vector
|
||||
bool vsetImm_;
|
||||
|
||||
Reference in New Issue
Block a user