/* * Generate a C file to test the constant pool range ode in the ARM * code generator. * * Usage: * make gen_pool_range * ./gen_pool_range < /dev/urandom > pool_range.c * make pool_range # inseer target-cpu options here, and probably -O2 * objdump -d pool_range | less * * Generated code is something like: foo(double pi) { register volatile unsigned long ul; ul = 0x0a9ddccaUL; ul = 0x3fe0945eUL; ul = 0x868d43eeUL; ... ul = 0xa63cc396UL; ul = 0xef0737b0UL; ul = 0xa25bf796UL; return ul; } main() { foo(3.14159265358979323); exit(0); } */ #include #include /* Enable various types/sizes of constants. * Set them to 0 or 1 */ #define UL 1 /* 32-bit unsigned longs */ #define ULL 0 /* 64-bit unsigned long longs */ #define DF 1 /* 64-bit double floating point */ #define MAX_POOL_SIZE 4096 /* Max size in bytes of constant pool made by GC */ #define STATIC_VARS 1 main() { int i; puts("/* Auto-generated C file to test GCC's ARM constant pool ranges */"); puts("#include "); puts("#include "); puts(""); #if UL puts("unsigned long"); #else puts("void"); #endif puts("foo(double pi)"); puts("{"); #if UL puts("\tregister volatile unsigned long ul;"); #endif #if ULL puts("\tregister volatile unsigned long long ull;"); #endif #if DF puts("\tregister volatile double df;"); #endif /* Output enough constants to fill two pools * so we are sure to get both edge cases */ for (i = MAX_POOL_SIZE * 2; i>0; ) { #if UL { unsigned long ul; fread ((void *)&ul, sizeof(ul), 1, stdin); printf("\tul = 0x%08lxUL;\n", ul); i -= sizeof(ul); } #endif #if ULL { unsigned long long ull; fread ((void *)&ull, sizeof(ull), 1, stdin); printf("\tull = 0x%016llxULL;\n", ull); i -= sizeof(ull); } #endif #if DF /* force hard floating point by doing a multiplication by an arg * otherwise it just uses pairs of ARM registers and/or does the * multiplication at compile time. */ { unsigned long long ull; fread ((void *)&ull, sizeof(ull), 1, stdin); printf("\tdf = pi * 0x%016llxULL;\n", ull); i -= sizeof(double); } #endif } #if UL puts("\treturn ul;"); #endif puts("}"); puts(""); puts("main()"); puts("{"); puts("\tfoo(3.14159265358979323);"); puts("\texit(0);"); puts("}"); exit(0); }