remove pointless concept of a builtin-type
authorMatthias Braun <matze@braunis.de>
Tue, 24 May 2011 09:32:10 +0000 (11:32 +0200)
committerMatthias Braun <matze@braunis.de>
Tue, 24 May 2011 09:32:10 +0000 (11:32 +0200)
ast2firm.c
mangle.c
parser.c
type.c
type.h
type_hash.c
type_t.h
types.c
wrappergen/write_jna.c

index 3dc0770..82fc742 100644 (file)
@@ -743,9 +743,6 @@ ir_type *get_ir_type(type_t *type)
        case TYPE_ENUM:
                firm_type = create_enum_type(&type->enumt);
                break;
-       case TYPE_BUILTIN:
-               firm_type = get_ir_type(type->builtin.real_type);
-               break;
        case TYPE_BITFIELD:
                firm_type = create_bitfield_type(&type->bitfield);
                break;
@@ -3317,7 +3314,6 @@ static ir_node *classify_type_to_firm(const classify_type_expression_t *const ex
                        /* gcc classifies the referenced type */
                        case TYPE_REFERENCE: type = type->reference.refers_to; continue;
 
-                       case TYPE_BUILTIN:
                        /* typedef/typeof should be skipped already */
                        case TYPE_TYPEDEF:
                        case TYPE_TYPEOF:
index ea4bc79..585ecaa 100644 (file)
--- a/mangle.c
+++ b/mangle.c
@@ -215,7 +215,6 @@ static void mangle_type(type_t *orig_type)
                panic("invalid type encountered while mangling");
        case TYPE_ERROR:
                panic("error type encountered while mangling");
-       case TYPE_BUILTIN:
        case TYPE_TYPEDEF:
        case TYPE_TYPEOF:
                panic("typeref not resolved while manging?!?");
index 4590d37..a28efbf 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1062,8 +1062,7 @@ static assign_error_t semantic_assign(type_t *orig_type_left,
                        (is_type_atomic(type_left, ATOMIC_TYPE_BOOL)
                                && is_type_pointer(type_right))) {
                return ASSIGN_SUCCESS;
-       } else if ((is_type_compound(type_left)  && is_type_compound(type_right))
-                       || (is_type_builtin(type_left) && is_type_builtin(type_right))) {
+       } else if (is_type_compound(type_left) && is_type_compound(type_right)) {
                type_t *const unqual_type_left  = get_unqualified_type(type_left);
                type_t *const unqual_type_right = get_unqualified_type(type_right);
                if (types_compatible(unqual_type_left, unqual_type_right)) {
@@ -2681,15 +2680,6 @@ typedef enum specifiers_t {
        SPECIFIER_IMAGINARY = 1 << 18,
 } specifiers_t;
 
-static type_t *create_builtin_type(symbol_t *const symbol,
-                                   type_t *const real_type)
-{
-       type_t *type            = allocate_type_zero(TYPE_BUILTIN);
-       type->builtin.symbol    = symbol;
-       type->builtin.real_type = real_type;
-       return identify_new_type(type);
-}
-
 static type_t *get_typedef_type(symbol_t *symbol)
 {
        entity_t *entity = get_entity(symbol, NAMESPACE_NORMAL);
@@ -10949,9 +10939,6 @@ void init_parser(void)
 
        init_expression_parsers();
        obstack_init(&temp_obst);
-
-       symbol_t *const va_list_sym = symbol_table_insert("__builtin_va_list");
-       type_valist = create_builtin_type(va_list_sym, type_void_ptr);
 }
 
 /**
diff --git a/type.c b/type.c
index 8b728d7..92f571c 100644 (file)
--- a/type.c
+++ b/type.c
@@ -70,7 +70,6 @@ static size_t get_type_struct_size(type_kind_t kind)
                [TYPE_FUNCTION]        = sizeof(function_type_t),
                [TYPE_POINTER]         = sizeof(pointer_type_t),
                [TYPE_ARRAY]           = sizeof(array_type_t),
-               [TYPE_BUILTIN]         = sizeof(builtin_type_t),
                [TYPE_TYPEDEF]         = sizeof(typedef_type_t),
                [TYPE_TYPEOF]          = sizeof(typeof_type_t),
        };
@@ -706,9 +705,6 @@ static void intern_print_type_pre(const type_t *const type)
        case TYPE_COMPOUND_UNION:
                print_compound_type(&type->compound);
                return;
-       case TYPE_BUILTIN:
-               print_string(type->builtin.symbol->string);
-               return;
        case TYPE_FUNCTION:
                print_function_type_pre(&type->function);
                return;
@@ -765,7 +761,6 @@ static void intern_print_type_post(const type_t *const type)
        case TYPE_ENUM:
        case TYPE_COMPOUND_STRUCT:
        case TYPE_COMPOUND_UNION:
-       case TYPE_BUILTIN:
        case TYPE_TYPEOF:
        case TYPE_TYPEDEF:
                break;
@@ -1015,11 +1010,8 @@ bool is_type_scalar(const type_t *type)
 {
        assert(!is_typeref(type));
 
-       switch (type->kind) {
-       case TYPE_POINTER: return true;
-       case TYPE_BUILTIN: return is_type_scalar(type->builtin.real_type);
-       default:           break;
-       }
+       if (type->kind == TYPE_POINTER)
+               return true;
 
        return is_type_arithmetic(type);
 }
@@ -1060,7 +1052,6 @@ bool is_type_incomplete(const type_t *type)
        case TYPE_FUNCTION:
        case TYPE_POINTER:
        case TYPE_REFERENCE:
-       case TYPE_BUILTIN:
        case TYPE_ERROR:
                return false;
 
@@ -1079,14 +1070,6 @@ bool is_type_object(const type_t *type)
        return !is_type_function(type) && !is_type_incomplete(type);
 }
 
-bool is_builtin_va_list(type_t *type)
-{
-       type_t *tp = skip_typeref(type);
-
-       return tp->kind == type_valist->kind &&
-              tp->builtin.symbol == type_valist->builtin.symbol;
-}
-
 /**
  * Check if two function types are compatible.
  */
@@ -1210,7 +1193,6 @@ bool types_compatible(const type_t *type1, const type_t *type2)
                break;
        }
        case TYPE_ENUM:
-       case TYPE_BUILTIN:
                /* TODO: not implemented */
                break;
 
@@ -1319,8 +1301,6 @@ unsigned get_type_size(type_t *type)
        }
        case TYPE_BITFIELD:
                return 0;
-       case TYPE_BUILTIN:
-               return get_type_size(type->builtin.real_type);
        case TYPE_TYPEDEF:
                return get_type_size(type->typedeft.typedefe->type);
        case TYPE_TYPEOF:
@@ -1365,8 +1345,6 @@ unsigned get_type_alignment(type_t *type)
                return get_type_alignment(type->array.element_type);
        case TYPE_BITFIELD:
                return 0;
-       case TYPE_BUILTIN:
-               return get_type_alignment(type->builtin.real_type);
        case TYPE_TYPEDEF: {
                il_alignment_t alignment
                        = get_type_alignment(type->typedeft.typedefe->type);
@@ -1405,8 +1383,6 @@ decl_modifiers_t get_type_modifiers(const type_t *type)
        case TYPE_BITFIELD:
        case TYPE_ARRAY:
                return 0;
-       case TYPE_BUILTIN:
-               return get_type_modifiers(type->builtin.real_type);
        case TYPE_TYPEDEF: {
                decl_modifiers_t modifiers = type->typedeft.typedefe->modifiers;
                modifiers |= get_type_modifiers(type->typedeft.typedefe->type);
diff --git a/type.h b/type.h
index 2ea193e..1f84787 100644 (file)
--- a/type.h
+++ b/type.h
@@ -166,11 +166,6 @@ bool is_type_incomplete(const type_t *type);
 
 bool is_type_object(const type_t *type);
 
-/**
- * returns true if teh type is the builtin va_list type.
- */
-bool is_builtin_va_list(type_t *type);
-
 bool types_compatible(const type_t *type1, const type_t *type2);
 
 type_t *get_unqualified_type(type_t *type);
index 369c76a..78658bc 100644 (file)
@@ -166,9 +166,6 @@ static unsigned hash_type(const type_t *type)
        case TYPE_ARRAY:
                hash = hash_array_type(&type->array);
                break;
-       case TYPE_BUILTIN:
-               hash = hash_ptr(type->builtin.symbol);
-               break;
        case TYPE_TYPEDEF:
                hash = hash_ptr(type->typedeft.typedefe);
                break;
@@ -271,12 +268,6 @@ static bool array_types_equal(const array_type_t *type1,
        return false;
 }
 
-static bool builtin_types_equal(const builtin_type_t *type1,
-                                const builtin_type_t *type2)
-{
-       return type1->symbol == type2->symbol;
-}
-
 static bool compound_types_equal(const compound_type_t *type1,
                                  const compound_type_t *type2)
 {
@@ -349,8 +340,6 @@ static bool types_equal(const type_t *type1, const type_t *type2)
                return reference_types_equal(&type1->reference, &type2->reference);
        case TYPE_ARRAY:
                return array_types_equal(&type1->array, &type2->array);
-       case TYPE_BUILTIN:
-               return builtin_types_equal(&type1->builtin, &type2->builtin);
        case TYPE_TYPEOF:
                return typeof_types_equal(&type1->typeoft, &type2->typeoft);
        case TYPE_TYPEDEF:
index a793f7a..a2ccb37 100644 (file)
--- a/type_t.h
+++ b/type_t.h
@@ -47,7 +47,6 @@ typedef enum type_kind_t {
        TYPE_REFERENCE,
        TYPE_ARRAY,
        TYPE_BITFIELD,
-       TYPE_BUILTIN,
        TYPE_TYPEDEF,
        TYPE_TYPEOF,
 } type_kind_t;
@@ -75,12 +74,6 @@ struct imaginary_type_t {
        atomic_type_kind_t  akind;
 };
 
-struct builtin_type_t {
-       type_base_t  base;
-       symbol_t    *symbol;
-       type_t      *real_type;
-};
-
 struct pointer_type_t {
        type_base_t  base;
        type_t      *points_to;
@@ -189,7 +182,6 @@ union type_t {
        atomic_type_t    atomic;
        complex_type_t   complex;
        imaginary_type_t imaginary;
-       builtin_type_t   builtin;
        pointer_type_t   pointer;
        reference_type_t reference;
        array_type_t     array;
@@ -269,12 +261,6 @@ static inline bool is_type_struct(const type_t *type)
        return type->kind == TYPE_COMPOUND_STRUCT;
 }
 
-static inline bool is_type_builtin(const type_t *type)
-{
-       assert(!is_typeref(type));
-       return type->kind == TYPE_BUILTIN;
-}
-
 static inline bool is_type_compound(const type_t *type)
 {
        assert(!is_typeref(type));
diff --git a/types.c b/types.c
index e62c07f..8473799 100644 (file)
--- a/types.c
+++ b/types.c
@@ -162,6 +162,7 @@ void init_basic_types(void)
        type_long_long_ptr      = make_pointer_type(type_long_long,         TYPE_QUALIFIER_NONE);
 
        type_char_ptr_ptr       = make_pointer_type(type_char_ptr,          TYPE_QUALIFIER_NONE);
+       type_valist             = type_void_ptr;
 
        /* const character types */
        type_const_char         = make_atomic_type(ATOMIC_TYPE_CHAR,        TYPE_QUALIFIER_CONST);
index 189425c..e99761b 100644 (file)
@@ -224,9 +224,6 @@ static void write_type(type_t *type)
        case TYPE_ENUM:
                write_enum_type(&type->enumt);
                return;
-       case TYPE_BUILTIN:
-               write_type(type->builtin.real_type);
-               return;
        case TYPE_ERROR:
        case TYPE_INVALID:
        case TYPE_TYPEOF: