[llvm-commits] [llvm-gcc-4.2] r121122 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Jay Foad
jay.foad at gmail.com
Tue Dec 7 00:26:04 PST 2010
Author: foad
Date: Tue Dec 7 02:26:04 2010
New Revision: 121122
URL: http://llvm.org/viewvc/llvm-project?rev=121122&view=rev
Log:
PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=121122&r1=121121&r2=121122&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Dec 7 02:26:04 2010
@@ -8346,7 +8346,7 @@
ValC = 0;
} else if (!BYTES_BIG_ENDIAN) {
// Little endian, take bits from the bottom of the field value.
- ValForPrevField.trunc(BitsInPreviousField);
+ ValForPrevField = ValForPrevField.trunc(BitsInPreviousField);
APInt Tmp = ValC->getValue();
Tmp = Tmp.lshr(BitsInPreviousField);
Tmp = Tmp.trunc(ValBitSize-BitsInPreviousField);
@@ -8354,7 +8354,7 @@
} else {
// Big endian, take bits from the top of the field value.
ValForPrevField = ValForPrevField.lshr(ValBitSize-BitsInPreviousField);
- ValForPrevField.trunc(BitsInPreviousField);
+ ValForPrevField = ValForPrevField.trunc(BitsInPreviousField);
APInt Tmp = ValC->getValue();
Tmp = Tmp.trunc(ValBitSize-BitsInPreviousField);
@@ -8363,7 +8363,7 @@
// Okay, we're going to insert ValForPrevField into the previous i8, extend
// it and shift into place.
- ValForPrevField.zext(8);
+ ValForPrevField = ValForPrevField.zext(8);
if (!BYTES_BIG_ENDIAN) {
ValForPrevField = ValForPrevField.shl(8-BitsInPreviousField);
} else {
@@ -8391,23 +8391,19 @@
if (Val.getBitWidth() > 8) {
if (!BYTES_BIG_ENDIAN) {
// Little endian lays out low bits first.
- APInt Tmp = Val;
- Tmp.trunc(8);
+ APInt Tmp = Val.trunc(8);
ValToAppend = ConstantInt::get(Context, Tmp);
Val = Val.lshr(8);
} else {
// Big endian lays out high bits first.
- APInt Tmp = Val;
- Tmp = Tmp.lshr(Tmp.getBitWidth()-8);
- Tmp.trunc(8);
+ APInt Tmp = Val.lshr(Tmp.getBitWidth()-8).trunc(8);
ValToAppend = ConstantInt::get(Context, Tmp);
}
} else if (Val.getBitWidth() == 8) {
ValToAppend = ConstantInt::get(Context, Val);
} else {
- APInt Tmp = Val;
- Tmp.zext(8);
+ APInt Tmp = Val.zext(8);
if (BYTES_BIG_ENDIAN)
Tmp = Tmp << 8-Val.getBitWidth();
@@ -8419,7 +8415,7 @@
if (Val.getBitWidth() <= 8)
break;
- Val.trunc(Val.getBitWidth()-8);
+ Val = Val.trunc(Val.getBitWidth()-8);
}
}
More information about the llvm-commits
mailing list