Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/42362 )
Change subject: arch-x86: Move the step division helper out of the ISA desc.
......................................................................
arch-x86: Move the step division helper out of the ISA desc.
Change-Id: I3c5714d6485c3b000561bdaa478c9393bc844bca
---
M src/arch/x86/insts/static_inst.cc
M src/arch/x86/insts/static_inst.hh
M src/arch/x86/isa/microops/regop.isa
3 files changed, 35 insertions(+), 37 deletions(-)
diff --git a/src/arch/x86/insts/static_inst.cc
b/src/arch/x86/insts/static_inst.cc
index 59c0089..2bd6b3d 100644
--- a/src/arch/x86/insts/static_inst.cc
+++ b/src/arch/x86/insts/static_inst.cc
@@ -120,6 +120,36 @@
}
void
+X86StaticInst::divideStep(uint64_t dividend, uint64_t divisor,
+ uint64_t "ient, uint64_t &remainder)
+{
+ // Check for divide by zero.
+ assert(divisor != 0);
+ // If the divisor is bigger than the dividend, don't do anything.
+ if (divisor <= dividend) {
+ // Shift the divisor so it's msb lines up with the dividend.
+ int dividendMsb = findMsbSet(dividend);
+ int divisorMsb = findMsbSet(divisor);
+ int shift = dividendMsb - divisorMsb;
+ divisor <<= shift;
+ // Compute what we'll add to the quotient if the divisor isn't
+ // now larger than the dividend.
+ uint64_t quotientBit = 1;
+ quotientBit <<= shift;
+ // If we need to step back a bit (no pun intended) because the
+ // divisor got too to large, do that here. This is the "or two"
+ // part of one or two bit division.
+ if (divisor > dividend) {
+ quotientBit >>= 1;
+ divisor >>= 1;
+ }
+ // Decrement the remainder and increment the quotient.
+ quotient += quotientBit;
+ remainder -= divisor;
+ }
+}
+
+void
X86StaticInst::printReg(std::ostream &os, RegId reg, int size)
{
assert(size == 1 || size == 2 || size == 4 || size == 8);
diff --git a/src/arch/x86/insts/static_inst.hh
b/src/arch/x86/insts/static_inst.hh
index 8c70d05..ea9c249 100644
--- a/src/arch/x86/insts/static_inst.hh
+++ b/src/arch/x86/insts/static_inst.hh
@@ -119,6 +119,9 @@
void printSrcReg(std::ostream &os, int reg, int size) const;
void printDestReg(std::ostream &os, int reg, int size) const;
+ static void divideStep(uint64_t divident, uint64_t divisor,
+ uint64_t "ient, uint64_t &remainder);
+
static inline uint64_t
merge(uint64_t into, RegIndex index, uint64_t val, int size)
{
diff --git a/src/arch/x86/isa/microops/regop.isa
b/src/arch/x86/isa/microops/regop.isa
index f83ec84..7e79b35 100644
--- a/src/arch/x86/isa/microops/regop.isa
+++ b/src/arch/x86/isa/microops/regop.isa
@@ -133,9 +133,6 @@
}};
output header {{
- void divide(uint64_t dividend, uint64_t divisor,
- uint64_t "ient, uint64_t &remainder);
-
enum SegmentSelectorCheck
{
SegNoCheck,
@@ -163,38 +160,6 @@
};
}};
-output decoder {{
- void
- divide(uint64_t dividend, uint64_t divisor,
- uint64_t "ient, uint64_t &remainder)
- {
- //Check for divide by zero.
- assert(divisor != 0);
- //If the divisor is bigger than the dividend, don't do anything.
- if (divisor <= dividend) {
- //Shift the divisor so it's msb lines up with the dividend.
- int dividendMsb = findMsbSet(dividend);
- int divisorMsb = findMsbSet(divisor);
- int shift = dividendMsb - divisorMsb;
- divisor <<= shift;
- //Compute what we'll add to the quotient if the divisor isn't
- //now larger than the dividend.
- uint64_t quotientBit = 1;
- quotientBit <<= shift;
- //If we need to step back a bit (no pun intended) because the
- //divisor got too to large, do that here. This is the "or two"
- //part of one or two bit division.
- if (divisor > dividend) {
- quotientBit >>= 1;
- divisor >>= 1;
- }
- //Decrement the remainder and increment the quotient.
- quotient += quotientBit;
- remainder -= divisor;
- }
- }
-}};
-
let {{
# Make these empty strings so that concatenating onto
# them will always work.
@@ -681,7 +646,7 @@
if (divisor == 0) {
fault = std::make_shared<DivideError>();
} else {
- divide(dividend, divisor, quotient, remainder);
+ divideStep(dividend, divisor, quotient, remainder);
//Record the final results.
Remainder = remainder;
Quotient = quotient;
@@ -736,7 +701,7 @@
}
remainder = dividend;
//Do the division.
- divide(dividend, divisor, quotient, remainder);
+ divideStep(dividend, divisor, quotient, remainder);
}
}
//Keep track of how many bits there are still to pull in.
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/42362
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: I3c5714d6485c3b000561bdaa478c9393bc844bca
Gerrit-Change-Number: 42362
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