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/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc2/] [gcc/] [config/] [i386/] [i386-builtin-types.awk] - Diff between revs 282 and 384

Only display areas with differences | Details | Blame | View Log

Rev 282 Rev 384
#  Copyright (C) 2009 Free Software Foundation, Inc.
#  Copyright (C) 2009 Free Software Foundation, Inc.
#
#
# This program is free software; you can redistribute it and/or modify it
# 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 the
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any
# Free Software Foundation; either version 3, or (at your option) any
# later version.
# 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; see the file COPYING3.  If not see
# along with this program; see the file COPYING3.  If not see
# <http://www.gnu.org/licenses/>.
# <http://www.gnu.org/licenses/>.
 
 
# Generates compressed tables for types for i386 builtin functions.
# Generates compressed tables for types for i386 builtin functions.
 
 
function do_error(string) {
function do_error(string) {
    print FILENAME ":" FNR ": " string > "/dev/stderr"
    print FILENAME ":" FNR ": " string > "/dev/stderr"
    errors = 1
    errors = 1
}
}
 
 
function check_type(string) {
function check_type(string) {
    if (!(string in type_hash))
    if (!(string in type_hash))
        do_error("undefined type code " string)
        do_error("undefined type code " string)
}
}
 
 
# We can significantly reduce the size of the read-only tables
# We can significantly reduce the size of the read-only tables
# by forcing the compiler to use a smaller implementation type
# by forcing the compiler to use a smaller implementation type
# for the enumerations.
# for the enumerations.
function attribute_mode(count) {
function attribute_mode(count) {
    # ??? Except that we get strange "comparison always false" warnings
    # ??? Except that we get strange "comparison always false" warnings
    # for comparisons between different elements of the enumeration.
    # for comparisons between different elements of the enumeration.
    #    print "#ifdef __GNUC__"
    #    print "#ifdef __GNUC__"
    #    if (count < 256)
    #    if (count < 256)
    #   print "  __attribute__((__mode__(__QI__)))"
    #   print "  __attribute__((__mode__(__QI__)))"
    #    else
    #    else
    #   print "  __attribute__((__mode__(__HI__)))"
    #   print "  __attribute__((__mode__(__HI__)))"
    #    print "#endif"
    #    print "#endif"
}
}
 
 
BEGIN {
BEGIN {
    FS = "[() \t,]+"
    FS = "[() \t,]+"
 
 
    prim_defs = 0
    prim_defs = 0
    vect_defs = 0
    vect_defs = 0
    ptr_defs = 0
    ptr_defs = 0
    cptr_defs = 0
    cptr_defs = 0
    func_defs = 0
    func_defs = 0
    func_args = 0
    func_args = 0
    alias_defs = 0
    alias_defs = 0
}
}
 
 
# Skip blank lines or comments.
# Skip blank lines or comments.
/^[ \t]*(#|$)/ {
/^[ \t]*(#|$)/ {
    next
    next
}
}
 
 
$1 == "DEF_PRIMITIVE_TYPE" {
$1 == "DEF_PRIMITIVE_TYPE" {
    if (NF == 4) {
    if (NF == 4) {
        type_hash[$2] = 1
        type_hash[$2] = 1
        prim_name[prim_defs] = $2
        prim_name[prim_defs] = $2
        prim_base[prim_defs] = $3
        prim_base[prim_defs] = $3
        prim_defs++
        prim_defs++
    } else
    } else
        do_error("DEF_PRIMITIVE_TYPE expected 2 arguments")
        do_error("DEF_PRIMITIVE_TYPE expected 2 arguments")
    next
    next
}
}
 
 
$1 == "DEF_VECTOR_TYPE" {
$1 == "DEF_VECTOR_TYPE" {
    if (NF == 4 || NF == 5) {
    if (NF == 4 || NF == 5) {
        check_type($3)
        check_type($3)
        type_hash[$2] = 1
        type_hash[$2] = 1
        vect_name[vect_defs] = $2
        vect_name[vect_defs] = $2
        vect_base[vect_defs] = $3
        vect_base[vect_defs] = $3
        vect_mode[vect_defs] = (NF == 5 ? $4 : $2)
        vect_mode[vect_defs] = (NF == 5 ? $4 : $2)
        vect_defs++
        vect_defs++
    } else
    } else
        do_error("DEF_VECTOR_TYPE expected 2 arguments")
        do_error("DEF_VECTOR_TYPE expected 2 arguments")
    next
    next
}
}
 
 
$1 == "DEF_POINTER_TYPE" {
$1 == "DEF_POINTER_TYPE" {
    if (NF == 4) {
    if (NF == 4) {
        check_type($3)
        check_type($3)
        type_hash[$2] = 1
        type_hash[$2] = 1
        ptr_name[ptr_defs] = $2
        ptr_name[ptr_defs] = $2
        ptr_base[ptr_defs] = $3
        ptr_base[ptr_defs] = $3
        ptr_defs++
        ptr_defs++
    } else if (NF == 5) {
    } else if (NF == 5) {
        check_type($3)
        check_type($3)
        if ($4 == "CONST") {
        if ($4 == "CONST") {
            type_hash[$2] = 1
            type_hash[$2] = 1
            cptr_name[cptr_defs] = $2
            cptr_name[cptr_defs] = $2
            cptr_base[cptr_defs] = $3
            cptr_base[cptr_defs] = $3
            cptr_defs++
            cptr_defs++
        } else
        } else
            do_error("invalid qualifier \"" $4 "\"")
            do_error("invalid qualifier \"" $4 "\"")
    }
    }
    else
    else
        do_error("DEF_POINTER_TYPE expected 2 or 3 arguments")
        do_error("DEF_POINTER_TYPE expected 2 or 3 arguments")
    next
    next
}
}
 
 
$1 == "DEF_FUNCTION_TYPE" {
$1 == "DEF_FUNCTION_TYPE" {
    func_start[func_defs] = func_args
    func_start[func_defs] = func_args
    for (i = 2; i < NF; ++i) {
    for (i = 2; i < NF; ++i) {
        check_type($i)
        check_type($i)
        func_types[func_args++] = $i
        func_types[func_args++] = $i
    }
    }
 
 
    if (NF < 3)
    if (NF < 3)
        do_error("DEF_FUNCTION_TYPE expected at least 1 argument")
        do_error("DEF_FUNCTION_TYPE expected at least 1 argument")
    else if (NF == 3)
    else if (NF == 3)
        name = $2 "_FTYPE_VOID"
        name = $2 "_FTYPE_VOID"
    else {
    else {
        name = $2 "_FTYPE"
        name = $2 "_FTYPE"
        for (i = 3; i < NF; ++i)
        for (i = 3; i < NF; ++i)
            name = name "_" $i
            name = name "_" $i
    }
    }
    func_hash[name] = 1
    func_hash[name] = 1
    func_name[func_defs++] = name
    func_name[func_defs++] = name
    next
    next
}
}
 
 
$1 == "DEF_FUNCTION_TYPE_ALIAS" {
$1 == "DEF_FUNCTION_TYPE_ALIAS" {
    if (NF == 4) {
    if (NF == 4) {
        if ($2 in func_hash) {
        if ($2 in func_hash) {
            alias_base[alias_defs] = $2
            alias_base[alias_defs] = $2
            alias_name[alias_defs] = $2 "_" $3
            alias_name[alias_defs] = $2 "_" $3
            alias_defs++
            alias_defs++
        } else
        } else
            do_error("undefined function code " $2)
            do_error("undefined function code " $2)
    } else
    } else
        do_error("DEF_FUNCTION_TYPE_ALIAS expected 2 arguments")
        do_error("DEF_FUNCTION_TYPE_ALIAS expected 2 arguments")
    next
    next
}
}
 
 
{
{
    do_error("unknown directive \"" $1 "\"");
    do_error("unknown directive \"" $1 "\"");
}
}
 
 
END {
END {
    if (errors)
    if (errors)
        exit 1
        exit 1
 
 
    print "/* This file is auto-generated by i386-builtin-types.awk.  */\n"
    print "/* This file is auto-generated by i386-builtin-types.awk.  */\n"
 
 
    # This first enumeration contains all of the non-function types.
    # This first enumeration contains all of the non-function types.
    print "enum ix86_builtin_type {"
    print "enum ix86_builtin_type {"
    for (i = 0; i < prim_defs; ++i)
    for (i = 0; i < prim_defs; ++i)
        print "  IX86_BT_" prim_name[i] ","
        print "  IX86_BT_" prim_name[i] ","
    print "  IX86_BT_LAST_PRIM = IX86_BT_" prim_name[i-1] ","
    print "  IX86_BT_LAST_PRIM = IX86_BT_" prim_name[i-1] ","
    for (i = 0; i < vect_defs; ++i)
    for (i = 0; i < vect_defs; ++i)
        print "  IX86_BT_" vect_name[i] ","
        print "  IX86_BT_" vect_name[i] ","
    print "  IX86_BT_LAST_VECT = IX86_BT_" vect_name[i-1] ","
    print "  IX86_BT_LAST_VECT = IX86_BT_" vect_name[i-1] ","
    for (i = 0; i < ptr_defs; ++i)
    for (i = 0; i < ptr_defs; ++i)
        print "  IX86_BT_" ptr_name[i] ","
        print "  IX86_BT_" ptr_name[i] ","
    print "  IX86_BT_LAST_PTR = IX86_BT_" ptr_name[i-1] ","
    print "  IX86_BT_LAST_PTR = IX86_BT_" ptr_name[i-1] ","
    for (i = 0; i < cptr_defs; ++i)
    for (i = 0; i < cptr_defs; ++i)
        print "  IX86_BT_" cptr_name[i] ","
        print "  IX86_BT_" cptr_name[i] ","
    print "  IX86_BT_LAST_CPTR = IX86_BT_" cptr_name[i-1] "\n}"
    print "  IX86_BT_LAST_CPTR = IX86_BT_" cptr_name[i-1] "\n}"
    attribute_mode(prim_defs + vect_defs + ptr_defs + cptr_defs)
    attribute_mode(prim_defs + vect_defs + ptr_defs + cptr_defs)
    print ";\n\n"
    print ";\n\n"
 
 
    # We can't tabularize the initialization of the primitives, since
    # We can't tabularize the initialization of the primitives, since
    # at least one of them is created via a local variable.  That's ok,
    # at least one of them is created via a local variable.  That's ok,
    # just create a nice big macro to do all the work.
    # just create a nice big macro to do all the work.
    print "#define DEFINE_BUILTIN_PRIMITIVE_TYPES \\"
    print "#define DEFINE_BUILTIN_PRIMITIVE_TYPES \\"
    for (i = 0; i < prim_defs; ++i) {
    for (i = 0; i < prim_defs; ++i) {
        printf "  ix86_builtin_type_tab[(int)IX86_BT_" prim_name[i] \
        printf "  ix86_builtin_type_tab[(int)IX86_BT_" prim_name[i] \
            "] = " prim_base[i]
            "] = " prim_base[i]
        if (i < prim_defs - 1)
        if (i < prim_defs - 1)
            print ", \\"
            print ", \\"
    }
    }
    print "\n\n"
    print "\n\n"
 
 
    # The vector types are defined via two tables defining the real
    # The vector types are defined via two tables defining the real
    # machine mode and the builtin primitive type.  We use two tables
    # machine mode and the builtin primitive type.  We use two tables
    # rather than a structure to avoid structure padding and save space.
    # rather than a structure to avoid structure padding and save space.
    print "static const enum machine_mode ix86_builtin_type_vect_mode[] = {"
    print "static const enum machine_mode ix86_builtin_type_vect_mode[] = {"
    for (i = 0; i < vect_defs; ++i) {
    for (i = 0; i < vect_defs; ++i) {
        if (i == 0)
        if (i == 0)
            printf "  "
            printf "  "
        else if (i % 6 == 0)
        else if (i % 6 == 0)
            printf ",\n  "
            printf ",\n  "
        else
        else
            printf ", "
            printf ", "
        printf vect_mode[i] "mode"
        printf vect_mode[i] "mode"
    }
    }
    print "\n};\n\n"
    print "\n};\n\n"
 
 
    print "static const enum ix86_builtin_type " \
    print "static const enum ix86_builtin_type " \
        "ix86_builtin_type_vect_base[] = {"
        "ix86_builtin_type_vect_base[] = {"
    for (i = 0; i < vect_defs; ++i) {
    for (i = 0; i < vect_defs; ++i) {
        if (i == 0)
        if (i == 0)
            printf "  "
            printf "  "
        else if (i % 4 == 0)
        else if (i % 4 == 0)
            printf ",\n  "
            printf ",\n  "
        else
        else
            printf ", "
            printf ", "
        printf "IX86_BT_" vect_base[i]
        printf "IX86_BT_" vect_base[i]
    }
    }
    print "\n};\n\n"
    print "\n};\n\n"
 
 
    # The pointer types are defined via a single table defining the
    # The pointer types are defined via a single table defining the
    # builtin primitive type.  The const-ness of the pointer is taken
    # builtin primitive type.  The const-ness of the pointer is taken
    # from the enumeration value > IX86_BT_LAST_PTR.
    # from the enumeration value > IX86_BT_LAST_PTR.
    print "static const enum ix86_builtin_type " \
    print "static const enum ix86_builtin_type " \
        "ix86_builtin_type_ptr_base[] = {"
        "ix86_builtin_type_ptr_base[] = {"
    for (i = 0; i < ptr_defs; ++i) {
    for (i = 0; i < ptr_defs; ++i) {
        if (i == 0)
        if (i == 0)
            printf " "
            printf " "
        else if (i % 4 == 0)
        else if (i % 4 == 0)
            printf "\n "
            printf "\n "
        printf " IX86_BT_" ptr_base[i] ","
        printf " IX86_BT_" ptr_base[i] ","
    }
    }
    print "\n  /* pointer-to-constant defs start here */"
    print "\n  /* pointer-to-constant defs start here */"
    for (i = 0; i < cptr_defs; ++i) {
    for (i = 0; i < cptr_defs; ++i) {
        if (i == 0)
        if (i == 0)
            printf "  "
            printf "  "
        else if (i % 4 == 0)
        else if (i % 4 == 0)
            printf ",\n  "
            printf ",\n  "
        else
        else
            printf ", "
            printf ", "
        printf "IX86_BT_" cptr_base[i]
        printf "IX86_BT_" cptr_base[i]
    }
    }
    print "\n};\n\n"
    print "\n};\n\n"
 
 
    # This second enumeration contains all of the function types.
    # This second enumeration contains all of the function types.
    print "enum ix86_builtin_func_type {"
    print "enum ix86_builtin_func_type {"
    for (i = 0; i < func_defs; ++i)
    for (i = 0; i < func_defs; ++i)
        print "  " func_name[i] ","
        print "  " func_name[i] ","
    print "  IX86_BT_LAST_FUNC = " func_name[i-1] ","
    print "  IX86_BT_LAST_FUNC = " func_name[i-1] ","
    for (i = 0; i < alias_defs; ++i)
    for (i = 0; i < alias_defs; ++i)
        print "  " alias_name[i] ","
        print "  " alias_name[i] ","
    print "  IX86_BT_LAST_ALIAS = " alias_name[i-1] "\n}"
    print "  IX86_BT_LAST_ALIAS = " alias_name[i-1] "\n}"
    attribute_mode(func_defs + alias_defs)
    attribute_mode(func_defs + alias_defs)
    print ";\n\n"
    print ";\n\n"
 
 
    # The function types are defined via two tables.  The first contains
    # The function types are defined via two tables.  The first contains
    # ranges consiting of the function's return type, followed by all of
    # ranges consiting of the function's return type, followed by all of
    # the function argument types.  The ranges for all of the builtin
    # the function argument types.  The ranges for all of the builtin
    # functions are smooshed together in the same array.  The second array
    # functions are smooshed together in the same array.  The second array
    # contains, for each builtin, the index of the function's return type
    # contains, for each builtin, the index of the function's return type
    # within the first array.
    # within the first array.
    print "static const enum ix86_builtin_type ix86_builtin_func_args[] = {"
    print "static const enum ix86_builtin_type ix86_builtin_func_args[] = {"
    for (i = 0; i < func_args; ++i) {
    for (i = 0; i < func_args; ++i) {
        if (i == 0)
        if (i == 0)
            printf "  "
            printf "  "
        else if (i % 4 == 0)
        else if (i % 4 == 0)
            printf ",\n  "
            printf ",\n  "
        else
        else
            printf ", "
            printf ", "
        printf "IX86_BT_" func_types[i]
        printf "IX86_BT_" func_types[i]
    }
    }
    print "\n};\n\n"
    print "\n};\n\n"
 
 
    print "static const unsigned short ix86_builtin_func_start[] = {"
    print "static const unsigned short ix86_builtin_func_start[] = {"
    for (i = 0; i < func_defs; ++i) {
    for (i = 0; i < func_defs; ++i) {
        if (i == 0)
        if (i == 0)
            printf " "
            printf " "
        else if (i % 10 == 0)
        else if (i % 10 == 0)
            printf "\n "
            printf "\n "
        printf " " func_start[i] ","
        printf " " func_start[i] ","
    }
    }
    print " " func_args "\n};\n\n"
    print " " func_args "\n};\n\n"
 
 
    print "static const enum ix86_builtin_func_type " \
    print "static const enum ix86_builtin_func_type " \
        "ix86_builtin_func_alias_base[] = {"
        "ix86_builtin_func_alias_base[] = {"
    for (i = 0; i < alias_defs; ++i) {
    for (i = 0; i < alias_defs; ++i) {
        if (i == 0)
        if (i == 0)
            printf "  "
            printf "  "
        else
        else
            printf ",\n  "
            printf ",\n  "
        printf alias_base[i]
        printf alias_base[i]
    }
    }
    print "\n};"
    print "\n};"
}
}
 
 

powered by: WebSVN 2.1.0

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