[llvm-commits] CVS: llvm/test/Regression/LLC/casts.c

Vikram Adve vadve at cs.uiuc.edu
Fri Sep 27 08:27:01 PDT 2002


Changes in directory llvm/test/Regression/LLC:

casts.c updated: 1.2 -> 1.3

---
Log message:

Overhauled completely.


---
Diffs of the changes:

Index: llvm/test/Regression/LLC/casts.c
diff -u llvm/test/Regression/LLC/casts.c:1.2 llvm/test/Regression/LLC/casts.c:1.3
--- llvm/test/Regression/LLC/casts.c:1.2	Thu Sep 19 20:05:16 2002
+++ llvm/test/Regression/LLC/casts.c	Fri Sep 27 08:26:36 2002
@@ -8,80 +8,119 @@
 int
 main(int argc, char** argv)
 {
-  char          c1;
-  short         s1, ssf1, ssd1;
-  uint8_t       ubs0;
-  int8_t        bs0;
-  unsigned char ubc0, uc2;
-  unsigned      short us2, usf1, usd1;
-  int           ic3, is3, sif1, sid1;
-  unsigned      uic4, uis4, uif1, uid1;
-  long          slf1, sld1;
-  unsigned long ulf1, uld1;
-  float         f1;
-  double        d1;
+  int8_t        C, c1;
+  uint8_t       uc1;
+
+  short         S, s1;
+  unsigned short us1;
+
+  int           i1;
+  unsigned      ui1;
+
+  int64_t       L, l1;
+  uint64_t      ul1;
+
+  float         F;
+  double        D;
+  
+  /* input values */
+  C = (char)  (argc >= 2)? atoi(argv[1]) : 0x64;           /* 100 = 'd' */
+  S = (short) (argc >= 3)? atoi(argv[2]) : -769;           /* 0xfcff = -769 */
+  L = (long)  (argc >= 4)? atoi(argv[3]) : 0xa3a3a3a3a3a3; /*179923220407203*/
   
   /* Test integer to integer conversions */
-  
-  c1 = (char)  (argc >= 2)? atoi(argv[1]) : 0xff64; /* 100 = 'd' */
-  s1 = (short) (argc >= 3)? atoi(argv[2]) : -769;   /* 0xfcff = -769 */
-  
-  ubc0 = (unsigned char) c1;                      /* 100 = 'd' */
-  ubs0 = (uint8_t) s1;                            /* 0xff = 255 */
-  bs0  = (int8_t) s1;                             /* 0xff = -1 */
-  
-  uc2 = (unsigned char) c1;                       /* 100 = 'd' */
-  us2 = (unsigned short) s1;                      /* 0xfcff = 64767 */
-  
-  ic3 = (int) c1;                                 /* 100 = 'd' */
-  is3 = (int) s1;                                 /* 0xfffffcff = -769 */
-  
-  uic4 = (unsigned int) c1;                       /*  100 = 'd' */
-  uis4 = (unsigned int) s1;                       /* 0xfffffcff = 4294966527 */
-  
-  printf("ubc0 = '%c'\n", ubc0);
-  printf("ubs0 = %u\n",   ubs0);
-  printf("bs0  = %d\n",   bs0);
-  printf("c1   = '%c'\n", c1);
-  printf("s1   = %d\n",   s1);
-  printf("uc2  = '%c'\n", uc2);
-  printf("us2  = %u\n",   us2);
-  printf("ic3  = '%c'\n", ic3);
-  printf("is3  = %d\n",   is3);
-  printf("uic4 = '%c'\n", uic4);
-  printf("uis4 = %u\n",   uis4);
-  
+  uc1 = (uint8_t) C;                       /* 100 = 'd' */
+  us1 = (unsigned short) C;                /* 100 = 'd' */
+  ui1 = (unsigned int) C;                  /* 100 = 'd' */
+  ul1 = (unsigned long) C;                 /* 100 = 'd' */
+
+  s1  = (short) C;                         /* 100 = 'd' */
+  i1  = (int) C;                           /* 100 = 'd' */
+  l1  = (long) C;                          /* 100 = 'd' */
+  
+  printf("\nCHAR             C = '%c' (%d)\t\t(0x%x)\n", C, C, C);
+  printf("char to short   s1 = %d\t\t(0x%x)\n", s1, s1);
+  printf("char to int     i1 = %d\t\t(0x%x)\n", i1, i1);
+  printf("char to long    l1 = %ld\t\t(0x%lx)\n", l1, l1);
+
+  printf("\nchar to ubyte  uc1 = %u\t\t(0x%x)\n", uc1, uc1);
+  printf("char to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
+  printf("char to uint   ui1 = %u\t\t(0x%x)\n", ui1, ui1);
+  printf("char to ulong  ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
+
+  uc1 = (uint8_t) S;                            /* 0xff = 255 */
+  us1 = (unsigned short) S;                     /* 0xfcff = 64767 */
+  ui1 = (unsigned int) S;                       /* 0xfffffcff = 4294966527 */
+  ul1 = (unsigned long) S;                      /* */
+
+  c1  = (int8_t) S;                             /* 0xff = -1 */
+  i1  = (int) S;                                /* 0xfffffcff = -769 */
+  l1  = (long) S;                               /* */
+
+  printf("\n\nSHORT            S = %d\t\t(0x%x)\n", S, S);
+  printf("short to byte    c1 = %d\t\t(0x%x)\n", c1, c1);
+  printf("short to int     i1 = %d\t\t(0x%x)\n", i1, i1);
+  printf("short to long    l1 = %ld\t\t(0x%lx)\n", l1, l1);
+
+  printf("\nshort to ubyte  uc1 = %u\t\t(0x%x)\n", uc1, uc1);
+  printf("short to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
+  printf("short to uint   ui1 = %u\t\t(0x%x)\n", ui1, ui1);
+  printf("short to ulong  ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
+
+  uc1 = (unsigned char) L;                      /* */
+  c1  = (int8_t) L;                             /* */
+  s1  = (short) L;                              /* */
+  us1 = (unsigned short) L;                     /* */
+  i1  = (int) L;                                /* */
+  ui1 = (unsigned int) L;                       /* */
+  ul1 = (unsigned long) L;                       /* */
+
+  printf("\n\nLONG            L = %ld\t\t(0x%lx)\n", L, L);
+  printf("long to byte    c1 = %d\t\t(0x%x)\n", c1, c1);
+  printf("long to short   s1 = %d\t\t(0x%x)\n", s1, s1);
+  printf("long to int     i1 = %d\t\t(0x%x)\n", i1, i1);
+
+  printf("\nlong to ubyte  uc1 = %u\t\t(0x%x)\n", uc1, uc1);
+  printf("long to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
+  printf("long to uint   ui1 = %u\t\t(0x%x)\n", ui1, ui1);
+  printf("long to ulong  ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
+
   /* Test floating-point to integer conversions */
-  f1 = (float)  (argc >= 4)? atof(argv[3]) : 1.0;
-  d1 =          (argc >= 5)? atof(argv[4]) : 2.0;
-  
-  usf1 = (unsigned short) f1;
-  usd1 = (unsigned short) d1;
-  uif1 = (unsigned int) f1;
-  uid1 = (unsigned int) d1;
-  ulf1 = (unsigned long) f1;
-  uld1 = (unsigned long) d1;
-  
-  ssf1 = (short) f1;
-  ssd1 = (short) d1;
-  sif1 = (int) f1;
-  sid1 = (int) d1;
-  slf1 = (long) f1;
-  sld1 = (long) d1;
-  
-  printf("usf1 = %u\n", usf1);
-  printf("usd1 = %u\n", usd1);
-  printf("uif1 = %u\n", uif1);
-  printf("uid1 = %u\n", uid1);
-  printf("ulf1 = %lu\n", ulf1);
-  printf("uld1 = %lu\n", uld1);
-  
-  printf("ssf1 = %d\n", ssf1);
-  printf("ssd1 = %d\n", ssd1);
-  printf("sif1 = %d\n", sif1);
-  printf("sid1 = %d\n", sid1);
-  printf("slf1 = %ld\n", slf1);
-  printf("sld1 = %ld\n", sld1);
+  F = (float)  (argc >= 4)? atof(argv[3]) : 1.0;
+  D =          (argc >= 5)? atof(argv[4]) : 2.0;
   
+  us1 = (unsigned short) F;
+  ui1 = (unsigned int) F;
+  ul1 = (unsigned long) F;
+
+  s1  = (short) F;
+  i1  = (int) F;
+  l1  = (long) F;
+
+  printf("\n\nFLOAT            F = %f\n", F);
+  printf("float to short   s1 = %d\t\t(0x%x)\n", s1, s1);
+  printf("float to int     i1 = %d\t\t(0x%x)\n", i1, i1);
+
+  printf("float to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
+  printf("float to uint   ui1 = %u\t\t(0x%x)\n", ui1, ui1);
+  printf("float to ulong  ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
+
+  us1 = (unsigned short) D;
+  ui1 = (unsigned int) D;
+  ul1 = (unsigned long) D;
+  
+  s1  = (short) D;
+  i1  = (int) D;
+  l1  = (long) D;
+
+  printf("\n\nDOUBLE            D = %f\n", D);
+  printf("double to short   s1 = %d\t\t(0x%x)\n", s1, s1);
+  printf("double to int     i1 = %d\t\t(0x%x)\n", i1, i1);
+  printf("double to long    l1 = %ld\t\t(0x%lx)\n", l1, l1);
+
+  printf("double to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
+  printf("double to uint   ui1 = %u\t\t(0x%x)\n", ui1, ui1);
+  printf("double to ulong  ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
+
   return 0;
 }





More information about the llvm-commits mailing list