aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2001-06-28 21:50:09 +0000
committerZack Weinberg <zack@gcc.gnu.org>2001-06-28 21:50:09 +0000
commit0f40f9f7c68aadde4d52b4fc04d016b72451d238 (patch)
treeac4e7f001b87da3b312391bda96de6043b090057 /gcc/doc
parent0168a84948b3ad7d0b02ff00947c90d003020bd8 (diff)
downloadgcc-0f40f9f7c68aadde4d52b4fc04d016b72451d238.zip
gcc-0f40f9f7c68aadde4d52b4fc04d016b72451d238.tar.gz
gcc-0f40f9f7c68aadde4d52b4fc04d016b72451d238.tar.bz2
i386.md: Global update to use new string syntax where it will improve readability.
* config/i386/i386.md: Global update to use new string syntax where it will improve readability. Warning fixes: (*truncdfsf2_2): Abort if which_alternative is not 0 or 1. (*adddi_1_rex64, *adddi_2_rex64, *adddi_3_rex64, *adddi_4_rex64, *adddi_5_rex64): Cast 1 to unsigned int. * read-rtl.c: Syntactic sugar for C embedded in strings in machine descriptions. (read_string): Break inner loop into separate function. Takes an int. Dispatch to read_quoted_string or read_braced_string as appropriate. Automatically insert a leading star on braced strings if STAR_IF_BRACED is true. (read_quoted_string, read_braced_string): New functions. * doc/rtl.texi, doc/md.texi: Document new syntax. Update examples to match. * rtl.c: Split RTL reader (read_rtx, read_skip_spaces, traverse_md_constants, fatal_with_file_and_line, fatal_expected_char, read_name, read_string, def_hash, def_name_eq_p, read_constants, and related data) to its own file. Weed out now-unnecessary #includes. * read-rtl.c: New file. * Makefile.in (HOST_RTL): Add read-rtl.o. (read-rtl.o): New rule. (rtl.o, $(HOST_PREFIX_1)rtl.o): Update dependencies. * doc/gcc.texi (Passes): Talk briefly about the support library used by genfoo. * doc/rtl.texi (Reading RTL): read_rtx is not available in the compiler itself. From-SVN: r43646
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/gcc.texi4
-rw-r--r--gcc/doc/md.texi53
-rw-r--r--gcc/doc/rtl.texi24
3 files changed, 59 insertions, 22 deletions
diff --git a/gcc/doc/gcc.texi b/gcc/doc/gcc.texi
index be4773e..6601ab6 100644
--- a/gcc/doc/gcc.texi
+++ b/gcc/doc/gcc.texi
@@ -3724,6 +3724,10 @@ and @file{rtl.def}, and subroutines in file @file{rtl.c}. The tools
@code{gen*} also use these files to read and work with the machine
description RTL@.
+@item
+All the tools that read the machine description use support routines
+found in @file{gensupport.c}, @file{errors.c}, and @file{read-rtl.c}.
+
@findex genconfig
@item
Several passes refer to the header file @file{insn-config.h} which
diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index 15374c6..3d4d2b1 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -184,9 +184,26 @@ Here is an actual example of an instruction pattern, for the 68000/68020.
(match_operand:SI 0 "general_operand" "rm"))]
""
"*
-@{ if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
+@{
+ if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
return \"tstl %0\";
- return \"cmpl #0,%0\"; @}")
+ return \"cmpl #0,%0\";
+@}")
+@end example
+
+@noindent
+This can also be written using braced strings:
+
+@example
+(define_insn "tstsi"
+ [(set (cc0)
+ (match_operand:SI 0 "general_operand" "rm"))]
+ ""
+@{
+ if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
+ return "tstl %0";
+ return "cmpl #0,%0";
+@})
@end example
This is an instruction that sets the condition codes based on the value of
@@ -620,6 +637,11 @@ template-string you want. Most such templates use C string literals, which
require doublequote characters to delimit them. To include these
doublequote characters in the string, prefix each one with @samp{\}.
+If the output control string is written as a brace block instead of a
+double-quoted string, it is automatically assumed to be C code. In that
+case, it is not necessary to put in a leading asterisk, or to escape the
+doublequotes surrounding C string literals.
+
The operands may be found in the array @code{operands}, whose C data type
is @code{rtx []}.
@@ -656,10 +678,10 @@ a pattern could use @code{which_alternative} to choose between them:
[(set (match_operand:SI 0 "general_operand" "=r,m")
(const_int 0))]
""
- "*
+ @{
return (which_alternative == 0
- ? \"clrreg %0\" : \"clrmem %0\");
- ")
+ ? "clrreg %0" : "clrmem %0");
+ @})
@end smallexample
The example above, where the assembler code to generate was
@@ -3943,21 +3965,19 @@ Here is an example, taken from the 68000 machine description:
(set (match_operand:DF 0 "register_operand" "=f")
(match_operand:DF 1 "register_operand" "ad"))]
"FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
- "*
@{
rtx xoperands[2];
xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
#ifdef MOTOROLA
- output_asm_insn (\"move.l %1,(sp)\", xoperands);
- output_asm_insn (\"move.l %1,-(sp)\", operands);
- return \"fmove.d (sp)+,%0\";
+ output_asm_insn ("move.l %1,(sp)", xoperands);
+ output_asm_insn ("move.l %1,-(sp)", operands);
+ return "fmove.d (sp)+,%0";
#else
- output_asm_insn (\"movel %1,sp@@\", xoperands);
- output_asm_insn (\"movel %1,sp@@-\", operands);
- return \"fmoved sp@@+,%0\";
+ output_asm_insn ("movel %1,sp@@", xoperands);
+ output_asm_insn ("movel %1,sp@@-", operands);
+ return "fmoved sp@@+,%0";
#endif
-@}
-")
+@})
@end smallexample
@need 1000
@@ -4656,11 +4676,10 @@ as follows:
[(set (pc)
(label_ref (match_operand 0 "" "")))]
""
- "*
@{
return (get_attr_length (insn) == 4
- ? \"b %l0\" : \"l r15,=a(%l0); br r15\");
-@}"
+ ? "b %l0" : "l r15,=a(%l0); br r15");
+@}
[(set (attr "length") (if_then_else (lt (match_dup 0) (const_int 4096))
(const_int 4)
(const_int 6)))])
diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
index dbd3691..618322a 100644
--- a/gcc/doc/rtl.texi
+++ b/gcc/doc/rtl.texi
@@ -70,6 +70,21 @@ pointers instead of strings are valid. Within RTL code, strings are most
commonly found inside @code{symbol_ref} expressions, but they appear in
other contexts in the RTL expressions that make up machine descriptions.
+In a machine description, strings are normally written with double
+quotes, as you would in C. However, strings in machine descriptions may
+extend over many lines, which is invalid C, and adjacent string
+constants are not concatenated as they are in C. Any string constant
+may be surrounded with a single set of parentheses. Sometimes this
+makes the machine description easier to read.
+
+There is also a special syntax for strings, which can be useful when C
+code is embedded in a machine description. Wherever a string can
+appear, it is also valid to write a C-style brace block. The entire
+brace block, including the outermost pair of braces, is considered to be
+the string constant. Double quote characters inside the braces are not
+special. Therefore, if you write string constants in the C code, you
+need not escape each quote character with a backslash.
+
A vector contains an arbitrary number of pointers to expressions. The
number of elements in the vector is explicitly present in the vector.
The written form of a vector consists of square brackets
@@ -3182,11 +3197,10 @@ combiner is finished with the insn. This is done by calling
@section Reading RTL
To read an RTL object from a file, call @code{read_rtx}. It takes one
-argument, a stdio stream, and returns a single RTL object.
-
-Reading RTL from a file is very slow. This is not currently a
-problem since reading RTL occurs only as part of building the
-compiler.
+argument, a stdio stream, and returns a single RTL object. This routine
+is defined in @file{read-rtl.c}. It is not available in the compiler
+itself, only the various programs that generate the compiler back end
+from the machine description.
People frequently have the idea of using RTL stored as text in a file as
an interface between a language front end and the bulk of GCC@. This