* [patch,avr] Add built-in function to emit NOPs
@ 2016-08-01 8:23 Georg-Johann Lay
2016-08-01 11:51 ` Denis Chertykov
0 siblings, 1 reply; 2+ messages in thread
From: Georg-Johann Lay @ 2016-08-01 8:23 UTC (permalink / raw)
To: gcc-patches; +Cc: Denis Chertykov
[-- Attachment #1: Type: text/plain, Size: 403 bytes --]
This adds a new built-in function that inserts a requested number of NOPs into
the instruction stream. I found it useful when testing avr-gcc.
Ok to apply?
Johann
* doc/extend.texi (AVR Built-in Functions): Document
__builtin_avr_nops.
* config/avr/builtins.def (NOPS): New.
* config/avr/avr.c (avr_expand_nops): New static function.
(avr_expand_builtin): Use it to handle AVR_BUILTIN_NOPS.
[-- Attachment #2: nops.diff --]
[-- Type: text/x-patch, Size: 2223 bytes --]
Index: doc/extend.texi
===================================================================
--- doc/extend.texi (revision 238849)
+++ doc/extend.texi (working copy)
@@ -12552,6 +12552,14 @@ __builtin_avr_insert_bits (0xffff3210, b
__builtin_avr_insert_bits (0x01234567, bits, 0)
@end smallexample
+@smallexample
+void __builtin_avr_nops (unsigned count)
+@end smallexample
+
+@noindent
+Insert @code{count} @code{NOP} instructions.
+The number of instructions must be a compile-time integer constant.
+
@node Blackfin Built-in Functions
@subsection Blackfin Built-in Functions
Index: config/avr/builtins.def
===================================================================
--- config/avr/builtins.def (revision 238849)
+++ config/avr/builtins.def (working copy)
@@ -51,6 +51,7 @@ DEF_BUILTIN (FMULSU, 2, int_ftype_char_u
/* More complex stuff that cannot be mapped 1:1 to an instruction. */
DEF_BUILTIN (DELAY_CYCLES, -1, void_ftype_ulong, nothing, NULL)
+DEF_BUILTIN (NOPS, -1, void_ftype_ulong, nothing, NULL)
DEF_BUILTIN (INSERT_BITS, 3, uchar_ftype_ulong_uchar_uchar, insert_bits, NULL)
DEF_BUILTIN (FLASH_SEGMENT, 1, char_ftype_const_memx_ptr, flash_segment, NULL)
Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c (revision 238879)
+++ config/avr/avr.c (working copy)
@@ -12714,6 +12714,18 @@ avr_expand_delay_cycles (rtx operands0)
}
+static void
+avr_expand_nops (rtx operands0)
+{
+ unsigned HOST_WIDE_INT n_nops = UINTVAL (operands0) & GET_MODE_MASK (HImode);
+
+ while (n_nops--)
+ {
+ emit_insn (gen_nopv (const1_rtx));
+ }
+}
+
+
/* Compute the image of x under f, i.e. perform x --> f(x) */
static int
@@ -13387,6 +13399,19 @@ avr_expand_builtin (tree exp, rtx target
return NULL_RTX;
}
+
+ case AVR_BUILTIN_NOPS:
+ {
+ arg0 = CALL_EXPR_ARG (exp, 0);
+ op0 = expand_expr (arg0, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+
+ if (!CONST_INT_P (op0))
+ error ("%s expects a compile time integer constant", bname);
+ else
+ avr_expand_nops (op0);
+
+ return NULL_RTX;
+ }
case AVR_BUILTIN_INSERT_BITS:
{
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch,avr] Add built-in function to emit NOPs
2016-08-01 8:23 [patch,avr] Add built-in function to emit NOPs Georg-Johann Lay
@ 2016-08-01 11:51 ` Denis Chertykov
0 siblings, 0 replies; 2+ messages in thread
From: Denis Chertykov @ 2016-08-01 11:51 UTC (permalink / raw)
To: Georg-Johann Lay; +Cc: gcc-patches
2016-08-01 11:23 GMT+03:00 Georg-Johann Lay <avr@gjlay.de>:
> This adds a new built-in function that inserts a requested number of NOPs
> into the instruction stream. I found it useful when testing avr-gcc.
>
> Ok to apply?
>
>
> Johann
>
>
> * doc/extend.texi (AVR Built-in Functions): Document
> __builtin_avr_nops.
> * config/avr/builtins.def (NOPS): New.
> * config/avr/avr.c (avr_expand_nops): New static function.
> (avr_expand_builtin): Use it to handle AVR_BUILTIN_NOPS.
Please apply.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-01 11:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-01 8:23 [patch,avr] Add built-in function to emit NOPs Georg-Johann Lay
2016-08-01 11:51 ` Denis Chertykov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).