[gem5-dev] Change in gem5/gem5[develop]: arch-x86: Factor out duplication in the new RegOp base classes.
Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/42344 ) Change subject: arch-x86: Factor out duplication in the new RegOp base classes. .. arch-x86: Factor out duplication in the new RegOp base classes. Instead of having the cross product of dest/src1/src2 and folded int, debug, control, misc, and segment operands, break them up so they can be mixed together in different combinations using "using" declarations. Change-Id: I04357b08bd8a6cd91c2e4df64a2c6cb760bfe90e Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/42344 Reviewed-by: Gabe Black Maintainer: Gabe Black Tested-by: kokoro --- M src/arch/x86/insts/microregop.hh 1 file changed, 90 insertions(+), 186 deletions(-) Approvals: Gabe Black: Looks good to me, approved; Looks good to me, approved kokoro: Regressions pass diff --git a/src/arch/x86/insts/microregop.hh b/src/arch/x86/insts/microregop.hh index e7bd053..37e9d6f 100644 --- a/src/arch/x86/insts/microregop.hh +++ b/src/arch/x86/insts/microregop.hh @@ -43,217 +43,121 @@ namespace X86ISA { -struct RegOpDest +struct DestOp { using ArgType = InstRegIndex; +const RegIndex dest; +const size_t size; +RegIndex index() const { return dest; } -RegIndex dest; -size_t size; +DestOp(RegIndex _dest, size_t _size) : dest(_dest), size(_size) {} +}; +struct Src1Op +{ +using ArgType = InstRegIndex; +const RegIndex src1; +const size_t size; +RegIndex index() const { return src1; } + +Src1Op(RegIndex _src1, size_t _size) : src1(_src1), size(_size) {} +}; + +struct Src2Op +{ +using ArgType = InstRegIndex; +const RegIndex src2; +const size_t size; +RegIndex index() const { return src2; } + +Src2Op(RegIndex _src2, size_t _size) : src2(_src2), size(_size) {} +}; + +template +struct FoldedOp : public Base +{ template -RegOpDest(InstType *inst, ArgType idx) : -dest(INTREG_FOLDED(idx.index(), inst->foldOBit)), -size(inst->dataSize) +FoldedOp(InstType *inst, typename Base::ArgType idx) : +Base(INTREG_FOLDED(idx.index(), inst->foldOBit), inst->dataSize) {} void print(std::ostream &os) const { -X86StaticInst::printReg(os, RegId(IntRegClass, dest), size); +X86StaticInst::printReg(os, RegId(IntRegClass, this->index()), +this->size); } }; -struct RegOpDbgDest +template +struct CrOp : public Base { -using ArgType = InstRegIndex; - -RegIndex dest; -size_t size; - template -RegOpDbgDest(InstType *inst, ArgType idx) : dest(idx.index()), -size(inst->dataSize) +CrOp(InstType *inst, typename Base::ArgType idx) : Base(idx.index(), 0) {} + +void +print(std::ostream &os) const +{ +ccprintf(os, "cr%d", this->index()); +} +}; + +template +struct DbgOp : public Base +{ +template +DbgOp(InstType *inst, typename Base::ArgType idx) : Base(idx.index(), 0) {} + +void +print(std::ostream &os) const +{ +ccprintf(os, "dr%d", this->index()); +} + +}; + +template +struct SegOp : public Base +{ +template +SegOp(InstType *inst, typename Base::ArgType idx) : Base(idx.index(), 0) {} + +void +print(std::ostream &os) const +{ +X86StaticInst::printSegment(os, this->index()); +} +}; + +template +struct MiscOp : public Base +{ +template +MiscOp(InstType *inst, typename Base::ArgType idx) : +Base(idx.index(), inst->dataSize) {} void print(std::ostream &os) const { -ccprintf(os, "dr%d", dest); +X86StaticInst::printReg(os, RegId(MiscRegClass, this->index()), +this->size); } }; -struct RegOpCrDest -{ -using ArgType = InstRegIndex; +using RegOpDest = FoldedOp; +using RegOpDbgDest = DbgOp; +using RegOpCrDest = CrOp; +using RegOpSegDest = SegOp; +using RegOpMiscDest = MiscOp; -RegIndex dest; -size_t size; +using RegOpSrc1 = FoldedOp; +using RegOpDbgSrc1 = DbgOp; +using RegOpCrSrc1 = CrOp; +using RegOpSegSrc1 = SegOp; +using RegOpMiscSrc1 = MiscOp; -template -RegOpCrDest(InstType *inst, ArgType idx) : dest(idx.index()), -size(inst->dataSize) -{} - -void -print(std::ostream &os) const -{ -ccprintf(os, "cr%d", dest); -} -}; - -struct RegOpSegDest -{ -using ArgType = InstRegIndex; - -RegIndex dest; -size_t size; - -template -RegOpSegDest(InstType *inst, ArgType idx) : dest(idx.index()), -size(inst->dataSize) -{} - -void -print(std::ostream &os) const -{ -X86StaticInst::printSegment(os, dest); -} -}; - -struct RegOpMiscDest -{ -using ArgType = InstRegIndex; - -RegIndex dest; -size_t size; - -template -RegOpMiscDest(InstType *inst, ArgType idx) : dest(idx.index()), -size(inst->dataSize) -{} - -
[gem5-dev] Change in gem5/gem5[develop]: arch-x86: Factor out duplication in the new RegOp base classes.
Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/42344 ) Change subject: arch-x86: Factor out duplication in the new RegOp base classes. .. arch-x86: Factor out duplication in the new RegOp base classes. Instead of having the cross product of dest/src1/src2 and folded int, debug, control, misc, and segment operands, break them up so they can be mixed together in different combinations using "using" declarations. Change-Id: I04357b08bd8a6cd91c2e4df64a2c6cb760bfe90e --- M src/arch/x86/insts/microregop.hh 1 file changed, 90 insertions(+), 186 deletions(-) diff --git a/src/arch/x86/insts/microregop.hh b/src/arch/x86/insts/microregop.hh index e7bd053..37e9d6f 100644 --- a/src/arch/x86/insts/microregop.hh +++ b/src/arch/x86/insts/microregop.hh @@ -43,217 +43,121 @@ namespace X86ISA { -struct RegOpDest +struct DestOp { using ArgType = InstRegIndex; +const RegIndex dest; +const size_t size; +RegIndex index() const { return dest; } -RegIndex dest; -size_t size; +DestOp(RegIndex _dest, size_t _size) : dest(_dest), size(_size) {} +}; +struct Src1Op +{ +using ArgType = InstRegIndex; +const RegIndex src1; +const size_t size; +RegIndex index() const { return src1; } + +Src1Op(RegIndex _src1, size_t _size) : src1(_src1), size(_size) {} +}; + +struct Src2Op +{ +using ArgType = InstRegIndex; +const RegIndex src2; +const size_t size; +RegIndex index() const { return src2; } + +Src2Op(RegIndex _src2, size_t _size) : src2(_src2), size(_size) {} +}; + +template +struct FoldedOp : public Base +{ template -RegOpDest(InstType *inst, ArgType idx) : -dest(INTREG_FOLDED(idx.index(), inst->foldOBit)), -size(inst->dataSize) +FoldedOp(InstType *inst, typename Base::ArgType idx) : +Base(INTREG_FOLDED(idx.index(), inst->foldOBit), inst->dataSize) {} void print(std::ostream &os) const { -X86StaticInst::printReg(os, RegId(IntRegClass, dest), size); +X86StaticInst::printReg(os, RegId(IntRegClass, this->index()), +this->size); } }; -struct RegOpDbgDest +template +struct CrOp : public Base { -using ArgType = InstRegIndex; - -RegIndex dest; -size_t size; - template -RegOpDbgDest(InstType *inst, ArgType idx) : dest(idx.index()), -size(inst->dataSize) +CrOp(InstType *inst, typename Base::ArgType idx) : Base(idx.index(), 0) {} + +void +print(std::ostream &os) const +{ +ccprintf(os, "cr%d", this->index()); +} +}; + +template +struct DbgOp : public Base +{ +template +DbgOp(InstType *inst, typename Base::ArgType idx) : Base(idx.index(), 0) {} + +void +print(std::ostream &os) const +{ +ccprintf(os, "dr%d", this->index()); +} + +}; + +template +struct SegOp : public Base +{ +template +SegOp(InstType *inst, typename Base::ArgType idx) : Base(idx.index(), 0) {} + +void +print(std::ostream &os) const +{ +X86StaticInst::printSegment(os, this->index()); +} +}; + +template +struct MiscOp : public Base +{ +template +MiscOp(InstType *inst, typename Base::ArgType idx) : +Base(idx.index(), inst->dataSize) {} void print(std::ostream &os) const { -ccprintf(os, "dr%d", dest); +X86StaticInst::printReg(os, RegId(MiscRegClass, this->index()), +this->size); } }; -struct RegOpCrDest -{ -using ArgType = InstRegIndex; +using RegOpDest = FoldedOp; +using RegOpDbgDest = DbgOp; +using RegOpCrDest = CrOp; +using RegOpSegDest = SegOp; +using RegOpMiscDest = MiscOp; -RegIndex dest; -size_t size; +using RegOpSrc1 = FoldedOp; +using RegOpDbgSrc1 = DbgOp; +using RegOpCrSrc1 = CrOp; +using RegOpSegSrc1 = SegOp; +using RegOpMiscSrc1 = MiscOp; -template -RegOpCrDest(InstType *inst, ArgType idx) : dest(idx.index()), -size(inst->dataSize) -{} - -void -print(std::ostream &os) const -{ -ccprintf(os, "cr%d", dest); -} -}; - -struct RegOpSegDest -{ -using ArgType = InstRegIndex; - -RegIndex dest; -size_t size; - -template -RegOpSegDest(InstType *inst, ArgType idx) : dest(idx.index()), -size(inst->dataSize) -{} - -void -print(std::ostream &os) const -{ -X86StaticInst::printSegment(os, dest); -} -}; - -struct RegOpMiscDest -{ -using ArgType = InstRegIndex; - -RegIndex dest; -size_t size; - -template -RegOpMiscDest(InstType *inst, ArgType idx) : dest(idx.index()), -size(inst->dataSize) -{} - -void -print(std::ostream &os) const -{ -X86StaticInst::printReg(os, RegId(MiscRegClass, dest), size); -} -}; - -struct RegOpSrc1 -{ -using ArgType = InstRegIndex; - -RegIndex src1; -size_t size; - -t