[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp

2007-02-13 Thread Reid Spencer


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.3 -> 1.4
---
Log message:

Significantly beef up this test to check all interface operations on a
variety of bitwidths from 1 to 1024 and using randomly generated data.


---
Diffs of the changes:  (+162 -54)

 arith.cpp |  216 ++
 1 files changed, 162 insertions(+), 54 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.3 
llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.4
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.3Sun Feb 
11 02:49:48 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cppTue Feb 13 
16:40:41 2007
@@ -11,6 +11,7 @@
 
 #include "llvm/ADT/APInt.h"
 #include 
+#include 
 
 using namespace llvm;
 
@@ -18,67 +19,174 @@
 
 APInt y(0x0f, 21);
 
-int my_test()
-{
-  APInt i(uint64_t(0), 10);
-  APInt j(0, 10);
-  APInt k(0, 10);
-  APInt l(0, 10);
-  APInt result(0, 21);
-  short temp;
-  int i_temp;
-  unsigned int ui_x;
-  unsigned int ui_y;
-  j = i;
-  j -= 1;
-  temp = (short)j.getValue();
-  printf( "temp = %hd\n", temp);
-  k = i;
-  k += 1;
-  temp = k.getValue();
-  printf( "temp = %hd\n", temp);
-  k = j * k;
-  temp = k.getValue();
-  printf( "temp = %hd\n", temp);
-  j *= 120;
-  l = APIntOps::sdiv(j, k);
-  temp = l.getValue();
-  printf( "temp = %hd\n", temp);
-  j *= (-176); // after truncation, the value should be -384
-  l = APIntOps::sdiv(j, k);
-  temp = l.getValue();
-  printf( "temp = %hd\n", temp);
-  l = 120;
-  l = (j * l);
-  l = APIntOps::urem(l, 4);
-  temp = l.getValue();
-  printf( "temp = %hd\n", temp);
-  l = -217;
-  l = (j * l);
-  l = APIntOps::sdiv(l, (++i));
-  temp = l.getValue();
-  printf( "temp = %hd\n", temp);
-  result = ++x;
-  
-  i_temp = result.getValue();
-  printf( "i_temp = %x\n", i_temp);
+const char* str(const APInt& X) {
+  static std::string temp_str;
+  temp_str = X.to_string();
+  return temp_str.c_str(); 
+}
+
+void test_interface(const APInt &val) {
+  printf("INTERFACE TEST: val = %s\n", str(val));
+  unsigned bitwidth = val.getNumBits();
+  unsigned pos = rand() % bitwidth;
+  printf("val[%u] = %d\n", pos, val[pos]);
+  APInt smax = APInt::getMaxValue(bitwidth, true);
+  APInt umax = APInt::getMaxValue(bitwidth, false);
+  APInt smin = APInt::getMinValue(bitwidth, true);
+  APInt umin = APInt::getMinValue(bitwidth, false);
+  printf("APInt::getMaxValue(%d, true)  = %s\n", bitwidth, str(smax));
+  printf("APInt::getMaxValue(%d, false) = %s\n", bitwidth, str(umax));
+  printf("APInt::getMinValue(%d, true)  = %s\n", bitwidth, str(smin));
+  printf("APInt::getMinValue(%d, false) = %s\n", bitwidth, str(umin));
+  APInt null = APInt::getNullValue(bitwidth);
+  APInt allone = APInt::getAllOnesValue(bitwidth);
+  printf("APInt::getNullValue(%d) = %s\n", bitwidth, str(umin));
+  printf("APInt::getAllOnesValue(%d) = %s\n", bitwidth, str(umin));
+  APInt x(val);
+  x.set(pos);
+  printf("val.set(%d) = %s\n", pos, str(x));
+  x.set();
+  printf("val.set() = %s\n", str(x));
+  x = val;
+  x.clear(pos);
+  printf("val.clear(%d) = %s\n", pos, str(x));
+  x.clear();
+  printf("val.clear() = %s\n", str(x));
+  x = val;
+  x.flip(pos);
+  printf("val.flip(%d) = %s\n", pos, str(x));
+  x = val;
+  x.flip();
+  printf("val.flip() = %s\n", str(x));
+  unsigned bitsize = bitwidth / 2;
+  printf("val.HiBits(%d) = %s\n", bitsize, str(val.HiBits(bitsize)));
+  printf("val.LoBits(%d) = %s\n", bitsize, str(val.LoBits(bitsize)));
+  printf("val.IsIntN(%d) = %d\n", bitsize, str(val.IsIntN(bitsize)));
+}
+
+void test_unops(const APInt &val) {
+  printf("UNARY OPERATORS TEST: val = %s\n", str(val));
+  APInt x(val);
+  x++;
+  printf("val++ = %s\n", str(x));
+  x = val;
+  ++x;
+  printf("++val = %s\n", str(x));
+  x = val;
   x--;
- 
-  result = x + y;
-  i_temp = result.getValue();
-  printf("i_temp = %x\n", i_temp);
-  ui_x = x.getValue();
-  ui_y = y.getValue();
-  i_temp = ui_x - ui_y;
-  printf("i_temp = %x\n", i_temp);
+  printf("val-- = %s\n", str(x));
+  x = val;
+  --x;
+  printf("--val = %s\n", str(x));
+  x = -val;
+  printf("-val = %s\n", str(x));
+  x = ~val;
+  printf("~val = %s\n", str(x));
+  printf("!val = %d\n", !val);
+  printf("val.isPowerOf2() = %d\n", val.isPowerOf2());
+  printf("val.LogBase2() = %d\n", val.getNumBits());
+  printf("val.CountLeadingZeros() = %d\n", val.CountLeadingZeros());
+  printf("val.CountTrailingZeros() = %d\n", val.CountTrailingZeros());
+  printf("val.CountPopulation() = %d\n", val.CountPopulation());
+  printf("val.getNumBits() = %d\n", val.getNumBits());
+  x = val.ByteSwap();
+  printf("val.ByteSwap() = %d\n", str(x));
+  printf("val.RoundToDouble(true) %d = %f\n", val.RoundToDouble(true));
+  printf("val.getValue() = ");
+  if (val.getNumBits() > 64)
+printf("too wide\n");
+  else
+printf("%ul\n", val.getValue

[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp

2007-02-13 Thread Reid Spencer


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.4 -> 1.5
---
Log message:

1. Add a utility function for getting a printable string from an APInt
2. Comment out the ByteSwap function, it crashes.
3. Prevent divid by zero.
4. Test every bit width from 1 to 1024, not 1024 random bit widths.


---
Diffs of the changes:  (+20 -14)

 arith.cpp |   34 --
 1 files changed, 20 insertions(+), 14 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.4 
llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.5
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.4Tue Feb 
13 16:40:41 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cppTue Feb 13 
21:05:33 2007
@@ -19,8 +19,9 @@
 
 APInt y(0x0f, 21);
 
+static std::string temp_str;
+
 const char* str(const APInt& X) {
-  static std::string temp_str;
   temp_str = X.to_string();
   return temp_str.c_str(); 
 }
@@ -89,15 +90,17 @@
   printf("val.CountTrailingZeros() = %d\n", val.CountTrailingZeros());
   printf("val.CountPopulation() = %d\n", val.CountPopulation());
   printf("val.getNumBits() = %d\n", val.getNumBits());
-  x = val.ByteSwap();
-  printf("val.ByteSwap() = %d\n", str(x));
+  if (val.getNumBits() >= 16 && val.getNumBits() % 16 == 0) {
+// FIXME: ByteSwap crashes!
+// x = val.ByteSwap();
+printf("val.ByteSwap() = %d\n", str(x));
+  }
   printf("val.RoundToDouble(true) %d = %f\n", val.RoundToDouble(true));
   printf("val.getValue() = ");
   if (val.getNumBits() > 64)
 printf("too wide\n");
   else
 printf("%ul\n", val.getValue());
-
 }
 
 void test_binops(const APInt &v1, const APInt &v2) {
@@ -151,21 +154,24 @@
 printf("LShr(v1,%d) = %s\n", shiftAmt, str(result));
 result = Shl(v1,shiftAmt);
 printf("Shl(v1,%d) = %s\n", shiftAmt, str(result));
-result = SDiv(v1,v2);
-printf("SDiv(v1,v2) = %s\n", str(result));
-result = UDiv(v1,v2);
-printf("UDiv(v1,v2) = %s\n", str(result));
-result = SRem(v1,v2);
-printf("SRem(v1,v2) = %s\n", str(result));
-result = URem(v1,v2);
-printf("URem(v1,v2) = %s\n", str(result));
+if (v2 == 0)
+  printf("SDiv/UDiv/SRem/URem not tested, v2 == 0\n");
+else {
+  result = SDiv(v1,v2);
+  printf("SDiv(v1,v2) = %s\n", str(result));
+  result = UDiv(v1,v2);
+  printf("UDiv(v1,v2) = %s\n", str(result));
+  result = SRem(v1,v2);
+  printf("SRem(v1,v2) = %s\n", str(result));
+  result = URem(v1,v2);
+  printf("URem(v1,v2) = %s\n", str(result));
+}
   }
 }
 
 void test_multiple() {
   srand(0);
-  for (unsigned i = 0; i < 1024; ++i) {
-unsigned bits = rand() % 1024;
+  for (unsigned bits = 1; bits <= 1024; ++bits) {
 APInt v1(0u, bits);
 APInt v2(0u, bits);
 for (unsigned i = 0; i < bits; ++i) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp

2007-02-13 Thread Reid Spencer


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.5 -> 1.6
---
Log message:

Clean up some output.
Actually shift the bits when generating the random values.


---
Diffs of the changes:  (+6 -4)

 arith.cpp |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.5 
llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.6
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.5Tue Feb 
13 21:05:33 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cppTue Feb 13 
21:38:26 2007
@@ -100,11 +100,12 @@
   if (val.getNumBits() > 64)
 printf("too wide\n");
   else
-printf("%ul\n", val.getValue());
+printf("%lu\n", val.getValue());
 }
 
 void test_binops(const APInt &v1, const APInt &v2) {
-  printf("BINARY OPERATORS TEST: vl = %s, v2 = %s\n", str(v1), str(v2));
+  printf("BINARY OPERATORS TEST: vl = %s, ", str(v1));
+  printf("v2 = %s\n", str(v2));
   APInt result(v1);
   result &= v2;
   printf("v1 &= v2: %s\n", str(result));
@@ -176,14 +177,15 @@
 APInt v2(0u, bits);
 for (unsigned i = 0; i < bits; ++i) {
   unsigned bit = rand() % 2;
-  v1.Shl(1);
+  v1 = v1.Shl(1);
   v1 |= bit;
 }
 for (unsigned i = 0; i < bits; ++i) {
   unsigned bit = rand() % 2;
-  v2.Shl(1);
+  v2 = v2.Shl(1);
   v2 |= bit;
 }
+printf("\nTEST CASE: %d bits\n\n", bits);
 test_interface(v1);
 test_unops(v2);
 test_binops(v1,v2);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp

2007-02-14 Thread Zhou Sheng


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.6 -> 1.7
---
Log message:

Fix some errors.


---
Diffs of the changes:  (+4 -5)

 arith.cpp |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.6 
llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.7
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.6Tue Feb 
13 21:38:26 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cppThu Feb 15 
00:29:21 2007
@@ -41,8 +41,8 @@
   printf("APInt::getMinValue(%d, false) = %s\n", bitwidth, str(umin));
   APInt null = APInt::getNullValue(bitwidth);
   APInt allone = APInt::getAllOnesValue(bitwidth);
-  printf("APInt::getNullValue(%d) = %s\n", bitwidth, str(umin));
-  printf("APInt::getAllOnesValue(%d) = %s\n", bitwidth, str(umin));
+  printf("APInt::getNullValue(%d) = %s\n", bitwidth, str(null));
+  printf("APInt::getAllOnesValue(%d) = %s\n", bitwidth, str(allone));
   APInt x(val);
   x.set(pos);
   printf("val.set(%d) = %s\n", pos, str(x));
@@ -62,7 +62,7 @@
   unsigned bitsize = bitwidth / 2;
   printf("val.HiBits(%d) = %s\n", bitsize, str(val.HiBits(bitsize)));
   printf("val.LoBits(%d) = %s\n", bitsize, str(val.LoBits(bitsize)));
-  printf("val.IsIntN(%d) = %d\n", bitsize, str(val.IsIntN(bitsize)));
+  printf("val.IsIntN(%d) = %d\n", bitwidth, val.IsIntN(bitwidth));
 }
 
 void test_unops(const APInt &val) {
@@ -91,8 +91,7 @@
   printf("val.CountPopulation() = %d\n", val.CountPopulation());
   printf("val.getNumBits() = %d\n", val.getNumBits());
   if (val.getNumBits() >= 16 && val.getNumBits() % 16 == 0) {
-// FIXME: ByteSwap crashes!
-// x = val.ByteSwap();
+x = val.ByteSwap();
 printf("val.ByteSwap() = %d\n", str(x));
   }
   printf("val.RoundToDouble(true) %d = %f\n", val.RoundToDouble(true));



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp

2007-02-17 Thread Reid Spencer


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.7 -> 1.8
---
Log message:

Update for changes in APInt interface.


---
Diffs of the changes:  (+53 -51)

 arith.cpp |  104 +++---
 1 files changed, 53 insertions(+), 51 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.7 
llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.8
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.7Thu Feb 
15 00:29:21 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cppSat Feb 17 
02:18:20 2007
@@ -15,26 +15,26 @@
 
 using namespace llvm;
 
-APInt x(0x1f, 21);
+APInt x(21, 0x1f);
 
-APInt y(0x0f, 21);
+APInt y(21, 0x0f);
 
 static std::string temp_str;
 
 const char* str(const APInt& X) {
-  temp_str = X.to_string();
+  temp_str = X.toString();
   return temp_str.c_str(); 
 }
 
 void test_interface(const APInt &val) {
   printf("INTERFACE TEST: val = %s\n", str(val));
-  unsigned bitwidth = val.getNumBits();
+  unsigned bitwidth = val.getBitWidth();
   unsigned pos = rand() % bitwidth;
   printf("val[%u] = %d\n", pos, val[pos]);
-  APInt smax = APInt::getMaxValue(bitwidth, true);
-  APInt umax = APInt::getMaxValue(bitwidth, false);
-  APInt smin = APInt::getMinValue(bitwidth, true);
-  APInt umin = APInt::getMinValue(bitwidth, false);
+  APInt smax(APInt::getMaxValue(bitwidth, true));
+  APInt umax(APInt::getMaxValue(bitwidth, false));
+  APInt smin(APInt::getMinValue(bitwidth, true));
+  APInt umin(APInt::getMinValue(bitwidth, false));
   printf("APInt::getMaxValue(%d, true)  = %s\n", bitwidth, str(smax));
   printf("APInt::getMaxValue(%d, false) = %s\n", bitwidth, str(umax));
   printf("APInt::getMinValue(%d, true)  = %s\n", bitwidth, str(smin));
@@ -60,9 +60,9 @@
   x.flip();
   printf("val.flip() = %s\n", str(x));
   unsigned bitsize = bitwidth / 2;
-  printf("val.HiBits(%d) = %s\n", bitsize, str(val.HiBits(bitsize)));
-  printf("val.LoBits(%d) = %s\n", bitsize, str(val.LoBits(bitsize)));
-  printf("val.IsIntN(%d) = %d\n", bitwidth, val.IsIntN(bitwidth));
+  printf("val.getHiBits(%d) = %s\n", bitsize, str(val.getHiBits(bitsize)));
+  printf("val.getLoBits(%d) = %s\n", bitsize, str(val.getLoBits(bitsize)));
+  printf("val.isIntN(%d) = %d\n", bitwidth, val.isIntN(bitwidth));
 }
 
 void test_unops(const APInt &val) {
@@ -85,18 +85,18 @@
   printf("~val = %s\n", str(x));
   printf("!val = %d\n", !val);
   printf("val.isPowerOf2() = %d\n", val.isPowerOf2());
-  printf("val.LogBase2() = %d\n", val.getNumBits());
-  printf("val.CountLeadingZeros() = %d\n", val.CountLeadingZeros());
-  printf("val.CountTrailingZeros() = %d\n", val.CountTrailingZeros());
-  printf("val.CountPopulation() = %d\n", val.CountPopulation());
-  printf("val.getNumBits() = %d\n", val.getNumBits());
-  if (val.getNumBits() >= 16 && val.getNumBits() % 16 == 0) {
-x = val.ByteSwap();
-printf("val.ByteSwap() = %d\n", str(x));
+  printf("val.logBase2() = %d\n", val.logBase2());
+  printf("val.countLeadingZeros() = %d\n", val.countLeadingZeros());
+  printf("val.countTrailingZeros() = %d\n", val.countTrailingZeros());
+  printf("val.countPopulation() = %d\n", val.countPopulation());
+  printf("val.getBitWidth() = %d\n", val.getBitWidth());
+  if (val.getBitWidth() >= 16 && val.getBitWidth() % 16 == 0) {
+x = val.byteSwap();
+printf("val.byteSwap() = %d\n", str(x));
   }
-  printf("val.RoundToDouble(true) %d = %f\n", val.RoundToDouble(true));
+  printf("val.roundToDouble(true) %d = %f\n", val.roundToDouble(true));
   printf("val.getValue() = ");
-  if (val.getNumBits() > 64)
+  if (val.getBitWidth() > 64)
 printf("too wide\n");
   else
 printf("%lu\n", val.getValue());
@@ -129,10 +129,6 @@
   printf("v1 |  v2: %s\n", str(result));
   result = v1 ^ v2;
   printf("v1 ^  v2: %s\n", str(result));
-  result = v1 && v2;
-  printf("v1 && v2: %s\n", str(result));
-  result = v1 || v2;
-  printf("v1 || v2: %s\n", str(result));
   result = v1 * v2;
   printf("v1 *  v2: %s\n", str(result));
   result = v1 + v2;
@@ -141,30 +137,36 @@
   printf("v1 -  v2: %s\n", str(result));
   printf("v1 == v2: %d\n", v1 == v2);
   printf("v1 != v2: %d\n", v1 == v2);
-  printf("v1 <  v2: %d\n", v1 == v2);
-  printf("v1 <= v2: %d\n", v1 == v2);
-  printf("v1 >  v2: %d\n", v1 == v2);
-  printf("v1 >= v2: %d\n", v1 == v2);
+  printf("v1.eq(v2): %d\n", v1.eq(v2));
+  printf("v1.ne(v2): %d\n", v1.ne(v2));
+  printf("v1.ult(v2): %d\n", v1.ult(v2));
+  printf("v1.slt(v2): %d\n", v1.slt(v2));
+  printf("v1.ule(v2): %d\n", v1.ule(v2));
+  printf("v1.sle(v2): %d\n", v1.sle(v2));
+  printf("v1.ugt(v2): %d\n", v1.ugt(v2));
+  printf("v1.sgt(v2): %d\n", v1.sgt(v2));
+  printf("v1.uge(v2): %d\n", v1.uge(v2));
+  printf("v1.sge(v2): %d\n", v1.sge(v2));
   {
 using namespace APIntOps;
-unsigned shiftAmt = rand() % v1.getNumBi

[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp

2007-02-18 Thread Reid Spencer


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.8 -> 1.9
---
Log message:

Make use of ability to print signed values.
Fix a bug in the display of != result.


---
Diffs of the changes:  (+8 -7)

 arith.cpp |   15 ---
 1 files changed, 8 insertions(+), 7 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.8 
llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.9
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.8Sat Feb 
17 02:18:20 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cppSun Feb 18 
14:21:27 2007
@@ -21,8 +21,8 @@
 
 static std::string temp_str;
 
-const char* str(const APInt& X) {
-  temp_str = X.toString();
+const char* str(const APInt& X, bool wantSigned = false) {
+  temp_str = X.toString(10,wantSigned);
   return temp_str.c_str(); 
 }
 
@@ -35,10 +35,10 @@
   APInt umax(APInt::getMaxValue(bitwidth, false));
   APInt smin(APInt::getMinValue(bitwidth, true));
   APInt umin(APInt::getMinValue(bitwidth, false));
-  printf("APInt::getMaxValue(%d, true)  = %s\n", bitwidth, str(smax));
-  printf("APInt::getMaxValue(%d, false) = %s\n", bitwidth, str(umax));
-  printf("APInt::getMinValue(%d, true)  = %s\n", bitwidth, str(smin));
+  printf("APInt::getMinValue(%d, true)  = %s\n", bitwidth, str(smin,true));
+  printf("APInt::getMaxValue(%d, true)  = %s\n", bitwidth, str(smax,true));
   printf("APInt::getMinValue(%d, false) = %s\n", bitwidth, str(umin));
+  printf("APInt::getMaxValue(%d, false) = %s\n", bitwidth, str(umax));
   APInt null = APInt::getNullValue(bitwidth);
   APInt allone = APInt::getAllOnesValue(bitwidth);
   printf("APInt::getNullValue(%d) = %s\n", bitwidth, str(null));
@@ -94,7 +94,8 @@
 x = val.byteSwap();
 printf("val.byteSwap() = %d\n", str(x));
   }
-  printf("val.roundToDouble(true) %d = %f\n", val.roundToDouble(true));
+  printf("val.roundToDouble(false) = %f\n", val.roundToDouble(false));
+  printf("val.roundToDouble(true)  = %f\n", val.roundToDouble(true));
   printf("val.getValue() = ");
   if (val.getBitWidth() > 64)
 printf("too wide\n");
@@ -136,7 +137,7 @@
   result = v1 - v2;
   printf("v1 -  v2: %s\n", str(result));
   printf("v1 == v2: %d\n", v1 == v2);
-  printf("v1 != v2: %d\n", v1 == v2);
+  printf("v1 != v2: %d\n", v1 != v2);
   printf("v1.eq(v2): %d\n", v1.eq(v2));
   printf("v1.ne(v2): %d\n", v1.ne(v2));
   printf("v1.ult(v2): %d\n", v1.ult(v2));



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp

2007-02-18 Thread Reid Spencer


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.9 -> 1.10
---
Log message:

Consolidate printing of APInt into a single functions.
Always print both the decimal and hexadecimal representations of an APInt.


---
Diffs of the changes:  (+50 -50)

 arith.cpp |  100 +++---
 1 files changed, 50 insertions(+), 50 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.9 
llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.10
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.9Sun Feb 
18 14:21:27 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cppSun Feb 18 
16:29:58 2007
@@ -16,18 +16,18 @@
 using namespace llvm;
 
 APInt x(21, 0x1f);
-
 APInt y(21, 0x0f);
 
-static std::string temp_str;
-
-const char* str(const APInt& X, bool wantSigned = false) {
-  temp_str = X.toString(10,wantSigned);
-  return temp_str.c_str(); 
+void print(const APInt& X, bool wantSigned = false, bool withNL = true) {
+  std::string decstr = X.toString(10,wantSigned);
+  std::string hexstr = X.toString(16,false);
+  printf("%s (%s)", decstr.c_str(), hexstr.c_str());
+  if (withNL)
+printf("\n");
 }
 
 void test_interface(const APInt &val) {
-  printf("INTERFACE TEST: val = %s\n", str(val));
+  printf("INTERFACE TEST: val = "); print(val);
   unsigned bitwidth = val.getBitWidth();
   unsigned pos = rand() % bitwidth;
   printf("val[%u] = %d\n", pos, val[pos]);
@@ -35,54 +35,54 @@
   APInt umax(APInt::getMaxValue(bitwidth, false));
   APInt smin(APInt::getMinValue(bitwidth, true));
   APInt umin(APInt::getMinValue(bitwidth, false));
-  printf("APInt::getMinValue(%d, true)  = %s\n", bitwidth, str(smin,true));
-  printf("APInt::getMaxValue(%d, true)  = %s\n", bitwidth, str(smax,true));
-  printf("APInt::getMinValue(%d, false) = %s\n", bitwidth, str(umin));
-  printf("APInt::getMaxValue(%d, false) = %s\n", bitwidth, str(umax));
+  printf("APInt::getMinValue(%d, true)  = ", bitwidth); print(smin,true);
+  printf("APInt::getMaxValue(%d, true)  = ", bitwidth); print(smax,true);
+  printf("APInt::getMinValue(%d, false) = ", bitwidth); print(umin);
+  printf("APInt::getMaxValue(%d, false) = ", bitwidth); print(umax);
   APInt null = APInt::getNullValue(bitwidth);
   APInt allone = APInt::getAllOnesValue(bitwidth);
-  printf("APInt::getNullValue(%d) = %s\n", bitwidth, str(null));
-  printf("APInt::getAllOnesValue(%d) = %s\n", bitwidth, str(allone));
+  printf("APInt::getNullValue(%d) = ", bitwidth); print(null);
+  printf("APInt::getAllOnesValue(%d) = ", bitwidth); print(allone);
   APInt x(val);
   x.set(pos);
-  printf("val.set(%d) = %s\n", pos, str(x));
+  printf("val.set(%d) = ", pos);  print(x);
   x.set();
-  printf("val.set() = %s\n", str(x));
+  printf("val.set() = "); print(x);
   x = val;
   x.clear(pos);
-  printf("val.clear(%d) = %s\n", pos, str(x));
+  printf("val.clear(%d) = ", pos);  print(x);
   x.clear();
-  printf("val.clear() = %s\n", str(x));
+  printf("val.clear() = "); print(x);
   x = val;
   x.flip(pos);
-  printf("val.flip(%d) = %s\n", pos, str(x));
+  printf("val.flip(%d) = ", pos); print(x);
   x = val;
   x.flip();
-  printf("val.flip() = %s\n", str(x));
+  printf("val.flip() = "); print(x);
   unsigned bitsize = bitwidth / 2;
-  printf("val.getHiBits(%d) = %s\n", bitsize, str(val.getHiBits(bitsize)));
-  printf("val.getLoBits(%d) = %s\n", bitsize, str(val.getLoBits(bitsize)));
+  printf("val.getHiBits(%d) = ", bitsize); print(val.getHiBits(bitsize));
+  printf("val.getLoBits(%d) = ", bitsize); print(val.getLoBits(bitsize));
   printf("val.isIntN(%d) = %d\n", bitwidth, val.isIntN(bitwidth));
 }
 
 void test_unops(const APInt &val) {
-  printf("UNARY OPERATORS TEST: val = %s\n", str(val));
+  printf("UNARY OPERATORS TEST: val = "); print(val);
   APInt x(val);
   x++;
-  printf("val++ = %s\n", str(x));
+  printf("val++ = "); print(x);
   x = val;
   ++x;
-  printf("++val = %s\n", str(x));
+  printf("++val = "); print(x);
   x = val;
   x--;
-  printf("val-- = %s\n", str(x));
+  printf("val-- = "); print(x);
   x = val;
   --x;
-  printf("--val = %s\n", str(x));
+  printf("--val = "); print(x);
   x = -val;
-  printf("-val = %s\n", str(x));
+  printf("-val = "); print(x);
   x = ~val;
-  printf("~val = %s\n", str(x));
+  printf("~val = "); print(x);
   printf("!val = %d\n", !val);
   printf("val.isPowerOf2() = %d\n", val.isPowerOf2());
   printf("val.logBase2() = %d\n", val.logBase2());
@@ -92,7 +92,7 @@
   printf("val.getBitWidth() = %d\n", val.getBitWidth());
   if (val.getBitWidth() >= 16 && val.getBitWidth() % 16 == 0) {
 x = val.byteSwap();
-printf("val.byteSwap() = %d\n", str(x));
+printf("val.byteSwap() = "); print(x);
   }
   printf("val.roundToDouble(false) = %f\n", val.roundToDouble(false));
   printf("val.roundToDouble(true)  = %f\n", val.roundToDouble(true

[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp

2007-02-20 Thread Reid Spencer


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.10 -> 1.11
---
Log message:

Consolidate code, expand testing to more values.


---
Diffs of the changes:  (+55 -18)

 arith.cpp |   73 ++
 1 files changed, 55 insertions(+), 18 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.10 
llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.11
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.10   Sun Feb 
18 16:29:58 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cppTue Feb 20 
14:39:34 2007
@@ -26,6 +26,16 @@
 printf("\n");
 }
 
+APInt randomAPInt(unsigned bits) {
+  APInt val(bits, 0u);
+  for (unsigned i = 0; i < bits; ++i) {
+unsigned bit = rand() % 2;
+val = val.shl(1);
+val |= APInt(bits, bit);
+  }
+  return val;
+}
+
 void test_interface(const APInt &val) {
   printf("INTERFACE TEST: val = "); print(val);
   unsigned bitwidth = val.getBitWidth();
@@ -104,8 +114,8 @@
 }
 
 void test_binops(const APInt &v1, const APInt &v2) {
-  printf("BINARY OPERATORS TEST: vl = "); print(v1,false,false);
-  printf(", v2 = "); print(v2);
+  printf("BINARY OPERATORS TEST: \n  vl: "); print(v1,false,false);
+  printf("\n  v2: "); print(v2);
   APInt result(v1);
   result &= v2;
   printf("v1 &= v2: "); print(result);
@@ -157,7 +167,7 @@
 printf("lshr(v1,%d) = ", shiftAmt); print(result);
 result = shl(v1,shiftAmt);
 printf("shl(v1,%d) = ", shiftAmt); print(result);
-if (v2 == 0)
+if (v2 == APInt(v2.getBitWidth(), 0))
   printf("sdiv/udiv/srem/urem not tested, v2 == 0\n");
 else {
   result = sdiv(v1,v2);
@@ -174,28 +184,55 @@
 
 void test_multiple() {
   srand(0);
-  for (unsigned bits = 1; bits <= 1024; ++bits) {
-APInt v1(bits, 0u);
-APInt v2(bits, 0u);
-for (unsigned i = 0; i < bits; ++i) {
-  unsigned bit = rand() % 2;
-  v1 = v1.shl(1);
-  v1 |= APInt(bits, bit);
+  for (unsigned bits = 1; bits <= 256; ++bits) {
+printf("\nTEST CASE: %d BITS\n\n", bits);
+APInt zero(bits,0);
+APInt one(bits,1);
+if (bits == 1) {
+  test_interface(zero);
+  test_interface(one);
+  test_unops(zero);
+  test_unops(one);
+  test_binops(zero,one);
+  test_binops(one,zero);
+  continue;
+}
+APInt two(bits,1);
+APInt three(bits,1);
+APInt min = APInt::getMinValue(bits, true);
+APInt max = APInt::getMaxValue(bits, true);
+APInt mid = APIntOps::lshr(max, bits/2);
+APInt r1 = randomAPInt(bits);
+APInt r2 = randomAPInt(bits);
+APInt *list[9];
+list[0] = &zero;
+list[1] = &one;
+list[2] = &two;
+list[3] = &three;
+list[4] = &min;
+list[5] = &r1;
+list[6] = ∣
+list[7] = &r2;
+list[8] = &max;
+for (unsigned i = 0; i < 9; ++i) {
+  test_interface(*(list[i]));
+  test_unops(*(list[i]));
 }
-for (unsigned i = 0; i < bits; ++i) {
-  unsigned bit = rand() % 2;
-  v2 = v2.shl(1);
-  v2 |= APInt(bits, bit);
+for (unsigned i = 0; i < 9; ++i) {
+  for (unsigned j = 0; j < 9; ++j) {
+test_binops(*(list[i]), *(list[j]));
+  }
 }
-printf("\nTEST CASE: %d bits\n\n", bits);
-test_interface(v1);
-test_unops(v2);
-test_binops(v1,v2);
   }
 }
 
 int main()
 {
+  APInt X(48, 100);
+  APInt Y(48, 10);
+  APInt Q(1,0);
+  APInt R(1,0);
+  APInt::divide(X, 1, Y, 1, &Q, &R);
   test_multiple();
   return 0;
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp

2007-02-27 Thread Reid Spencer


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.11 -> 1.12
---
Log message:

Update for changes in APInt interface.


---
Diffs of the changes:  (+30 -24)

 arith.cpp |   54 ++
 1 files changed, 30 insertions(+), 24 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.11 
llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.12
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.11   Tue Feb 
20 14:39:34 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cppTue Feb 27 
14:13:37 2007
@@ -10,6 +10,8 @@
 
//===--===//
 
 #include "llvm/ADT/APInt.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
 #include 
 #include 
 
@@ -19,8 +21,12 @@
 APInt y(21, 0x0f);
 
 void print(const APInt& X, bool wantSigned = false, bool withNL = true) {
-  std::string decstr = X.toString(10,wantSigned);
-  std::string hexstr = X.toString(16,false);
+  std::string decstr;
+  if (wantSigned)
+decstr = X.toStringSigned(10);
+  else
+decstr = X.toString(10);
+  std::string hexstr = X.toString(16);
   printf("%s (%s)", decstr.c_str(), hexstr.c_str());
   if (withNL)
 printf("\n");
@@ -41,10 +47,10 @@
   unsigned bitwidth = val.getBitWidth();
   unsigned pos = rand() % bitwidth;
   printf("val[%u] = %d\n", pos, val[pos]);
-  APInt smax(APInt::getMaxValue(bitwidth, true));
-  APInt umax(APInt::getMaxValue(bitwidth, false));
-  APInt smin(APInt::getMinValue(bitwidth, true));
-  APInt umin(APInt::getMinValue(bitwidth, false));
+  APInt smax(APInt::getSignedMaxValue(bitwidth));
+  APInt umax(APInt::getMaxValue(bitwidth));
+  APInt smin(APInt::getSignedMinValue(bitwidth));
+  APInt umin(APInt::getMinValue(bitwidth));
   printf("APInt::getMinValue(%d, true)  = ", bitwidth); print(smin,true);
   printf("APInt::getMaxValue(%d, true)  = ", bitwidth); print(smax,true);
   printf("APInt::getMinValue(%d, false) = ", bitwidth); print(umin);
@@ -104,13 +110,15 @@
 x = val.byteSwap();
 printf("val.byteSwap() = "); print(x);
   }
-  printf("val.roundToDouble(false) = %f\n", val.roundToDouble(false));
-  printf("val.roundToDouble(true)  = %f\n", val.roundToDouble(true));
+  printf("val.roundToDouble() = %f\n", val.roundToDouble());
+  printf("val.signedRoundToDouble()  = %f\n", val.signedRoundToDouble());
   printf("val.getValue() = ");
   if (val.getBitWidth() > 64)
 printf("too wide\n");
-  else
-printf("%lu\n", val.getValue());
+  else {
+printf("%lu\n", val.getZExtValue());
+printf("%ld\n", val.getSExtValue());
+  }
 }
 
 void test_binops(const APInt &v1, const APInt &v2) {
@@ -184,7 +192,7 @@
 
 void test_multiple() {
   srand(0);
-  for (unsigned bits = 1; bits <= 256; ++bits) {
+  for (unsigned bits = 257; bits <= 257; ++bits) {
 printf("\nTEST CASE: %d BITS\n\n", bits);
 APInt zero(bits,0);
 APInt one(bits,1);
@@ -199,12 +207,13 @@
 }
 APInt two(bits,1);
 APInt three(bits,1);
-APInt min = APInt::getMinValue(bits, true);
-APInt max = APInt::getMaxValue(bits, true);
+APInt min = APInt::getSignedMinValue(bits);
+APInt max = APInt::getSignedMaxValue(bits);
 APInt mid = APIntOps::lshr(max, bits/2);
 APInt r1 = randomAPInt(bits);
 APInt r2 = randomAPInt(bits);
-APInt *list[9];
+APInt r3 = randomAPInt(bits);
+APInt *list[10];
 list[0] = &zero;
 list[1] = &one;
 list[2] = &two;
@@ -214,26 +223,23 @@
 list[6] = ∣
 list[7] = &r2;
 list[8] = &max;
-for (unsigned i = 0; i < 9; ++i) {
+list[9] = &r3;
+for (unsigned i = 0; i < 10; ++i) {
   test_interface(*(list[i]));
   test_unops(*(list[i]));
 }
-for (unsigned i = 0; i < 9; ++i) {
-  for (unsigned j = 0; j < 9; ++j) {
+for (unsigned i = 0; i < 10; ++i) {
+  for (unsigned j = 0; j < 10; ++j) {
 test_binops(*(list[i]), *(list[j]));
   }
 }
   }
 }
 
-int main()
+int main(int argc, char** argv)
 {
-  APInt X(48, 100);
-  APInt Y(48, 10);
-  APInt Q(1,0);
-  APInt R(1,0);
-  APInt::divide(X, 1, Y, 1, &Q, &R);
+  cl::ParseCommandLineOptions(argc, argv, "APInt arithmetic test\n");
   test_multiple();
+  llvm_shutdown();
   return 0;
 }
-



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp bigint.cpp sign.cpp

2007-02-11 Thread Zhou Sheng


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.2 -> 1.3
bigint.cpp updated: 1.2 -> 1.3
sign.cpp updated: 1.2 -> 1.3
---
Log message:

Updates these test cases as APInt class modifed.


---
Diffs of the changes:  (+19 -16)

 arith.cpp  |8 
 bigint.cpp |6 +++---
 sign.cpp   |   21 -
 3 files changed, 19 insertions(+), 16 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.2 
llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.3
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.2Mon Feb 
 5 21:02:16 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cppSun Feb 11 
02:49:48 2007
@@ -41,21 +41,21 @@
   temp = k.getValue();
   printf( "temp = %hd\n", temp);
   j *= 120;
-  l = j / k;
+  l = APIntOps::sdiv(j, k);
   temp = l.getValue();
   printf( "temp = %hd\n", temp);
   j *= (-176); // after truncation, the value should be -384
-  l = j / k;
+  l = APIntOps::sdiv(j, k);
   temp = l.getValue();
   printf( "temp = %hd\n", temp);
   l = 120;
   l = (j * l);
-  l %= 4;
+  l = APIntOps::urem(l, 4);
   temp = l.getValue();
   printf( "temp = %hd\n", temp);
   l = -217;
   l = (j * l);
-  l = l / (++i);
+  l = APIntOps::sdiv(l, (++i));
   temp = l.getValue();
   printf( "temp = %hd\n", temp);
   result = ++x;


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp:1.2 
llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp:1.3
--- llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp:1.2   Mon Feb 
 5 21:02:16 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp   Sun Feb 11 
02:49:48 2007
@@ -31,7 +31,7 @@
 for ( ; ; ) {
   bool ssdm_tmp_1 = (i < bnd);
   if (!ssdm_tmp_1) break;
-  if (i % 2 == 0)
+  if (APIntOps::urem(i, 2) == 0)
 x = x + 1;
   else 
 y = y - x;
@@ -40,11 +40,11 @@
 }
   }
   result = x*y;
-  l_result = result % 0x37015; 
+  l_result = APIntOps::srem(result, 0x37015);
   rem = l_result.getValue();
   printf("rem = %lld\n", rem);
 
-  l_result = result % -198721;
+  l_result = APIntOps::srem(result, -198721);
   rem2 = l_result.getValue();
   printf("rem2 = %lld\n", rem2);
   return 0;


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp:1.2 
llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp:1.3
--- llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp:1.2 Mon Feb  5 
21:02:16 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp Sun Feb 11 
02:49:48 2007
@@ -19,7 +19,7 @@
 main ( int argc, char** argv)
 {
   int num, r;
-  APInt x(0, 24, true), y(0, 24, true), z(0, 24, true);
+  APInt x(0, 24), y(0, 24), z(0, 24);
   APInt ux(0, 24), uy(0, 24), uz(0, 24);
 
   r = rand();
@@ -30,10 +30,13 @@
   
   if (argc > 1)
 num = atoi(argv[1]);
+  else
+num = 0;
 
   
   num = num - 0xdf5e75; //0x101
 
+  printf("num = %d\n", num);
   x = num;
   ux = num;
   printf("x = %d, ux = %u, y=%d, uy = %u\n", int(x.getValue()), 
@@ -44,20 +47,20 @@
   uz = ux * uy;
   printf("z=%d, uz=%u\n", int(z.getValue()), (unsigned int)uz.getValue());
 
-  z = x % 314;
-  uz = ux % 314;
+  z = APIntOps::srem(x, 314);
+  uz = APIntOps::urem(ux, 314);
   printf("z=%d, uz=%u\n", int(z.getValue()), (unsigned int)uz.getValue());
 
-  z = x / 314;
-  uz = ux / 314;
+  z = APIntOps::sdiv(x, 314);
+  uz = APIntOps::udiv(ux, 314);
   printf("z=%d, uz=%u\n", int(z.getValue()), (unsigned int)uz.getValue());
 
-  z = (x+0xf28) / 314;
-  uz = (ux + 0xf28) / 314;
+  z = APIntOps::sdiv((x+0xf28), 314);
+  uz = APIntOps::udiv((ux + 0xf28), 314);
   printf("z=%d, uz=%u\n", int(z.getValue()), (unsigned int)uz.getValue());
 
-  z = (x - 580) / 314;
-  uz = (((ux - 580)) / 314);
+  z = APIntOps::sdiv((x - 580), 314);
+  uz = APIntOps::udiv((ux - 580), 314);
   printf("z=%d, uz=%u\n", int(z.getValue()), (unsigned int)uz.getValue());
 
   return 0;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp bigint.cpp bitlogic.cpp sign.cpp

2007-02-05 Thread Zhou Sheng


Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.1 -> 1.2
bigint.cpp updated: 1.1 -> 1.2
bitlogic.cpp updated: 1.1 -> 1.2
sign.cpp updated: 1.1 -> 1.2
---
Log message:

Modify these test cases as APInt changed.


---
Diffs of the changes:  (+41 -40)

 arith.cpp|   36 ++--
 bigint.cpp   |   16 
 bitlogic.cpp |   10 +-
 sign.cpp |   19 ++-
 4 files changed, 41 insertions(+), 40 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.1 
llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.2
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.1Mon Jan 
29 17:07:32 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cppMon Feb  5 
21:02:16 2007
@@ -14,61 +14,61 @@
 
 using namespace llvm;
 
-APInt x(21,0x1f);
+APInt x(0x1f, 21);
 
-APInt y(21,0x0f);
+APInt y(0x0f, 21);
 
 int my_test()
 {
-  APInt i(10,uint64_t(0));
-  APInt j(10);
-  APInt k(10);
-  APInt l(10);
-  APInt result(21);
+  APInt i(uint64_t(0), 10);
+  APInt j(0, 10);
+  APInt k(0, 10);
+  APInt l(0, 10);
+  APInt result(0, 21);
   short temp;
   int i_temp;
   unsigned int ui_x;
   unsigned int ui_y;
   j = i;
   j -= 1;
-  temp = (short)j;
+  temp = (short)j.getValue();
   printf( "temp = %hd\n", temp);
   k = i;
   k += 1;
-  temp = k;
+  temp = k.getValue();
   printf( "temp = %hd\n", temp);
   k = j * k;
-  temp = k;
+  temp = k.getValue();
   printf( "temp = %hd\n", temp);
   j *= 120;
   l = j / k;
-  temp = l;
+  temp = l.getValue();
   printf( "temp = %hd\n", temp);
   j *= (-176); // after truncation, the value should be -384
   l = j / k;
-  temp = l;
+  temp = l.getValue();
   printf( "temp = %hd\n", temp);
   l = 120;
   l = (j * l);
   l %= 4;
-  temp = l;
+  temp = l.getValue();
   printf( "temp = %hd\n", temp);
   l = -217;
   l = (j * l);
   l = l / (++i);
-  temp = l;
+  temp = l.getValue();
   printf( "temp = %hd\n", temp);
   result = ++x;
   
-  i_temp = result;
+  i_temp = result.getValue();
   printf( "i_temp = %x\n", i_temp);
   x--;
  
   result = x + y;
-  i_temp = result;
+  i_temp = result.getValue();
   printf("i_temp = %x\n", i_temp);
-  ui_x = x;
-  ui_y = y;
+  ui_x = x.getValue();
+  ui_y = y.getValue();
   i_temp = ui_x - ui_y;
   printf("i_temp = %x\n", i_temp);
 


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp:1.1 
llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp:1.2
--- llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp:1.1   Mon Jan 
29 17:07:32 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp   Mon Feb  5 
21:02:16 2007
@@ -13,17 +13,17 @@
 
 using namespace llvm;
 
-const APInt bnd(10,1023);
+const APInt bnd(1023, 10);
 
 
-APInt x(169, 0xULL);
-APInt y(169, -0xabcdefdeULL);
+APInt x(0xULL, 169);
+APInt y(-0xabcdefdeULL, 169);
 
 int my_test()
 {
-  APInt i(10,uint64_t(0));
-  APInt result(169);
-  APInt l_result(32);
+  APInt i(uint64_t(0), 10);
+  APInt result(0, 169);
+  APInt l_result(0, 32);
   long long rem;
   long long rem2;
   {
@@ -41,11 +41,11 @@
   }
   result = x*y;
   l_result = result % 0x37015; 
-  rem = l_result;
+  rem = l_result.getValue();
   printf("rem = %lld\n", rem);
 
   l_result = result % -198721;
-  rem2 = l_result;
+  rem2 = l_result.getValue();
   printf("rem2 = %lld\n", rem2);
   return 0;
 }


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/bitlogic.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/bitlogic.cpp:1.1 
llvm-test/SingleSource/UnitTests/Integer/APInt/bitlogic.cpp:1.2
--- llvm-test/SingleSource/UnitTests/Integer/APInt/bitlogic.cpp:1.1 Mon Jan 
29 19:10:43 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/bitlogic.cpp Mon Feb  5 
21:02:16 2007
@@ -16,11 +16,11 @@
 
 int my_test()
 {
-  APInt x(1,0x1);
-  APInt y(1);
-  APInt z(9,0x1ff);
-  APInt uz(9,0x1ff);
-  APInt temp(9);
+  APInt x(0x1, 1);
+  APInt y(0, 1);
+  APInt z(0x1ff, 9);
+  APInt uz(0x1ff, 9);
+  APInt temp(0, 9);
   y = x;
   y -= 1;
   if (!y)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp:1.1 
llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp:1.2
--- llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp:1.1 Mon Jan 29 
19:08:52 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp Mon Feb  5 
21:02:16 2007
@@ -19,8 +19,8 @@
 main ( int argc, char** argv)
 {
   int num, r;
-  APInt x(24), y(24), z(24);
-  APInt ux(24), uy(24), uz(24);
+  APInt x(0, 24, true), y(0, 24, true), z(0, 24, true);
+  APInt ux(0, 24), uy(0, 24), uz(0, 24);
 
   r = rand();
   r = r - 1804289384; // -1
@@ -36,28 +36,29 @@
 
   x = num;
   ux = num;
-  printf("x = %d, ux = %u, y=%d, uy = %u\n", int(x)