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
;
689 iuse
= VEC_safe_push (iterator_use
, heap
, iterator_uses
, NULL
);
690 iuse
->iterator
= iterator
;
694 /* Record that PTR uses attribute VALUE, which must match a built-in
695 value from group GROUP. */
698 record_attribute_use (struct iterator_group
*group
, void *ptr
,
701 struct attribute_use
*ause
;
703 ause
= VEC_safe_push (attribute_use
, heap
, attribute_uses
, NULL
);
709 /* Interpret NAME as either a built-in value, iterator or attribute
710 for group GROUP. PTR is the value to pass to GROUP's apply_iterator
714 record_potential_iterator_use (struct iterator_group
*group
, void *ptr
,
721 if (name
[0] == '<' && name
[len
- 1] == '>')
723 /* Copy the attribute string into permanent storage, without the
724 angle brackets around it. */
725 obstack_grow0 (&string_obstack
, name
+ 1, len
- 2);
726 record_attribute_use (group
, ptr
, XOBFINISH (&string_obstack
, char *));
730 m
= (struct mapping
*) htab_find (group
->iterators
, &name
);
732 record_iterator_use (m
, ptr
);
734 group
->apply_iterator (ptr
, group
->find_builtin (name
));
738 /* Finish reading a declaration of the form:
740 (define... <name> [<value1> ... <valuen>])
742 from the MD file, where each <valuei> is either a bare symbol name or a
743 "(<name> <string>)" pair. The "(define..." part has already been read.
745 Represent the declaration as a "mapping" structure; add it to TABLE
746 (which belongs to GROUP) and return it. */
748 static struct mapping
*
749 read_mapping (struct iterator_group
*group
, htab_t table
)
753 struct map_value
**end_ptr
;
757 /* Read the mapping name and create a structure for it. */
759 m
= add_mapping (group
, table
, name
.string
);
761 c
= read_skip_spaces ();
763 fatal_expected_char ('[', c
);
765 /* Read each value. */
766 end_ptr
= &m
->values
;
767 c
= read_skip_spaces ();
772 /* A bare symbol name that is implicitly paired to an
780 /* A "(name string)" pair. */
782 string
= read_string (false);
783 c
= read_skip_spaces ();
785 fatal_expected_char (')', c
);
787 number
= group
->find_builtin (name
.string
);
788 end_ptr
= add_map_value (end_ptr
, number
, string
);
789 c
= read_skip_spaces ();
796 /* Check newly-created code iterator ITERATOR to see whether every code has the
800 check_code_iterator (struct mapping
*iterator
)
803 enum rtx_code bellwether
;
805 bellwether
= (enum rtx_code
) iterator
->values
->number
;
806 for (v
= iterator
->values
->next
; v
!= 0; v
= v
->next
)
807 if (strcmp (GET_RTX_FORMAT (bellwether
), GET_RTX_FORMAT (v
->number
)) != 0)
808 fatal_with_file_and_line ("code iterator `%s' combines "
809 "different rtx formats", iterator
->name
);
812 /* Read an rtx-related declaration from the MD file, given that it
813 starts with directive name RTX_NAME. Return true if it expands to
814 one or more rtxes (as defined by rtx.def). When returning true,
815 store the list of rtxes as an EXPR_LIST in *X. */
818 read_rtx (const char *rtx_name
, rtx
*x
)
820 static rtx queue_head
;
822 /* Do one-time initialization. */
825 initialize_iterators ();
826 queue_head
= rtx_alloc (EXPR_LIST
);
829 /* Handle various rtx-related declarations that aren't themselves
831 if (strcmp (rtx_name
, "define_conditions") == 0)
836 if (strcmp (rtx_name
, "define_mode_attr") == 0)
838 read_mapping (&modes
, modes
.attrs
);
841 if (strcmp (rtx_name
, "define_mode_iterator") == 0)
843 read_mapping (&modes
, modes
.iterators
);
846 if (strcmp (rtx_name
, "define_code_attr") == 0)
848 read_mapping (&codes
, codes
.attrs
);
851 if (strcmp (rtx_name
, "define_code_iterator") == 0)
853 check_code_iterator (read_mapping (&codes
, codes
.iterators
));
856 if (strcmp (rtx_name
, "define_int_attr") == 0)
858 read_mapping (&ints
, ints
.attrs
);
861 if (strcmp (rtx_name
, "define_int_iterator") == 0)
863 read_mapping (&ints
, ints
.iterators
);
867 apply_iterators (read_rtx_code (rtx_name
), &queue_head
);
868 VEC_truncate (iterator_use
, iterator_uses
, 0);
869 VEC_truncate (attribute_use
, attribute_uses
, 0);
875 /* Subroutine of read_rtx and read_nested_rtx. CODE_NAME is the name of
876 either an rtx code or a code iterator. Parse the rest of the rtx and
880 read_rtx_code (const char *code_name
)
884 struct mapping
*iterator
;
885 const char *format_ptr
;
889 HOST_WIDE_INT tmp_wide
;
891 /* Linked list structure for making RTXs: */
894 struct rtx_list
*next
;
895 rtx value
; /* Value of this node. */
898 /* If this code is an iterator, build the rtx using the iterator's
900 iterator
= (struct mapping
*) htab_find (codes
.iterators
, &code_name
);
902 code
= (enum rtx_code
) iterator
->values
->number
;
904 code
= (enum rtx_code
) codes
.find_builtin (code_name
);
906 /* If we end up with an insn expression then we free this space below. */
907 return_rtx
= rtx_alloc (code
);
908 format_ptr
= GET_RTX_FORMAT (code
);
909 PUT_CODE (return_rtx
, code
);
912 record_iterator_use (iterator
, return_rtx
);
914 /* If what follows is `: mode ', read it and
915 store the mode in the rtx. */
917 i
= read_skip_spaces ();
921 record_potential_iterator_use (&modes
, return_rtx
, name
.string
);
926 for (i
= 0; format_ptr
[i
] != 0; i
++)
927 switch (format_ptr
[i
])
929 /* 0 means a field for internal use only.
930 Don't expect it to be present in the input. */
936 XEXP (return_rtx
, i
) = read_nested_rtx ();
940 /* 'V' is an optional vector: if a closeparen follows,
941 just store NULL for this element. */
942 c
= read_skip_spaces ();
946 XVEC (return_rtx
, i
) = 0;
949 /* Now process the vector. */
953 /* Obstack to store scratch vector in. */
954 struct obstack vector_stack
;
955 int list_counter
= 0;
956 rtvec return_vec
= NULL_RTVEC
;
958 c
= read_skip_spaces ();
960 fatal_expected_char ('[', c
);
962 /* Add expressions to a list, while keeping a count. */
963 obstack_init (&vector_stack
);
964 while ((c
= read_skip_spaces ()) && c
!= ']')
967 fatal_expected_char (']', c
);
970 obstack_ptr_grow (&vector_stack
, read_nested_rtx ());
972 if (list_counter
> 0)
974 return_vec
= rtvec_alloc (list_counter
);
975 memcpy (&return_vec
->elem
[0], obstack_finish (&vector_stack
),
976 list_counter
* sizeof (rtx
));
978 else if (format_ptr
[i
] == 'E')
979 fatal_with_file_and_line ("vector must have at least one element");
980 XVEC (return_rtx
, i
) = return_vec
;
981 obstack_free (&vector_stack
, NULL
);
982 /* close bracket gotten */
993 c
= read_skip_spaces ();
997 /* 'S' fields are optional and should be NULL if no string
998 was given. Also allow normal 's' and 'T' strings to be
999 omitted, treating them in the same way as empty strings. */
1000 XSTR (return_rtx
, i
) = (format_ptr
[i
] == 'S' ? NULL
: "");
1004 /* The output template slot of a DEFINE_INSN,
1005 DEFINE_INSN_AND_SPLIT, or DEFINE_PEEPHOLE automatically
1006 gets a star inserted as its first character, if it is
1007 written with a brace block instead of a string constant. */
1008 star_if_braced
= (format_ptr
[i
] == 'T');
1010 stringbuf
= read_string (star_if_braced
);
1012 /* For insn patterns, we want to provide a default name
1013 based on the file and line, like "*foo.md:12", if the
1014 given name is blank. These are only for define_insn and
1015 define_insn_and_split, to aid debugging. */
1016 if (*stringbuf
== '\0'
1018 && (GET_CODE (return_rtx
) == DEFINE_INSN
1019 || GET_CODE (return_rtx
) == DEFINE_INSN_AND_SPLIT
))
1022 const char *fn
= (read_md_filename
? read_md_filename
: "rtx");
1024 for (slash
= fn
; *slash
; slash
++)
1025 if (*slash
== '/' || *slash
== '\\' || *slash
== ':')
1027 obstack_1grow (&string_obstack
, '*');
1028 obstack_grow (&string_obstack
, fn
, strlen (fn
));
1029 sprintf (line_name
, ":%d", read_md_lineno
);
1030 obstack_grow (&string_obstack
, line_name
, strlen (line_name
)+1);
1031 stringbuf
= XOBFINISH (&string_obstack
, char *);
1035 XTMPL (return_rtx
, i
) = stringbuf
;
1037 XSTR (return_rtx
, i
) = stringbuf
;
1043 validate_const_int (name
.string
);
1044 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
1045 tmp_wide
= atoi (name
.string
);
1047 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
1048 tmp_wide
= atol (name
.string
);
1050 /* Prefer atoll over atoq, since the former is in the ISO C99 standard.
1051 But prefer not to use our hand-rolled function above either. */
1052 #if defined(HAVE_ATOLL) || !defined(HAVE_ATOQ)
1053 tmp_wide
= atoll (name
.string
);
1055 tmp_wide
= atoq (name
.string
);
1059 XWINT (return_rtx
, i
) = tmp_wide
;
1064 /* Can be an iterator or an integer constant. */
1066 record_potential_iterator_use (&ints
, &XINT (return_rtx
, i
),
1074 c
= read_skip_spaces ();
1075 /* Syntactic sugar for AND and IOR, allowing Lisp-like
1076 arbitrary number of arguments for them. */
1078 && (GET_CODE (return_rtx
) == AND
1079 || GET_CODE (return_rtx
) == IOR
))
1080 return read_rtx_variadic (return_rtx
);
1086 /* Read a nested rtx construct from the MD file and return it. */
1089 read_nested_rtx (void)
1091 struct md_name name
;
1095 c
= read_skip_spaces ();
1097 fatal_expected_char ('(', c
);
1100 if (strcmp (name
.string
, "nil") == 0)
1103 return_rtx
= read_rtx_code (name
.string
);
1105 c
= read_skip_spaces ();
1107 fatal_expected_char (')', c
);
1112 /* Mutually recursive subroutine of read_rtx which reads
1113 (thing x1 x2 x3 ...) and produces RTL as if
1114 (thing x1 (thing x2 (thing x3 ...))) had been written.
1115 When called, FORM is (thing x1 x2), and the file position
1116 is just past the leading parenthesis of x3. Only works
1117 for THINGs which are dyadic expressions, e.g. AND, IOR. */
1119 read_rtx_variadic (rtx form
)
1128 q
= rtx_alloc (GET_CODE (p
));
1129 PUT_MODE (q
, GET_MODE (p
));
1131 XEXP (q
, 0) = XEXP (p
, 1);
1132 XEXP (q
, 1) = read_nested_rtx ();
1136 c
= read_skip_spaces ();