Commit f30990b2 by Ian Lance Taylor Committed by Ian Lance Taylor

read-rtl.c (struct macro_traverse_data): Define.

	* read-rtl.c (struct macro_traverse_data): Define.
	(map_attr_string): New static function, broken out of
	apply_macro_to_string.
	(mode_attr_index, apply_mode_maps): New static functions.
	(apply_macro_to_string): Call map_attr_string.
	(apply_macro_to_rtx): Add mode_maps and infile parameters.  Change
	all callers.
	(apply_macro_traverse): Expect data to point to a struct
	macro_traverse_data.
	(read_rtx): Add mode_maps local variable.  Use mode_traverse_data
	to pass data through htab_traverse.
	(read_rtx_1): Add mode_maps parameter.  Change all callers.
	Handle mode names which are attribute strings.
	* doc/md.texi (Substitutions): Rename from String Substitutions.
	Change references.  Document using attributes as modes.

From-SVN: r99548
parent 5deaef19
2005-05-10 Ian Lance Taylor <ian@airs.com>
* read-rtl.c (struct macro_traverse_data): Define.
(map_attr_string): New static function, broken out of
apply_macro_to_string.
(mode_attr_index, apply_mode_maps): New static functions.
(apply_macro_to_string): Call map_attr_string.
(apply_macro_to_rtx): Add mode_maps and infile parameters. Change
all callers.
(apply_macro_traverse): Expect data to point to a struct
macro_traverse_data.
(read_rtx): Add mode_maps local variable. Use mode_traverse_data
to pass data through htab_traverse.
(read_rtx_1): Add mode_maps parameter. Change all callers.
Handle mode names which are attribute strings.
* doc/md.texi (Substitutions): Rename from String Substitutions.
Change references. Document using attributes as modes.
2005-05-10 Zdenek Dvorak <dvorakz@suse.cz> 2005-05-10 Zdenek Dvorak <dvorakz@suse.cz>
* tree-cfg.c (tree_duplicate_sese_region): Update profile. * tree-cfg.c (tree_duplicate_sese_region): Update profile.
......
...@@ -6718,7 +6718,7 @@ rtx-based construct, such as a @code{define_insn}, ...@@ -6718,7 +6718,7 @@ rtx-based construct, such as a @code{define_insn},
@menu @menu
* Defining Mode Macros:: Defining a new mode macro. * Defining Mode Macros:: Defining a new mode macro.
* String Substitutions:: Combining mode macros with string substitutions * Substitutions:: Combining mode macros with substitutions
* Examples:: Examples * Examples:: Examples
@end menu @end menu
...@@ -6764,14 +6764,15 @@ but that the @code{:SI} expansion has no such constraint. ...@@ -6764,14 +6764,15 @@ but that the @code{:SI} expansion has no such constraint.
Macros are applied in the order they are defined. This can be Macros are applied in the order they are defined. This can be
significant if two macros are used in a construct that requires significant if two macros are used in a construct that requires
string substitutions. @xref{String Substitutions}. substitutions. @xref{Substitutions}.
@node String Substitutions @node Substitutions
@subsubsection String Substitution in Mode Macros @subsubsection Substitution in Mode Macros
@findex define_mode_attr @findex define_mode_attr
If an @file{.md} file construct uses mode macros, each version of the If an @file{.md} file construct uses mode macros, each version of the
construct will often need slightly different strings. For example: construct will often need slightly different strings or modes. For
example:
@itemize @bullet @itemize @bullet
@item @item
...@@ -6782,6 +6783,11 @@ appropriate mode name for @var{m}. ...@@ -6782,6 +6783,11 @@ appropriate mode name for @var{m}.
@item @item
When a @code{define_insn} defines several instruction patterns, When a @code{define_insn} defines several instruction patterns,
each instruction will often use a different assembler mnemonic. each instruction will often use a different assembler mnemonic.
@item
When a @code{define_insn} requires operands with different modes,
using a macro for one of the operand modes usually requires a specific
mode for the other operand(s).
@end itemize @end itemize
GCC supports such variations through a system of ``mode attributes''. GCC supports such variations through a system of ``mode attributes''.
...@@ -6796,12 +6802,12 @@ upper case. You can define other attributes using: ...@@ -6796,12 +6802,12 @@ upper case. You can define other attributes using:
where @var{name} is the name of the attribute and @var{valuei} where @var{name} is the name of the attribute and @var{valuei}
is the value associated with @var{modei}. is the value associated with @var{modei}.
When GCC replaces some @var{:macro} with @var{:mode}, it will When GCC replaces some @var{:macro} with @var{:mode}, it will scan
scan each string in the pattern for sequences of the form each string and mode in the pattern for sequences of the form
@code{<@var{macro}:@var{attr}>}, where @var{attr} is the name of @code{<@var{macro}:@var{attr}>}, where @var{attr} is the name of a
a mode attribute. If the attribute is defined for @var{mode}, the mode attribute. If the attribute is defined for @var{mode}, the whole
whole @code{<...>} sequence will be replaced by the appropriate @code{<...>} sequence will be replaced by the appropriate attribute
attribute value. value.
For example, suppose an @file{.md} file has: For example, suppose an @file{.md} file has:
...@@ -6815,6 +6821,15 @@ If one of the patterns that uses @code{:P} contains the string ...@@ -6815,6 +6821,15 @@ If one of the patterns that uses @code{:P} contains the string
will use @code{"lw\t%0,%1"} and the @code{DI} version will use will use @code{"lw\t%0,%1"} and the @code{DI} version will use
@code{"ld\t%0,%1"}. @code{"ld\t%0,%1"}.
Here is an example of using an attribute for a mode:
@smallexample
(define_mode_macro LONG [SI DI])
(define_mode_attr SHORT [(SI "HI") (DI "SI")])
(define_insn ...
(sign_extend:LONG (match_operand:<LONG:SHORT> ...)) ...)
@end smallexample
The @code{@var{macro}:} prefix may be omitted, in which case the The @code{@var{macro}:} prefix may be omitted, in which case the
substitution will be attempted for every macro expansion. substitution will be attempted for every macro expansion.
......
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