OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [sim/] [igen/] [compare_igen_models] - Blame information for rev 474

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
#!/bin/sh
2
 
3
# Script to compare functions and instructions used by different igen models.
4
# Copyright (C) 2002, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5
# Contributed by Chris Demetriou of Broadcom Corporation (SiByte).
6
#
7
# This file is part of GDB, the GNU debugger.
8
#
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 3 of the License, or
12
# (at your option) any later version.
13
#
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.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with this program.  If not, see .
21
 
22
# This is a simple-minded script to compare the functions and instructions
23
# listed for two different models in one or more .igen files.
24
#
25
# It was intended to be useful to help factor models into common subsets.
26
#
27
# Things to note:
28
#
29
#    * igen include directives are not processed!
30
#
31
#    * functions and instructions with multiple definitions (e.g., based
32
#      on model names) are treated as being different.  In other words,
33
#      if two models have different functions named 'foo', this
34
#      script will say that one has one of the function definitions, and
35
#      the other has the other.
36
 
37
if [ "$#" -lt 2 ]; then
38
        echo "usage: $0 model1 model2 [file ...]" 1>&2
39
        exit 1
40
fi
41
model1="$1"
42
model2="$2"
43
shift; shift
44
 
45
gawk -v model1="$model1" -v model2="$model2" -F: -- '
46
BEGIN {
47
        thang_count = 0
48
}
49
function thang_has_model(t, m) {
50
#       printf("thang_has_model(%s, %s) (@ %s:%d)\n", t, m,
51
#              thangs[t,"file"], thangs[t,"line"]);
52
        if (thangs[t,"nmodels"] == 0) return 1;
53
 
54
        for (j = 0; j < thangs[t,"nmodels"]; j++) {
55
#               printf("\tmodel \"%s\"\n", thangs[t,"models",j]);
56
                if (thangs[t,"models",j] == m) return 1;
57
        }
58
#       printf("\t-> 0\n");
59
        return 0
60
}
61
function compare_models(m1, m2) {
62
#       printf("compare_models(%s, %s)\n", m1, m2);
63
        seen_any=0
64
        for (i = 0; i < thang_count; i++) {
65
                if (thang_has_model(i, m1) && !thang_has_model(i, m2)) {
66
                        if (!seen_any) {
67
                                printf("Things in %s but not in %s:\n", m1, m2);
68
                                seen_any = 1
69
                        }
70
                        printf("%s:%d: %s\n", thangs[i,"file"],
71
                               thangs[i,"line"], thangs[i,"contents"]);
72
                }
73
        }
74
}
75
$0 ~ /^:/ && $2 == "model" {
76
        # ignore.
77
        # print "model " $0
78
}
79
($0 ~ /^:/ && $2 == "function") || \
80
($0 ~ /^:/ && $2 == "internal") || \
81
($0 ~ /^[0-9]/) {
82
        # a function, internal, or instruction.
83
 
84
        current_thang = thang_count
85
        thang_count++
86
 
87
        thangs[current_thang,"file"] = FILENAME
88
        thangs[current_thang,"line"] = NR
89
        thangs[current_thang,"contents"] = $0
90
        thangs[current_thang,"nmodels"] = 0
91
 
92
        if ($0 ~ /^:/) {
93
                thangs[current_thang,"type"] = $2
94
        } else {
95
                thangs[current_thang,"type"] = "instruction"
96
        }
97
}
98
$0 ~ /^\*/ {
99
        split(substr($1, 2), tmp_models, /,/)
100
        for (key in tmp_models) {
101
                current_model = thangs[current_thang,"nmodels"]
102
                thangs[current_thang,"nmodels"]++
103
                thangs[current_thang,"models",current_model] = tmp_models[key]
104
        }
105
}
106
END {
107
        compare_models(model1, model2)
108
        if (seen_any) printf("\n");
109
        compare_models(model2, model1)
110
}' "$@"
111
 
112
exit "$?"

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.