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

Reid Spencer reid at x10sys.com
Wed Jan 17 17:31:43 PST 2007



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

general-test.c updated: 1.1 -> 1.2
general-test.reference_output updated: 1.1 -> 1.2
---
Log message:

Provide a simple test case and its reference output.


---
Diffs of the changes:  (+63 -22)

 general-test.c                |   66 ++++++++++++++++++++++++++++++------------
 general-test.reference_output |   19 +++++++++---
 2 files changed, 63 insertions(+), 22 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/general-test.c
diff -u llvm-test/SingleSource/UnitTests/Integer/general-test.c:1.1 llvm-test/SingleSource/UnitTests/Integer/general-test.c:1.2
--- llvm-test/SingleSource/UnitTests/Integer/general-test.c:1.1	Tue Jan 16 14:30:27 2007
+++ llvm-test/SingleSource/UnitTests/Integer/general-test.c	Wed Jan 17 19:31:25 2007
@@ -7,41 +7,71 @@
 
 #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;
+typedef unsigned char ATTR_BITS( 4) My04BitInt;
+typedef unsigned short ATTR_BITS(16) My16BitInt;
+typedef unsigned int ATTR_BITS(17) My17BitInt;
+typedef unsigned long long ATTR_BITS(37) My37BitInt;
+typedef unsigned ATTR_BITS(65) My65BitInt;
 
 struct MyStruct {
+  struct MyStruct* next;
   My04BitInt i4Field;
-  short ATTR_BITS(12) i12Field;
-  long ATTR_BITS(17) i17Field;
+  unsigned short ATTR_BITS(12) i12Field;
+  unsigned ATTR_BITS(17) i17Field;
   My37BitInt i37Field;
 };
 
-My37BitInt getSizes( short ATTR_BITS(23) num) {
+struct MyStruct Data1;
+struct MyStruct Data2;
+
+struct MyStruct* getSizes( short ATTR_BITS(23) num, My37BitInt * result) {
   My17BitInt i;
-  struct MyStruct strct;
-  int __attribute__((bitwidth(9))) j;
-  int result;
+  short __attribute__((bitwidth(9))) j;
   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;
+  Data1.i4Field = num;
+  Data1.i12Field = num + 1;
+  Data1.i17Field = num + 2;
+  Data1.i37Field = num + 3;
+  Data1.next = 0;
+  Data2 = Data1;
+  Data2.i4Field  *= 7;
+  Data2.i12Field *= 7;
+  Data2.i17Field *= 7;
+  Data2.i37Field *= 7;
+  Data2.next = &Data1;
+  j = num * 2;
   printf("j = %d\n", j);
   printf("size sum is %d\n", result);
-  return result;
+  return &Data2;
 }
 
 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;
+  struct MyStruct* strct = malloc(sizeof(struct MyStruct));
+  int r = rand();
+  int num = 0;
+  int ATTR_BITS(23) val = 0;
+  My37BitInt* sizes = 0;
+  printf("rand = %d\n", r);
+  printf("argc = %d\n", argc);
+  if (argc > 1)
+    num = atoi(argv[1]);
+  printf("num  = %d\n", num);
+  val = r + argc + num;
+  printf("val  = %d\n", val);
+  struct MyStruct* that = ((int ATTR_BITS(32)) getSizes(val, &sizes));
+  printf("that.i4Field  = %d\n", (int)that->i4Field);
+  printf("that.i12Field = %d\n", (int)that->i12Field);
+  printf("that.i17Field = %d\n", (int)that->i17Field);
+  printf("that.i37Field = %d\n", (int)that->i37Field);
+  printf("next.i4Field  = %d\n", (int)that->next->i4Field);
+  printf("next.i12Field = %d\n", (int)that->next->i12Field);
+  printf("next.i17Field = %d\n", (int)that->next->i17Field);
+  printf("next.i37Field = %d\n", (int)that->next->i37Field);
+  return ((int)sizes) & 1;
 }


Index: llvm-test/SingleSource/UnitTests/Integer/general-test.reference_output
diff -u llvm-test/SingleSource/UnitTests/Integer/general-test.reference_output:1.1 llvm-test/SingleSource/UnitTests/Integer/general-test.reference_output:1.2
--- llvm-test/SingleSource/UnitTests/Integer/general-test.reference_output:1.1	Tue Jan 16 14:30:27 2007
+++ llvm-test/SingleSource/UnitTests/Integer/general-test.reference_output	Wed Jan 17 19:31:25 2007
@@ -1,7 +1,18 @@
-X is 1802150879
-sizeof(MyStruct) == 12
+rand = 1804289383
+argc = 2
+num  = 31415926
+val  = 6988767
+sizeof(MyStruct) == 20
 sizeof(My17BitInt) == 4
 sizeof(j) == 2
-j = 257
-size sum is 18
+j = 446
+size sum is 26
+that.i4Field  = 9
+that.i12Field = 2848
+that.i17Field = 31527
+that.i37Field = 48921390
+next.i4Field  = 15
+next.i12Field = 992
+next.i17Field = 41953
+next.i37Field = 6988770
 exit 0






More information about the llvm-commits mailing list