OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-6.8/] [pre-binutils-2.20.1-sync/] [sim/] [igen/] [compare_igen_models] - Diff between revs 24 and 157

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 24 Rev 157
#!/bin/sh
#!/bin/sh
# Script to compare functions and instructions used by different igen models.
# Script to compare functions and instructions used by different igen models.
# Copyright (C) 2002, 2007, 2008 Free Software Foundation, Inc.
# Copyright (C) 2002, 2007, 2008 Free Software Foundation, Inc.
# Contributed by Chris Demetriou of Broadcom Corporation (SiByte).
# Contributed by Chris Demetriou of Broadcom Corporation (SiByte).
#
#
# This file is part of GDB, the GNU debugger.
# This file is part of GDB, the GNU debugger.
#
#
# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .
# along with this program.  If not, see .
# This is a simple-minded script to compare the functions and instructions
# This is a simple-minded script to compare the functions and instructions
# listed for two different models in one or more .igen files.
# listed for two different models in one or more .igen files.
#
#
# It was intended to be useful to help factor models into common subsets.
# It was intended to be useful to help factor models into common subsets.
#
#
# Things to note:
# Things to note:
#
#
#    * igen include directives are not processed!
#    * igen include directives are not processed!
#
#
#    * functions and instructions with multiple definitions (e.g., based
#    * functions and instructions with multiple definitions (e.g., based
#      on model names) are treated as being different.  In other words,
#      on model names) are treated as being different.  In other words,
#      if two models have different functions named 'foo', this
#      if two models have different functions named 'foo', this
#      script will say that one has one of the function definitions, and
#      script will say that one has one of the function definitions, and
#      the other has the other.
#      the other has the other.
if [ "$#" -lt 2 ]; then
if [ "$#" -lt 2 ]; then
        echo "usage: $0 model1 model2 [file ...]" 1>&2
        echo "usage: $0 model1 model2 [file ...]" 1>&2
        exit 1
        exit 1
fi
fi
model1="$1"
model1="$1"
model2="$2"
model2="$2"
shift; shift
shift; shift
gawk -v model1="$model1" -v model2="$model2" -F: -- '
gawk -v model1="$model1" -v model2="$model2" -F: -- '
BEGIN {
BEGIN {
        thang_count = 0
        thang_count = 0
}
}
function thang_has_model(t, m) {
function thang_has_model(t, m) {
#       printf("thang_has_model(%s, %s) (@ %s:%d)\n", t, m,
#       printf("thang_has_model(%s, %s) (@ %s:%d)\n", t, m,
#              thangs[t,"file"], thangs[t,"line"]);
#              thangs[t,"file"], thangs[t,"line"]);
        if (thangs[t,"nmodels"] == 0) return 1;
        if (thangs[t,"nmodels"] == 0) return 1;
        for (j = 0; j < thangs[t,"nmodels"]; j++) {
        for (j = 0; j < thangs[t,"nmodels"]; j++) {
#               printf("\tmodel \"%s\"\n", thangs[t,"models",j]);
#               printf("\tmodel \"%s\"\n", thangs[t,"models",j]);
                if (thangs[t,"models",j] == m) return 1;
                if (thangs[t,"models",j] == m) return 1;
        }
        }
#       printf("\t-> 0\n");
#       printf("\t-> 0\n");
        return 0
        return 0
}
}
function compare_models(m1, m2) {
function compare_models(m1, m2) {
#       printf("compare_models(%s, %s)\n", m1, m2);
#       printf("compare_models(%s, %s)\n", m1, m2);
        seen_any=0
        seen_any=0
        for (i = 0; i < thang_count; i++) {
        for (i = 0; i < thang_count; i++) {
                if (thang_has_model(i, m1) && !thang_has_model(i, m2)) {
                if (thang_has_model(i, m1) && !thang_has_model(i, m2)) {
                        if (!seen_any) {
                        if (!seen_any) {
                                printf("Things in %s but not in %s:\n", m1, m2);
                                printf("Things in %s but not in %s:\n", m1, m2);
                                seen_any = 1
                                seen_any = 1
                        }
                        }
                        printf("%s:%d: %s\n", thangs[i,"file"],
                        printf("%s:%d: %s\n", thangs[i,"file"],
                               thangs[i,"line"], thangs[i,"contents"]);
                               thangs[i,"line"], thangs[i,"contents"]);
                }
                }
        }
        }
}
}
$0 ~ /^:/ && $2 == "model" {
$0 ~ /^:/ && $2 == "model" {
        # ignore.
        # ignore.
        # print "model " $0
        # print "model " $0
}
}
($0 ~ /^:/ && $2 == "function") || \
($0 ~ /^:/ && $2 == "function") || \
($0 ~ /^:/ && $2 == "internal") || \
($0 ~ /^:/ && $2 == "internal") || \
($0 ~ /^[0-9]/) {
($0 ~ /^[0-9]/) {
        # a function, internal, or instruction.
        # a function, internal, or instruction.
        current_thang = thang_count
        current_thang = thang_count
        thang_count++
        thang_count++
        thangs[current_thang,"file"] = FILENAME
        thangs[current_thang,"file"] = FILENAME
        thangs[current_thang,"line"] = NR
        thangs[current_thang,"line"] = NR
        thangs[current_thang,"contents"] = $0
        thangs[current_thang,"contents"] = $0
        thangs[current_thang,"nmodels"] = 0
        thangs[current_thang,"nmodels"] = 0
        if ($0 ~ /^:/) {
        if ($0 ~ /^:/) {
                thangs[current_thang,"type"] = $2
                thangs[current_thang,"type"] = $2
        } else {
        } else {
                thangs[current_thang,"type"] = "instruction"
                thangs[current_thang,"type"] = "instruction"
        }
        }
}
}
$0 ~ /^\*/ {
$0 ~ /^\*/ {
        split(substr($1, 2), tmp_models, /,/)
        split(substr($1, 2), tmp_models, /,/)
        for (key in tmp_models) {
        for (key in tmp_models) {
                current_model = thangs[current_thang,"nmodels"]
                current_model = thangs[current_thang,"nmodels"]
                thangs[current_thang,"nmodels"]++
                thangs[current_thang,"nmodels"]++
                thangs[current_thang,"models",current_model] = tmp_models[key]
                thangs[current_thang,"models",current_model] = tmp_models[key]
        }
        }
}
}
END {
END {
        compare_models(model1, model2)
        compare_models(model1, model2)
        if (seen_any) printf("\n");
        if (seen_any) printf("\n");
        compare_models(model2, model1)
        compare_models(model2, model1)
}' "$@"
}' "$@"
exit "$?"
exit "$?"
 
 

powered by: WebSVN 2.1.0

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