From b28522528109f87d9420e59a31cef88a045ed0e6 Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Tue, 2 Apr 2019 16:28:08 +0800 Subject: methods to set taint --- src/cpu/base_dyn_inst.hh | 7 +++++++ src/cpu/o3/cpu.cc | 7 +++++++ src/cpu/o3/cpu.hh | 3 +++ src/cpu/o3/regfile.hh | 21 +++++++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/src/cpu/base_dyn_inst.hh b/src/cpu/base_dyn_inst.hh index 6301864b7..4d8014445 100644 --- a/src/cpu/base_dyn_inst.hh +++ b/src/cpu/base_dyn_inst.hh @@ -478,6 +478,13 @@ class BaseDynInst : public ExecContext, public RefCounted _prevDestRegIdx[idx] = previous_rename; } + void taintDestRegs(void) + { + for (auto dstreg: _destRegIdx) { + cpu->setTaint(dstreg); + } + } + /** Renames a source logical register to the physical register which * has/will produce that logical register's result. * @todo: add in whether or not the source register is ready. diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc index b298b9baa..2566cf12a 100644 --- a/src/cpu/o3/cpu.cc +++ b/src/cpu/o3/cpu.cc @@ -1278,6 +1278,13 @@ FullO3CPU::setMiscReg(int misc_reg, this->isa[tid]->setMiscReg(misc_reg, val, tcBase(tid)); } +template +void +FullO3CPU::setTaint(PhysRegIdPtr phys_reg) +{ + regFile.setTaint(phys_reg); +} + template uint64_t FullO3CPU::readIntReg(PhysRegIdPtr phys_reg) diff --git a/src/cpu/o3/cpu.hh b/src/cpu/o3/cpu.hh index 19b9a34e0..23e6f7434 100644 --- a/src/cpu/o3/cpu.hh +++ b/src/cpu/o3/cpu.hh @@ -399,6 +399,9 @@ class FullO3CPU : public BaseO3CPU void setMiscReg(int misc_reg, const TheISA::MiscReg &val, ThreadID tid); + /** taint a register */ + void setTaint(PhysRegIdPtr phys_reg); + uint64_t readIntReg(PhysRegIdPtr phys_reg); TheISA::FloatReg readFloatReg(PhysRegIdPtr phys_reg); diff --git a/src/cpu/o3/regfile.hh b/src/cpu/o3/regfile.hh index 943df35b9..00b4ef045 100644 --- a/src/cpu/o3/regfile.hh +++ b/src/cpu/o3/regfile.hh @@ -182,6 +182,27 @@ class PhysRegFile return &miscRegIds[reg_idx]; } + /** Set a physical register as tainted */ + void setTaint(PhysRegIdPtr phys_reg) { + RegIndex idx = phys_reg->index(); + switch (phys_reg->classValue()) { + case IntRegClass: + intTaintMap[idx] = true; + break; + case FloatRegClass: + floatTaintMap[idx] = true; + break; + case CCRegClass: + ccTaintMap[idx] = true; + break; + case MiscRegClass: + miscTaintMap[idx] = true; + break; + default: + break; + } + } + /** Reads an integer register. */ uint64_t readIntReg(PhysRegIdPtr phys_reg) const { -- cgit v1.2.3