1 /* This file is part of the program psim.
3 Copyright (C) 1994,1995,1996, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include "ld-decode.h"
33 update_depth(insn_table
*entry
,
39 int *max_depth
= (int*)data
;
40 if (*max_depth
< depth
)
46 insn_table_depth(insn_table
*table
)
49 insn_table_traverse_tree(table
,
62 parse_insn_format(table_entry
*entry
,
66 insn_fields
*fields
= ZALLOC(insn_fields
);
68 /* create a leading sentinal */
69 fields
->first
= ZALLOC(insn_field
);
70 fields
->first
->first
= -1;
71 fields
->first
->last
= -1;
72 fields
->first
->width
= 0;
74 /* and a trailing sentinal */
75 fields
->last
= ZALLOC(insn_field
);
76 fields
->last
->first
= insn_bit_size
;
77 fields
->last
->last
= insn_bit_size
;
78 fields
->last
->width
= 0;
80 /* link them together */
81 fields
->first
->next
= fields
->last
;
82 fields
->last
->prev
= fields
->first
;
84 /* now work through the formats */
87 while (*chp
!= '\0') {
92 insn_field
*new_field
;
96 error("%s:%d: missing position field at `%s'\n",
97 entry
->file_name
, entry
->line_nr
, chp
);
100 /* break out the bit position */
102 while (isdigit(*chp
))
104 strlen_pos
= chp
- start_pos
;
105 if (*chp
== '.' && strlen_pos
> 0)
108 error("%s:%d: missing field value at %s\n",
109 entry
->file_name
, entry
->line_nr
, chp
);
113 /* break out the value */
115 while ((*start_val
== '/' && *chp
== '/')
116 || (isdigit(*start_val
) && isdigit(*chp
))
117 || (isalpha(*start_val
) && (isalnum(*chp
) || *chp
== '_')))
119 strlen_val
= chp
- start_val
;
122 else if (*chp
!= '\0' || strlen_val
== 0) {
123 error("%s:%d: missing field terminator at %s\n",
124 entry
->file_name
, entry
->line_nr
, chp
);
128 /* create a new field and insert it */
129 new_field
= ZALLOC(insn_field
);
130 new_field
->next
= fields
->last
;
131 new_field
->prev
= fields
->last
->prev
;
132 new_field
->next
->prev
= new_field
;
133 new_field
->prev
->next
= new_field
;
136 new_field
->val_string
= (char*)zalloc(strlen_val
+1);
137 strncpy(new_field
->val_string
, start_val
, strlen_val
);
138 if (isdigit(*new_field
->val_string
)) {
139 new_field
->val_int
= a2i(new_field
->val_string
);
140 new_field
->is_int
= 1;
142 else if (new_field
->val_string
[0] == '/') {
143 new_field
->is_slash
= 1;
146 new_field
->is_string
= 1;
150 new_field
->pos_string
= (char*)zalloc(strlen_pos
+1);
151 strncpy(new_field
->pos_string
, start_pos
, strlen_pos
);
152 new_field
->first
= target_a2i(hi_bit_nr
, new_field
->pos_string
);
153 new_field
->last
= new_field
->next
->first
- 1; /* guess */
154 new_field
->width
= new_field
->last
- new_field
->first
+ 1; /* guess */
155 new_field
->prev
->last
= new_field
->first
-1; /*fix*/
156 new_field
->prev
->width
= new_field
->first
- new_field
->prev
->first
; /*fix*/
159 /* fiddle first/last so that the sentinals `disapear' */
160 ASSERT(fields
->first
->last
< 0);
161 ASSERT(fields
->last
->first
>= insn_bit_size
);
162 fields
->first
= fields
->first
->next
;
163 fields
->last
= fields
->last
->prev
;
165 /* now go over this again, pointing each bit position at a field
170 field
= fields
->first
;
171 for (i
= 0; i
< insn_bit_size
; i
++) {
172 while (field
->last
< i
)
174 fields
->bits
[i
] = field
;
178 /* go over each of the fields, and compute a `value' for the insn */
182 for (field
= fields
->first
;
183 field
->last
< insn_bit_size
;
184 field
= field
->next
) {
185 fields
->value
<<= field
->width
;
187 fields
->value
|= field
->val_int
;
195 model_table_insert(insn_table
*table
,
196 table_entry
*file_entry
)
200 /* create a new model */
201 model
*new_model
= ZALLOC(model
);
203 new_model
->name
= file_entry
->fields
[model_identifer
];
204 new_model
->printable_name
= file_entry
->fields
[model_name
];
205 new_model
->insn_default
= file_entry
->fields
[model_default
];
207 while (*new_model
->insn_default
&& isspace(*new_model
->insn_default
))
208 new_model
->insn_default
++;
210 len
= strlen(new_model
->insn_default
);
211 if (max_model_fields_len
< len
)
212 max_model_fields_len
= len
;
214 /* append it to the end of the model list */
216 last_model
->next
= new_model
;
219 last_model
= new_model
;
223 model_table_insert_specific(insn_table
*table
,
224 table_entry
*file_entry
,
228 insn
*ptr
= ZALLOC(insn
);
229 ptr
->file_entry
= file_entry
;
231 (*end_ptr
)->next
= ptr
;
239 insn_table_insert_function(insn_table
*table
,
240 table_entry
*file_entry
)
242 /* create a new function */
243 insn
*new_function
= ZALLOC(insn
);
244 new_function
->file_entry
= file_entry
;
246 /* append it to the end of the function list */
247 if (table
->last_function
)
248 table
->last_function
->next
= new_function
;
250 table
->functions
= new_function
;
251 table
->last_function
= new_function
;
255 insn_table_insert_insn(insn_table
*table
,
256 table_entry
*file_entry
,
259 insn
**ptr_to_cur_insn
= &table
->insns
;
260 insn
*cur_insn
= *ptr_to_cur_insn
;
261 table_model_entry
*insn_model_ptr
;
264 /* create a new instruction */
265 insn
*new_insn
= ZALLOC(insn
);
266 new_insn
->file_entry
= file_entry
;
267 new_insn
->fields
= fields
;
269 /* Check out any model information returned to make sure the model
271 for(insn_model_ptr
= file_entry
->model_first
; insn_model_ptr
; insn_model_ptr
= insn_model_ptr
->next
) {
272 char *name
= insn_model_ptr
->fields
[insn_model_name
];
273 int len
= strlen (insn_model_ptr
->fields
[insn_model_fields
]);
275 while (len
> 0 && isspace(*insn_model_ptr
->fields
[insn_model_fields
])) {
277 insn_model_ptr
->fields
[insn_model_fields
]++;
280 if (max_model_fields_len
< len
)
281 max_model_fields_len
= len
;
283 for(model_ptr
= models
; model_ptr
; model_ptr
= model_ptr
->next
) {
284 if (strcmp(name
, model_ptr
->printable_name
) == 0) {
286 /* Replace the name field with that of the global model, so that when we
287 want to print it out, we can just compare pointers. */
288 insn_model_ptr
->fields
[insn_model_name
] = model_ptr
->printable_name
;
294 error("%s:%d: machine model `%s' was not known about\n",
295 file_entry
->file_name
, file_entry
->line_nr
, name
);
298 /* insert it according to the order of the fields */
299 while (cur_insn
!= NULL
300 && new_insn
->fields
->value
>= cur_insn
->fields
->value
) {
301 ptr_to_cur_insn
= &cur_insn
->next
;
302 cur_insn
= *ptr_to_cur_insn
;
305 new_insn
->next
= cur_insn
;
306 *ptr_to_cur_insn
= new_insn
;
314 load_insn_table(const char *file_name
,
315 decode_table
*decode_rules
,
318 table
*file
= table_open(file_name
, nr_insn_table_fields
, nr_insn_model_table_fields
);
319 insn_table
*table
= ZALLOC(insn_table
);
320 table_entry
*file_entry
;
321 table
->opcode_rule
= decode_rules
;
323 while ((file_entry
= table_entry_read(file
)) != NULL
) {
324 if (it_is("function", file_entry
->fields
[insn_flags
])
325 || it_is("internal", file_entry
->fields
[insn_flags
])) {
326 insn_table_insert_function(table
, file_entry
);
328 else if (it_is("model", file_entry
->fields
[insn_flags
])) {
329 model_table_insert(table
, file_entry
);
331 else if (it_is("model-macro", file_entry
->fields
[insn_flags
])) {
332 model_table_insert_specific(table
, file_entry
, &model_macros
, &last_model_macro
);
334 else if (it_is("model-function", file_entry
->fields
[insn_flags
])) {
335 model_table_insert_specific(table
, file_entry
, &model_functions
, &last_model_function
);
337 else if (it_is("model-internal", file_entry
->fields
[insn_flags
])) {
338 model_table_insert_specific(table
, file_entry
, &model_internal
, &last_model_internal
);
340 else if (it_is("model-static", file_entry
->fields
[insn_flags
])) {
341 model_table_insert_specific(table
, file_entry
, &model_static
, &last_model_static
);
343 else if (it_is("model-data", file_entry
->fields
[insn_flags
])) {
344 model_table_insert_specific(table
, file_entry
, &model_data
, &last_model_data
);
348 /* skip instructions that aren't relevant to the mode */
349 if (is_filtered_out(file_entry
->fields
[insn_flags
], filters
)) {
350 fprintf(stderr
, "Dropping %s - %s\n",
351 file_entry
->fields
[insn_name
],
352 file_entry
->fields
[insn_flags
]);
355 /* create/insert the new instruction */
356 fields
= parse_insn_format(file_entry
,
357 file_entry
->fields
[insn_format
]);
358 insn_table_insert_insn(table
, file_entry
, fields
);
367 insn_table_traverse_tree(insn_table
*table
,
374 padding_handler
*padding
)
380 && table
->opcode
!= NULL
381 && table
->nr_entries
> 0
382 && table
->entries
!= 0);
384 if (start
!= NULL
&& depth
>= 0)
385 start(table
, file
, data
, depth
);
387 for (entry_nr
= 0, entry
= table
->entries
;
388 entry_nr
< (table
->opcode
->is_boolean
390 : (1 << (table
->opcode
->last
- table
->opcode
->first
+ 1)));
393 || (!table
->opcode
->is_boolean
394 && entry_nr
< entry
->opcode_nr
)) {
395 if (padding
!= NULL
&& depth
>= 0)
396 padding(table
, file
, data
, depth
, entry_nr
);
399 ASSERT(entry
!= NULL
&& (entry
->opcode_nr
== entry_nr
400 || table
->opcode
->is_boolean
));
401 if (entry
->opcode
!= NULL
&& depth
!= 0) {
402 insn_table_traverse_tree(entry
, file
, data
, depth
+1,
403 start
, leaf
, end
, padding
);
405 else if (depth
>= 0) {
407 leaf(entry
, file
, data
, entry
->insns
, depth
);
409 entry
= entry
->sibling
;
412 if (end
!= NULL
&& depth
>= 0)
413 end(table
, file
, data
, depth
);
418 insn_table_traverse_function(insn_table
*table
,
421 function_handler
*leaf
)
424 for (function
= table
->functions
;
426 function
= function
->next
) {
427 leaf(table
, file
, data
, function
->file_entry
);
432 insn_table_traverse_insn(insn_table
*table
,
435 insn_handler
*handler
)
438 for (instruction
= table
->insns
;
440 instruction
= instruction
->next
) {
441 handler(table
, file
, data
, instruction
, 0);
446 /****************************************************************/
449 field_constant_int
= 1,
450 field_constant_slash
= 2,
451 field_constant_string
= 3
452 } constant_field_types
;
456 insn_field_is_constant(insn_field
*field
,
459 /* field is an integer */
461 return field_constant_int
;
462 /* field is `/' and treating that as a constant */
463 if (field
->is_slash
&& rule
->force_slash
)
464 return field_constant_slash
;
465 /* field, though variable is on the list */
466 if (field
->is_string
&& rule
->force_expansion
!= NULL
) {
467 char *forced_fields
= rule
->force_expansion
;
468 while (*forced_fields
!= '\0') {
470 char *end
= strchr(forced_fields
, ',');
472 field_len
= strlen(forced_fields
);
474 field_len
= end
-forced_fields
;
475 if (strncmp(forced_fields
, field
->val_string
, field_len
) == 0
476 && field
->val_string
[field_len
] == '\0')
477 return field_constant_string
;
478 forced_fields
+= field_len
;
479 if (*forced_fields
== ',')
487 static opcode_field
*
488 insn_table_find_opcode_field(insn
*insns
,
492 opcode_field
*curr_opcode
= ZALLOC(opcode_field
);
496 curr_opcode
->first
= insn_bit_size
;
497 curr_opcode
->last
= -1;
498 for (entry
= insns
; entry
!= NULL
; entry
= entry
->next
) {
499 insn_fields
*fields
= entry
->fields
;
500 opcode_field new_opcode
;
502 /* find a start point for the opcode field */
503 new_opcode
.first
= rule
->first
;
504 while (new_opcode
.first
<= rule
->last
506 || insn_field_is_constant(fields
->bits
[new_opcode
.first
],
507 rule
) != field_constant_string
)
509 || !insn_field_is_constant(fields
->bits
[new_opcode
.first
],
511 new_opcode
.first
= fields
->bits
[new_opcode
.first
]->last
+ 1;
512 ASSERT(new_opcode
.first
> rule
->last
514 && insn_field_is_constant(fields
->bits
[new_opcode
.first
],
515 rule
) == field_constant_string
)
517 && insn_field_is_constant(fields
->bits
[new_opcode
.first
],
520 /* find the end point for the opcode field */
521 new_opcode
.last
= rule
->last
;
522 while (new_opcode
.last
>= rule
->first
524 || insn_field_is_constant(fields
->bits
[new_opcode
.last
],
525 rule
) != field_constant_string
)
527 || !insn_field_is_constant(fields
->bits
[new_opcode
.last
],
529 new_opcode
.last
= fields
->bits
[new_opcode
.last
]->first
- 1;
530 ASSERT(new_opcode
.last
< rule
->first
532 && insn_field_is_constant(fields
->bits
[new_opcode
.last
],
533 rule
) == field_constant_string
)
535 && insn_field_is_constant(fields
->bits
[new_opcode
.last
],
538 /* now see if our current opcode needs expanding */
539 if (new_opcode
.first
<= rule
->last
540 && curr_opcode
->first
> new_opcode
.first
)
541 curr_opcode
->first
= new_opcode
.first
;
542 if (new_opcode
.last
>= rule
->first
543 && curr_opcode
->last
< new_opcode
.last
)
544 curr_opcode
->last
= new_opcode
.last
;
548 /* was any thing interesting found? */
549 if (curr_opcode
->first
> rule
->last
) {
550 ASSERT(curr_opcode
->last
< rule
->first
);
553 ASSERT(curr_opcode
->last
>= rule
->first
);
554 ASSERT(curr_opcode
->first
<= rule
->last
);
556 /* if something was found, check it includes the forced field range */
558 && curr_opcode
->first
> rule
->force_first
) {
559 curr_opcode
->first
= rule
->force_first
;
562 && curr_opcode
->last
< rule
->force_last
) {
563 curr_opcode
->last
= rule
->force_last
;
565 /* handle special case elminating any need to do shift after mask */
567 && rule
->force_last
== insn_bit_size
-1) {
568 curr_opcode
->last
= insn_bit_size
-1;
571 /* handle any special cases */
572 switch (rule
->type
) {
573 case normal_decode_rule
:
574 /* let the above apply */
576 case expand_forced_rule
:
577 /* expand a limited nr of bits, ignoring the rest */
578 curr_opcode
->first
= rule
->force_first
;
579 curr_opcode
->last
= rule
->force_last
;
582 curr_opcode
->is_boolean
= 1;
583 curr_opcode
->boolean_constant
= rule
->special_constant
;
586 error("Something is going wrong\n");
594 insn_table_insert_expanded(insn_table
*table
,
599 insn_table
**ptr_to_cur_entry
= &table
->entries
;
600 insn_table
*cur_entry
= *ptr_to_cur_entry
;
602 /* find the new table for this entry */
603 while (cur_entry
!= NULL
604 && cur_entry
->opcode_nr
< new_opcode_nr
) {
605 ptr_to_cur_entry
= &cur_entry
->sibling
;
606 cur_entry
= *ptr_to_cur_entry
;
609 if (cur_entry
== NULL
|| cur_entry
->opcode_nr
!= new_opcode_nr
) {
610 insn_table
*new_entry
= ZALLOC(insn_table
);
611 new_entry
->opcode_nr
= new_opcode_nr
;
612 new_entry
->expanded_bits
= new_bits
;
613 new_entry
->opcode_rule
= table
->opcode_rule
->next
;
614 new_entry
->sibling
= cur_entry
;
615 new_entry
->parent
= table
;
616 *ptr_to_cur_entry
= new_entry
;
617 cur_entry
= new_entry
;
620 /* ASSERT new_bits == cur_entry bits */
621 ASSERT(cur_entry
!= NULL
&& cur_entry
->opcode_nr
== new_opcode_nr
);
622 insn_table_insert_insn(cur_entry
,
623 old_insn
->file_entry
,
628 insn_table_expand_opcode(insn_table
*table
,
635 if (field_nr
> table
->opcode
->last
) {
636 insn_table_insert_expanded(table
, instruction
, opcode_nr
, bits
);
639 insn_field
*field
= instruction
->fields
->bits
[field_nr
];
640 if (field
->is_int
|| field
->is_slash
) {
641 ASSERT(field
->first
>= table
->opcode
->first
642 && field
->last
<= table
->opcode
->last
);
643 insn_table_expand_opcode(table
, instruction
, field
->last
+1,
644 ((opcode_nr
<< field
->width
) + field
->val_int
),
649 int last_pos
= ((field
->last
< table
->opcode
->last
)
650 ? field
->last
: table
->opcode
->last
);
651 int first_pos
= ((field
->first
> table
->opcode
->first
)
652 ? field
->first
: table
->opcode
->first
);
653 int width
= last_pos
- first_pos
+ 1;
654 int last_val
= (table
->opcode
->is_boolean
656 for (val
= 0; val
< last_val
; val
++) {
657 insn_bits
*new_bits
= ZALLOC(insn_bits
);
658 new_bits
->field
= field
;
659 new_bits
->value
= val
;
660 new_bits
->last
= bits
;
661 new_bits
->opcode
= table
->opcode
;
662 insn_table_expand_opcode(table
, instruction
, last_pos
+1,
663 ((opcode_nr
<< width
) | val
),
671 insn_table_insert_expanding(insn_table
*table
,
674 insn_table_expand_opcode(table
,
676 table
->opcode
->first
,
678 table
->expanded_bits
);
683 insn_table_expand_insns(insn_table
*table
)
686 ASSERT(table
->nr_insn
>= 1);
688 /* determine a valid opcode */
689 while (table
->opcode_rule
) {
690 /* specials only for single instructions */
691 if ((table
->nr_insn
> 1
692 && table
->opcode_rule
->special_mask
== 0
693 && table
->opcode_rule
->type
== normal_decode_rule
)
694 || (table
->nr_insn
== 1
695 && table
->opcode_rule
->special_mask
!= 0
696 && ((table
->insns
->fields
->value
697 & table
->opcode_rule
->special_mask
)
698 == table
->opcode_rule
->special_value
))
699 || (generate_expanded_instructions
700 && table
->opcode_rule
->special_mask
== 0
701 && table
->opcode_rule
->type
== normal_decode_rule
))
703 insn_table_find_opcode_field(table
->insns
,
705 table
->nr_insn
== 1/*string*/
707 if (table
->opcode
!= NULL
)
709 table
->opcode_rule
= table
->opcode_rule
->next
;
712 /* did we find anything */
713 if (table
->opcode
== NULL
) {
716 ASSERT(table
->opcode
!= NULL
);
718 /* back link what we found to its parent */
719 if (table
->parent
!= NULL
) {
720 ASSERT(table
->parent
->opcode
!= NULL
);
721 table
->opcode
->parent
= table
->parent
->opcode
;
724 /* expand the raw instructions according to the opcode */
727 for (entry
= table
->insns
; entry
!= NULL
; entry
= entry
->next
) {
728 insn_table_insert_expanding(table
, entry
);
732 /* and do the same for the sub entries */
735 for (entry
= table
->entries
; entry
!= NULL
; entry
= entry
->sibling
) {
736 insn_table_expand_insns(entry
);
747 dump_insn_field(insn_field
*field
,
751 printf("(insn_field*)0x%x\n", (unsigned)field
);
753 dumpf(indent
, "(first %d)\n", field
->first
);
755 dumpf(indent
, "(last %d)\n", field
->last
);
757 dumpf(indent
, "(width %d)\n", field
->width
);
760 dumpf(indent
, "(is_int %d)\n", field
->val_int
);
763 dumpf(indent
, "(is_slash)\n");
765 if (field
->is_string
)
766 dumpf(indent
, "(is_string `%s')\n", field
->val_string
);
768 dumpf(indent
, "(next 0x%x)\n", field
->next
);
770 dumpf(indent
, "(prev 0x%x)\n", field
->prev
);
776 dump_insn_fields(insn_fields
*fields
,
781 printf("(insn_fields*)%p\n", fields
);
783 dumpf(indent
, "(first 0x%x)\n", fields
->first
);
784 dumpf(indent
, "(last 0x%x)\n", fields
->last
);
786 dumpf(indent
, "(value 0x%x)\n", fields
->value
);
788 for (i
= 0; i
< insn_bit_size
; i
++) {
789 dumpf(indent
, "(bits[%d] ", i
, fields
->bits
[i
]);
790 dump_insn_field(fields
->bits
[i
], indent
+1);
791 dumpf(indent
, " )\n");
798 dump_opcode_field(opcode_field
*field
, int indent
, int levels
)
800 printf("(opcode_field*)%p\n", field
);
801 if (levels
&& field
!= NULL
) {
802 dumpf(indent
, "(first %d)\n", field
->first
);
803 dumpf(indent
, "(last %d)\n", field
->last
);
804 dumpf(indent
, "(is_boolean %d)\n", field
->is_boolean
);
805 dumpf(indent
, "(parent ");
806 dump_opcode_field(field
->parent
, indent
, levels
-1);
812 dump_insn_bits(insn_bits
*bits
, int indent
, int levels
)
814 printf("(insn_bits*)%p\n", bits
);
816 if (levels
&& bits
!= NULL
) {
817 dumpf(indent
, "(value %d)\n", bits
->value
);
818 dumpf(indent
, "(opcode ");
819 dump_opcode_field(bits
->opcode
, indent
+1, 0);
820 dumpf(indent
, " )\n");
821 dumpf(indent
, "(field ");
822 dump_insn_field(bits
->field
, indent
+1);
823 dumpf(indent
, " )\n");
824 dumpf(indent
, "(last ");
825 dump_insn_bits(bits
->last
, indent
+1, levels
-1);
832 dump_insn(insn
*entry
, int indent
, int levels
)
834 printf("(insn*)%p\n", entry
);
836 if (levels
&& entry
!= NULL
) {
838 dumpf(indent
, "(file_entry ");
839 dump_table_entry(entry
->file_entry
, indent
+1);
840 dumpf(indent
, " )\n");
842 dumpf(indent
, "(fields ");
843 dump_insn_fields(entry
->fields
, indent
+1);
844 dumpf(indent
, " )\n");
846 dumpf(indent
, "(next ");
847 dump_insn(entry
->next
, indent
+1, levels
-1);
848 dumpf(indent
, " )\n");
856 dump_insn_table(insn_table
*table
,
857 int indent
, int levels
)
860 printf("(insn_table*)%p\n", table
);
862 if (levels
&& table
!= NULL
) {
864 dumpf(indent
, "(opcode_nr %d)\n", table
->opcode_nr
);
866 dumpf(indent
, "(expanded_bits ");
867 dump_insn_bits(table
->expanded_bits
, indent
+1, -1);
868 dumpf(indent
, " )\n");
870 dumpf(indent
, "(int nr_insn %d)\n", table
->nr_insn
);
872 dumpf(indent
, "(insns ");
873 dump_insn(table
->insns
, indent
+1, table
->nr_insn
);
874 dumpf(indent
, " )\n");
876 dumpf(indent
, "(opcode_rule ");
877 dump_decode_rule(table
->opcode_rule
, indent
+1);
878 dumpf(indent
, " )\n");
880 dumpf(indent
, "(opcode ");
881 dump_opcode_field(table
->opcode
, indent
+1, 1);
882 dumpf(indent
, " )\n");
884 dumpf(indent
, "(nr_entries %d)\n", table
->entries
);
885 dumpf(indent
, "(entries ");
886 dump_insn_table(table
->entries
, indent
+1, table
->nr_entries
);
887 dumpf(indent
, " )\n");
889 dumpf(indent
, "(sibling ", table
->sibling
);
890 dump_insn_table(table
->sibling
, indent
+1, levels
-1);
891 dumpf(indent
, " )\n");
893 dumpf(indent
, "(parent ", table
->parent
);
894 dump_insn_table(table
->parent
, indent
+1, 0);
895 dumpf(indent
, " )\n");
900 int insn_bit_size
= max_insn_bit_size
;
902 int generate_expanded_instructions
;
905 main(int argc
, char **argv
)
907 filter
*filters
= NULL
;
908 decode_table
*decode_rules
= NULL
;
909 insn_table
*instructions
= NULL
;
912 error("Usage: insn <filter> <hi-bit-nr> <decode-table> <insn-table>\n");
914 filters
= new_filter(argv
[1], filters
);
915 hi_bit_nr
= a2i(argv
[2]);
916 ASSERT(hi_bit_nr
< insn_bit_size
);
917 decode_rules
= load_decode_table(argv
[3], hi_bit_nr
);
918 instructions
= load_insn_table(argv
[4], decode_rules
, filters
);
919 insn_table_expand_insns(instructions
);
921 dump_insn_table(instructions
, 0, -1);