[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/SignlessTypes/ccc.c

Reid Spencer reid at x10sys.com
Wed Jan 10 09:54:17 PST 2007



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

ccc.c added (r1.1)
---
Log message:

A little test for parameter attributes.


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

 ccc.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+)


Index: llvm-test/SingleSource/UnitTests/SignlessTypes/ccc.c
diff -c /dev/null llvm-test/SingleSource/UnitTests/SignlessTypes/ccc.c:1.1
*** /dev/null	Wed Jan 10 11:54:12 2007
--- llvm-test/SingleSource/UnitTests/SignlessTypes/ccc.c	Wed Jan 10 11:54:02 2007
***************
*** 0 ****
--- 1,54 ----
+ /* 
+  * This file is used to the C calling conventions with signless
+  * LLVM. Integer arguments in this convention are promoted to at
+  * least a 32-bit size. Consequently signed values must be 
+  * sign extended and unsigned values must be zero extended to
+  * at least a 32-bit integer type. 
+  */
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+ int Y = 0;
+ 
+ int ubyteArg( unsigned char X) {
+   return X + 2 + Y;
+ }
+ 
+ int sbyteArg( signed char X ) {
+   return X + 3 + Y;
+ }
+ 
+ int ushortArg( unsigned short X ) {
+   return X + 4 + Y;
+ }
+ 
+ int sshortArg( signed short X) {
+   return X + 5 + Y;
+ }
+ 
+ int F1, F2, F3, F4;
+ 
+ int main(int argc, char**argv) {
+   int TestVal;
+   short sh;
+   unsigned short ush;
+ 
+   if (argc < 2) {
+     fprintf(stderr, "Program requires integer parameter");
+     exit (1);
+   }
+ 
+   F1 = (int)(void*)ubyteArg;
+   F2 = (int)(void*)sbyteArg;
+   F3 = (int)(void*)ushortArg;
+   F4 = (int)(void*)sshortArg;
+ 
+   TestVal = atoi(argv[1]);
+   sh = (short)-1;
+   ush = (unsigned short) -1;
+ 
+   printf("%d %hd %hu", TestVal, sh, ush);
+ 
+   return TestVal;
+ }






More information about the llvm-commits mailing list