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
;
62 DEF_VEC_P (mapping_ptr
);
63 DEF_VEC_ALLOC_P (mapping_ptr
, heap
);
65 /* A structure for abstracting the common parts of iterators. */
66 struct iterator_group
{
67 /* Tables of "mapping" structures, one for attributes and one for
69 htab_t attrs
, iterators
;
71 /* Treat the given string as the name of a standard mode, etc., and
72 return its integer value. */
73 int (*find_builtin
) (const char *);
75 /* Make the given pointer use the given iterator value. */
76 void (*apply_iterator
) (void *, int);
79 /* Records one use of an iterator. */
81 /* The iterator itself. */
82 struct mapping
*iterator
;
84 /* The location of the use, as passed to the apply_iterator callback. */
88 /* Vector definitions for the above. */
89 typedef struct iterator_use iterator_use
;
90 DEF_VEC_O (iterator_use
);
91 DEF_VEC_ALLOC_O (iterator_use
, heap
);
93 /* Records one use of an attribute (the "<[iterator:]attribute>" syntax)
94 in a non-string rtx field. */
95 struct attribute_use
{
96 /* The group that describes the use site. */
97 struct iterator_group
*group
;
99 /* The name of the attribute, possibly with an "iterator:" prefix. */
102 /* The location of the use, as passed to GROUP's apply_iterator callback. */
106 /* Vector definitions for the above. */
107 typedef struct attribute_use attribute_use
;
108 DEF_VEC_O (attribute_use
);
109 DEF_VEC_ALLOC_O (attribute_use
, heap
);
111 static void validate_const_int (const char *);
112 static rtx
read_rtx_code (const char *);
113 static rtx
read_nested_rtx (void);
114 static rtx
read_rtx_variadic (rtx
);
116 /* The mode and code iterator structures. */
117 static struct iterator_group modes
, codes
, ints
;
119 /* All iterators used in the current rtx. */
120 static VEC (mapping_ptr
, heap
) *current_iterators
;
122 /* The list of all iterator uses in the current rtx. */
123 static VEC (iterator_use
, heap
) *iterator_uses
;
125 /* The list of all attribute uses in the current rtx. */
126 static VEC (attribute_use
, heap
) *attribute_uses
;
128 /* Implementations of the iterator_group callbacks for modes. */
131 find_mode (const char *name
)
135 for (i
= 0; i
< NUM_MACHINE_MODES
; i
++)
136 if (strcmp (GET_MODE_NAME (i
), name
) == 0)
139 fatal_with_file_and_line ("unknown mode `%s'", name
);
143 apply_mode_iterator (void *loc
, int mode
)
145 PUT_MODE ((rtx
) loc
, (enum machine_mode
) mode
);
148 /* Implementations of the iterator_group callbacks for codes. */
151 find_code (const char *name
)
155 for (i
= 0; i
< NUM_RTX_CODE
; i
++)
156 if (strcmp (GET_RTX_NAME (i
), name
) == 0)
159 fatal_with_file_and_line ("unknown rtx code `%s'", name
);
163 apply_code_iterator (void *loc
, int code
)
165 PUT_CODE ((rtx
) loc
, (enum rtx_code
) code
);
168 /* Implementations of the iterator_group callbacks for ints. */
170 /* Since GCC does not construct a table of valid constants,
171 we have to accept any int as valid. No cross-checking can
175 find_int (const char *name
)
177 validate_const_int (name
);
182 apply_int_iterator (void *loc
, int value
)
187 /* Map attribute string P to its current value. Return null if the attribute
190 static struct map_value
*
191 map_attr_string (const char *p
)
194 struct mapping
*iterator
;
198 int iterator_name_len
;
200 /* Peel off any "iterator:" prefix. Set ATTR to the start of the
202 attr
= strchr (p
, ':');
205 iterator_name_len
= -1;
210 iterator_name_len
= attr
- p
;
214 FOR_EACH_VEC_ELT (mapping_ptr
, current_iterators
, i
, iterator
)
216 /* If an iterator name was specified, check that it matches. */
217 if (iterator_name_len
>= 0
218 && (strncmp (p
, iterator
->name
, iterator_name_len
) != 0
219 || iterator
->name
[iterator_name_len
] != 0))
222 /* Find the attribute specification. */
223 m
= (struct mapping
*) htab_find (iterator
->group
->attrs
, &attr
);
225 /* Find the attribute value associated with the current
227 for (v
= m
->values
; v
; v
= v
->next
)
228 if (v
->number
== iterator
->current_value
->number
)
234 /* Apply the current iterator values to STRING. Return the new string
235 if any changes were needed, otherwise return STRING itself. */
238 apply_iterator_to_string (const char *string
)
240 char *base
, *copy
, *p
, *start
, *end
;
246 base
= p
= copy
= ASTRDUP (string
);
247 while ((start
= strchr (p
, '<')) && (end
= strchr (start
, '>')))
252 v
= map_attr_string (p
);
257 /* Add everything between the last copied byte and the '<',
258 then add in the attribute value. */
259 obstack_grow (&string_obstack
, base
, start
- base
);
260 obstack_grow (&string_obstack
, v
->string
, strlen (v
->string
));
265 obstack_grow (&string_obstack
, base
, strlen (base
) + 1);
266 copy
= XOBFINISH (&string_obstack
, char *);
267 copy_md_ptr_loc (copy
, string
);
273 /* Return a deep copy of X, substituting the current iterator
274 values into any strings. */
277 copy_rtx_for_iterators (rtx original
)
279 const char *format_ptr
;
286 /* Create a shallow copy of ORIGINAL. */
287 x
= rtx_alloc (GET_CODE (original
));
288 memcpy (x
, original
, RTX_CODE_SIZE (GET_CODE (original
)));
290 /* Change each string and recursively change each rtx. */
291 format_ptr
= GET_RTX_FORMAT (GET_CODE (original
));
292 for (i
= 0; format_ptr
[i
] != 0; i
++)
293 switch (format_ptr
[i
])
296 XTMPL (x
, i
) = apply_iterator_to_string (XTMPL (x
, i
));
301 XSTR (x
, i
) = apply_iterator_to_string (XSTR (x
, i
));
305 XEXP (x
, i
) = copy_rtx_for_iterators (XEXP (x
, i
));
310 if (XVEC (original
, i
))
312 XVEC (x
, i
) = rtvec_alloc (XVECLEN (original
, i
));
313 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
315 = copy_rtx_for_iterators (XVECEXP (original
, i
, j
));
325 /* Return a condition that must satisfy both ORIGINAL and EXTRA. If ORIGINAL
326 has the form "&& ..." (as used in define_insn_and_splits), assume that
327 EXTRA is already satisfied. Empty strings are treated like "true". */
330 add_condition_to_string (const char *original
, const char *extra
)
332 if (original
!= 0 && original
[0] == '&' && original
[1] == '&')
334 return join_c_conditions (original
, extra
);
337 /* Like add_condition, but applied to all conditions in rtx X. */
340 add_condition_to_rtx (rtx x
, const char *extra
)
342 switch (GET_CODE (x
))
346 XSTR (x
, 2) = add_condition_to_string (XSTR (x
, 2), extra
);
350 case DEFINE_PEEPHOLE
:
351 case DEFINE_PEEPHOLE2
:
352 case DEFINE_COND_EXEC
:
353 XSTR (x
, 1) = add_condition_to_string (XSTR (x
, 1), extra
);
356 case DEFINE_INSN_AND_SPLIT
:
357 XSTR (x
, 2) = add_condition_to_string (XSTR (x
, 2), extra
);
358 XSTR (x
, 4) = add_condition_to_string (XSTR (x
, 4), extra
);
366 /* Apply the current iterator values to all attribute_uses. */
369 apply_attribute_uses (void)
375 FOR_EACH_VEC_ELT (attribute_use
, attribute_uses
, i
, ause
)
377 v
= map_attr_string (ause
->value
);
379 fatal_with_file_and_line ("unknown iterator value `%s'", ause
->value
);
380 ause
->group
->apply_iterator (ause
->ptr
,
381 ause
->group
->find_builtin (v
->string
));
385 /* A htab_traverse callback for iterators. Add all used iterators
386 to current_iterators. */
389 add_current_iterators (void **slot
, void *data ATTRIBUTE_UNUSED
)
391 struct mapping
*iterator
;
393 iterator
= (struct mapping
*) *slot
;
394 if (iterator
->current_value
)
395 VEC_safe_push (mapping_ptr
, heap
, current_iterators
, iterator
);
399 /* Expand all iterators in the current rtx, which is given as ORIGINAL.
400 Build a list of expanded rtxes in the EXPR_LIST pointed to by QUEUE. */
403 apply_iterators (rtx original
, rtx
*queue
)
406 const char *condition
;
408 struct mapping
*iterator
;
412 if (VEC_empty (iterator_use
, iterator_uses
))
414 /* Raise an error if any attributes were used. */
415 apply_attribute_uses ();
416 XEXP (*queue
, 0) = original
;
417 XEXP (*queue
, 1) = NULL_RTX
;
421 /* Clear out the iterators from the previous run. */
422 FOR_EACH_VEC_ELT (mapping_ptr
, current_iterators
, i
, iterator
)
423 iterator
->current_value
= NULL
;
424 VEC_truncate (mapping_ptr
, current_iterators
, 0);
426 /* Mark the iterators that we need this time. */
427 FOR_EACH_VEC_ELT (iterator_use
, iterator_uses
, i
, iuse
)
428 iuse
->iterator
->current_value
= iuse
->iterator
->values
;
430 /* Get the list of iterators that are in use, preserving the
431 definition order within each group. */
432 htab_traverse (modes
.iterators
, add_current_iterators
, NULL
);
433 htab_traverse (codes
.iterators
, add_current_iterators
, NULL
);
434 htab_traverse (ints
.iterators
, add_current_iterators
, NULL
);
435 gcc_assert (!VEC_empty (mapping_ptr
, current_iterators
));
439 /* Apply the current iterator values. Accumulate a condition to
440 say when the resulting rtx can be used. */
442 FOR_EACH_VEC_ELT (iterator_use
, iterator_uses
, i
, iuse
)
444 v
= iuse
->iterator
->current_value
;
445 iuse
->iterator
->group
->apply_iterator (iuse
->ptr
, v
->number
);
446 condition
= join_c_conditions (condition
, v
->string
);
448 apply_attribute_uses ();
449 x
= copy_rtx_for_iterators (original
);
450 add_condition_to_rtx (x
, condition
);
452 /* Add the new rtx to the end of the queue. */
453 XEXP (*queue
, 0) = x
;
454 XEXP (*queue
, 1) = NULL_RTX
;
456 /* Lexicographically increment the iterator value sequence.
457 That is, cycle through iterator values, starting from the right,
458 and stopping when one of them doesn't wrap around. */
459 i
= VEC_length (mapping_ptr
, current_iterators
);
465 iterator
= VEC_index (mapping_ptr
, current_iterators
, i
);
466 iterator
->current_value
= iterator
->current_value
->next
;
467 if (iterator
->current_value
)
469 iterator
->current_value
= iterator
->values
;
472 /* At least one more rtx to go. Allocate room for it. */
473 XEXP (*queue
, 1) = rtx_alloc (EXPR_LIST
);
474 queue
= &XEXP (*queue
, 1);
478 /* Add a new "mapping" structure to hashtable TABLE. NAME is the name
479 of the mapping and GROUP is the group to which it belongs. */
481 static struct mapping
*
482 add_mapping (struct iterator_group
*group
, htab_t table
, const char *name
)
487 m
= XNEW (struct mapping
);
488 m
->name
= xstrdup (name
);
491 m
->current_value
= NULL
;
493 slot
= htab_find_slot (table
, m
, INSERT
);
495 fatal_with_file_and_line ("`%s' already defined", name
);
501 /* Add the pair (NUMBER, STRING) to a list of map_value structures.
502 END_PTR points to the current null terminator for the list; return
503 a pointer the new null terminator. */
505 static struct map_value
**
506 add_map_value (struct map_value
**end_ptr
, int number
, const char *string
)
508 struct map_value
*value
;
510 value
= XNEW (struct map_value
);
512 value
->number
= number
;
513 value
->string
= string
;
519 /* Do one-time initialization of the mode and code attributes. */
522 initialize_iterators (void)
524 struct mapping
*lower
, *upper
;
525 struct map_value
**lower_ptr
, **upper_ptr
;
529 modes
.attrs
= htab_create (13, leading_string_hash
, leading_string_eq_p
, 0);
530 modes
.iterators
= htab_create (13, leading_string_hash
,
531 leading_string_eq_p
, 0);
532 modes
.find_builtin
= find_mode
;
533 modes
.apply_iterator
= apply_mode_iterator
;
535 codes
.attrs
= htab_create (13, leading_string_hash
, leading_string_eq_p
, 0);
536 codes
.iterators
= htab_create (13, leading_string_hash
,
537 leading_string_eq_p
, 0);
538 codes
.find_builtin
= find_code
;
539 codes
.apply_iterator
= apply_code_iterator
;
541 ints
.attrs
= htab_create (13, leading_string_hash
, leading_string_eq_p
, 0);
542 ints
.iterators
= htab_create (13, leading_string_hash
,
543 leading_string_eq_p
, 0);
544 ints
.find_builtin
= find_int
;
545 ints
.apply_iterator
= apply_int_iterator
;
547 lower
= add_mapping (&modes
, modes
.attrs
, "mode");
548 upper
= add_mapping (&modes
, modes
.attrs
, "MODE");
549 lower_ptr
= &lower
->values
;
550 upper_ptr
= &upper
->values
;
551 for (i
= 0; i
< MAX_MACHINE_MODE
; i
++)
553 copy
= xstrdup (GET_MODE_NAME (i
));
554 for (p
= copy
; *p
!= 0; p
++)
557 upper_ptr
= add_map_value (upper_ptr
, i
, GET_MODE_NAME (i
));
558 lower_ptr
= add_map_value (lower_ptr
, i
, copy
);
561 lower
= add_mapping (&codes
, codes
.attrs
, "code");
562 upper
= add_mapping (&codes
, codes
.attrs
, "CODE");
563 lower_ptr
= &lower
->values
;
564 upper_ptr
= &upper
->values
;
565 for (i
= 0; i
< NUM_RTX_CODE
; i
++)
567 copy
= xstrdup (GET_RTX_NAME (i
));
568 for (p
= copy
; *p
!= 0; p
++)
571 lower_ptr
= add_map_value (lower_ptr
, i
, GET_RTX_NAME (i
));
572 upper_ptr
= add_map_value (upper_ptr
, i
, copy
);
576 /* Provide a version of a function to read a long long if the system does
578 #if HOST_BITS_PER_WIDE_INT > HOST_BITS_PER_LONG && !defined(HAVE_ATOLL) && !defined(HAVE_ATOQ)
579 HOST_WIDE_INT
atoll (const char *);
582 atoll (const char *p
)
585 HOST_WIDE_INT tmp_wide
;
597 HOST_WIDE_INT new_wide
= tmp_wide
*10 + (*p
- '0');
598 if (new_wide
< tmp_wide
)
600 /* Return INT_MAX equiv on overflow. */
601 tmp_wide
= (~(unsigned HOST_WIDE_INT
) 0) >> 1;
609 tmp_wide
= -tmp_wide
;
614 /* Process a define_conditions directive, starting with the optional
615 space after the "define_conditions". The directive looks like this:
623 It's not intended to appear in machine descriptions. It is
624 generated by (the program generated by) genconditions.c, and
625 slipped in at the beginning of the sequence of MD files read by
626 most of the other generators. */
628 read_conditions (void)
632 c
= read_skip_spaces ();
634 fatal_expected_char ('[', c
);
636 while ( (c
= read_skip_spaces ()) != ']')
643 fatal_expected_char ('(', c
);
646 validate_const_int (name
.string
);
647 value
= atoi (name
.string
);
649 c
= read_skip_spaces ();
651 fatal_expected_char ('"', c
);
652 expr
= read_quoted_string ();
654 c
= read_skip_spaces ();
656 fatal_expected_char (')', c
);
658 add_c_test (expr
, value
);
663 validate_const_int (const char *string
)
669 while (*cp
&& ISSPACE (*cp
))
671 if (*cp
== '-' || *cp
== '+')
679 fatal_with_file_and_line ("invalid decimal constant \"%s\"\n", string
);
682 /* Record that PTR uses iterator ITERATOR. */
685 record_iterator_use (struct mapping
*iterator
, void *ptr
)
687 struct iterator_use iuse
= {iterator
, ptr
};
688 VEC_safe_push (iterator_use
, heap
, iterator_uses
, iuse
);
691 /* Record that PTR uses attribute VALUE, which must match a built-in
692 value from group GROUP. */
695 record_attribute_use (struct iterator_group
*group
, void *ptr
,
698 struct attribute_use ause
= {group
, value
, ptr
};
699 VEC_safe_push (attribute_use
, heap
, attribute_uses
, ause
);
702 /* Interpret NAME as either a built-in value, iterator or attribute
703 for group GROUP. PTR is the value to pass to GROUP's apply_iterator
707 record_potential_iterator_use (struct iterator_group
*group
, void *ptr
,
714 if (name
[0] == '<' && name
[len
- 1] == '>')
716 /* Copy the attribute string into permanent storage, without the
717 angle brackets around it. */
718 obstack_grow0 (&string_obstack
, name
+ 1, len
- 2);
719 record_attribute_use (group
, ptr
, XOBFINISH (&string_obstack
, char *));
723 m
= (struct mapping
*) htab_find (group
->iterators
, &name
);
725 record_iterator_use (m
, ptr
);
727 group
->apply_iterator (ptr
, group
->find_builtin (name
));
731 /* Finish reading a declaration of the form:
733 (define... <name> [<value1> ... <valuen>])
735 from the MD file, where each <valuei> is either a bare symbol name or a
736 "(<name> <string>)" pair. The "(define..." part has already been read.
738 Represent the declaration as a "mapping" structure; add it to TABLE
739 (which belongs to GROUP) and return it. */
741 static struct mapping
*
742 read_mapping (struct iterator_group
*group
, htab_t table
)
746 struct map_value
**end_ptr
;
750 /* Read the mapping name and create a structure for it. */
752 m
= add_mapping (group
, table
, name
.string
);
754 c
= read_skip_spaces ();
756 fatal_expected_char ('[', c
);
758 /* Read each value. */
759 end_ptr
= &m
->values
;
760 c
= read_skip_spaces ();
765 /* A bare symbol name that is implicitly paired to an
773 /* A "(name string)" pair. */
775 string
= read_string (false);
776 c
= read_skip_spaces ();
778 fatal_expected_char (')', c
);
780 number
= group
->find_builtin (name
.string
);
781 end_ptr
= add_map_value (end_ptr
, number
, string
);
782 c
= read_skip_spaces ();
789 /* Check newly-created code iterator ITERATOR to see whether every code has the
793 check_code_iterator (struct mapping
*iterator
)
796 enum rtx_code bellwether
;
798 bellwether
= (enum rtx_code
) iterator
->values
->number
;
799 for (v
= iterator
->values
->next
; v
!= 0; v
= v
->next
)
800 if (strcmp (GET_RTX_FORMAT (bellwether
), GET_RTX_FORMAT (v
->number
)) != 0)
801 fatal_with_file_and_line ("code iterator `%s' combines "
802 "different rtx formats", iterator
->name
);
805 /* Read an rtx-related declaration from the MD file, given that it
806 starts with directive name RTX_NAME. Return true if it expands to
807 one or more rtxes (as defined by rtx.def). When returning true,
808 store the list of rtxes as an EXPR_LIST in *X. */
811 read_rtx (const char *rtx_name
, rtx
*x
)
813 static rtx queue_head
;
815 /* Do one-time initialization. */
818 initialize_iterators ();
819 queue_head
= rtx_alloc (EXPR_LIST
);
822 /* Handle various rtx-related declarations that aren't themselves
824 if (strcmp (rtx_name
, "define_conditions") == 0)
829 if (strcmp (rtx_name
, "define_mode_attr") == 0)
831 read_mapping (&modes
, modes
.attrs
);
834 if (strcmp (rtx_name
, "define_mode_iterator") == 0)
836 read_mapping (&modes
, modes
.iterators
);
839 if (strcmp (rtx_name
, "define_code_attr") == 0)
841 read_mapping (&codes
, codes
.attrs
);
844 if (strcmp (rtx_name
, "define_code_iterator") == 0)
846 check_code_iterator (read_mapping (&codes
, codes
.iterators
));
849 if (strcmp (rtx_name
, "define_int_attr") == 0)
851 read_mapping (&ints
, ints
.attrs
);
854 if (strcmp (rtx_name
, "define_int_iterator") == 0)
856 read_mapping (&ints
, ints
.iterators
);
860 apply_iterators (read_rtx_code (rtx_name
), &queue_head
);
861 VEC_truncate (iterator_use
, iterator_uses
, 0);
862 VEC_truncate (attribute_use
, attribute_uses
, 0);
868 /* Subroutine of read_rtx and read_nested_rtx. CODE_NAME is the name of
869 either an rtx code or a code iterator. Parse the rest of the rtx and
873 read_rtx_code (const char *code_name
)
877 struct mapping
*iterator
;
878 const char *format_ptr
;
882 HOST_WIDE_INT tmp_wide
;
884 /* Linked list structure for making RTXs: */
887 struct rtx_list
*next
;
888 rtx value
; /* Value of this node. */
891 /* If this code is an iterator, build the rtx using the iterator's
893 iterator
= (struct mapping
*) htab_find (codes
.iterators
, &code_name
);
895 code
= (enum rtx_code
) iterator
->values
->number
;
897 code
= (enum rtx_code
) codes
.find_builtin (code_name
);
899 /* If we end up with an insn expression then we free this space below. */
900 return_rtx
= rtx_alloc (code
);
901 format_ptr
= GET_RTX_FORMAT (code
);
902 PUT_CODE (return_rtx
, code
);
905 record_iterator_use (iterator
, return_rtx
);
907 /* If what follows is `: mode ', read it and
908 store the mode in the rtx. */
910 i
= read_skip_spaces ();
914 record_potential_iterator_use (&modes
, return_rtx
, name
.string
);
919 for (i
= 0; format_ptr
[i
] != 0; i
++)
920 switch (format_ptr
[i
])
922 /* 0 means a field for internal use only.
923 Don't expect it to be present in the input. */
929 XEXP (return_rtx
, i
) = read_nested_rtx ();
933 /* 'V' is an optional vector: if a closeparen follows,
934 just store NULL for this element. */
935 c
= read_skip_spaces ();
939 XVEC (return_rtx
, i
) = 0;
942 /* Now process the vector. */
946 /* Obstack to store scratch vector in. */
947 struct obstack vector_stack
;
948 int list_counter
= 0;
949 rtvec return_vec
= NULL_RTVEC
;
951 c
= read_skip_spaces ();
953 fatal_expected_char ('[', c
);
955 /* Add expressions to a list, while keeping a count. */
956 obstack_init (&vector_stack
);
957 while ((c
= read_skip_spaces ()) && c
!= ']')
960 fatal_expected_char (']', c
);
963 obstack_ptr_grow (&vector_stack
, read_nested_rtx ());
965 if (list_counter
> 0)
967 return_vec
= rtvec_alloc (list_counter
);
968 memcpy (&return_vec
->elem
[0], obstack_finish (&vector_stack
),
969 list_counter
* sizeof (rtx
));
971 else if (format_ptr
[i
] == 'E')
972 fatal_with_file_and_line ("vector must have at least one element");
973 XVEC (return_rtx
, i
) = return_vec
;
974 obstack_free (&vector_stack
, NULL
);
975 /* close bracket gotten */
986 c
= read_skip_spaces ();
990 /* 'S' fields are optional and should be NULL if no string
991 was given. Also allow normal 's' and 'T' strings to be
992 omitted, treating them in the same way as empty strings. */
993 XSTR (return_rtx
, i
) = (format_ptr
[i
] == 'S' ? NULL
: "");
997 /* The output template slot of a DEFINE_INSN,
998 DEFINE_INSN_AND_SPLIT, or DEFINE_PEEPHOLE automatically
999 gets a star inserted as its first character, if it is
1000 written with a brace block instead of a string constant. */
1001 star_if_braced
= (format_ptr
[i
] == 'T');
1003 stringbuf
= read_string (star_if_braced
);
1005 /* For insn patterns, we want to provide a default name
1006 based on the file and line, like "*foo.md:12", if the
1007 given name is blank. These are only for define_insn and
1008 define_insn_and_split, to aid debugging. */
1009 if (*stringbuf
== '\0'
1011 && (GET_CODE (return_rtx
) == DEFINE_INSN
1012 || GET_CODE (return_rtx
) == DEFINE_INSN_AND_SPLIT
))
1015 const char *fn
= (read_md_filename
? read_md_filename
: "rtx");
1017 for (slash
= fn
; *slash
; slash
++)
1018 if (*slash
== '/' || *slash
== '\\' || *slash
== ':')
1020 obstack_1grow (&string_obstack
, '*');
1021 obstack_grow (&string_obstack
, fn
, strlen (fn
));
1022 sprintf (line_name
, ":%d", read_md_lineno
);
1023 obstack_grow (&string_obstack
, line_name
, strlen (line_name
)+1);
1024 stringbuf
= XOBFINISH (&string_obstack
, char *);
1028 XTMPL (return_rtx
, i
) = stringbuf
;
1030 XSTR (return_rtx
, i
) = stringbuf
;
1036 validate_const_int (name
.string
);
1037 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
1038 tmp_wide
= atoi (name
.string
);
1040 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
1041 tmp_wide
= atol (name
.string
);
1043 /* Prefer atoll over atoq, since the former is in the ISO C99 standard.
1044 But prefer not to use our hand-rolled function above either. */
1045 #if defined(HAVE_ATOLL) || !defined(HAVE_ATOQ)
1046 tmp_wide
= atoll (name
.string
);
1048 tmp_wide
= atoq (name
.string
);
1052 XWINT (return_rtx
, i
) = tmp_wide
;
1057 /* Can be an iterator or an integer constant. */
1059 record_potential_iterator_use (&ints
, &XINT (return_rtx
, i
),
1067 c
= read_skip_spaces ();
1068 /* Syntactic sugar for AND and IOR, allowing Lisp-like
1069 arbitrary number of arguments for them. */
1071 && (GET_CODE (return_rtx
) == AND
1072 || GET_CODE (return_rtx
) == IOR
))
1073 return read_rtx_variadic (return_rtx
);
1079 /* Read a nested rtx construct from the MD file and return it. */
1082 read_nested_rtx (void)
1084 struct md_name name
;
1088 c
= read_skip_spaces ();
1090 fatal_expected_char ('(', c
);
1093 if (strcmp (name
.string
, "nil") == 0)
1096 return_rtx
= read_rtx_code (name
.string
);
1098 c
= read_skip_spaces ();
1100 fatal_expected_char (')', c
);
1105 /* Mutually recursive subroutine of read_rtx which reads
1106 (thing x1 x2 x3 ...) and produces RTL as if
1107 (thing x1 (thing x2 (thing x3 ...))) had been written.
1108 When called, FORM is (thing x1 x2), and the file position
1109 is just past the leading parenthesis of x3. Only works
1110 for THINGs which are dyadic expressions, e.g. AND, IOR. */
1112 read_rtx_variadic (rtx form
)
1121 q
= rtx_alloc (GET_CODE (p
));
1122 PUT_MODE (q
, GET_MODE (p
));
1124 XEXP (q
, 0) = XEXP (p
, 1);
1125 XEXP (q
, 1) = read_nested_rtx ();
1129 c
= read_skip_spaces ();