Message ID | 4F3C199A.2090309@gjlay.de |
---|---|
State | New |
Headers | show |
http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00843.html Georg-Johann Lay wrote: > This patch introduces a new file builtins.def that is used as central registry > to hold built-ins' information. > > The file is used by defining DEF_BUILTIN macre and then including the file as > described in the head comment of builtins.def. > > Up to here it's all code clean-up and no functional change. > > Moreover there are some minor changes and ICE fixes: > > * Fold __builtin_avr_swap to rotate <<< 4 > * Don't fold __builtin_avr_insert_bits if first arg is non-const (was ICE) > * Don't expand __builtin_avr_delay_cycles if arg is not-const (was ICE) > > Ok for trunk? > > Johann > > gcc/testsuite/ > * gcc.target/avr/torture/builtins-1.c: New test. > * gcc.target/avr/torture/builtins-error.c: New test. > gcc/ > * config/avr/builtins.def: New file. > * config/avr/t-avr (avr.o, avr-c.o): Depend on it. > * config/avr/avr.c (enum avr_builtin_id): Use it. > (avr_init_builtins): Use it. And use avr_bdesc. > (bdesc_1arg): Remove. > (bdesc_2arg): Remove. > (bdesc_3arg): Remove. > (struct avr_builtin_description): Add field n_args. > (avr_bdesc): New static variable using builtins.def. > (avr_expand_builtin): Use it. > Don't call avr_expand_delay_cycles if op0 is not CONST_INT. > (avr_fold_builtin): Fold AVR_BUILTIN_SWAP. > Don't fold AVR_BUILTIN_INSERT_BITS if arg0 is not INTEGER_CST.
2012/2/24 Georg-Johann Lay <avr@gjlay.de>: > http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00843.html > > Georg-Johann Lay wrote: >> This patch introduces a new file builtins.def that is used as central registry >> to hold built-ins' information. >> >> The file is used by defining DEF_BUILTIN macre and then including the file as >> described in the head comment of builtins.def. >> >> Up to here it's all code clean-up and no functional change. >> >> Moreover there are some minor changes and ICE fixes: >> >> * Fold __builtin_avr_swap to rotate <<< 4 >> * Don't fold __builtin_avr_insert_bits if first arg is non-const (was ICE) >> * Don't expand __builtin_avr_delay_cycles if arg is not-const (was ICE) >> >> Ok for trunk? >> >> Johann >> >> gcc/testsuite/ >> * gcc.target/avr/torture/builtins-1.c: New test. >> * gcc.target/avr/torture/builtins-error.c: New test. >> gcc/ >> * config/avr/builtins.def: New file. >> * config/avr/t-avr (avr.o, avr-c.o): Depend on it. >> * config/avr/avr.c (enum avr_builtin_id): Use it. >> (avr_init_builtins): Use it. And use avr_bdesc. >> (bdesc_1arg): Remove. >> (bdesc_2arg): Remove. >> (bdesc_3arg): Remove. >> (struct avr_builtin_description): Add field n_args. >> (avr_bdesc): New static variable using builtins.def. >> (avr_expand_builtin): Use it. >> Don't call avr_expand_delay_cycles if op0 is not CONST_INT. >> (avr_fold_builtin): Fold AVR_BUILTIN_SWAP. >> Don't fold AVR_BUILTIN_INSERT_BITS if arg0 is not INTEGER_CST. > > Approved. Denis.
Index: testsuite/gcc.target/avr/torture/builtins-error.c =================================================================== --- testsuite/gcc.target/avr/torture/builtins-error.c (revision 0) +++ testsuite/gcc.target/avr/torture/builtins-error.c (revision 0) @@ -0,0 +1,11 @@ +/* { dg-do assemble } */ + +char insert (long a) +{ + return __builtin_avr_insert_bits (15.3f+a, 0, 0); /* { dg-error "expects a compile time" } */ +} + +void delay (long a) +{ + __builtin_avr_delay_cycles (a); /* { dg-error "expects a compile time" } */ +} Index: testsuite/gcc.target/avr/torture/builtins-1.c =================================================================== --- testsuite/gcc.target/avr/torture/builtins-1.c (revision 0) +++ testsuite/gcc.target/avr/torture/builtins-1.c (revision 0) @@ -0,0 +1,38 @@ +/* { dg-do compile } */ + +void nop (void) { __builtin_avr_nop (); } +void sei (void) { __builtin_avr_sei (); } +void cli (void) { __builtin_avr_cli (); } +void wdr (void) { __builtin_avr_wdr (); } +void sleep (void) { __builtin_avr_sleep (); } + +char fmul (char a, char b) { return __builtin_avr_fmul (a, b); } +char fmuls (char a, char b) { return __builtin_avr_fmuls (a, b); } +char fmulsu (char a, char b) { return __builtin_avr_fmulsu (a, b); } + +char swap1 (char a) +{ + return __builtin_avr_swap (a+1); +} + +char swap2 (char a) +{ + return __builtin_avr_swap (__builtin_avr_swap (a+1)); +} + +char swap15 (void) +{ + return __builtin_avr_swap (15); +} + +void delay0 (void) { __builtin_avr_delay_cycles (0); } +void delay1 (void) { __builtin_avr_delay_cycles (1); } +void delay2 (void) { __builtin_avr_delay_cycles (2); } +void delay3 (void) { __builtin_avr_delay_cycles (3); } + +void delay_1 (void) { __builtin_avr_delay_cycles (44); } +void delay_2 (void) { __builtin_avr_delay_cycles (0x1234); } +void delay_3 (void) { __builtin_avr_delay_cycles (0x123456); } +void delay_4 (void) { __builtin_avr_delay_cycles (-1ul); } + +/* { dg-final { scan-assembler-not "__builtin_avr_" } } */