This patch adds support for [[len=nl]] annotations.

Most asm have only 1-word instructions, and their size is
given by the number of lines in the code template.

So you don't need to count the number of instruction in such templates.
Also simplified the documentation of the default length.

Ok for trunk?

Johann

--

AVR: Support [[len=nl]] in asm templates.

Most inline asm consists of 1-word instruction, so their exact
size can be conveniently specified with [[len=nl]], which is
half the default size.

gcc/
        * config/avr/avr.cc (avr_length_of_asm): Support "nl" as
        the number of lines in the code template.
        * doc/extend.texi (Size of an asm): Document [[len=nl]].
        Simplify the description of the default length.
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index c6443c03423..b03402e1cb5 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -11156,6 +11156,10 @@ avr_read_number (const char *start, const char **end)
    then return -1.  Otherwise, return the sum over all [[len=<words>]]
    annotations, where:
 
+   <words> = nl
+	The number of lines in the code template.
+	This is half the default size.
+
    <words> = [0-9]+
 	Specifies a non-negative decimal integer.
 
@@ -11215,6 +11219,13 @@ avr_length_of_asm (rtx_insn *insn, int default_len, const char *tpl,
 	  else if (startswith (pos, "call"))
 	    pos += 4;
 	}
+      else if (startswith (pos, "nl"))
+	{
+	  // "nl" denotes the number of lines in the code template,
+	  // which is half of the default length.
+	  inc = asm_str_count (tpl);
+	  pos += 2;
+	}
       else if (startswith (pos, "lds")
 	       || startswith (pos, "sts"))
 	{
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index d9a6594d72a..c54855f3e0a 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -13477,6 +13477,11 @@ The following @code{@var{spec}}'s are supported.  They specify the
 size of the @code{asm} --- or parts of it --- in units of 16-bit words:
 
 @table @code
+@item nl
+The number of lines in the code template, which is half the default size.
+It suits code templates that only use 1-word instructions with
+no superfuous physical @samp{\n} or logical @samp{$} line breaks.
+
 @item [0-9]+
 The decimal representation of a non-negative integer.
 
@@ -13526,9 +13531,9 @@ number of physical and logical line breaks.  Such cases can lead to errors when
 a jump that uses a too optimistic jump offset is crossing such assembly code.
 
 @item Better code generation for jumps that are crossing an @code{asm}.
-The default length of an asm is (1 + @var{NL}) * 2 words, where @var{NL}
-denotes the sum of physical and logical line breaks.  However, almost
-all AVR instructions occupy only a single 16-bit word.
+The default length in words is @emph{twice} the number of lines in
+the code template, though almost all AVR instructions occupy only
+@emph{one} 16-bit word.
 @end itemize
 
 

Reply via email to