[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/Makefile arith.cpp bigint.cpp
Reid Spencer
reid at x10sys.com
Mon Jan 29 15:07:48 PST 2007
Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:
Makefile added (r1.1)
arith.cpp added (r1.1)
bigint.cpp added (r1.1)
---
Log message:
Add some tests for the upcoming APInt class.
---
Diffs of the changes: (+151 -0)
Makefile | 7 +++++
arith.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bigint.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 151 insertions(+)
Index: llvm-test/SingleSource/UnitTests/Integer/APInt/Makefile
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/APInt/Makefile:1.1
*** /dev/null Mon Jan 29 17:07:42 2007
--- llvm-test/SingleSource/UnitTests/Integer/APInt/Makefile Mon Jan 29 17:07:32 2007
***************
*** 0 ****
--- 1,7 ----
+ # SingleSource/UnitTests/Integer/Makefile
+ LEVEL = ../../../..
+
+ include $(LEVEL)/SingleSource/Makefile.singlesrc
+
+ LDFLAGS += -L$(LLVM_OBJ_ROOT)/Debug/lib -lLLVMSupport -lLLVMSystem -lstdc++
+ CXXFLAGS += -I$(LLVM_SRC_ROOT)/include -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__NO_MATH_INLINES
Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.1
*** /dev/null Mon Jan 29 17:07:48 2007
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp Mon Jan 29 17:07:32 2007
***************
*** 0 ****
--- 1,84 ----
+ //===--- arith.c --- Test Cases for Bit Accurate Types --------------------===//
+ //
+ // This file was developed by Guoling Han and is distributed under the
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This is a general test for arithmetic operations.
+ //
+ //===----------------------------------------------------------------------===//
+
+ #include "llvm/ADT/APInt.h"
+ #include <stdio.h>
+
+ using namespace llvm;
+
+ APInt x(21,0x1fffff);
+
+ APInt y(21,0x0fffff);
+
+ int my_test()
+ {
+ APInt i(10,uint64_t(0));
+ APInt j(10);
+ APInt k(10);
+ APInt l(10);
+ APInt result(21);
+ short temp;
+ int i_temp;
+ unsigned int ui_x;
+ unsigned int ui_y;
+ j = i;
+ j -= 1;
+ temp = (short)j;
+ printf( "temp = %hd\n", temp);
+ k = i;
+ k += 1;
+ temp = k;
+ printf( "temp = %hd\n", temp);
+ k = j * k;
+ temp = k;
+ printf( "temp = %hd\n", temp);
+ j *= 120;
+ l = j / k;
+ temp = l;
+ printf( "temp = %hd\n", temp);
+ j *= (-176); // after truncation, the value should be -384
+ l = j / k;
+ temp = l;
+ printf( "temp = %hd\n", temp);
+ l = 120;
+ l = (j * l);
+ l %= 4;
+ temp = l;
+ printf( "temp = %hd\n", temp);
+ l = -217;
+ l = (j * l);
+ l = l / (++i);
+ temp = l;
+ printf( "temp = %hd\n", temp);
+ result = ++x;
+
+ i_temp = result;
+ printf( "i_temp = %x\n", i_temp);
+ x--;
+
+ result = x + y;
+ i_temp = result;
+ printf("i_temp = %x\n", i_temp);
+ ui_x = x;
+ ui_y = y;
+ i_temp = ui_x - ui_y;
+ printf("i_temp = %x\n", i_temp);
+
+ return 0;
+
+ }
+
+ int main()
+ {
+ my_test();
+ return 0;
+ }
+
Index: llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp:1.1
*** /dev/null Mon Jan 29 17:07:48 2007
--- llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp Mon Jan 29 17:07:32 2007
***************
*** 0 ****
--- 1,60 ----
+ //===--- bigint.c --- Test Cases for Bit Accurate Types -------------------===//
+ //
+ // This file was developed by Guoling Han and is distributed under the
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This is a general test for big integer type.
+ //
+ //===----------------------------------------------------------------------===//
+ #include <llvm/ADT/APInt.h>
+ #include <stdio.h>
+
+ using namespace llvm;
+
+ const APInt bnd(10,1023);
+
+
+ APInt x(169, 0xffffffffULL);
+ APInt y(169, -0xabcdefdeULL);
+
+ int my_test()
+ {
+ APInt i(10,uint64_t(0));
+ APInt result(169);
+ APInt l_result(32);
+ long long rem;
+ long long rem2;
+ {
+ ;
+ for ( ; ; ) {
+ bool ssdm_tmp_1 = (i < bnd);
+ if (!ssdm_tmp_1) break;
+ if (i % 2 == 0)
+ x = x + 1;
+ else
+ y = y - x;
+
+ ++i;
+ }
+ }
+ result = x*y;
+ l_result = result % 0x37015;
+ rem = l_result;
+ printf("rem = %lld\n", rem);
+
+ l_result = result % -198721;
+ rem2 = l_result;
+ printf("rem2 = %lld\n", rem2);
+ return 0;
+ }
+
+ int main()
+ {
+ my_test();
+ return 0;
+ }
+
+
+
More information about the llvm-commits
mailing list