Commit 0f40f9f7 by Zack Weinberg

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
parent 0168a849
2001-06-28 Zack Weinberg <zackw@stanford.edu>
* 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.
2001-06-28 Stan Shebs <shebs@apple.com> 2001-06-28 Stan Shebs <shebs@apple.com>
* config/darwin.h (REGISTER_TARGET_PRAGMAS): Define. * config/darwin.h (REGISTER_TARGET_PRAGMAS): Define.
......
...@@ -633,7 +633,7 @@ LIBS = $(OBSTACK) $(INTLLIBS) @LIBS@ $(VFPRINTF) $(DOPRINT) \ ...@@ -633,7 +633,7 @@ LIBS = $(OBSTACK) $(INTLLIBS) @LIBS@ $(VFPRINTF) $(DOPRINT) \
HOST_LIBS = $(USE_HOST_OBSTACK) $(USE_HOST_VFPRINTF) \ HOST_LIBS = $(USE_HOST_OBSTACK) $(USE_HOST_VFPRINTF) \
$(USE_HOST_DOPRINT) $(USE_HOST_STRSTR) $(USE_HOST_DOPRINT) $(USE_HOST_STRSTR)
HOST_RTL = $(HOST_PREFIX)rtl.o $(HOST_PREFIX)bitmap.o \ HOST_RTL = $(HOST_PREFIX)rtl.o read-rtl.o $(HOST_PREFIX)bitmap.o \
$(HOST_PREFIX)ggc-none.o gensupport.o hashtab.o safe-ctype.o $(HOST_PREFIX)ggc-none.o gensupport.o hashtab.o safe-ctype.o
HOST_PRINT = $(HOST_PREFIX)print-rtl.o HOST_PRINT = $(HOST_PREFIX)print-rtl.o
...@@ -1344,12 +1344,13 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) function.h \ ...@@ -1344,12 +1344,13 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) function.h \
-c $(srcdir)/toplev.c -c $(srcdir)/toplev.c
main.o : main.c toplev.h main.o : main.c toplev.h
rtl.o : rtl.c $(GCONFIG_H) $(SYSTEM_H) $(RTL_H) bitmap.h $(GGC_H) toplev.h rtl.o : rtl.c $(GCONFIG_H) $(SYSTEM_H) $(RTL_H) real.h $(GGC_H)
$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) $(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
print-rtl.o : print-rtl.c $(GCONFIG_H) $(SYSTEM_H) $(RTL_H) hard-reg-set.h \ print-rtl.o : print-rtl.c $(GCONFIG_H) $(SYSTEM_H) $(RTL_H) hard-reg-set.h \
$(BASIC_BLOCK_H) $(BASIC_BLOCK_H)
$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) $(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
rtlanal.o : rtlanal.c $(CONFIG_H) $(SYSTEM_H) toplev.h $(RTL_H) hard-reg-set.h rtlanal.o : rtlanal.c $(CONFIG_H) $(SYSTEM_H) toplev.h $(RTL_H) hard-reg-set.h
errors.o : errors.c $(GCONFIG_H) $(SYSTEM_H) errors.h errors.o : errors.c $(GCONFIG_H) $(SYSTEM_H) errors.h
$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) $(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
...@@ -1704,6 +1705,10 @@ s-genrtl: gengenrtl$(build_exeext) $(srcdir)/move-if-change $(RTL_BASE_H) ...@@ -1704,6 +1705,10 @@ s-genrtl: gengenrtl$(build_exeext) $(srcdir)/move-if-change $(RTL_BASE_H)
# about the target machine. They do depend on config.h itself, # about the target machine. They do depend on config.h itself,
# since that describes the host machine. # since that describes the host machine.
read-rtl.o: read-rtl.c $(HCONFIG_H) $(SYSTEM_H) $(RTL_H) \
$(OBSTACK_H) $(HASHTAB_H)
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/read-rtl.c
gensupport.o: gensupport.c $(RTL_H) $(OBSTACK_H) $(SYSTEM_H) errors.h gensupport.h gensupport.o: gensupport.c $(RTL_H) $(OBSTACK_H) $(SYSTEM_H) errors.h gensupport.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gensupport.c $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gensupport.c
...@@ -1814,7 +1819,7 @@ gengenrtl.o : gengenrtl.c $(RTL_BASE_H) $(HCONFIG_H) $(SYSTEM_H) real.h ...@@ -1814,7 +1819,7 @@ gengenrtl.o : gengenrtl.c $(RTL_BASE_H) $(HCONFIG_H) $(SYSTEM_H) real.h
# and HOST_PREFIX_1 is `foobar', just to ensure these rules don't conflict # and HOST_PREFIX_1 is `foobar', just to ensure these rules don't conflict
# with the rules for rtl.o, etc. # with the rules for rtl.o, etc.
$(HOST_PREFIX_1)rtl.o: $(srcdir)/rtl.c $(HCONFIG_H) $(SYSTEM_H) $(RTL_H) \ $(HOST_PREFIX_1)rtl.o: $(srcdir)/rtl.c $(HCONFIG_H) $(SYSTEM_H) $(RTL_H) \
bitmap.h $(GGC_H) toplev.h $(HASHTAB_H) $(GGC_H)
rm -f $(HOST_PREFIX)rtl.c rm -f $(HOST_PREFIX)rtl.c
sed -e 's/config[.]h/hconfig.h/' $(srcdir)/rtl.c > $(HOST_PREFIX)rtl.c sed -e 's/config[.]h/hconfig.h/' $(srcdir)/rtl.c > $(HOST_PREFIX)rtl.c
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)rtl.c $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)rtl.c
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3724,6 +3724,10 @@ and @file{rtl.def}, and subroutines in file @file{rtl.c}. The tools ...@@ -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 @code{gen*} also use these files to read and work with the machine
description RTL@. 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 @findex genconfig
@item @item
Several passes refer to the header file @file{insn-config.h} which Several passes refer to the header file @file{insn-config.h} which
......
...@@ -184,9 +184,26 @@ Here is an actual example of an instruction pattern, for the 68000/68020. ...@@ -184,9 +184,26 @@ Here is an actual example of an instruction pattern, for the 68000/68020.
(match_operand:SI 0 "general_operand" "rm"))] (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 \"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 @end example
This is an instruction that sets the condition codes based on the value of 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 ...@@ -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 require doublequote characters to delimit them. To include these
doublequote characters in the string, prefix each one with @samp{\}. 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 The operands may be found in the array @code{operands}, whose C data type
is @code{rtx []}. is @code{rtx []}.
...@@ -656,10 +678,10 @@ a pattern could use @code{which_alternative} to choose between them: ...@@ -656,10 +678,10 @@ a pattern could use @code{which_alternative} to choose between them:
[(set (match_operand:SI 0 "general_operand" "=r,m") [(set (match_operand:SI 0 "general_operand" "=r,m")
(const_int 0))] (const_int 0))]
"" ""
"* @{
return (which_alternative == 0 return (which_alternative == 0
? \"clrreg %0\" : \"clrmem %0\"); ? "clrreg %0" : "clrmem %0");
") @})
@end smallexample @end smallexample
The example above, where the assembler code to generate was The example above, where the assembler code to generate was
...@@ -3943,21 +3965,19 @@ Here is an example, taken from the 68000 machine description: ...@@ -3943,21 +3965,19 @@ Here is an example, taken from the 68000 machine description:
(set (match_operand:DF 0 "register_operand" "=f") (set (match_operand:DF 0 "register_operand" "=f")
(match_operand:DF 1 "register_operand" "ad"))] (match_operand:DF 1 "register_operand" "ad"))]
"FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])" "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
"*
@{ @{
rtx xoperands[2]; rtx xoperands[2];
xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
#ifdef MOTOROLA #ifdef MOTOROLA
output_asm_insn (\"move.l %1,(sp)\", xoperands); output_asm_insn ("move.l %1,(sp)", xoperands);
output_asm_insn (\"move.l %1,-(sp)\", operands); output_asm_insn ("move.l %1,-(sp)", operands);
return \"fmove.d (sp)+,%0\"; return "fmove.d (sp)+,%0";
#else #else
output_asm_insn (\"movel %1,sp@@\", xoperands); output_asm_insn ("movel %1,sp@@", xoperands);
output_asm_insn (\"movel %1,sp@@-\", operands); output_asm_insn ("movel %1,sp@@-", operands);
return \"fmoved sp@@+,%0\"; return "fmoved sp@@+,%0";
#endif #endif
@} @})
")
@end smallexample @end smallexample
@need 1000 @need 1000
...@@ -4656,11 +4676,10 @@ as follows: ...@@ -4656,11 +4676,10 @@ as follows:
[(set (pc) [(set (pc)
(label_ref (match_operand 0 "" "")))] (label_ref (match_operand 0 "" "")))]
"" ""
"*
@{ @{
return (get_attr_length (insn) == 4 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)) [(set (attr "length") (if_then_else (lt (match_dup 0) (const_int 4096))
(const_int 4) (const_int 4)
(const_int 6)))]) (const_int 6)))])
......
...@@ -70,6 +70,21 @@ pointers instead of strings are valid. Within RTL code, strings are most ...@@ -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 commonly found inside @code{symbol_ref} expressions, but they appear in
other contexts in the RTL expressions that make up machine descriptions. 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 A vector contains an arbitrary number of pointers to expressions. The
number of elements in the vector is explicitly present in the vector. number of elements in the vector is explicitly present in the vector.
The written form of a vector consists of square brackets 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 ...@@ -3182,11 +3197,10 @@ combiner is finished with the insn. This is done by calling
@section Reading RTL @section Reading RTL
To read an RTL object from a file, call @code{read_rtx}. It takes one 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. 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
Reading RTL from a file is very slow. This is not currently a itself, only the various programs that generate the compiler back end
problem since reading RTL occurs only as part of building the from the machine description.
compiler.
People frequently have the idea of using RTL stored as text in a file as 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 an interface between a language front end and the bulk of GCC@. This
......
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment