Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/52044 )
Change subject: arch,cpu: Use PCStateBase in buildRetPC.
......................................................................
arch,cpu: Use PCStateBase in buildRetPC.
Change-Id: I9d9f5b25613440737b1d67134fcae09aa68baf8b
---
M src/cpu/pred/bpred_unit.cc
M src/arch/arm/insts/static_inst.hh
M src/arch/x86/insts/static_inst.hh
M src/arch/power/insts/static_inst.hh
M src/cpu/static_inst.hh
M src/arch/mips/isa/base.isa
M src/arch/riscv/insts/static_inst.hh
M src/arch/sparc/insts/static_inst.hh
8 files changed, 55 insertions(+), 35 deletions(-)
diff --git a/src/arch/arm/insts/static_inst.hh
b/src/arch/arm/insts/static_inst.hh
index 3979a49..07181c2 100644
--- a/src/arch/arm/insts/static_inst.hh
+++ b/src/arch/arm/insts/static_inst.hh
@@ -205,12 +205,13 @@
uint64_t getEMI() const override { return machInst; }
- PCState
- buildRetPC(const PCState &curPC, const PCState &callPC) const override
+ std::unique_ptr<PCStateBase>
+ buildRetPC(const PCStateBase &cur_pc,
+ const PCStateBase &call_pc) const override
{
- PCState retPC = callPC;
- retPC.uEnd();
- return retPC;
+ PCStateBase *ret_pc = call_pc.clone();
+ ret_pc->as<PCState>().uEnd();
+ return std::unique_ptr<PCStateBase>{ret_pc};
}
std::string generateDisassembly(
diff --git a/src/arch/mips/isa/base.isa b/src/arch/mips/isa/base.isa
index b02a8c4..cd13de2 100644
--- a/src/arch/mips/isa/base.isa
+++ b/src/arch/mips/isa/base.isa
@@ -64,13 +64,18 @@
pc.as<PCState>().advance();
}
- PCState
- buildRetPC(const PCState &curPC, const PCState &callPC) const
override
+ std::unique_ptr<PCStateBase>
+ buildRetPC(const PCStateBase &cur_pc,
+ const PCStateBase &call_pc) const override
{
- PCState ret = callPC;
+ PCStateBase *ret_pc = call_pc.clone();
+
+ auto &ret = ret_pc->as<PCState>();
+
ret.advance();
- ret.pc(curPC.npc());
- return ret;
+ ret.pc(cur_pc.as<PCState>().npc());
+
+ return std::unique_ptr<PCStateBase>{ret_pc};
}
size_t
diff --git a/src/arch/power/insts/static_inst.hh
b/src/arch/power/insts/static_inst.hh
index bbe93fe..eaa0100 100644
--- a/src/arch/power/insts/static_inst.hh
+++ b/src/arch/power/insts/static_inst.hh
@@ -74,12 +74,13 @@
pc_state.as<PCState>().advance();
}
- PCState
- buildRetPC(const PCState &curPC, const PCState &callPC) const override
+ std::unique_ptr<PCStateBase>
+ buildRetPC(const PCStateBase &cur_pc,
+ const PCStateBase &call_pc) const override
{
- PCState retPC = callPC;
- retPC.advance();
- return retPC;
+ PCStateBase *ret_pc = call_pc.clone();
+ ret_pc->as<PCState>().advance();
+ return std::unique_ptr<PCStateBase>{ret_pc};
}
size_t
diff --git a/src/arch/riscv/insts/static_inst.hh
b/src/arch/riscv/insts/static_inst.hh
index 1e2ec28..ed180ed 100644
--- a/src/arch/riscv/insts/static_inst.hh
+++ b/src/arch/riscv/insts/static_inst.hh
@@ -64,13 +64,15 @@
pc.as<PCState>().advance();
}
- PCState
- buildRetPC(const PCState &curPC, const PCState &callPC) const override
+ std::unique_ptr<PCStateBase>
+ buildRetPC(const PCStateBase &cur_pc,
+ const PCStateBase &call_pc) const override
{
- PCState retPC = callPC;
- retPC.advance();
- retPC.pc(curPC.npc());
- return retPC;
+ PCStateBase *ret_pc_ptr = call_pc.clone();
+ auto &ret_pc = ret_pc_ptr->as<PCState>();
+ ret_pc.advance();
+ ret_pc.pc(cur_pc.as<PCState>().npc());
+ return std::unique_ptr<PCStateBase>{ret_pc_ptr};
}
size_t
diff --git a/src/arch/sparc/insts/static_inst.hh
b/src/arch/sparc/insts/static_inst.hh
index b2dfd5e..c5cec25 100644
--- a/src/arch/sparc/insts/static_inst.hh
+++ b/src/arch/sparc/insts/static_inst.hh
@@ -122,13 +122,15 @@
return simpleAsBytes(buf, size, machInst);
}
- PCState
- buildRetPC(const PCState &curPC, const PCState &callPC) const override
+ std::unique_ptr<PCStateBase>
+ buildRetPC(const PCStateBase &cur_pc,
+ const PCStateBase &call_pc) const override
{
- PCState ret = callPC;
+ PCStateBase *ret_ptr = call_pc.clone();
+ auto &ret = ret_ptr->as<PCState>();
ret.uEnd();
- ret.pc(curPC.npc());
- return ret;
+ ret.pc(cur_pc.as<PCState>().npc());
+ return std::unique_ptr<PCStateBase>{ret_ptr};
}
};
diff --git a/src/arch/x86/insts/static_inst.hh
b/src/arch/x86/insts/static_inst.hh
index 1654e81..d890904 100644
--- a/src/arch/x86/insts/static_inst.hh
+++ b/src/arch/x86/insts/static_inst.hh
@@ -204,12 +204,13 @@
pcState.as<PCState>().advance();
}
- PCState
- buildRetPC(const PCState &curPC, const PCState &callPC) const override
+ std::unique_ptr<PCStateBase>
+ buildRetPC(const PCStateBase &cur_pc,
+ const PCStateBase &call_pc) const override
{
- PCState retPC = callPC;
- retPC.uEnd();
- return retPC;
+ PCStateBase *ret_pc_ptr = call_pc.clone();
+ ret_pc_ptr->as<PCState>().uEnd();
+ return std::unique_ptr<PCStateBase>{ret_pc_ptr};
}
};
diff --git a/src/cpu/pred/bpred_unit.cc b/src/cpu/pred/bpred_unit.cc
index 9fcb9ba..502b345 100644
--- a/src/cpu/pred/bpred_unit.cc
+++ b/src/cpu/pred/bpred_unit.cc
@@ -180,7 +180,7 @@
// If it's a function return call, then look up the address
// in the RAS.
TheISA::PCState rasTop = RAS[tid].top();
- target = inst->buildRetPC(pc, rasTop);
+ target = inst->buildRetPC(pc, rasTop)->as<TheISA::PCState>();
// Record the top entry of the RAS, and its index.
predict_record.usedRAS = true;
diff --git a/src/cpu/static_inst.hh b/src/cpu/static_inst.hh
index d8c09ad..9b5fd38 100644
--- a/src/cpu/static_inst.hh
+++ b/src/cpu/static_inst.hh
@@ -322,9 +322,8 @@
virtual void advancePC(PCStateBase &pc_state) const = 0;
- virtual TheISA::PCState
- buildRetPC(const TheISA::PCState &cur_pc,
- const TheISA::PCState &call_pc) const
+ virtual std::unique_ptr<PCStateBase>
+ buildRetPC(const PCStateBase &cur_pc, const PCStateBase &call_pc) const
{
panic("buildRetPC not defined!");
}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/52044
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I9d9f5b25613440737b1d67134fcae09aa68baf8b
Gerrit-Change-Number: 52044
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s