The calling convention is orthogonal to the linkage specification.
authorChristoph Mallon <christoph.mallon@gmx.de>
Sat, 15 Nov 2008 10:59:20 +0000 (10:59 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sat, 15 Nov 2008 10:59:20 +0000 (10:59 +0000)
[r23678]

ast2firm.c
mangle.c
type.c
type_hash.c
type_t.h

index ab5a261..79c5078 100644 (file)
@@ -398,8 +398,6 @@ static ir_type *create_method_type(const function_type_t *function_type)
                set_method_variadicity(irtype, variadicity_variadic);
        }
 
-#if 0
-       /* TODO: revive this with linkage stuff */
        unsigned cc = get_method_calling_convention(irtype);
        switch (function_type->calling_convention) {
        case CC_DEFAULT: /* unspecified calling convention, equal to one of the other, typically cdecl */
@@ -427,7 +425,6 @@ is_cdecl:
                /* Hmm, leave default, not accepted by the parser yet. */
                break;
        }
-#endif
 
        return irtype;
 }
index a845a6a..403277b 100644 (file)
--- a/mangle.c
+++ b/mangle.c
@@ -34,7 +34,6 @@
 static ident          *id_underscore;
 static ident          *id_imp;
 static symbol_t       *sym_C;
-static symbol_t       *sym_stdcall;
 static struct obstack  obst;
 
 static void mangle_type(type_t *type);
@@ -160,7 +159,7 @@ ident *create_name_win32(entity_t *entity)
        ident *id = new_id_from_str(entity->base.symbol->string);
 
        if (entity->kind == ENTITY_FUNCTION) {
-               if (entity->declaration.type->function.linkage == sym_stdcall) {
+               if (entity->declaration.type->function.calling_convention == CC_STDCALL) {
                        char     buf[16];
                        ir_type *irtype = get_ir_type(entity->declaration.type);
                        size_t   size   = 0;
@@ -253,7 +252,6 @@ void init_mangle(void)
        id_underscore = new_id_from_chars("_", 1);
        id_imp        = new_id_from_chars("__imp_", 6);
        sym_C         = symbol_table_insert("C");
-       sym_stdcall   = symbol_table_insert("stdcall");
 
        obstack_init(&obst);
 }
diff --git a/type.c b/type.c
index 204d6f0..d089e25 100644 (file)
--- a/type.c
+++ b/type.c
@@ -307,25 +307,13 @@ static void print_function_type_pre(const function_type_t *type, bool top)
 
        intern_print_type_pre(type->return_type, false);
 
-#if 0
-       /* TODO: revive with linkage */
-       switch (type->linkage) {
-       case CC_CDECL:
-               fputs("__cdecl ", out);
-               break;
-       case CC_STDCALL:
-               fputs("__stdcall ", out);
-               break;
-       case CC_FASTCALL:
-               fputs("__fastcall ", out);
-               break;
-       case CC_THISCALL:
-               fputs("__thiscall ", out);
-               break;
-       case CC_DEFAULT:
-               break;
+       switch (type->calling_convention) {
+       case CC_CDECL:    fputs("__cdecl ",    out); break;
+       case CC_STDCALL:  fputs("__stdcall ",  out); break;
+       case CC_FASTCALL: fputs("__fastcall ", out); break;
+       case CC_THISCALL: fputs("__thiscall ", out); break;
+       case CC_DEFAULT:  break;
        }
-#endif
 
        /* don't emit parenthesis if we're the toplevel type... */
        if (!top)
@@ -1040,6 +1028,9 @@ static bool function_types_compatible(const function_type_t *func1,
        if (func1->linkage != func2->linkage)
                return false;
 
+       if (func1->calling_convention != func2->calling_convention)
+               return false;
+
        /* can parameters be compared? */
        if (func1->unspecified_parameters || func2->unspecified_parameters)
                return true;
index 88de01c..9eddefe 100644 (file)
@@ -99,6 +99,7 @@ static unsigned hash_function_type(const function_type_t *type)
                parameter = parameter->next;
        }
        result ^= hash_ptr(type->linkage);
+       result += type->calling_convention;
 
        return result;
 }
@@ -210,6 +211,8 @@ static bool function_types_equal(const function_type_t *type1,
                return false;
        if (type1->linkage != type2->linkage)
                return false;
+       if (type1->calling_convention != type2->calling_convention)
+               return false;
 
        function_parameter_t *param1 = type1->parameters;
        function_parameter_t *param2 = type2->parameters;
index 0773f70..b9cfcc8 100644 (file)
--- a/type_t.h
+++ b/type_t.h
@@ -133,6 +133,7 @@ struct function_type_t {
        type_t               *return_type;        /**< The return type. */
        function_parameter_t *parameters;         /**< A list of the parameter types. */
        symbol_t             *linkage;
+       cc_kind_t             calling_convention; /**< The specified calling convention. */
        bool                  variadic : 1;
        bool                  unspecified_parameters : 1;
        bool                  kr_style_parameters : 1;