3 # Script to compare functions and instructions used by different igen models.
4 # Copyright (C) 2002 Free Software Foundation, Inc.
5 # Contributed by Broadcom Corporation (SiByte).
7 # This file is part of GDB, the GNU debugger.
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, or (at your option)
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 along
20 # with this program; if not, write to the Free Software Foundation, Inc.,
21 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 # This is a simple-minded script to compare the functions and instructions
24 # listed for two different models in one or more .igen files.
26 # It was intended to be useful to help factor models into common subsets.
30 # * igen include directives are not processed!
32 # * functions and instructions with multiple definitions (e.g., based
33 # on model names) are treated as being different. In other words,
34 # if two models have different functions named 'foo', this
35 # script will say that one has one of the function definitions, and
36 # the other has the other.
38 if [ "$#" -lt 2 ]; then
39 echo "usage: $0 model1 model2 [file ...]" 1>&2
46 gawk
-v model1
="$model1" -v model2
="$model2" -F: -- '
50 function thang_has_model(t, m) {
51 # printf("thang_has_model(%s, %s) (@ %s:%d)\n", t, m,
52 # thangs[t,"file"], thangs[t,"line"]);
53 if (thangs[t,"nmodels"] == 0) return 1;
55 for (j = 0; j < thangs[t,"nmodels"]; j++) {
56 # printf("\tmodel \"%s\"\n", thangs[t,"models",j]);
57 if (thangs[t,"models",j] == m) return 1;
62 function compare_models(m1, m2) {
63 # printf("compare_models(%s, %s)\n", m1, m2);
65 for (i = 0; i < thang_count; i++) {
66 if (thang_has_model(i, m1) && !thang_has_model(i, m2)) {
68 printf("Things in %s but not in %s:\n", m1, m2);
71 printf("%s:%d: %s\n", thangs[i,"file"],
72 thangs[i,"line"], thangs[i,"contents"]);
76 $0 ~ /^:/ && $2 == "model" {
80 ($0 ~ /^:/ && $2 == "function") || \
81 ($0 ~ /^:/ && $2 == "internal") || \
83 # a function, internal, or instruction.
85 current_thang = thang_count
88 thangs[current_thang,"file"] = FILENAME
89 thangs[current_thang,"line"] = NR
90 thangs[current_thang,"contents"] = $0
91 thangs[current_thang,"nmodels"] = 0
94 thangs[current_thang,"type"] = $2
96 thangs[current_thang,"type"] = "instruction"
100 split(substr($1, 2), tmp_models, /,/)
101 for (key in tmp_models) {
102 current_model = thangs[current_thang,"nmodels"]
103 thangs[current_thang,"nmodels"]++
104 thangs[current_thang,"models",current_model] = tmp_models[key]
108 compare_models(model1, model2)
109 if (seen_any) printf("\n");
110 compare_models(model2, model1)