mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-17 03:24:34 +00:00
Overhauled completely.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3955 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
177
test/LLC/casts.c
177
test/LLC/casts.c
@@ -8,80 +8,119 @@
|
|||||||
int
|
int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
char c1;
|
int8_t C, c1;
|
||||||
short s1, ssf1, ssd1;
|
uint8_t uc1;
|
||||||
uint8_t ubs0;
|
|
||||||
int8_t bs0;
|
short S, s1;
|
||||||
unsigned char ubc0, uc2;
|
unsigned short us1;
|
||||||
unsigned short us2, usf1, usd1;
|
|
||||||
int ic3, is3, sif1, sid1;
|
int i1;
|
||||||
unsigned uic4, uis4, uif1, uid1;
|
unsigned ui1;
|
||||||
long slf1, sld1;
|
|
||||||
unsigned long ulf1, uld1;
|
int64_t L, l1;
|
||||||
float f1;
|
uint64_t ul1;
|
||||||
double d1;
|
|
||||||
|
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 */
|
/* Test integer to integer conversions */
|
||||||
|
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' */
|
||||||
|
|
||||||
c1 = (char) (argc >= 2)? atoi(argv[1]) : 0xff64; /* 100 = 'd' */
|
printf("\nCHAR C = '%c' (%d)\t\t(0x%x)\n", C, C, C);
|
||||||
s1 = (short) (argc >= 3)? atoi(argv[2]) : -769; /* 0xfcff = -769 */
|
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);
|
||||||
ubc0 = (unsigned char) c1; /* 100 = 'd' */
|
printf("char to long l1 = %ld\t\t(0x%lx)\n", l1, l1);
|
||||||
ubs0 = (uint8_t) s1; /* 0xff = 255 */
|
|
||||||
bs0 = (int8_t) s1; /* 0xff = -1 */
|
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);
|
||||||
uc2 = (unsigned char) c1; /* 100 = 'd' */
|
printf("char to uint ui1 = %u\t\t(0x%x)\n", ui1, ui1);
|
||||||
us2 = (unsigned short) s1; /* 0xfcff = 64767 */
|
printf("char to ulong ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
|
||||||
|
|
||||||
ic3 = (int) c1; /* 100 = 'd' */
|
uc1 = (uint8_t) S; /* 0xff = 255 */
|
||||||
is3 = (int) s1; /* 0xfffffcff = -769 */
|
us1 = (unsigned short) S; /* 0xfcff = 64767 */
|
||||||
|
ui1 = (unsigned int) S; /* 0xfffffcff = 4294966527 */
|
||||||
uic4 = (unsigned int) c1; /* 100 = 'd' */
|
ul1 = (unsigned long) S; /* */
|
||||||
uis4 = (unsigned int) s1; /* 0xfffffcff = 4294966527 */
|
|
||||||
|
c1 = (int8_t) S; /* 0xff = -1 */
|
||||||
printf("ubc0 = '%c'\n", ubc0);
|
i1 = (int) S; /* 0xfffffcff = -769 */
|
||||||
printf("ubs0 = %u\n", ubs0);
|
l1 = (long) S; /* */
|
||||||
printf("bs0 = %d\n", bs0);
|
|
||||||
printf("c1 = '%c'\n", c1);
|
printf("\n\nSHORT S = %d\t\t(0x%x)\n", S, S);
|
||||||
printf("s1 = %d\n", s1);
|
printf("short to byte c1 = %d\t\t(0x%x)\n", c1, c1);
|
||||||
printf("uc2 = '%c'\n", uc2);
|
printf("short to int i1 = %d\t\t(0x%x)\n", i1, i1);
|
||||||
printf("us2 = %u\n", us2);
|
printf("short to long l1 = %ld\t\t(0x%lx)\n", l1, l1);
|
||||||
printf("ic3 = '%c'\n", ic3);
|
|
||||||
printf("is3 = %d\n", is3);
|
printf("\nshort to ubyte uc1 = %u\t\t(0x%x)\n", uc1, uc1);
|
||||||
printf("uic4 = '%c'\n", uic4);
|
printf("short to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
|
||||||
printf("uis4 = %u\n", uis4);
|
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 */
|
/* Test floating-point to integer conversions */
|
||||||
f1 = (float) (argc >= 4)? atof(argv[3]) : 1.0;
|
F = (float) (argc >= 4)? atof(argv[3]) : 1.0;
|
||||||
d1 = (argc >= 5)? atof(argv[4]) : 2.0;
|
D = (argc >= 5)? atof(argv[4]) : 2.0;
|
||||||
|
|
||||||
usf1 = (unsigned short) f1;
|
us1 = (unsigned short) F;
|
||||||
usd1 = (unsigned short) d1;
|
ui1 = (unsigned int) F;
|
||||||
uif1 = (unsigned int) f1;
|
ul1 = (unsigned long) F;
|
||||||
uid1 = (unsigned int) d1;
|
|
||||||
ulf1 = (unsigned long) f1;
|
s1 = (short) F;
|
||||||
uld1 = (unsigned long) d1;
|
i1 = (int) F;
|
||||||
|
l1 = (long) F;
|
||||||
ssf1 = (short) f1;
|
|
||||||
ssd1 = (short) d1;
|
printf("\n\nFLOAT F = %f\n", F);
|
||||||
sif1 = (int) f1;
|
printf("float to short s1 = %d\t\t(0x%x)\n", s1, s1);
|
||||||
sid1 = (int) d1;
|
printf("float to int i1 = %d\t\t(0x%x)\n", i1, i1);
|
||||||
slf1 = (long) f1;
|
|
||||||
sld1 = (long) d1;
|
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("usf1 = %u\n", usf1);
|
printf("float to ulong ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
|
||||||
printf("usd1 = %u\n", usd1);
|
|
||||||
printf("uif1 = %u\n", uif1);
|
us1 = (unsigned short) D;
|
||||||
printf("uid1 = %u\n", uid1);
|
ui1 = (unsigned int) D;
|
||||||
printf("ulf1 = %lu\n", ulf1);
|
ul1 = (unsigned long) D;
|
||||||
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);
|
|
||||||
|
|
||||||
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user