1 /* The IGEN simulator generator for GDB, the GNU Debugger.
3 Copyright 2002 Free Software Foundation, Inc.
5 Contributed by Andrew Cagney.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
32 static insn_word_entry
*
33 parse_insn_word (line_ref
*line
, char *string
, int word_nr
)
36 insn_word_entry
*word
= ZALLOC (insn_word_entry
);
38 /* create a leading sentinal */
39 word
->first
= ZALLOC (insn_field_entry
);
40 word
->first
->first
= -1;
41 word
->first
->last
= -1;
42 word
->first
->width
= 0;
44 /* and a trailing sentinal */
45 word
->last
= ZALLOC (insn_field_entry
);
46 word
->last
->first
= options
.insn_bit_size
;
47 word
->last
->last
= options
.insn_bit_size
;
48 word
->last
->width
= 0;
50 /* link them together */
51 word
->first
->next
= word
->last
;
52 word
->last
->prev
= word
->first
;
54 /* now work through the formats */
55 chp
= skip_spaces (string
);
63 insn_field_entry
*new_field
;
65 /* create / link in the new field */
66 new_field
= ZALLOC (insn_field_entry
);
67 new_field
->next
= word
->last
;
68 new_field
->prev
= word
->last
->prev
;
69 new_field
->next
->prev
= new_field
;
70 new_field
->prev
->next
= new_field
;
71 new_field
->word_nr
= word_nr
;
73 /* break out the first field (if present) */
75 chp
= skip_to_separator (chp
, ".,!");
76 strlen_pos
= back_spaces (start_pos
, chp
) - start_pos
;
78 /* break out the second field (if present) */
81 /* assume what was specified was the value (and not the start
82 position). Assume the value length implicitly specifies
84 start_val
= start_pos
;
85 strlen_val
= strlen_pos
;
92 chp
= skip_spaces (chp
);
94 if (*chp
== '/' || *chp
== '*')
100 while (*chp
== '/' || *chp
== '*');
102 else if (isalpha (*start_val
))
108 while (isalnum (*chp
) || *chp
== '_');
110 else if (isdigit (*start_val
))
116 while (isalnum (*chp
));
118 strlen_val
= chp
- start_val
;
119 chp
= skip_spaces (chp
);
122 error (line
, "Empty value field\n");
124 /* break out any conditional fields - { [ "!" | "=" [ <value> | <field-name> } */
125 while (*chp
== '!' || *chp
== '=')
130 insn_field_cond
*new_cond
= ZALLOC (insn_field_cond
);
132 /* determine the conditional test */
136 new_cond
->test
= insn_field_cond_eq
;
139 new_cond
->test
= insn_field_cond_ne
;
147 chp
= skip_spaces (chp
);
149 chp
= skip_to_separator (chp
, "+,:!=");
150 end
= back_spaces (start
, chp
);
153 error (line
, "Missing or invalid conditional value\n");
154 new_cond
->string
= NZALLOC (char, len
+ 1);
155 strncpy (new_cond
->string
, start
, len
);
157 /* determine the conditional type */
158 if (isdigit (*start
))
160 /* [ "!" | "=" ] <value> */
161 new_cond
->type
= insn_field_cond_value
;
162 new_cond
->value
= a2i (new_cond
->string
);
166 /* [ "!" | "=" ] <field> - check field valid */
167 new_cond
->type
= insn_field_cond_field
;
168 /* new_cond->field is determined in later */
171 /* Only a single `=' is permitted. */
172 if ((new_cond
->test
== insn_field_cond_eq
173 && new_field
->conditions
!= NULL
)
174 || (new_field
->conditions
!= NULL
175 && new_field
->conditions
->test
== insn_field_cond_eq
))
176 error (line
, "Only single conditional when `=' allowed\n");
180 insn_field_cond
**last
= &new_field
->conditions
;
181 while (*last
!= NULL
)
182 last
= &(*last
)->next
;
187 /* NOW verify that the field was finished */
190 chp
= skip_spaces (chp
+ 1);
192 error (line
, "empty field\n");
194 else if (*chp
!= '\0')
196 error (line
, "Missing field separator\n");
200 new_field
->val_string
= NZALLOC (char, strlen_val
+ 1);
201 strncpy (new_field
->val_string
, start_val
, strlen_val
);
202 if (isdigit (new_field
->val_string
[0]))
206 /* when the length/pos field is omited, an integer field
210 for (i
= 0; i
< strlen_val
; i
++)
212 if (new_field
->val_string
[i
] != '0'
213 && new_field
->val_string
[i
] != '1')
214 error (line
, "invalid binary field %s\n",
215 new_field
->val_string
);
216 val
= (val
<< 1) + (new_field
->val_string
[i
] == '1');
218 new_field
->val_int
= val
;
219 new_field
->type
= insn_field_int
;
223 new_field
->val_int
= a2i (new_field
->val_string
);
224 new_field
->type
= insn_field_int
;
227 else if (new_field
->val_string
[0] == '/')
229 new_field
->type
= insn_field_reserved
;
231 else if (new_field
->val_string
[0] == '*')
233 new_field
->type
= insn_field_wild
;
237 new_field
->type
= insn_field_string
;
238 if (filter_is_member (word
->field_names
, new_field
->val_string
))
239 error (line
, "Field name %s is duplicated\n",
240 new_field
->val_string
);
241 filter_parse (&word
->field_names
, new_field
->val_string
);
243 if (new_field
->type
!= insn_field_string
244 && new_field
->conditions
!= NULL
)
245 error (line
, "Conditionals can only be applied to named fields\n");
247 /* the copy the position */
248 new_field
->pos_string
= NZALLOC (char, strlen_pos
+ 1);
249 strncpy (new_field
->pos_string
, start_pos
, strlen_pos
);
252 new_field
->first
= new_field
->prev
->last
+ 1;
253 if (new_field
->first
== 0 /* first field */
254 && *chp
== '\0' /* no further fields */
255 && new_field
->type
== insn_field_string
)
257 /* A single string without any position, assume that it
258 represents the entire instruction word */
259 new_field
->width
= options
.insn_bit_size
;
263 /* No explicit width/position, assume value implicitly
264 supplies the width */
265 new_field
->width
= strlen_val
;
267 new_field
->last
= new_field
->first
+ new_field
->width
- 1;
268 if (new_field
->last
>= options
.insn_bit_size
)
269 error (line
, "Bit position %d exceed instruction bit size (%d)\n",
270 new_field
->last
, options
.insn_bit_size
);
272 else if (options
.insn_specifying_widths
)
274 new_field
->first
= new_field
->prev
->last
+ 1;
275 new_field
->width
= a2i (new_field
->pos_string
);
276 new_field
->last
= new_field
->first
+ new_field
->width
- 1;
277 if (new_field
->last
>= options
.insn_bit_size
)
278 error (line
, "Bit position %d exceed instruction bit size (%d)\n",
279 new_field
->last
, options
.insn_bit_size
);
283 new_field
->first
= target_a2i (options
.hi_bit_nr
,
284 new_field
->pos_string
);
285 new_field
->last
= new_field
->next
->first
- 1; /* guess */
286 new_field
->width
= new_field
->last
- new_field
->first
+ 1; /* guess */
287 new_field
->prev
->last
= new_field
->first
- 1; /*fix */
288 new_field
->prev
->width
= new_field
->first
- new_field
->prev
->first
; /*fix */
292 /* fiddle first/last so that the sentinals disapear */
293 ASSERT (word
->first
->last
< 0);
294 ASSERT (word
->last
->first
>= options
.insn_bit_size
);
295 word
->first
= word
->first
->next
;
296 word
->last
= word
->last
->prev
;
298 /* check that the last field goes all the way to the last bit */
299 if (word
->last
->last
!= options
.insn_bit_size
- 1)
301 if (options
.warn
.width
)
302 options
.warning (line
, "Instruction format is not %d bits wide\n",
303 options
.insn_bit_size
);
304 word
->last
->last
= options
.insn_bit_size
- 1;
307 /* now go over this again, pointing each bit position at a field
310 insn_field_entry
*field
;
311 for (field
= word
->first
;
312 field
->last
< options
.insn_bit_size
; field
= field
->next
)
315 for (i
= field
->first
; i
<= field
->last
; i
++)
317 word
->bit
[i
] = ZALLOC (insn_bit_entry
);
318 word
->bit
[i
]->field
= field
;
321 case insn_field_invalid
:
325 word
->bit
[i
]->mask
= 1;
326 word
->bit
[i
]->value
= ((field
->val_int
328 (field
->last
- i
))) != 0);
329 case insn_field_reserved
:
330 case insn_field_wild
:
331 case insn_field_string
:
332 /* if we encounter a constant conditional, encode
334 if (field
->conditions
!= NULL
335 && field
->conditions
->test
== insn_field_cond_eq
336 && field
->conditions
->type
== insn_field_cond_value
)
338 word
->bit
[i
]->mask
= 1;
339 word
->bit
[i
]->value
= ((field
->conditions
->value
341 (field
->last
- i
))) != 0);
354 parse_insn_words (insn_entry
* insn
, char *formats
)
356 insn_word_entry
**last_word
= &insn
->words
;
359 /* now work through the formats */
369 insn_word_entry
*new_word
;
371 /* skip leading spaces */
372 chp
= skip_spaces (chp
);
374 /* break out the format */
376 chp
= skip_to_separator (chp
, "+");
377 end_pos
= back_spaces (start_pos
, chp
);
378 strlen_pos
= end_pos
- start_pos
;
380 /* check that something was there */
382 error (insn
->line
, "missing or empty instruction format\n");
384 /* parse the field */
385 format
= NZALLOC (char, strlen_pos
+ 1);
386 strncpy (format
, start_pos
, strlen_pos
);
387 new_word
= parse_insn_word (insn
->line
, format
, insn
->nr_words
);
389 if (filter_is_common (insn
->field_names
, new_word
->field_names
))
390 error (insn
->line
, "Field name duplicated between two words\n");
391 filter_add (&insn
->field_names
, new_word
->field_names
);
394 *last_word
= new_word
;
395 last_word
= &new_word
->next
;
400 ASSERT (*chp
== '+');
404 /* create a quick access array (indexed by word) of the same structure */
407 insn_word_entry
*word
;
408 insn
->word
= NZALLOC (insn_word_entry
*, insn
->nr_words
+ 1);
409 for (i
= 0, word
= insn
->words
;
410 i
< insn
->nr_words
; i
++, word
= word
->next
)
411 insn
->word
[i
] = word
;
414 /* Go over all fields that have conditionals refering to other
415 fields. Link the fields up. Verify that the two fields have the
416 same size. Verify that the two fields are different */
419 for (i
= 0; i
< insn
->nr_words
; i
++)
421 insn_word_entry
*word
= insn
->word
[i
];
423 for (f
= word
->first
; f
->last
< options
.insn_bit_size
; f
= f
->next
)
425 insn_field_cond
*cond
;
426 for (cond
= f
->conditions
; cond
!= NULL
; cond
= cond
->next
)
428 if (cond
->type
== insn_field_cond_field
)
431 if (strcmp (cond
->string
, f
->val_string
) == 0)
433 "Conditional `%s' of field `%s' refers to its self\n",
434 cond
->string
, f
->val_string
);
435 for (j
= 0; j
<= i
&& cond
->field
== NULL
; j
++)
437 insn_word_entry
*refered_word
= insn
->word
[j
];
438 insn_field_entry
*refered_field
;
439 for (refered_field
= refered_word
->first
;
440 refered_field
!= NULL
&& cond
->field
== NULL
;
441 refered_field
= refered_field
->next
)
443 if (refered_field
->type
== insn_field_string
444 && strcmp (refered_field
->val_string
,
447 /* found field being refered to by conditonal */
448 cond
->field
= refered_field
;
449 /* check refered to and this field are
451 if (f
->width
!= refered_field
->width
)
453 "Conditional `%s' of field `%s' should be of size %s\n",
454 cond
->string
, f
->val_string
,
455 refered_field
->width
);
459 if (cond
->field
== NULL
)
461 "Conditional `%s' of field `%s' not yet defined\n",
462 cond
->string
, f
->val_string
);
474 insn_record
, /* default */
480 string_function_record
,
485 model_processor_record
,
489 model_function_record
,
490 model_internal_record
,
494 static const name_map insn_type_map
[] = {
495 {"option", option_record
},
496 {"cache", cache_record
},
497 {"compute", compute_record
},
498 {"scratch", scratch_record
},
499 {"define", define_record
},
500 {"include", include_record
},
501 {"%s", string_function_record
},
502 {"function", function_record
},
503 {"internal", internal_record
},
504 {"model", model_processor_record
},
505 {"model-macro", model_macro_record
},
506 {"model-data", model_data_record
},
507 {"model-static", model_static_record
},
508 {"model-internal", model_internal_record
},
509 {"model-function", model_function_record
},
515 record_is_old (table_entry
*entry
)
517 if (entry
->nr_fields
> record_type_field
518 && strlen (entry
->field
[record_type_field
]) == 0)
523 static insn_record_type
524 record_type (table_entry
*entry
)
528 case table_code_entry
:
531 case table_colon_entry
:
532 if (record_is_old (entry
))
535 if (entry
->nr_fields
> old_record_type_field
)
537 int i
= name2i (entry
->field
[old_record_type_field
],
543 return unknown_record
;
546 else if (entry
->nr_fields
> record_type_field
547 && entry
->field
[0][0] == '\0')
550 int i
= name2i (entry
->field
[record_type_field
],
555 return insn_record
; /* default */
557 return unknown_record
;
561 record_prefix_is (table_entry
*entry
, char ch
, int nr_fields
)
563 if (entry
->type
!= table_colon_entry
)
565 if (entry
->nr_fields
< nr_fields
)
567 if (entry
->field
[0][0] != ch
&& ch
!= '\0')
573 parse_model_data_record (insn_table
*isa
,
576 int nr_fields
, model_data
**list
)
578 table_entry
*model_record
= record
;
579 table_entry
*code_record
= NULL
;
580 model_data
*new_data
;
581 if (record
->nr_fields
< nr_fields
)
582 error (record
->line
, "Incorrect number of fields\n");
583 record
= table_read (file
);
584 if (record
->type
== table_code_entry
)
586 code_record
= record
;
587 record
= table_read (file
);
589 /* create the new data record */
590 new_data
= ZALLOC (model_data
);
591 new_data
->line
= model_record
->line
;
592 filter_parse (&new_data
->flags
,
593 model_record
->field
[record_filter_flags_field
]);
594 new_data
->entry
= model_record
;
595 new_data
->code
= code_record
;
596 /* append it if not filtered out */
597 if (!is_filtered_out (options
.flags_filter
,
598 model_record
->field
[record_filter_flags_field
])
599 && !is_filtered_out (options
.model_filter
,
600 model_record
->field
[record_filter_models_field
]))
602 while (*list
!= NULL
)
603 list
= &(*list
)->next
;
612 insn_bit_size_option
= 1,
613 insn_specifying_widths_option
,
624 static const name_map option_map
[] = {
625 {"insn-bit-size", insn_bit_size_option
},
626 {"insn-specifying-widths", insn_specifying_widths_option
},
627 {"hi-bit-nr", hi_bit_nr_option
},
628 {"flags-filter", flags_filter_option
},
629 {"model-filter", model_filter_option
},
630 {"multi-sim", multi_sim_option
},
631 {"format-names", format_names_option
},
632 {"gen-delayed-branch", gen_delayed_branch
},
633 {NULL
, unknown_option
},
637 parse_include_record (table
*file
, table_entry
*record
)
639 /* parse the include record */
640 if (record
->nr_fields
< nr_include_fields
)
641 error (record
->line
, "Incorrect nr fields for include record\n");
643 if (!is_filtered_out (options
.flags_filter
,
644 record
->field
[record_filter_flags_field
])
645 && !is_filtered_out (options
.model_filter
,
646 record
->field
[record_filter_models_field
]))
648 table_push (file
, record
->line
, options
.include
,
649 record
->field
[include_filename_field
]);
651 /* nb: can't read next record until after the file has been pushed */
652 record
= table_read (file
);
658 parse_option_record (table
*file
, table_entry
*record
)
660 table_entry
*option_record
;
661 /* parse the option record */
662 option_record
= record
;
663 if (record
->nr_fields
< nr_option_fields
)
664 error (record
->line
, "Incorrect nr of fields for option record\n");
665 record
= table_read (file
);
667 if (!is_filtered_out (options
.flags_filter
,
668 option_record
->field
[record_filter_flags_field
])
669 && !is_filtered_out (options
.model_filter
,
670 option_record
->field
[record_filter_models_field
]))
672 char *name
= option_record
->field
[option_name_field
];
673 option_names option
= name2i (name
, option_map
);
674 char *value
= option_record
->field
[option_value_field
];
677 case insn_bit_size_option
:
679 options
.insn_bit_size
= a2i (value
);
680 if (options
.insn_bit_size
< 0
681 || options
.insn_bit_size
> max_insn_bit_size
)
682 error (option_record
->line
,
683 "Instruction bit size out of range\n");
684 if (options
.hi_bit_nr
!= options
.insn_bit_size
- 1
685 && options
.hi_bit_nr
!= 0)
686 error (option_record
->line
,
687 "insn-bit-size / hi-bit-nr conflict\n");
690 case insn_specifying_widths_option
:
692 options
.insn_specifying_widths
= a2i (value
);
695 case hi_bit_nr_option
:
697 options
.hi_bit_nr
= a2i (value
);
698 if (options
.hi_bit_nr
!= 0
699 && options
.hi_bit_nr
!= options
.insn_bit_size
- 1)
700 error (option_record
->line
,
701 "hi-bit-nr / insn-bit-size conflict\n");
704 case flags_filter_option
:
706 filter_parse (&options
.flags_filter
, value
);
709 case model_filter_option
:
711 filter_parse (&options
.model_filter
, value
);
714 case multi_sim_option
:
716 options
.gen
.multi_sim
= a2i (value
);
719 case format_names_option
:
721 filter_parse (&options
.format_name_filter
, value
);
724 case gen_delayed_branch
:
726 options
.gen
.delayed_branch
= a2i (value
);
731 error (option_record
->line
, "Unknown option - %s\n", name
);
741 parse_function_record (table
*file
,
743 function_entry
** list
,
744 function_entry
** list_entry
,
745 int is_internal
, model_table
*model
)
747 function_entry
*new_function
;
748 new_function
= ZALLOC (function_entry
);
749 new_function
->line
= record
->line
;
750 new_function
->is_internal
= is_internal
;
751 /* parse the function header */
752 if (record_is_old (record
))
754 if (record
->nr_fields
< nr_old_function_fields
)
755 error (record
->line
, "Missing fields from (old) function record\n");
756 new_function
->type
= record
->field
[old_function_typedef_field
];
757 new_function
->type
= record
->field
[old_function_typedef_field
];
758 if (record
->nr_fields
> old_function_param_field
)
759 new_function
->param
= record
->field
[old_function_param_field
];
760 new_function
->name
= record
->field
[old_function_name_field
];
764 if (record
->nr_fields
< nr_function_fields
)
765 error (record
->line
, "Missing fields from function record\n");
766 filter_parse (&new_function
->flags
,
767 record
->field
[record_filter_flags_field
]);
768 filter_parse (&new_function
->models
,
769 record
->field
[record_filter_models_field
]);
770 new_function
->type
= record
->field
[function_typedef_field
];
771 new_function
->param
= record
->field
[function_param_field
];
772 new_function
->name
= record
->field
[function_name_field
];
774 record
= table_read (file
);
775 /* parse any function-model records */
776 while (record
!= NULL
777 && record_prefix_is (record
, '*', nr_function_model_fields
))
779 char *model_name
= record
->field
[function_model_name_field
] + 1; /*skip `*' */
780 filter_parse (&new_function
->models
, model_name
);
781 if (!filter_is_subset (model
->processors
, new_function
->models
))
783 error (record
->line
, "machine model `%s' undefined\n", model_name
);
785 record
= table_read (file
);
787 /* parse the function body */
788 if (record
->type
== table_code_entry
)
790 new_function
->code
= record
;
791 record
= table_read (file
);
794 if (!filter_is_subset (options
.flags_filter
, new_function
->flags
))
796 if (options
.warn
.discard
)
797 notify (new_function
->line
, "Discarding function %s - filter flags\n",
800 else if (new_function
->models
!= NULL
801 && !filter_is_common (options
.model_filter
, new_function
->models
))
803 if (options
.warn
.discard
)
804 notify (new_function
->line
,
805 "Discarding function %s - filter models\n",
810 while (*list
!= NULL
)
811 list
= &(*list
)->next
;
812 *list
= new_function
;
813 if (list_entry
!= NULL
)
814 *list_entry
= new_function
;
821 parse_insn_model_record (table
*file
,
823 insn_entry
* insn
, model_table
*model
)
825 insn_model_entry
**last_insn_model
;
826 insn_model_entry
*new_insn_model
= ZALLOC (insn_model_entry
);
828 new_insn_model
->line
= record
->line
;
829 if (record
->nr_fields
> insn_model_unit_data_field
)
830 new_insn_model
->unit_data
= record
->field
[insn_model_unit_data_field
];
831 new_insn_model
->insn
= insn
;
832 /* parse the model names, verify that all were defined */
833 new_insn_model
->names
= NULL
;
834 filter_parse (&new_insn_model
->names
,
835 record
->field
[insn_model_name_field
] + 1 /*skip `*' */ );
836 if (new_insn_model
->names
== NULL
)
838 /* No processor names - a generic model entry, enter it into all
839 the non-empty fields */
841 for (index
= 0; index
< model
->nr_models
; index
++)
842 if (insn
->model
[index
] == 0)
844 insn
->model
[index
] = new_insn_model
;
846 /* also add the complete processor set to this processor's set */
847 filter_add (&insn
->processors
, model
->processors
);
851 /* Find the corresponding master model record for each name so
852 that they can be linked in. */
857 name
= filter_next (new_insn_model
->names
, name
);
860 index
= filter_is_member (model
->processors
, name
) - 1;
863 error (new_insn_model
->line
,
864 "machine model `%s' undefined\n", name
);
866 /* store it in the corresponding model array entry */
867 if (insn
->model
[index
] != NULL
&& insn
->model
[index
]->names
!= NULL
)
869 warning (new_insn_model
->line
,
870 "machine model `%s' previously defined\n", name
);
871 error (insn
->model
[index
]->line
, "earlier definition\n");
873 insn
->model
[index
] = new_insn_model
;
874 /* also add the name to the instructions processor set as an
875 alternative lookup mechanism */
876 filter_parse (&insn
->processors
, name
);
880 /* for some reason record the max length of any
881 function unit field */
882 int len
= strlen (insn_model_ptr
->field
[insn_model_fields
]);
883 if (model
->max_model_fields_len
< len
)
884 model
->max_model_fields_len
= len
;
887 last_insn_model
= &insn
->models
;
888 while ((*last_insn_model
) != NULL
)
889 last_insn_model
= &(*last_insn_model
)->next
;
890 *last_insn_model
= new_insn_model
;
895 parse_insn_mnemonic_record (table
*file
,
896 table_entry
*record
, insn_entry
* insn
)
898 insn_mnemonic_entry
**last_insn_mnemonic
;
899 insn_mnemonic_entry
*new_insn_mnemonic
= ZALLOC (insn_mnemonic_entry
);
901 new_insn_mnemonic
->line
= record
->line
;
902 ASSERT (record
->nr_fields
> insn_mnemonic_format_field
);
903 new_insn_mnemonic
->format
= record
->field
[insn_mnemonic_format_field
];
904 ASSERT (new_insn_mnemonic
->format
[0] == '"');
905 if (new_insn_mnemonic
->format
[strlen (new_insn_mnemonic
->format
) - 1] !=
907 error (new_insn_mnemonic
->line
,
908 "Missing closing double quote in mnemonic field\n");
909 if (record
->nr_fields
> insn_mnemonic_condition_field
)
910 new_insn_mnemonic
->condition
=
911 record
->field
[insn_mnemonic_condition_field
];
912 new_insn_mnemonic
->insn
= insn
;
914 last_insn_mnemonic
= &insn
->mnemonics
;
915 while ((*last_insn_mnemonic
) != NULL
)
916 last_insn_mnemonic
= &(*last_insn_mnemonic
)->next
;
917 insn
->nr_mnemonics
++;
918 *last_insn_mnemonic
= new_insn_mnemonic
;
923 parse_macro_record (table
*file
, table_entry
*record
)
926 error (record
->line
, "Macros are not implemented");
928 /* parse the define record */
929 if (record
->nr_fields
< nr_define_fields
)
930 error (record
->line
, "Incorrect nr fields for define record\n");
932 if (!is_filtered_out (options
.flags_filter
,
933 record
->field
[record_filter_flags_field
])
934 && !is_filtered_out (options
.model_filter
,
935 record
->field
[record_filter_models_field
]))
939 record
->field
[macro_name_field
],
940 record
->field
[macro_args_field
],
941 record
->field
[macro_expr_field
]);
943 record
= table_read (file
);
950 load_insn_table (char *file_name
, cache_entry
*cache
)
952 table
*file
= table_open (file_name
);
953 table_entry
*record
= table_read (file
);
955 insn_table
*isa
= ZALLOC (insn_table
);
956 model_table
*model
= ZALLOC (model_table
);
961 while (record
!= NULL
)
964 switch (record_type (record
))
969 record
= parse_include_record (file
, record
);
975 if (isa
->insns
!= NULL
)
976 error (record
->line
, "Option after first instruction\n");
977 record
= parse_option_record (file
, record
);
981 case string_function_record
:
983 function_entry
*function
= NULL
;
984 record
= parse_function_record (file
, record
,
986 &function
, 0 /*is-internal */ ,
988 /* convert a string function record into an internal function */
989 if (function
!= NULL
)
991 char *name
= NZALLOC (char,
993 + strlen (function
->name
) + 1));
994 strcat (name
, "str_");
995 strcat (name
, function
->name
);
996 function
->name
= name
;
997 function
->type
= "const char *";
1002 case function_record
: /* function record */
1004 record
= parse_function_record (file
, record
,
1006 NULL
, 0 /*is-internal */ ,
1011 case internal_record
:
1013 /* only insert it into the function list if it is unknown */
1014 function_entry
*function
= NULL
;
1015 record
= parse_function_record (file
, record
,
1017 &function
, 1 /*is-internal */ ,
1019 /* check what was inserted to see if a pseudo-instruction
1020 entry also needs to be created */
1021 if (function
!= NULL
)
1023 insn_entry
**insn
= NULL
;
1024 if (strcmp (function
->name
, "illegal") == 0)
1026 /* illegal function save it away */
1027 if (isa
->illegal_insn
!= NULL
)
1029 warning (function
->line
,
1030 "Multiple illegal instruction definitions\n");
1031 error (isa
->illegal_insn
->line
,
1032 "Location of first illegal instruction\n");
1035 insn
= &isa
->illegal_insn
;
1039 *insn
= ZALLOC (insn_entry
);
1040 (*insn
)->line
= function
->line
;
1041 (*insn
)->name
= function
->name
;
1042 (*insn
)->code
= function
->code
;
1048 case scratch_record
: /* cache macro records */
1050 case compute_record
:
1052 cache_entry
*new_cache
;
1053 /* parse the cache record */
1054 if (record
->nr_fields
< nr_cache_fields
)
1055 error (record
->line
,
1056 "Incorrect nr of fields for scratch/cache/compute record\n");
1058 new_cache
= ZALLOC (cache_entry
);
1059 new_cache
->line
= record
->line
;
1060 filter_parse (&new_cache
->flags
,
1061 record
->field
[record_filter_flags_field
]);
1062 filter_parse (&new_cache
->models
,
1063 record
->field
[record_filter_models_field
]);
1064 new_cache
->type
= record
->field
[cache_typedef_field
];
1065 new_cache
->name
= record
->field
[cache_name_field
];
1066 filter_parse (&new_cache
->original_fields
,
1067 record
->field
[cache_original_fields_field
]);
1068 new_cache
->expression
= record
->field
[cache_expression_field
];
1069 /* insert it but only if not filtered out */
1070 if (!filter_is_subset (options
.flags_filter
, new_cache
->flags
))
1072 notify (new_cache
->line
,
1073 "Discarding cache entry %s - filter flags\n",
1076 else if (is_filtered_out (options
.model_filter
,
1078 field
[record_filter_models_field
]))
1080 notify (new_cache
->line
,
1081 "Discarding cache entry %s - filter models\n",
1087 last
= &isa
->caches
;
1088 while (*last
!= NULL
)
1089 last
= &(*last
)->next
;
1092 /* advance things */
1093 record
= table_read (file
);
1098 case model_processor_record
:
1100 model_entry
*new_model
;
1101 /* parse the model */
1102 if (record
->nr_fields
< nr_model_processor_fields
)
1103 error (record
->line
,
1104 "Incorrect nr of fields for model record\n");
1105 if (isa
->insns
!= NULL
)
1106 error (record
->line
, "Model appears after first instruction\n");
1107 new_model
= ZALLOC (model_entry
);
1108 filter_parse (&new_model
->flags
,
1109 record
->field
[record_filter_flags_field
]);
1110 new_model
->line
= record
->line
;
1111 new_model
->name
= record
->field
[model_name_field
];
1112 new_model
->full_name
= record
->field
[model_full_name_field
];
1113 new_model
->unit_data
= record
->field
[model_unit_data_field
];
1114 /* only insert it if not filtered out */
1115 if (!filter_is_subset (options
.flags_filter
, new_model
->flags
))
1117 notify (new_model
->line
,
1118 "Discarding processor model %s - filter flags\n",
1121 else if (is_filtered_out (options
.model_filter
,
1123 field
[record_filter_models_field
]))
1125 notify (new_model
->line
,
1126 "Discarding processor model %s - filter models\n",
1129 else if (filter_is_member (model
->processors
, new_model
->name
))
1131 error (new_model
->line
, "Duplicate processor model %s\n",
1137 last
= &model
->models
;
1138 while (*last
!= NULL
)
1139 last
= &(*last
)->next
;
1143 filter_parse (&model
->processors
, new_model
->name
);
1145 /* advance things */
1146 record
= table_read (file
);
1150 case model_macro_record
:
1151 record
= parse_model_data_record (isa
, file
, record
,
1152 nr_model_macro_fields
,
1156 case model_data_record
:
1157 record
= parse_model_data_record (isa
, file
, record
,
1158 nr_model_data_fields
,
1162 case model_static_record
:
1163 record
= parse_function_record (file
, record
,
1165 NULL
, 0 /*is internal */ ,
1169 case model_internal_record
:
1170 record
= parse_function_record (file
, record
,
1172 NULL
, 1 /*is internal */ ,
1176 case model_function_record
:
1177 record
= parse_function_record (file
, record
,
1179 NULL
, 0 /*is internal */ ,
1183 case insn_record
: /* instruction records */
1185 insn_entry
*new_insn
;
1187 /* parse the instruction */
1188 if (record
->nr_fields
< nr_insn_fields
)
1189 error (record
->line
,
1190 "Incorrect nr of fields for insn record\n");
1191 new_insn
= ZALLOC (insn_entry
);
1192 new_insn
->line
= record
->line
;
1193 filter_parse (&new_insn
->flags
,
1194 record
->field
[record_filter_flags_field
]);
1195 /* save the format field. Can't parse it until after the
1196 filter-out checks. Could be filtered out because the
1197 format is invalid */
1198 format
= record
->field
[insn_word_field
];
1199 new_insn
->format_name
= record
->field
[insn_format_name_field
];
1200 if (options
.format_name_filter
!= NULL
1201 && !filter_is_member (options
.format_name_filter
,
1202 new_insn
->format_name
))
1203 error (new_insn
->line
,
1204 "Unreconized instruction format name `%s'\n",
1205 new_insn
->format_name
);
1206 filter_parse (&new_insn
->options
,
1207 record
->field
[insn_options_field
]);
1208 new_insn
->name
= record
->field
[insn_name_field
];
1209 record
= table_read (file
);
1210 /* Parse any model/assember records */
1211 new_insn
->nr_models
= model
->nr_models
;
1213 NZALLOC (insn_model_entry
*, model
->nr_models
+ 1);
1214 while (record
!= NULL
)
1216 if (record_prefix_is (record
, '*', nr_insn_model_fields
))
1217 parse_insn_model_record (file
, record
, new_insn
, model
);
1219 if (record_prefix_is (record
, '"', nr_insn_mnemonic_fields
))
1220 parse_insn_mnemonic_record (file
, record
, new_insn
);
1224 record
= table_read (file
);
1226 /* Parse the code record */
1227 if (record
!= NULL
&& record
->type
== table_code_entry
)
1229 new_insn
->code
= record
;
1230 record
= table_read (file
);
1232 else if (options
.warn
.unimplemented
)
1233 notify (new_insn
->line
, "unimplemented\n");
1235 if (!filter_is_subset (options
.flags_filter
, new_insn
->flags
))
1237 if (options
.warn
.discard
)
1238 notify (new_insn
->line
,
1239 "Discarding instruction %s (flags-filter)\n",
1242 else if (new_insn
->processors
!= NULL
1243 && options
.model_filter
!= NULL
1244 && !filter_is_common (options
.model_filter
,
1245 new_insn
->processors
))
1247 /* only discard an instruction based in the processor
1248 model when both the instruction and the options are
1250 if (options
.warn
.discard
)
1251 notify (new_insn
->line
,
1252 "Discarding instruction %s (processor-model)\n",
1258 /* finish the parsing */
1259 parse_insn_words (new_insn
, format
);
1263 last
= &(*last
)->next
;
1265 /* update global isa counters */
1267 if (isa
->max_nr_words
< new_insn
->nr_words
)
1268 isa
->max_nr_words
= new_insn
->nr_words
;
1269 filter_add (&isa
->flags
, new_insn
->flags
);
1270 filter_add (&isa
->options
, new_insn
->options
);
1276 record
= parse_macro_record (file
, record
);
1279 case unknown_record
:
1281 error (record
->line
, "Unknown or unexpected entry\n");
1291 print_insn_words (lf
*file
, insn_entry
* insn
)
1293 insn_word_entry
*word
= insn
->words
;
1298 insn_field_entry
*field
= word
->first
;
1301 if (options
.insn_specifying_widths
)
1302 lf_printf (file
, "%d.", field
->width
);
1304 lf_printf (file
, "%d.",
1305 i2target (options
.hi_bit_nr
, field
->first
));
1306 switch (field
->type
)
1308 case insn_field_invalid
:
1311 case insn_field_int
:
1312 lf_printf (file
, "0x%lx", (long) field
->val_int
);
1314 case insn_field_reserved
:
1315 lf_printf (file
, "/");
1317 case insn_field_wild
:
1318 lf_printf (file
, "*");
1320 case insn_field_string
:
1321 lf_printf (file
, "%s", field
->val_string
);
1324 if (field
== word
->last
)
1326 field
= field
->next
;
1327 lf_printf (file
, ",");
1332 lf_printf (file
, "+");
1340 function_entry_traverse (lf
*file
,
1341 function_entry
* functions
,
1342 function_entry_handler
* handler
, void *data
)
1344 function_entry
*function
;
1345 for (function
= functions
; function
!= NULL
; function
= function
->next
)
1347 handler (file
, function
, data
);
1352 insn_table_traverse_insn (lf
*file
,
1354 insn_entry_handler
* handler
, void *data
)
1357 for (insn
= isa
->insns
; insn
!= NULL
; insn
= insn
->next
)
1359 handler (file
, isa
, insn
, data
);
1365 dump_function_entry (lf
*file
,
1366 char *prefix
, function_entry
* entry
, char *suffix
)
1368 lf_printf (file
, "%s(function_entry *) 0x%lx", prefix
, (long) entry
);
1371 dump_line_ref (file
, "\n(line ", entry
->line
, ")");
1372 dump_filter (file
, "\n(flags ", entry
->flags
, ")");
1373 lf_printf (file
, "\n(type \"%s\")", entry
->type
);
1374 lf_printf (file
, "\n(name \"%s\")", entry
->name
);
1375 lf_printf (file
, "\n(param \"%s\")", entry
->param
);
1376 dump_table_entry (file
, "\n(code ", entry
->code
, ")");
1377 lf_printf (file
, "\n(is_internal %d)", entry
->is_internal
);
1378 lf_printf (file
, "\n(next 0x%lx)", (long) entry
->next
);
1380 lf_printf (file
, "%s", suffix
);
1384 dump_function_entries (lf
*file
,
1385 char *prefix
, function_entry
* entry
, char *suffix
)
1387 lf_printf (file
, "%s", prefix
);
1388 lf_indent (file
, +1);
1389 while (entry
!= NULL
)
1391 dump_function_entry (file
, "\n(", entry
, ")");
1392 entry
= entry
->next
;
1394 lf_indent (file
, -1);
1395 lf_printf (file
, "%s", suffix
);
1399 cache_entry_type_to_str (cache_entry_type type
)
1410 ERROR ("Bad switch");
1415 dump_cache_entry (lf
*file
, char *prefix
, cache_entry
*entry
, char *suffix
)
1417 lf_printf (file
, "%s(cache_entry *) 0x%lx", prefix
, (long) entry
);
1420 dump_line_ref (file
, "\n(line ", entry
->line
, ")");
1421 dump_filter (file
, "\n(flags ", entry
->flags
, ")");
1422 lf_printf (file
, "\n(entry_type \"%s\")",
1423 cache_entry_type_to_str (entry
->entry_type
));
1424 lf_printf (file
, "\n(name \"%s\")", entry
->name
);
1425 dump_filter (file
, "\n(original_fields ", entry
->original_fields
, ")");
1426 lf_printf (file
, "\n(type \"%s\")", entry
->type
);
1427 lf_printf (file
, "\n(expression \"%s\")", entry
->expression
);
1428 lf_printf (file
, "\n(next 0x%lx)", (long) entry
->next
);
1430 lf_printf (file
, "%s", suffix
);
1434 dump_cache_entries (lf
*file
, char *prefix
, cache_entry
*entry
, char *suffix
)
1436 lf_printf (file
, "%s", prefix
);
1437 lf_indent (file
, +1);
1438 while (entry
!= NULL
)
1440 dump_cache_entry (file
, "\n(", entry
, ")");
1441 entry
= entry
->next
;
1443 lf_indent (file
, -1);
1444 lf_printf (file
, "%s", suffix
);
1448 dump_model_data (lf
*file
, char *prefix
, model_data
*entry
, char *suffix
)
1450 lf_printf (file
, "%s(model_data *) 0x%lx", prefix
, (long) entry
);
1453 lf_indent (file
, +1);
1454 dump_line_ref (file
, "\n(line ", entry
->line
, ")");
1455 dump_filter (file
, "\n(flags ", entry
->flags
, ")");
1456 dump_table_entry (file
, "\n(entry ", entry
->entry
, ")");
1457 dump_table_entry (file
, "\n(code ", entry
->code
, ")");
1458 lf_printf (file
, "\n(next 0x%lx)", (long) entry
->next
);
1459 lf_indent (file
, -1);
1461 lf_printf (file
, "%s", prefix
);
1465 dump_model_datas (lf
*file
, char *prefix
, model_data
*entry
, char *suffix
)
1467 lf_printf (file
, "%s", prefix
);
1468 lf_indent (file
, +1);
1469 while (entry
!= NULL
)
1471 dump_model_data (file
, "\n(", entry
, ")");
1472 entry
= entry
->next
;
1474 lf_indent (file
, -1);
1475 lf_printf (file
, "%s", suffix
);
1479 dump_model_entry (lf
*file
, char *prefix
, model_entry
*entry
, char *suffix
)
1481 lf_printf (file
, "%s(model_entry *) 0x%lx", prefix
, (long) entry
);
1484 lf_indent (file
, +1);
1485 dump_line_ref (file
, "\n(line ", entry
->line
, ")");
1486 dump_filter (file
, "\n(flags ", entry
->flags
, ")");
1487 lf_printf (file
, "\n(name \"%s\")", entry
->name
);
1488 lf_printf (file
, "\n(full_name \"%s\")", entry
->full_name
);
1489 lf_printf (file
, "\n(unit_data \"%s\")", entry
->unit_data
);
1490 lf_printf (file
, "\n(next 0x%lx)", (long) entry
->next
);
1491 lf_indent (file
, -1);
1493 lf_printf (file
, "%s", prefix
);
1497 dump_model_entries (lf
*file
, char *prefix
, model_entry
*entry
, char *suffix
)
1499 lf_printf (file
, "%s", prefix
);
1500 lf_indent (file
, +1);
1501 while (entry
!= NULL
)
1503 dump_model_entry (file
, "\n(", entry
, ")");
1504 entry
= entry
->next
;
1506 lf_indent (file
, -1);
1507 lf_printf (file
, "%s", suffix
);
1512 dump_model_table (lf
*file
, char *prefix
, model_table
*entry
, char *suffix
)
1514 lf_printf (file
, "%s(model_table *) 0x%lx", prefix
, (long) entry
);
1517 lf_indent (file
, +1);
1518 dump_filter (file
, "\n(processors ", entry
->processors
, ")");
1519 lf_printf (file
, "\n(nr_models %d)", entry
->nr_models
);
1520 dump_model_entries (file
, "\n(models ", entry
->models
, ")");
1521 dump_model_datas (file
, "\n(macros ", entry
->macros
, ")");
1522 dump_model_datas (file
, "\n(data ", entry
->data
, ")");
1523 dump_function_entries (file
, "\n(statics ", entry
->statics
, ")");
1524 dump_function_entries (file
, "\n(internals ", entry
->functions
, ")");
1525 dump_function_entries (file
, "\n(functions ", entry
->functions
, ")");
1526 lf_indent (file
, -1);
1528 lf_printf (file
, "%s", suffix
);
1533 insn_field_type_to_str (insn_field_type type
)
1537 case insn_field_invalid
:
1540 case insn_field_int
:
1542 case insn_field_reserved
:
1544 case insn_field_wild
:
1546 case insn_field_string
:
1549 ERROR ("bad switch");
1554 dump_insn_field (lf
*file
,
1555 char *prefix
, insn_field_entry
*field
, char *suffix
)
1558 lf_printf (file
, "%s(insn_field_entry *) 0x%lx", prefix
, (long) field
);
1561 lf_indent (file
, +1);
1562 lf_printf (file
, "%s(first %d)", sep
, field
->first
);
1563 lf_printf (file
, "%s(last %d)", sep
, field
->last
);
1564 lf_printf (file
, "%s(width %d)", sep
, field
->width
);
1565 lf_printf (file
, "%s(type %s)", sep
,
1566 insn_field_type_to_str (field
->type
));
1567 switch (field
->type
)
1569 case insn_field_invalid
:
1572 case insn_field_int
:
1573 lf_printf (file
, "%s(val 0x%lx)", sep
, (long) field
->val_int
);
1575 case insn_field_reserved
:
1576 /* nothing output */
1578 case insn_field_wild
:
1579 /* nothing output */
1581 case insn_field_string
:
1582 lf_printf (file
, "%s(val \"%s\")", sep
, field
->val_string
);
1585 lf_printf (file
, "%s(next 0x%lx)", sep
, (long) field
->next
);
1586 lf_printf (file
, "%s(prev 0x%lx)", sep
, (long) field
->prev
);
1587 lf_indent (file
, -1);
1589 lf_printf (file
, "%s", suffix
);
1593 dump_insn_word_entry (lf
*file
,
1594 char *prefix
, insn_word_entry
*word
, char *suffix
)
1596 lf_printf (file
, "%s(insn_word_entry *) 0x%lx", prefix
, (long) word
);
1600 insn_field_entry
*field
;
1601 lf_indent (file
, +1);
1602 lf_printf (file
, "\n(first 0x%lx)", (long) word
->first
);
1603 lf_printf (file
, "\n(last 0x%lx)", (long) word
->last
);
1604 lf_printf (file
, "\n(bit");
1605 for (i
= 0; i
< options
.insn_bit_size
; i
++)
1606 lf_printf (file
, "\n ((value %d) (mask %d) (field 0x%lx))",
1607 word
->bit
[i
]->value
, word
->bit
[i
]->mask
,
1608 (long) word
->bit
[i
]->field
);
1609 lf_printf (file
, ")");
1610 for (field
= word
->first
; field
!= NULL
; field
= field
->next
)
1611 dump_insn_field (file
, "\n(", field
, ")");
1612 dump_filter (file
, "\n(field_names ", word
->field_names
, ")");
1613 lf_printf (file
, "\n(next 0x%lx)", (long) word
->next
);
1614 lf_indent (file
, -1);
1616 lf_printf (file
, "%s", suffix
);
1620 dump_insn_word_entries (lf
*file
,
1621 char *prefix
, insn_word_entry
*word
, char *suffix
)
1623 lf_printf (file
, "%s", prefix
);
1624 while (word
!= NULL
)
1626 dump_insn_word_entry (file
, "\n(", word
, ")");
1629 lf_printf (file
, "%s", suffix
);
1633 dump_insn_model_entry (lf
*file
,
1634 char *prefix
, insn_model_entry
*model
, char *suffix
)
1636 lf_printf (file
, "%s(insn_model_entry *) 0x%lx", prefix
, (long) model
);
1639 lf_indent (file
, +1);
1640 dump_line_ref (file
, "\n(line ", model
->line
, ")");
1641 dump_filter (file
, "\n(names ", model
->names
, ")");
1642 lf_printf (file
, "\n(full_name \"%s\")", model
->full_name
);
1643 lf_printf (file
, "\n(unit_data \"%s\")", model
->unit_data
);
1644 lf_printf (file
, "\n(insn (insn_entry *) 0x%lx)", (long) model
->insn
);
1645 lf_printf (file
, "\n(next (insn_model_entry *) 0x%lx)",
1646 (long) model
->next
);
1647 lf_indent (file
, -1);
1649 lf_printf (file
, "%s", suffix
);
1653 dump_insn_model_entries (lf
*file
,
1654 char *prefix
, insn_model_entry
*model
, char *suffix
)
1656 lf_printf (file
, "%s", prefix
);
1657 while (model
!= NULL
)
1659 dump_insn_model_entry (file
, "\n", model
, "");
1660 model
= model
->next
;
1662 lf_printf (file
, "%s", suffix
);
1667 dump_insn_mnemonic_entry (lf
*file
,
1669 insn_mnemonic_entry
*mnemonic
, char *suffix
)
1671 lf_printf (file
, "%s(insn_mnemonic_entry *) 0x%lx", prefix
,
1673 if (mnemonic
!= NULL
)
1675 lf_indent (file
, +1);
1676 dump_line_ref (file
, "\n(line ", mnemonic
->line
, ")");
1677 lf_printf (file
, "\n(format \"%s\")", mnemonic
->format
);
1678 lf_printf (file
, "\n(condition \"%s\")", mnemonic
->condition
);
1679 lf_printf (file
, "\n(insn (insn_entry *) 0x%lx)",
1680 (long) mnemonic
->insn
);
1681 lf_printf (file
, "\n(next (insn_mnemonic_entry *) 0x%lx)",
1682 (long) mnemonic
->next
);
1683 lf_indent (file
, -1);
1685 lf_printf (file
, "%s", suffix
);
1689 dump_insn_mnemonic_entries (lf
*file
,
1691 insn_mnemonic_entry
*mnemonic
, char *suffix
)
1693 lf_printf (file
, "%s", prefix
);
1694 while (mnemonic
!= NULL
)
1696 dump_insn_mnemonic_entry (file
, "\n", mnemonic
, "");
1697 mnemonic
= mnemonic
->next
;
1699 lf_printf (file
, "%s", suffix
);
1703 dump_insn_entry (lf
*file
, char *prefix
, insn_entry
* entry
, char *suffix
)
1705 lf_printf (file
, "%s(insn_entry *) 0x%lx", prefix
, (long) entry
);
1709 lf_indent (file
, +1);
1710 dump_line_ref (file
, "\n(line ", entry
->line
, ")");
1711 dump_filter (file
, "\n(flags ", entry
->flags
, ")");
1712 lf_printf (file
, "\n(nr_words %d)", entry
->nr_words
);
1713 dump_insn_word_entries (file
, "\n(words ", entry
->words
, ")");
1714 lf_printf (file
, "\n(word");
1715 for (i
= 0; i
< entry
->nr_models
; i
++)
1716 lf_printf (file
, " 0x%lx", (long) entry
->word
[i
]);
1717 lf_printf (file
, ")");
1718 dump_filter (file
, "\n(field_names ", entry
->field_names
, ")");
1719 lf_printf (file
, "\n(format_name \"%s\")", entry
->format_name
);
1720 dump_filter (file
, "\n(options ", entry
->options
, ")");
1721 lf_printf (file
, "\n(name \"%s\")", entry
->name
);
1722 lf_printf (file
, "\n(nr_models %d)", entry
->nr_models
);
1723 dump_insn_model_entries (file
, "\n(models ", entry
->models
, ")");
1724 lf_printf (file
, "\n(model");
1725 for (i
= 0; i
< entry
->nr_models
; i
++)
1726 lf_printf (file
, " 0x%lx", (long) entry
->model
[i
]);
1727 lf_printf (file
, ")");
1728 dump_filter (file
, "\n(processors ", entry
->processors
, ")");
1729 dump_insn_mnemonic_entries (file
, "\n(mnemonics ", entry
->mnemonics
,
1731 dump_table_entry (file
, "\n(code ", entry
->code
, ")");
1732 lf_printf (file
, "\n(next 0x%lx)", (long) entry
->next
);
1733 lf_indent (file
, -1);
1735 lf_printf (file
, "%s", suffix
);
1739 dump_insn_entries (lf
*file
, char *prefix
, insn_entry
* entry
, char *suffix
)
1741 lf_printf (file
, "%s", prefix
);
1742 lf_indent (file
, +1);
1743 while (entry
!= NULL
)
1745 dump_insn_entry (file
, "\n(", entry
, ")");
1746 entry
= entry
->next
;
1748 lf_indent (file
, -1);
1749 lf_printf (file
, "%s", suffix
);
1755 dump_insn_table (lf
*file
, char *prefix
, insn_table
*isa
, char *suffix
)
1757 lf_printf (file
, "%s(insn_table *) 0x%lx", prefix
, (long) isa
);
1760 lf_indent (file
, +1);
1761 dump_cache_entries (file
, "\n(caches ", isa
->caches
, ")");
1762 lf_printf (file
, "\n(nr_insns %d)", isa
->nr_insns
);
1763 lf_printf (file
, "\n(max_nr_words %d)", isa
->max_nr_words
);
1764 dump_insn_entries (file
, "\n(insns ", isa
->insns
, ")");
1765 dump_function_entries (file
, "\n(functions ", isa
->functions
, ")");
1766 dump_insn_entry (file
, "\n(illegal_insn ", isa
->illegal_insn
, ")");
1767 dump_model_table (file
, "\n(model ", isa
->model
, ")");
1768 dump_filter (file
, "\n(flags ", isa
->flags
, ")");
1769 dump_filter (file
, "\n(options ", isa
->options
, ")");
1770 lf_indent (file
, -1);
1772 lf_printf (file
, "%s", suffix
);
1777 igen_options options
;
1780 main (int argc
, char **argv
)
1785 INIT_OPTIONS (options
);
1788 filter_parse (&options
.flags_filter
, argv
[2]);
1790 error (NULL
, "Usage: insn <insn-table> [ <filter-in> ]\n");
1792 isa
= load_insn_table (argv
[1], NULL
);
1793 l
= lf_open ("-", "stdout", lf_omit_references
, lf_is_text
, "tmp-ld-insn");
1794 dump_insn_table (l
, "(isa ", isa
, ")\n");