Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/42386 )
Change subject: arch,mem: Use szext instead of sext as appropriate.
......................................................................
arch,mem: Use szext instead of sext as appropriate.
When the value being passed to sext needs to be masked first, szext can
be used instead without the masking.
Change-Id: I98c99ad2731216fe8ccf1253f5ac3891fe03b1de
---
M src/arch/arm/insts/vfp.cc
M src/arch/gcn3/insts/instructions.cc
M src/arch/mips/isa/decoder.isa
M src/arch/sparc/insts/blockmem.hh
M src/arch/sparc/insts/branch.hh
M src/arch/sparc/insts/integer.hh
M src/arch/sparc/insts/mem.hh
M src/arch/sparc/isa/decoder.isa
M src/arch/sparc/tlb.cc
M src/mem/cache/compressors/dictionary_compressor.hh
M src/mem/cache/compressors/fpc.hh
11 files changed, 33 insertions(+), 43 deletions(-)
diff --git a/src/arch/arm/insts/vfp.cc b/src/arch/arm/insts/vfp.cc
index a84b713..acbd586 100644
--- a/src/arch/arm/insts/vfp.cc
+++ b/src/arch/arm/insts/vfp.cc
@@ -692,9 +692,9 @@
{
fesetround(FeRoundNearest);
if (width == 16)
- val = sext<16>(val & mask(16));
+ val = szext<16>(val);
else if (width == 32)
- val = sext<32>(val & mask(32));
+ val = szext<32>(val);
else if (width != 64)
panic("Unsupported width %d", width);
@@ -731,9 +731,9 @@
{
fesetround(FeRoundNearest);
if (width == 16)
- val = sext<16>(val & mask(16));
+ val = szext<16>(val);
else if (width == 32)
- val = sext<32>(val & mask(32));
+ val = szext<32>(val);
else if (width != 64)
panic("Unsupported width %d", width);
diff --git a/src/arch/gcn3/insts/instructions.cc
b/src/arch/gcn3/insts/instructions.cc
index 29de1a8..28a0ea2 100644
--- a/src/arch/gcn3/insts/instructions.cc
+++ b/src/arch/gcn3/insts/instructions.cc
@@ -5730,8 +5730,7 @@
for (int lane = 0; lane < NumVecElemPerVecReg; ++lane) {
if (wf->execMask(lane)) {
- vdst[lane] = sext<24>(bits(src0[lane], 23, 0))
- * sext<24>(bits(src1[lane], 23, 0));
+ vdst[lane] = szext<24>(src0[lane]) * szext<24>(src1[lane]);
}
}
@@ -5762,10 +5761,8 @@
for (int lane = 0; lane < NumVecElemPerVecReg; ++lane) {
if (wf->execMask(lane)) {
- VecElemI64 tmp_src0
- = (VecElemI64)sext<24>(bits(src0[lane], 23, 0));
- VecElemI64 tmp_src1
- = (VecElemI64)sext<24>(bits(src1[lane], 23, 0));
+ VecElemI64 tmp_src0 = (VecElemI64)szext<24>(src0[lane]);
+ VecElemI64 tmp_src1 = (VecElemI64)szext<24>(src1[lane]);
vdst[lane] = (VecElemI32)((tmp_src0 * tmp_src1) >> 32);
}
@@ -23565,8 +23562,7 @@
for (int lane = 0; lane < NumVecElemPerVecReg; ++lane) {
if (wf->execMask(lane)) {
- vdst[lane] = sext<24>(bits(src0[lane], 23, 0))
- * sext<24>(bits(src1[lane], 23, 0));
+ vdst[lane] = szext<24>(src0[lane]) * szext<24>(src1[lane]);
}
}
@@ -23607,10 +23603,8 @@
for (int lane = 0; lane < NumVecElemPerVecReg; ++lane) {
if (wf->execMask(lane)) {
- VecElemI64 tmp_src0
- = (VecElemI64)sext<24>(bits(src0[lane], 23, 0));
- VecElemI64 tmp_src1
- = (VecElemI64)sext<24>(bits(src1[lane], 23, 0));
+ VecElemI64 tmp_src0 = (VecElemI64)szext<24>(src0[lane]);
+ VecElemI64 tmp_src1 = (VecElemI64)szext<24>(src1[lane]);
vdst[lane] = (VecElemI32)((tmp_src0 * tmp_src1) >> 32);
}
@@ -27787,8 +27781,8 @@
for (int lane = 0; lane < NumVecElemPerVecReg; ++lane) {
if (wf->execMask(lane)) {
- vdst[lane] = sext<24>(bits(src0[lane], 23, 0))
- * sext<24>(bits(src1[lane], 23, 0)) + src2[lane];
+ vdst[lane] = szext<24>(src0[lane])
+ * szext<24>(src1[lane]) + src2[lane];
}
}
diff --git a/src/arch/mips/isa/decoder.isa b/src/arch/mips/isa/decoder.isa
index e5613f5..b001d90 100644
--- a/src/arch/mips/isa/decoder.isa
+++ b/src/arch/mips/isa/decoder.isa
@@ -2441,19 +2441,18 @@
0x2: shilo({{
if ((int64_t)sext<6>(HILOSA) < 0) {
dspac = (uint64_t)dspac <<
- -sext<6>(HILOSA);
+ -szext<6>(HILOSA);
} else {
dspac = (uint64_t)dspac >>
- sext<6>(HILOSA);
+ szext<6>(HILOSA);
}
}});
0x3: shilov({{
- if ((int64_t)sext<6>(Rs_sw<5:0>) <
0) {
+ if ((int64_t)szext<6>(Rs_sw) < 0) {
dspac = (uint64_t)dspac <<
- -sext<6>(Rs_sw<5:0>);
+ -szext<6>(Rs_sw);
} else {
- dspac = (uint64_t)dspac >>
- sext<6>(Rs_sw<5:0>);
+ dspac = (uint64_t)dspac >>
szext<6>(Rs_sw);
}
}});
0x7: mthlip({{
diff --git a/src/arch/sparc/insts/blockmem.hh
b/src/arch/sparc/insts/blockmem.hh
index 0528b6a..f5bc397 100644
--- a/src/arch/sparc/insts/blockmem.hh
+++ b/src/arch/sparc/insts/blockmem.hh
@@ -75,7 +75,7 @@
BlockMemImmMicro(const char *mnem, ExtMachInst _machInst,
OpClass __opClass, int8_t _offset) :
BlockMemMicro(mnem, _machInst, __opClass, _offset),
- imm(sext<13>(bits(_machInst, 12, 0)))
+ imm(szext<13>(_machInst))
{}
std::string generateDisassembly(
diff --git a/src/arch/sparc/insts/branch.hh b/src/arch/sparc/insts/branch.hh
index 03842bf..915c0d8 100644
--- a/src/arch/sparc/insts/branch.hh
+++ b/src/arch/sparc/insts/branch.hh
@@ -77,8 +77,7 @@
protected:
// Constructor
BranchNBits(const char *mnem, ExtMachInst _machInst, OpClass
__opClass) :
- BranchDisp(mnem, _machInst, __opClass,
- sext<bits + 2>((_machInst & mask(bits)) << 2))
+ BranchDisp(mnem, _machInst, __opClass, szext<bits>(_machInst) << 2)
{}
};
@@ -105,8 +104,7 @@
protected:
// Constructor
BranchImm13(const char *mnem, ExtMachInst _machInst, OpClass
__opClass) :
- Branch(mnem, _machInst, __opClass),
- imm(sext<13>(bits(_machInst, 12, 0)))
+ Branch(mnem, _machInst, __opClass), imm(szext<13>(_machInst))
{}
std::string generateDisassembly(
diff --git a/src/arch/sparc/insts/integer.hh
b/src/arch/sparc/insts/integer.hh
index 1438cfd..beb43ee 100644
--- a/src/arch/sparc/insts/integer.hh
+++ b/src/arch/sparc/insts/integer.hh
@@ -83,7 +83,7 @@
protected:
// Constructor
IntOpImm10(const char *mnem, ExtMachInst _machInst, OpClass
__opClass) :
- IntOpImm(mnem, _machInst, __opClass, sext<10>(bits(_machInst, 9,
0)))
+ IntOpImm(mnem, _machInst, __opClass, szext<10>(_machInst))
{}
};
@@ -94,7 +94,7 @@
{
protected:
IntOpImm11(const char *mnem, ExtMachInst _machInst, OpClass
__opClass) :
- IntOpImm(mnem, _machInst, __opClass, sext<10>(bits(_machInst, 10,
0)))
+ IntOpImm(mnem, _machInst, __opClass, szext<10>(_machInst))
{}
};
@@ -105,7 +105,7 @@
{
protected:
IntOpImm13(const char *mnem, ExtMachInst _machInst, OpClass
__opClass) :
- IntOpImm(mnem, _machInst, __opClass, sext<13>(bits(_machInst, 12,
0)))
+ IntOpImm(mnem, _machInst, __opClass, szext<13>(_machInst))
{}
};
diff --git a/src/arch/sparc/insts/mem.hh b/src/arch/sparc/insts/mem.hh
index 929fa94..fb1f0ec 100644
--- a/src/arch/sparc/insts/mem.hh
+++ b/src/arch/sparc/insts/mem.hh
@@ -60,7 +60,7 @@
// Constructor
MemImm(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
- Mem(mnem, _machInst, __opClass), imm(sext<13>(bits(_machInst, 12,
0)))
+ Mem(mnem, _machInst, __opClass), imm(szext<13>(_machInst))
{}
std::string generateDisassembly(
diff --git a/src/arch/sparc/isa/decoder.isa b/src/arch/sparc/isa/decoder.isa
index ba11727..d8d9a27 100644
--- a/src/arch/sparc/isa/decoder.isa
+++ b/src/arch/sparc/isa/decoder.isa
@@ -155,7 +155,7 @@
Y = Rd<63:32>;
}});
0x0B: smul({{
- Rd_sdw = sext<32>(Rs1_sdw<31:0>) *
sext<32>(Rs2_or_imm13<31:0>);
+ Rd_sdw = szext<32>(Rs1_sdw) * szext<32>(Rs2_or_imm13);
Y = Rd_sdw<63:32>;
}});
0x0C: subc({{Rd_sdw = Rs1_sdw + (~Rs2_or_imm13) + 1 -
Ccr<0:0>}});
@@ -215,8 +215,7 @@
Y = resTemp<63:32>;}});
0x1B: IntOpCcRes::smulcc({{
int64_t resTemp;
- Rd = resTemp = sext<32>(Rs1_sdw<31:0>) *
- sext<32>(Rs2_or_imm13<31:0>);
+ Rd = resTemp = szext<32>(Rs1_sdw) *
szext<32>(Rs2_or_imm13);
Y = resTemp<63:32>;}});
0x1C: subccc({{
int64_t res, op1 = Rs1, op2 = Rs2_or_imm13;
diff --git a/src/arch/sparc/tlb.cc b/src/arch/sparc/tlb.cc
index 46e03e3..db36006 100644
--- a/src/arch/sparc/tlb.cc
+++ b/src/arch/sparc/tlb.cc
@@ -1238,7 +1238,7 @@
itb->sfsr = data;
break;
case 0x30:
- sext<59>(bits(data, 59,0));
+ szext<59>(data);
itb->tag_access = data;
break;
default:
@@ -1315,7 +1315,7 @@
sfsr = data;
break;
case 0x30:
- sext<59>(bits(data, 59,0));
+ szext<59>(data);
tag_access = data;
break;
case 0x80:
diff --git a/src/mem/cache/compressors/dictionary_compressor.hh
b/src/mem/cache/compressors/dictionary_compressor.hh
index fe70b59..ed4ae43 100644
--- a/src/mem/cache/compressors/dictionary_compressor.hh
+++ b/src/mem/cache/compressors/dictionary_compressor.hh
@@ -776,7 +776,7 @@
const DictionaryEntry& dict_bytes, const int match_location)
{
const T data = DictionaryCompressor<T>::fromDictionaryEntry(bytes);
- return data == sext<N>(data & mask(N));
+ return data == szext<N>(data);
}
DictionaryEntry
diff --git a/src/mem/cache/compressors/fpc.hh
b/src/mem/cache/compressors/fpc.hh
index d13f3dd..b0322b9 100644
--- a/src/mem/cache/compressors/fpc.hh
+++ b/src/mem/cache/compressors/fpc.hh
@@ -265,16 +265,16 @@
int16_t(data & mask(16)),
int16_t((data >> 16) & mask(16))
};
- return (halfwords[0] == sext<8>(halfwords[0] & mask(8))) &&
- (halfwords[1] == sext<8>(halfwords[1] & mask(8)));
+ return (halfwords[0] == szext<8>(halfwords[0])) &&
+ (halfwords[1] == szext<8>(halfwords[1]));
}
DictionaryEntry
decompress(const DictionaryEntry dict_bytes) const override
{
uint16_t halfwords[2] = {
- uint16_t(sext<8>(extendedBytes[0]) & mask(16)),
- uint16_t(sext<8>(extendedBytes[1]) & mask(16))
+ (uint16_t)szext<8>(extendedBytes[0]),
+ (uint16_t)szext<8>(extendedBytes[1])
};
return toDictionaryEntry((halfwords[1] << 16) | halfwords[0]);
}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/42386
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: I98c99ad2731216fe8ccf1253f5ac3891fe03b1de
Gerrit-Change-Number: 42386
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