ARM: Fix type comparison warnings in Neon.

This commit is contained in:
Gabe Black 2010-08-25 19:10:42 -05:00
parent 54a919f225
commit 0efe2f6769
2 changed files with 38 additions and 26 deletions

View file

@ -1718,7 +1718,7 @@ let {{
destElem = (srcElem1 >> shiftAmt); destElem = (srcElem1 >> shiftAmt);
} }
// Make sure the right shift sign extended when it should. // Make sure the right shift sign extended when it should.
if (srcElem1 < 0 && destElem >= 0) { if (ltz(srcElem1) && !ltz(destElem)) {
destElem |= -((Element)1 << (sizeof(Element) * 8 - destElem |= -((Element)1 << (sizeof(Element) * 8 -
1 - shiftAmt)); 1 - shiftAmt));
} }
@ -1740,7 +1740,7 @@ let {{
Element rBit = 0; Element rBit = 0;
if (shiftAmt <= sizeof(Element) * 8) if (shiftAmt <= sizeof(Element) * 8)
rBit = bits(srcElem1, shiftAmt - 1); rBit = bits(srcElem1, shiftAmt - 1);
if (shiftAmt > sizeof(Element) * 8 && srcElem1 < 0) if (shiftAmt > sizeof(Element) * 8 && ltz(srcElem1))
rBit = 1; rBit = 1;
if (shiftAmt >= sizeof(Element) * 8) { if (shiftAmt >= sizeof(Element) * 8) {
shiftAmt = sizeof(Element) * 8 - 1; shiftAmt = sizeof(Element) * 8 - 1;
@ -1749,7 +1749,7 @@ let {{
destElem = (srcElem1 >> shiftAmt); destElem = (srcElem1 >> shiftAmt);
} }
// Make sure the right shift sign extended when it should. // Make sure the right shift sign extended when it should.
if (srcElem1 < 0 && destElem >= 0) { if (ltz(srcElem1) && !ltz(destElem)) {
destElem |= -((Element)1 << (sizeof(Element) * 8 - destElem |= -((Element)1 << (sizeof(Element) * 8 -
1 - shiftAmt)); 1 - shiftAmt));
} }
@ -1778,11 +1778,6 @@ let {{
} else { } else {
destElem = (srcElem1 >> shiftAmt); destElem = (srcElem1 >> shiftAmt);
} }
// Make sure the right shift sign extended when it should.
if (srcElem1 < 0 && destElem >= 0) {
destElem |= -((Element)1 << (sizeof(Element) * 8 -
1 - shiftAmt));
}
} else if (shiftAmt > 0) { } else if (shiftAmt > 0) {
if (shiftAmt >= sizeof(Element) * 8) { if (shiftAmt >= sizeof(Element) * 8) {
if (srcElem1 != 0) { if (srcElem1 != 0) {
@ -1862,19 +1857,12 @@ let {{
Element rBit = 0; Element rBit = 0;
if (shiftAmt <= sizeof(Element) * 8) if (shiftAmt <= sizeof(Element) * 8)
rBit = bits(srcElem1, shiftAmt - 1); rBit = bits(srcElem1, shiftAmt - 1);
if (shiftAmt > sizeof(Element) * 8 && srcElem1 < 0)
rBit = 1;
if (shiftAmt >= sizeof(Element) * 8) { if (shiftAmt >= sizeof(Element) * 8) {
shiftAmt = sizeof(Element) * 8 - 1; shiftAmt = sizeof(Element) * 8 - 1;
destElem = 0; destElem = 0;
} else { } else {
destElem = (srcElem1 >> shiftAmt); destElem = (srcElem1 >> shiftAmt);
} }
// Make sure the right shift sign extended when it should.
if (srcElem1 < 0 && destElem >= 0) {
destElem |= -((Element)1 << (sizeof(Element) * 8 -
1 - shiftAmt));
}
destElem += rBit; destElem += rBit;
} else { } else {
if (shiftAmt >= sizeof(Element) * 8) { if (shiftAmt >= sizeof(Element) * 8) {
@ -2014,10 +2002,10 @@ let {{
midElem = ~((BigElement)maxNeg << (sizeof(Element) * 8)); midElem = ~((BigElement)maxNeg << (sizeof(Element) * 8));
fpscr.qc = 1; fpscr.qc = 1;
} }
bool negPreDest = (destElem < 0); bool negPreDest = ltz(destElem);
destElem += midElem; destElem += midElem;
bool negDest = (destElem < 0); bool negDest = ltz(destElem);
bool negMid = (midElem < 0); bool negMid = ltz(midElem);
if (negPreDest == negMid && negMid != negDest) { if (negPreDest == negMid && negMid != negDest) {
destElem = mask(sizeof(BigElement) * 8 - 1); destElem = mask(sizeof(BigElement) * 8 - 1);
if (negPreDest) if (negPreDest)
@ -2039,10 +2027,10 @@ let {{
midElem = ~((BigElement)maxNeg << (sizeof(Element) * 8)); midElem = ~((BigElement)maxNeg << (sizeof(Element) * 8));
fpscr.qc = 1; fpscr.qc = 1;
} }
bool negPreDest = (destElem < 0); bool negPreDest = ltz(destElem);
destElem -= midElem; destElem -= midElem;
bool negDest = (destElem < 0); bool negDest = ltz(destElem);
bool posMid = (midElem > 0); bool posMid = ltz((BigElement)-midElem);
if (negPreDest == posMid && posMid != negDest) { if (negPreDest == posMid && posMid != negDest) {
destElem = mask(sizeof(BigElement) * 8 - 1); destElem = mask(sizeof(BigElement) * 8 - 1);
if (negPreDest) if (negPreDest)
@ -2361,7 +2349,7 @@ let {{
vshrCode = ''' vshrCode = '''
if (imm >= sizeof(srcElem1) * 8) { if (imm >= sizeof(srcElem1) * 8) {
if (srcElem1 < 0) if (ltz(srcElem1))
destElem = -1; destElem = -1;
else else
destElem = 0; destElem = 0;
@ -2375,10 +2363,10 @@ let {{
vsraCode = ''' vsraCode = '''
Element mid;; Element mid;;
if (imm >= sizeof(srcElem1) * 8) { if (imm >= sizeof(srcElem1) * 8) {
mid = (srcElem1 < 0) ? -1 : 0; mid = ltz(srcElem1) ? -1 : 0;
} else { } else {
mid = srcElem1 >> imm; mid = srcElem1 >> imm;
if (srcElem1 < 0 && mid >= 0) { if (ltz(srcElem1) && !ltz(mid)) {
mid |= -(mid & ((Element)1 << mid |= -(mid & ((Element)1 <<
(sizeof(Element) * 8 - 1 - imm))); (sizeof(Element) * 8 - 1 - imm)));
} }
@ -2686,8 +2674,6 @@ let {{
} else { } else {
if (srcElem1 != (Element)srcElem1) { if (srcElem1 != (Element)srcElem1) {
destElem = mask(sizeof(Element) * 8 - 1); destElem = mask(sizeof(Element) * 8 - 1);
if (srcElem1 < 0)
destElem = ~destElem;
fpscr.qc = 1; fpscr.qc = 1;
} else { } else {
destElem = srcElem1; destElem = srcElem1;

View file

@ -142,6 +142,32 @@ def template NeonExecDeclare {{
%(CPU_exec_context)s *, Trace::InstRecord *) const; %(CPU_exec_context)s *, Trace::InstRecord *) const;
}}; }};
output header {{
template <class T>
// Implement a less-than-zero function: ltz()
// this function exists because some versions of GCC complain when a
// comparison is done between a unsigned variable and 0 and for GCC 4.2
// there is no way to disable this warning
inline bool ltz(T t);
template <>
inline bool ltz(uint8_t) { return false; }
template <>
inline bool ltz(uint16_t) { return false; }
template <>
inline bool ltz(uint32_t) { return false; }
template <>
inline bool ltz(uint64_t) { return false; }
template <>
inline bool ltz(int8_t v) { return v < 0; }
template <>
inline bool ltz(int16_t v) { return v < 0; }
template <>
inline bool ltz(int32_t v) { return v < 0; }
template <>
inline bool ltz(int64_t v) { return v < 0; }
}};
def template NeonEqualRegExecute {{ def template NeonEqualRegExecute {{
template <class Element> template <class Element>
Fault %(class_name)s<Element>::execute(%(CPU_exec_context)s *xc, Fault %(class_name)s<Element>::execute(%(CPU_exec_context)s *xc,