[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/negConst.c negConst.reference_output

Reid Spencer reid at x10sys.com
Mon May 14 00:30:55 PDT 2007



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

negConst.c added (r1.1)
negConst.reference_output added (r1.1)
---
Log message:

A test of negative literal constant values with various bit sizes.


---
Diffs of the changes:  (+69 -0)

 negConst.c                |   61 ++++++++++++++++++++++++++++++++++++++++++++++
 negConst.reference_output |    8 ++++++
 2 files changed, 69 insertions(+)


Index: llvm-test/SingleSource/UnitTests/Integer/negConst.c
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/negConst.c:1.1
*** /dev/null	Mon May 14 02:30:47 2007
--- llvm-test/SingleSource/UnitTests/Integer/negConst.c	Mon May 14 02:30:37 2007
***************
*** 0 ****
--- 1,61 ----
+ 
+ #include "bits.h"
+ 
+ 
+ void test1(int69 x)
+ {
+   int63 y = -120;
+   int63 y2 = part_select(y, 0, 31);
+   int32 z = 0;
+   int32 z2 = 0;
+   int i = 0;
+ 
+   // Compute the part_select manually using bit_select
+   for(i = 31; i >= 0; --i) {
+     z <<= 1;
+     if (bit_select(y, i))
+       z |= 1;
+   }
+ 
+   // Compute the part_select
+   z2 = y2;
+   
+   printf("Value1: %x = ", (int)y);
+   printBits(y);
+   printf("\n");
+   printf("Value2: %x = ", (int)y2);
+   printBits(y2);
+   printf("\n");
+   printf("Bits : %x = ", z);
+   printBits(z);
+   printf("\nPart : %x = ", z2);
+   printBits(z2);
+   printf("\n");
+ 
+   if (z != z2)
+     printf("Error: %x, %x\n", z, z2);
+   else
+     printf("OK.\n");
+ }
+ 
+ int main(int argc, char ** argv)
+ {
+   int69 n;
+   if (argc > 1) {
+     n = bitsFromString("9876543210000000", 69);
+   }
+   else
+     n = -1;
+   int54 n2 = n;
+   long long unsigned int U = n;
+   long long signed int   S = n2;
+ 
+   printf("Unsigned: %llu (%llx) = ", U, U);
+   printBits(n);
+   printf("\n");
+   printf("  Signed: %lld (%llx) = ", S, S);
+   printBits(n2);
+   printf("\n");
+   test1(n);
+   return 0;
+ }


Index: llvm-test/SingleSource/UnitTests/Integer/negConst.reference_output
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/negConst.reference_output:1.1
*** /dev/null	Mon May 14 02:30:55 2007
--- llvm-test/SingleSource/UnitTests/Integer/negConst.reference_output	Mon May 14 02:30:37 2007
***************
*** 0 ****
--- 1,8 ----
+ Unsigned: 9876543210000000 (2316a9e9a40e80) = 000000000000000100011000101101010100111101001101001000000111010000000
+   Signed: -8137855299481984 (ffe316a9e9a40e80) = 100011000101101010100111101001101001000000111010000000
+ Value1: ffffff88 = 111111111111111111111111111111111111111111111111111111110001000
+ Value2: ffffff88 = 000000000000000000000000000000011111111111111111111111110001000
+ Bits : ffffff88 = 11111111111111111111111110001000
+ Part : ffffff88 = 11111111111111111111111110001000
+ OK.
+ exit 0






More information about the llvm-commits mailing list