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

Reid Spencer reid at x10sys.com
Tue Jan 16 12:30:43 PST 2007



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

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

Provide a general bitwidth attribute usage test and its reference output.
This provides a test case for getting the CBE to handle aribitrary 
precision integers correctly. Currently it will fail. Soon it will pass.


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

 general-test.c                |   47 ++++++++++++++++++++++++++++++++++++++++++
 general-test.reference_output |    7 ++++++
 2 files changed, 54 insertions(+)


Index: llvm-test/SingleSource/UnitTests/Integer/general-test.c
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/general-test.c:1.1
*** /dev/null	Tue Jan 16 14:30:37 2007
--- llvm-test/SingleSource/UnitTests/Integer/general-test.c	Tue Jan 16 14:30:27 2007
***************
*** 0 ****
--- 1,47 ----
+ /* This test just tries out a few bitwidth attribute constructs and 
+  * generates some output based on the them.
+  */
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+ #define ATTR_BITS(N) __attribute__((bitwidth(N))) 
+ 
+ typedef int ATTR_BITS( 4) My04BitInt;
+ typedef int ATTR_BITS(16) My16BitInt;
+ typedef int ATTR_BITS(17) My17BitInt;
+ typedef int ATTR_BITS(37) My37BitInt;
+ typedef int ATTR_BITS(65) My65BitInt;
+ 
+ struct MyStruct {
+   My04BitInt i4Field;
+   short ATTR_BITS(12) i12Field;
+   long ATTR_BITS(17) i17Field;
+   My37BitInt i37Field;
+ };
+ 
+ My37BitInt getSizes( short ATTR_BITS(23) num) {
+   My17BitInt i;
+   struct MyStruct strct;
+   int __attribute__((bitwidth(9))) j;
+   int result;
+   printf("sizeof(MyStruct) == %d\n", sizeof(struct MyStruct));
+   printf("sizeof(My17BitInt) == %d\n", sizeof(My17BitInt));
+   printf("sizeof(j) == %d\n", sizeof(j));
+   result = sizeof(My17BitInt) + sizeof(j) + sizeof(struct MyStruct);
+   strct.i17Field = result;
+   j = 257;
+   printf("j = %d\n", j);
+   printf("size sum is %d\n", result);
+   return result;
+ }
+ 
+ int
+ main ( int argc, char** argv)
+ {
+   srand(0);
+   int r = rand() + argc + 31415926;
+   char ATTR_BITS(23) X = r;
+   printf("X is %d\n", X);
+   return ((int ATTR_BITS(32)) getSizes(X)) & 1;
+ }


Index: llvm-test/SingleSource/UnitTests/Integer/general-test.reference_output
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/general-test.reference_output:1.1
*** /dev/null	Tue Jan 16 14:30:43 2007
--- llvm-test/SingleSource/UnitTests/Integer/general-test.reference_output	Tue Jan 16 14:30:27 2007
***************
*** 0 ****
--- 1,7 ----
+ X is 1802150879
+ sizeof(MyStruct) == 12
+ sizeof(My17BitInt) == 4
+ sizeof(j) == 2
+ j = 257
+ size sum is 18
+ exit 0






More information about the llvm-commits mailing list