diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h')
-rw-r--r-- | gcc-4.9/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h b/gcc-4.9/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h new file mode 100644 index 000000000..c56e7cc67 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-2.h @@ -0,0 +1,101 @@ +/* This header file should be included for the purpose of function return + value testing. */ + +#include "abitest-common.h" +#include "validate_memory.h" + +void (*testfunc_ptr)(char* stack); + +/* Helper macros to generate function name. Example of the function name: + func_return_val_1. */ +#define FUNC_BASE_NAME func_return_val_ +#define FUNC_NAME_COMBINE(base,suffix) base ## suffix +#define FUNC_NAME_1(base,suffix) FUNC_NAME_COMBINE(base,suffix) +#define FUNC_NAME(suffix) FUNC_NAME_1(FUNC_BASE_NAME,suffix) +#define TEST_FUNC_BASE_NAME testfunc_ +#define TEST_FUNC_NAME(suffix) FUNC_NAME_1(TEST_FUNC_BASE_NAME,suffix) + +#undef DUMP_STATUS +#ifdef DUMP_ENABLED +#define DUMP_STATUS(type,val) printf ("### Checking "#type" "#val"\n"); +#else +#define DUMP_STATUS(type,val) +#endif + +/* Generate code to do memcmp to check if the returned value is in the + correct location and has the expected value. + Note that for value that is returned in the caller-allocated memory + block, we get the address from the saved x8 register. x8 is saved + just after the callee is returned; we assume that x8 has not been + clobbered at then, although there is no requirement for the callee + preserve the value stored in x8. Luckily, all test cases here are + simple enough that x8 doesn't normally get clobbered (although not + guaranteed). */ +#undef FUNC_VAL_CHECK +#define FUNC_VAL_CHECK(id, type, val, offset, layout) \ +void TEST_FUNC_NAME(id)(char* stack) \ +{ \ + type __x = val; \ + char* addr; \ + DUMP_STATUS(type,val) \ + if (offset != X8) \ + addr = stack + offset; \ + else \ + addr = *(char **)(stack + X8); \ + if (validate_memory (&__x, addr, sizeof (type), layout) != 0) \ + abort(); \ +} + +/* Composite larger than 16 bytes is replaced by a pointer to a copy prepared + by the caller, so here we extrat the pointer, deref it and compare the + content with that of the original one. */ +#define PTR(type, val, offset, ...) { \ + type * ptr; \ + DUMP_ARG(type,val) \ + ptr = *(type **)(stack + offset); \ + if (memcmp (ptr, &val, sizeof (type)) != 0) abort (); \ +} + +#include TESTFILE + +MYFUNCTYPE myfunc () PCSATTR; + +/* Define the function to return VAL of type TYPE. I and D in the + parameter list are two dummy parameters to help improve the detection + of bugs like a short vector being returned in X0 after copied from V0. */ +#undef FUNC_VAL_CHECK +#define FUNC_VAL_CHECK(id, type, var, offset, layout) \ +__attribute__ ((noinline)) type FUNC_NAME (id) (int i, double d, type t) \ + { \ + asm (""::"r" (i),"r" (d)); /* asm prevents function from getting \ + optimized away. Using i and d prevents \ + warnings about unused parameters. \ + */ \ + return t; \ + } +#include TESTFILE + + +/* Call the function to return value and call the checking function + to validate. See the comment above for the reason of having 0 and 0.0 + in the function argument list. */ +#undef FUNC_VAL_CHECK +#define FUNC_VAL_CHECK(id, type, var, offset, layout) \ + { \ + testfunc_ptr = TEST_FUNC_NAME(id); \ + FUNC_NAME(id) (0, 0.0, var); \ + myfunc (); \ + } + +int main() +{ + which_kind_of_test = TK_RETURN; + +#ifdef HAS_DATA_INIT_FUNC + init_data (); +#endif + +#include TESTFILE + + return 0; +} |