2 Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003, 2004, 2005, 2007, 2008, 2010
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 /* Disable rtl checking; it conflicts with the iterator handling. */
25 #undef ENABLE_RTL_CHECKING
28 #include "coretypes.h"
34 #include "gensupport.h"
36 /* One element in a singly-linked list of (integer, string) pairs. */
38 struct map_value
*next
;
43 /* Maps an iterator or attribute name to a list of (integer, string) pairs.
44 The integers are iterator values; the strings are either C conditions
45 or attribute values. */
47 /* The name of the iterator or attribute. */
50 /* The group (modes or codes) to which the iterator or attribute belongs. */
51 struct iterator_group
*group
;
53 /* The list of (integer, string) pairs. */
54 struct map_value
*values
;
56 /* For iterators, records the current value of the iterator. */
57 struct map_value
*current_value
;
60 /* Vector definitions for the above. */
61 typedef struct mapping
*mapping_ptr
;
63 /* A structure for abstracting the common parts of iterators. */
64 struct iterator_group
{
65 /* Tables of "mapping" structures, one for attributes and one for
67 htab_t attrs
, iterators
;
69 /* Treat the given string as the name of a standard mode, etc., and
70 return its integer value. */
71 int (*find_builtin
) (const char *);
73 /* Make the given pointer use the given iterator value. */
74 void (*apply_iterator
) (void *, int);
77 /* Records one use of an iterator. */
79 /* The iterator itself. */
80 struct mapping
*iterator
;
82 /* The location of the use, as passed to the apply_iterator callback. */
86 /* Vector definitions for the above. */
87 typedef struct iterator_use iterator_use
;
89 /* Records one use of an attribute (the "<[iterator:]attribute>" syntax)
90 in a non-string rtx field. */
91 struct attribute_use
{
92 /* The group that describes the use site. */
93 struct iterator_group
*group
;
95 /* The name of the attribute, possibly with an "iterator:" prefix. */
98 /* The location of the use, as passed to GROUP's apply_iterator callback. */
102 /* Vector definitions for the above. */
103 typedef struct attribute_use attribute_use
;
105 static void validate_const_int (const char *);
106 static rtx
read_rtx_code (const char *);
107 static rtx
read_nested_rtx (void);
108 static rtx
read_rtx_variadic (rtx
);
110 /* The mode and code iterator structures. */
111 static struct iterator_group modes
, codes
, ints
;
113 /* All iterators used in the current rtx. */
114 static vec
<mapping_ptr
> current_iterators
;
116 /* The list of all iterator uses in the current rtx. */
117 static vec
<iterator_use
> iterator_uses
;
119 /* The list of all attribute uses in the current rtx. */
120 static vec
<attribute_use
> attribute_uses
;
122 /* Implementations of the iterator_group callbacks for modes. */
125 find_mode (const char *name
)
129 for (i
= 0; i
< NUM_MACHINE_MODES
; i
++)
130 if (strcmp (GET_MODE_NAME (i
), name
) == 0)
133 fatal_with_file_and_line ("unknown mode `%s'", name
);
137 apply_mode_iterator (void *loc
, int mode
)
139 PUT_MODE ((rtx
) loc
, (enum machine_mode
) mode
);
142 /* Implementations of the iterator_group callbacks for codes. */
145 find_code (const char *name
)
149 for (i
= 0; i
< NUM_RTX_CODE
; i
++)
150 if (strcmp (GET_RTX_NAME (i
), name
) == 0)
153 fatal_with_file_and_line ("unknown rtx code `%s'", name
);
157 apply_code_iterator (void *loc
, int code
)
159 PUT_CODE ((rtx
) loc
, (enum rtx_code
) code
);
162 /* Implementations of the iterator_group callbacks for ints. */
164 /* Since GCC does not construct a table of valid constants,
165 we have to accept any int as valid. No cross-checking can
169 find_int (const char *name
)
171 validate_const_int (name
);
176 apply_int_iterator (void *loc
, int value
)
181 /* Map attribute string P to its current value. Return null if the attribute
184 static struct map_value
*
185 map_attr_string (const char *p
)
188 struct mapping
*iterator
;
192 int iterator_name_len
;
194 /* Peel off any "iterator:" prefix. Set ATTR to the start of the
196 attr
= strchr (p
, ':');
199 iterator_name_len
= -1;
204 iterator_name_len
= attr
- p
;
208 FOR_EACH_VEC_ELT (current_iterators
, i
, iterator
)
210 /* If an iterator name was specified, check that it matches. */
211 if (iterator_name_len
>= 0
212 && (strncmp (p
, iterator
->name
, iterator_name_len
) != 0
213 || iterator
->name
[iterator_name_len
] != 0))
216 /* Find the attribute specification. */
217 m
= (struct mapping
*) htab_find (iterator
->group
->attrs
, &attr
);
219 /* Find the attribute value associated with the current
221 for (v
= m
->values
; v
; v
= v
->next
)
222 if (v
->number
== iterator
->current_value
->number
)
228 /* Apply the current iterator values to STRING. Return the new string
229 if any changes were needed, otherwise return STRING itself. */
232 apply_iterator_to_string (const char *string
)
234 char *base
, *copy
, *p
, *start
, *end
;
240 base
= p
= copy
= ASTRDUP (string
);
241 while ((start
= strchr (p
, '<')) && (end
= strchr (start
, '>')))
246 v
= map_attr_string (p
);
251 /* Add everything between the last copied byte and the '<',
252 then add in the attribute value. */
253 obstack_grow (&string_obstack
, base
, start
- base
);
254 obstack_grow (&string_obstack
, v
->string
, strlen (v
->string
));
259 obstack_grow (&string_obstack
, base
, strlen (base
) + 1);
260 copy
= XOBFINISH (&string_obstack
, char *);
261 copy_md_ptr_loc (copy
, string
);
267 /* Return a deep copy of X, substituting the current iterator
268 values into any strings. */
271 copy_rtx_for_iterators (rtx original
)
273 const char *format_ptr
;
280 /* Create a shallow copy of ORIGINAL. */
281 x
= rtx_alloc (GET_CODE (original
));
282 memcpy (x
, original
, RTX_CODE_SIZE (GET_CODE (original
)));
284 /* Change each string and recursively change each rtx. */
285 format_ptr
= GET_RTX_FORMAT (GET_CODE (original
));
286 for (i
= 0; format_ptr
[i
] != 0; i
++)
287 switch (format_ptr
[i
])
290 XTMPL (x
, i
) = apply_iterator_to_string (XTMPL (x
, i
));
295 XSTR (x
, i
) = apply_iterator_to_string (XSTR (x
, i
));
299 XEXP (x
, i
) = copy_rtx_for_iterators (XEXP (x
, i
));
304 if (XVEC (original
, i
))
306 XVEC (x
, i
) = rtvec_alloc (XVECLEN (original
, i
));
307 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
309 = copy_rtx_for_iterators (XVECEXP (original
, i
, j
));
319 /* Return a condition that must satisfy both ORIGINAL and EXTRA. If ORIGINAL
320 has the form "&& ..." (as used in define_insn_and_splits), assume that
321 EXTRA is already satisfied. Empty strings are treated like "true". */
324 add_condition_to_string (const char *original
, const char *extra
)
326 if (original
!= 0 && original
[0] == '&' && original
[1] == '&')
328 return join_c_conditions (original
, extra
);
331 /* Like add_condition, but applied to all conditions in rtx X. */
334 add_condition_to_rtx (rtx x
, const char *extra
)
336 switch (GET_CODE (x
))
340 XSTR (x
, 2) = add_condition_to_string (XSTR (x
, 2), extra
);
344 case DEFINE_PEEPHOLE
:
345 case DEFINE_PEEPHOLE2
:
346 case DEFINE_COND_EXEC
:
347 XSTR (x
, 1) = add_condition_to_string (XSTR (x
, 1), extra
);
350 case DEFINE_INSN_AND_SPLIT
:
351 XSTR (x
, 2) = add_condition_to_string (XSTR (x
, 2), extra
);
352 XSTR (x
, 4) = add_condition_to_string (XSTR (x
, 4), extra
);
360 /* Apply the current iterator values to all attribute_uses. */
363 apply_attribute_uses (void)
369 FOR_EACH_VEC_ELT (attribute_uses
, i
, ause
)
371 v
= map_attr_string (ause
->value
);
373 fatal_with_file_and_line ("unknown iterator value `%s'", ause
->value
);
374 ause
->group
->apply_iterator (ause
->ptr
,
375 ause
->group
->find_builtin (v
->string
));
379 /* A htab_traverse callback for iterators. Add all used iterators
380 to current_iterators. */
383 add_current_iterators (void **slot
, void *data ATTRIBUTE_UNUSED
)
385 struct mapping
*iterator
;
387 iterator
= (struct mapping
*) *slot
;
388 if (iterator
->current_value
)
389 current_iterators
.safe_push (iterator
);
393 /* Expand all iterators in the current rtx, which is given as ORIGINAL.
394 Build a list of expanded rtxes in the EXPR_LIST pointed to by QUEUE. */
397 apply_iterators (rtx original
, rtx
*queue
)
400 const char *condition
;
402 struct mapping
*iterator
;
406 if (iterator_uses
.is_empty ())
408 /* Raise an error if any attributes were used. */
409 apply_attribute_uses ();
410 XEXP (*queue
, 0) = original
;
411 XEXP (*queue
, 1) = NULL_RTX
;
415 /* Clear out the iterators from the previous run. */
416 FOR_EACH_VEC_ELT (current_iterators
, i
, iterator
)
417 iterator
->current_value
= NULL
;
418 current_iterators
.truncate (0);
420 /* Mark the iterators that we need this time. */
421 FOR_EACH_VEC_ELT (iterator_uses
, i
, iuse
)
422 iuse
->iterator
->current_value
= iuse
->iterator
->values
;
424 /* Get the list of iterators that are in use, preserving the
425 definition order within each group. */
426 htab_traverse (modes
.iterators
, add_current_iterators
, NULL
);
427 htab_traverse (codes
.iterators
, add_current_iterators
, NULL
);
428 htab_traverse (ints
.iterators
, add_current_iterators
, NULL
);
429 gcc_assert (!current_iterators
.is_empty ());
433 /* Apply the current iterator values. Accumulate a condition to
434 say when the resulting rtx can be used. */
436 FOR_EACH_VEC_ELT (iterator_uses
, i
, iuse
)
438 v
= iuse
->iterator
->current_value
;
439 iuse
->iterator
->group
->apply_iterator (iuse
->ptr
, v
->number
);
440 condition
= join_c_conditions (condition
, v
->string
);
442 apply_attribute_uses ();
443 x
= copy_rtx_for_iterators (original
);
444 add_condition_to_rtx (x
, condition
);
446 /* Add the new rtx to the end of the queue. */
447 XEXP (*queue
, 0) = x
;
448 XEXP (*queue
, 1) = NULL_RTX
;
450 /* Lexicographically increment the iterator value sequence.
451 That is, cycle through iterator values, starting from the right,
452 and stopping when one of them doesn't wrap around. */
453 i
= current_iterators
.length ();
459 iterator
= current_iterators
[i
];
460 iterator
->current_value
= iterator
->current_value
->next
;
461 if (iterator
->current_value
)
463 iterator
->current_value
= iterator
->values
;
466 /* At least one more rtx to go. Allocate room for it. */
467 XEXP (*queue
, 1) = rtx_alloc (EXPR_LIST
);
468 queue
= &XEXP (*queue
, 1);
472 /* Add a new "mapping" structure to hashtable TABLE. NAME is the name
473 of the mapping and GROUP is the group to which it belongs. */
475 static struct mapping
*
476 add_mapping (struct iterator_group
*group
, htab_t table
, const char *name
)
481 m
= XNEW (struct mapping
);
482 m
->name
= xstrdup (name
);
485 m
->current_value
= NULL
;
487 slot
= htab_find_slot (table
, m
, INSERT
);
489 fatal_with_file_and_line ("`%s' already defined", name
);
495 /* Add the pair (NUMBER, STRING) to a list of map_value structures.
496 END_PTR points to the current null terminator for the list; return
497 a pointer the new null terminator. */
499 static struct map_value
**
500 add_map_value (struct map_value
**end_ptr
, int number
, const char *string
)
502 struct map_value
*value
;
504 value
= XNEW (struct map_value
);
506 value
->number
= number
;
507 value
->string
= string
;
513 /* Do one-time initialization of the mode and code attributes. */
516 initialize_iterators (void)
518 struct mapping
*lower
, *upper
;
519 struct map_value
**lower_ptr
, **upper_ptr
;
523 modes
.attrs
= htab_create (13, leading_string_hash
, leading_string_eq_p
, 0);
524 modes
.iterators
= htab_create (13, leading_string_hash
,
525 leading_string_eq_p
, 0);
526 modes
.find_builtin
= find_mode
;
527 modes
.apply_iterator
= apply_mode_iterator
;
529 codes
.attrs
= htab_create (13, leading_string_hash
, leading_string_eq_p
, 0);
530 codes
.iterators
= htab_create (13, leading_string_hash
,
531 leading_string_eq_p
, 0);
532 codes
.find_builtin
= find_code
;
533 codes
.apply_iterator
= apply_code_iterator
;
535 ints
.attrs
= htab_create (13, leading_string_hash
, leading_string_eq_p
, 0);
536 ints
.iterators
= htab_create (13, leading_string_hash
,
537 leading_string_eq_p
, 0);
538 ints
.find_builtin
= find_int
;
539 ints
.apply_iterator
= apply_int_iterator
;
541 lower
= add_mapping (&modes
, modes
.attrs
, "mode");
542 upper
= add_mapping (&modes
, modes
.attrs
, "MODE");
543 lower_ptr
= &lower
->values
;
544 upper_ptr
= &upper
->values
;
545 for (i
= 0; i
< MAX_MACHINE_MODE
; i
++)
547 copy
= xstrdup (GET_MODE_NAME (i
));
548 for (p
= copy
; *p
!= 0; p
++)
551 upper_ptr
= add_map_value (upper_ptr
, i
, GET_MODE_NAME (i
));
552 lower_ptr
= add_map_value (lower_ptr
, i
, copy
);
555 lower
= add_mapping (&codes
, codes
.attrs
, "code");
556 upper
= add_mapping (&codes
, codes
.attrs
, "CODE");
557 lower_ptr
= &lower
->values
;
558 upper_ptr
= &upper
->values
;
559 for (i
= 0; i
< NUM_RTX_CODE
; i
++)
561 copy
= xstrdup (GET_RTX_NAME (i
));
562 for (p
= copy
; *p
!= 0; p
++)
565 lower_ptr
= add_map_value (lower_ptr
, i
, GET_RTX_NAME (i
));
566 upper_ptr
= add_map_value (upper_ptr
, i
, copy
);
570 /* Provide a version of a function to read a long long if the system does
572 #if HOST_BITS_PER_WIDE_INT > HOST_BITS_PER_LONG && !defined(HAVE_ATOLL) && !defined(HAVE_ATOQ)
573 HOST_WIDE_INT
atoll (const char *);
576 atoll (const char *p
)
579 HOST_WIDE_INT tmp_wide
;
591 HOST_WIDE_INT new_wide
= tmp_wide
*10 + (*p
- '0');
592 if (new_wide
< tmp_wide
)
594 /* Return INT_MAX equiv on overflow. */
595 tmp_wide
= (~(unsigned HOST_WIDE_INT
) 0) >> 1;
603 tmp_wide
= -tmp_wide
;
608 /* Process a define_conditions directive, starting with the optional
609 space after the "define_conditions". The directive looks like this:
617 It's not intended to appear in machine descriptions. It is
618 generated by (the program generated by) genconditions.c, and
619 slipped in at the beginning of the sequence of MD files read by
620 most of the other generators. */
622 read_conditions (void)
626 c
= read_skip_spaces ();
628 fatal_expected_char ('[', c
);
630 while ( (c
= read_skip_spaces ()) != ']')
637 fatal_expected_char ('(', c
);
640 validate_const_int (name
.string
);
641 value
= atoi (name
.string
);
643 c
= read_skip_spaces ();
645 fatal_expected_char ('"', c
);
646 expr
= read_quoted_string ();
648 c
= read_skip_spaces ();
650 fatal_expected_char (')', c
);
652 add_c_test (expr
, value
);
657 validate_const_int (const char *string
)
663 while (*cp
&& ISSPACE (*cp
))
665 if (*cp
== '-' || *cp
== '+')
673 fatal_with_file_and_line ("invalid decimal constant \"%s\"\n", string
);
676 /* Record that PTR uses iterator ITERATOR. */
679 record_iterator_use (struct mapping
*iterator
, void *ptr
)
681 struct iterator_use iuse
= {iterator
, ptr
};
682 iterator_uses
.safe_push (iuse
);
685 /* Record that PTR uses attribute VALUE, which must match a built-in
686 value from group GROUP. */
689 record_attribute_use (struct iterator_group
*group
, void *ptr
,
692 struct attribute_use ause
= {group
, value
, ptr
};
693 attribute_uses
.safe_push (ause
);
696 /* Interpret NAME as either a built-in value, iterator or attribute
697 for group GROUP. PTR is the value to pass to GROUP's apply_iterator
701 record_potential_iterator_use (struct iterator_group
*group
, void *ptr
,
708 if (name
[0] == '<' && name
[len
- 1] == '>')
710 /* Copy the attribute string into permanent storage, without the
711 angle brackets around it. */
712 obstack_grow0 (&string_obstack
, name
+ 1, len
- 2);
713 record_attribute_use (group
, ptr
, XOBFINISH (&string_obstack
, char *));
717 m
= (struct mapping
*) htab_find (group
->iterators
, &name
);
719 record_iterator_use (m
, ptr
);
721 group
->apply_iterator (ptr
, group
->find_builtin (name
));
725 /* Finish reading a declaration of the form:
727 (define... <name> [<value1> ... <valuen>])
729 from the MD file, where each <valuei> is either a bare symbol name or a
730 "(<name> <string>)" pair. The "(define..." part has already been read.
732 Represent the declaration as a "mapping" structure; add it to TABLE
733 (which belongs to GROUP) and return it. */
735 static struct mapping
*
736 read_mapping (struct iterator_group
*group
, htab_t table
)
740 struct map_value
**end_ptr
;
744 /* Read the mapping name and create a structure for it. */
746 m
= add_mapping (group
, table
, name
.string
);
748 c
= read_skip_spaces ();
750 fatal_expected_char ('[', c
);
752 /* Read each value. */
753 end_ptr
= &m
->values
;
754 c
= read_skip_spaces ();
759 /* A bare symbol name that is implicitly paired to an
767 /* A "(name string)" pair. */
769 string
= read_string (false);
770 c
= read_skip_spaces ();
772 fatal_expected_char (')', c
);
774 number
= group
->find_builtin (name
.string
);
775 end_ptr
= add_map_value (end_ptr
, number
, string
);
776 c
= read_skip_spaces ();
783 /* Check newly-created code iterator ITERATOR to see whether every code has the
787 check_code_iterator (struct mapping
*iterator
)
790 enum rtx_code bellwether
;
792 bellwether
= (enum rtx_code
) iterator
->values
->number
;
793 for (v
= iterator
->values
->next
; v
!= 0; v
= v
->next
)
794 if (strcmp (GET_RTX_FORMAT (bellwether
), GET_RTX_FORMAT (v
->number
)) != 0)
795 fatal_with_file_and_line ("code iterator `%s' combines "
796 "different rtx formats", iterator
->name
);
799 /* Read an rtx-related declaration from the MD file, given that it
800 starts with directive name RTX_NAME. Return true if it expands to
801 one or more rtxes (as defined by rtx.def). When returning true,
802 store the list of rtxes as an EXPR_LIST in *X. */
805 read_rtx (const char *rtx_name
, rtx
*x
)
807 static rtx queue_head
;
809 /* Do one-time initialization. */
812 initialize_iterators ();
813 queue_head
= rtx_alloc (EXPR_LIST
);
816 /* Handle various rtx-related declarations that aren't themselves
818 if (strcmp (rtx_name
, "define_conditions") == 0)
823 if (strcmp (rtx_name
, "define_mode_attr") == 0)
825 read_mapping (&modes
, modes
.attrs
);
828 if (strcmp (rtx_name
, "define_mode_iterator") == 0)
830 read_mapping (&modes
, modes
.iterators
);
833 if (strcmp (rtx_name
, "define_code_attr") == 0)
835 read_mapping (&codes
, codes
.attrs
);
838 if (strcmp (rtx_name
, "define_code_iterator") == 0)
840 check_code_iterator (read_mapping (&codes
, codes
.iterators
));
843 if (strcmp (rtx_name
, "define_int_attr") == 0)
845 read_mapping (&ints
, ints
.attrs
);
848 if (strcmp (rtx_name
, "define_int_iterator") == 0)
850 read_mapping (&ints
, ints
.iterators
);
854 apply_iterators (read_rtx_code (rtx_name
), &queue_head
);
855 iterator_uses
.truncate (0);
856 attribute_uses
.truncate (0);
862 /* Subroutine of read_rtx and read_nested_rtx. CODE_NAME is the name of
863 either an rtx code or a code iterator. Parse the rest of the rtx and
867 read_rtx_code (const char *code_name
)
871 struct mapping
*iterator
;
872 const char *format_ptr
;
876 HOST_WIDE_INT tmp_wide
;
878 /* Linked list structure for making RTXs: */
881 struct rtx_list
*next
;
882 rtx value
; /* Value of this node. */
885 /* If this code is an iterator, build the rtx using the iterator's
887 iterator
= (struct mapping
*) htab_find (codes
.iterators
, &code_name
);
889 code
= (enum rtx_code
) iterator
->values
->number
;
891 code
= (enum rtx_code
) codes
.find_builtin (code_name
);
893 /* If we end up with an insn expression then we free this space below. */
894 return_rtx
= rtx_alloc (code
);
895 format_ptr
= GET_RTX_FORMAT (code
);
896 PUT_CODE (return_rtx
, code
);
899 record_iterator_use (iterator
, return_rtx
);
901 /* If what follows is `: mode ', read it and
902 store the mode in the rtx. */
904 i
= read_skip_spaces ();
908 record_potential_iterator_use (&modes
, return_rtx
, name
.string
);
913 for (i
= 0; format_ptr
[i
] != 0; i
++)
914 switch (format_ptr
[i
])
916 /* 0 means a field for internal use only.
917 Don't expect it to be present in the input. */
923 XEXP (return_rtx
, i
) = read_nested_rtx ();
927 /* 'V' is an optional vector: if a closeparen follows,
928 just store NULL for this element. */
929 c
= read_skip_spaces ();
933 XVEC (return_rtx
, i
) = 0;
936 /* Now process the vector. */
940 /* Obstack to store scratch vector in. */
941 struct obstack vector_stack
;
942 int list_counter
= 0;
943 rtvec return_vec
= NULL_RTVEC
;
945 c
= read_skip_spaces ();
947 fatal_expected_char ('[', c
);
949 /* Add expressions to a list, while keeping a count. */
950 obstack_init (&vector_stack
);
951 while ((c
= read_skip_spaces ()) && c
!= ']')
954 fatal_expected_char (']', c
);
957 obstack_ptr_grow (&vector_stack
, read_nested_rtx ());
959 if (list_counter
> 0)
961 return_vec
= rtvec_alloc (list_counter
);
962 memcpy (&return_vec
->elem
[0], obstack_finish (&vector_stack
),
963 list_counter
* sizeof (rtx
));
965 else if (format_ptr
[i
] == 'E')
966 fatal_with_file_and_line ("vector must have at least one element");
967 XVEC (return_rtx
, i
) = return_vec
;
968 obstack_free (&vector_stack
, NULL
);
969 /* close bracket gotten */
980 c
= read_skip_spaces ();
984 /* 'S' fields are optional and should be NULL if no string
985 was given. Also allow normal 's' and 'T' strings to be
986 omitted, treating them in the same way as empty strings. */
987 XSTR (return_rtx
, i
) = (format_ptr
[i
] == 'S' ? NULL
: "");
991 /* The output template slot of a DEFINE_INSN,
992 DEFINE_INSN_AND_SPLIT, or DEFINE_PEEPHOLE automatically
993 gets a star inserted as its first character, if it is
994 written with a brace block instead of a string constant. */
995 star_if_braced
= (format_ptr
[i
] == 'T');
997 stringbuf
= read_string (star_if_braced
);
999 /* For insn patterns, we want to provide a default name
1000 based on the file and line, like "*foo.md:12", if the
1001 given name is blank. These are only for define_insn and
1002 define_insn_and_split, to aid debugging. */
1003 if (*stringbuf
== '\0'
1005 && (GET_CODE (return_rtx
) == DEFINE_INSN
1006 || GET_CODE (return_rtx
) == DEFINE_INSN_AND_SPLIT
))
1009 const char *fn
= (read_md_filename
? read_md_filename
: "rtx");
1011 for (slash
= fn
; *slash
; slash
++)
1012 if (*slash
== '/' || *slash
== '\\' || *slash
== ':')
1014 obstack_1grow (&string_obstack
, '*');
1015 obstack_grow (&string_obstack
, fn
, strlen (fn
));
1016 sprintf (line_name
, ":%d", read_md_lineno
);
1017 obstack_grow (&string_obstack
, line_name
, strlen (line_name
)+1);
1018 stringbuf
= XOBFINISH (&string_obstack
, char *);
1022 XTMPL (return_rtx
, i
) = stringbuf
;
1024 XSTR (return_rtx
, i
) = stringbuf
;
1030 validate_const_int (name
.string
);
1031 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
1032 tmp_wide
= atoi (name
.string
);
1034 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
1035 tmp_wide
= atol (name
.string
);
1037 /* Prefer atoll over atoq, since the former is in the ISO C99 standard.
1038 But prefer not to use our hand-rolled function above either. */
1039 #if defined(HAVE_ATOLL) || !defined(HAVE_ATOQ)
1040 tmp_wide
= atoll (name
.string
);
1042 tmp_wide
= atoq (name
.string
);
1046 XWINT (return_rtx
, i
) = tmp_wide
;
1051 /* Can be an iterator or an integer constant. */
1053 record_potential_iterator_use (&ints
, &XINT (return_rtx
, i
),
1061 c
= read_skip_spaces ();
1062 /* Syntactic sugar for AND and IOR, allowing Lisp-like
1063 arbitrary number of arguments for them. */
1065 && (GET_CODE (return_rtx
) == AND
1066 || GET_CODE (return_rtx
) == IOR
))
1067 return read_rtx_variadic (return_rtx
);
1073 /* Read a nested rtx construct from the MD file and return it. */
1076 read_nested_rtx (void)
1078 struct md_name name
;
1082 c
= read_skip_spaces ();
1084 fatal_expected_char ('(', c
);
1087 if (strcmp (name
.string
, "nil") == 0)
1090 return_rtx
= read_rtx_code (name
.string
);
1092 c
= read_skip_spaces ();
1094 fatal_expected_char (')', c
);
1099 /* Mutually recursive subroutine of read_rtx which reads
1100 (thing x1 x2 x3 ...) and produces RTL as if
1101 (thing x1 (thing x2 (thing x3 ...))) had been written.
1102 When called, FORM is (thing x1 x2), and the file position
1103 is just past the leading parenthesis of x3. Only works
1104 for THINGs which are dyadic expressions, e.g. AND, IOR. */
1106 read_rtx_variadic (rtx form
)
1115 q
= rtx_alloc (GET_CODE (p
));
1116 PUT_MODE (q
, GET_MODE (p
));
1118 XEXP (q
, 0) = XEXP (p
, 1);
1119 XEXP (q
, 1) = read_nested_rtx ();
1123 c
= read_skip_spaces ();