panic("error type occured");
case TYPE_ATOMIC:
return get_atomic_type_size(type->atomic.akind);
+ case TYPE_COMPLEX:
+ return 2 * get_atomic_type_size(type->complex.akind);
+ case TYPE_IMAGINARY:
+ return get_atomic_type_size(type->imaginary.akind);
case TYPE_ENUM:
return get_mode_size_bytes(mode_int);
case TYPE_COMPOUND_UNION:
return count;
}
+/**
+ * Creates a Firm type for an atomic type
+ */
static ir_type *create_atomic_type(const atomic_type_t *type)
{
dbg_info *dbgi = get_dbg_info(&type->base.source_position);
atomic_type_kind_t kind = type->akind;
ir_mode *mode = _atomic_modes[kind];
- unsigned alignment = get_atomic_type_alignment(kind);
ident *id = get_mode_ident(mode);
ir_type *irtype = new_d_type_primitive(id, mode, dbgi);
- if(type->base.alignment > alignment)
- alignment = type->base.alignment;
+ set_type_alignment_bytes(irtype, type->base.alignment);
+
+ return irtype;
+}
+
+/**
+ * Creates a Firm type for a complex type
+ */
+static ir_type *create_complex_type(const complex_type_t *type)
+{
+ dbg_info *dbgi = get_dbg_info(&type->base.source_position);
+ atomic_type_kind_t kind = type->akind;
+ ir_mode *mode = _atomic_modes[kind];
+ ident *id = get_mode_ident(mode);
+
+ /* FIXME: finish the array */
+ return NULL;
+}
+
+/**
+ * Creates a Firm type for an imaginary type
+ */
+static ir_type *create_imaginary_type(const imaginary_type_t *type)
+{
+ dbg_info *dbgi = get_dbg_info(&type->base.source_position);
+ atomic_type_kind_t kind = type->akind;
+ ir_mode *mode = _atomic_modes[kind];
+ ident *id = get_mode_ident(mode);
+ ir_type *irtype = new_d_type_primitive(id, mode, dbgi);
- set_type_alignment_bytes(irtype, alignment);
+ set_type_alignment_bytes(irtype, type->base.alignment);
return irtype;
}
ir_type *firm_type = NULL;
switch(type->kind) {
case TYPE_ERROR:
- panic("error type occured");
+ panic("error type occurred");
case TYPE_ATOMIC:
firm_type = create_atomic_type(&type->atomic);
break;
+ case TYPE_COMPLEX:
+ firm_type = create_complex_type(&type->complex);
+ break;
+ case TYPE_IMAGINARY:
+ firm_type = create_imaginary_type(&type->imaginary);
+ break;
case TYPE_FUNCTION:
firm_type = create_method_type(&type->function);
break;
{ rts_strncmp, 1, "strncmp", 3, _C89 }
};
+/**
+ * Mangles an entity linker (ld) name for win32 usage.
+ *
+ * @param ent the entity to be mangled
+ * @param decl_modifiers the set of modifiers for this entity
+ */
+static ir_ident_ptr decorate_win32(ir_entity_ptr ent, decl_modifiers_t decl_modifiers) {
+ ir_ident_ptr id;
+
+ if (is_Method_type(get_entity_type(ent)))
+ id = decorate_win32_c_fkt(ent, get_entity_ident(ent));
+ else {
+ /* always add an underscore in win32 */
+ id = mangle(new_id_from_chars("_", 1), get_entity_ident(ent));
+ }
+
+ if (decl_modifiers & DM_DLLIMPORT) {
+ /* add prefix for imported symbols */
+ id = mangle(new_id_from_chars("__imp_", 6), id);
+ }
+ return id;
+}
+
+/**
+ * Mangles an entity linker (ld) name from a declaration.
+ *
+ * @param ent the entity to be mangled
+ * @param declaration the declaration
+ */
+static void mangle_ent_from_decl(ir_entity *ent, declaration_t *declaration)
+{
+ ident *id;
+
+ if (firm_opt.os_support == OS_SUPPORT_MINGW)
+ id = decorate_win32(ent, declaration->decl_modifiers);
+ else
+ id = get_entity_ident(ent);
+
+ set_entity_ld_ident(ent, id);
+}
+
static ir_entity* get_function_entity(declaration_t *declaration)
{
if(declaration->declaration_kind == DECLARATION_KIND_FUNCTION)
dbg_info *const dbgi = get_dbg_info(&declaration->source_position);
ir_entity *const entity = new_d_entity(global_type, id, ir_type_method, dbgi);
- set_entity_ld_ident(entity, id);
+ mangle_ent_from_decl(entity, declaration);
if(declaration->storage_class == STORAGE_CLASS_STATIC
|| declaration->is_inline) {
set_entity_visibility(entity, visibility_local);
{
case TYPE_ATOMIC: {
const atomic_type_t *const atomic_type = &type->atomic;
- switch ((atomic_type_kind_t) atomic_type->akind) {
+ switch (atomic_type->akind) {
/* should not be reached */
case ATOMIC_TYPE_INVALID:
tc = no_type_class;
case ATOMIC_TYPE_LONG_DOUBLE:
tc = real_type_class;
goto make_const;
-
- case ATOMIC_TYPE_FLOAT_COMPLEX:
- case ATOMIC_TYPE_DOUBLE_COMPLEX:
- case ATOMIC_TYPE_LONG_DOUBLE_COMPLEX:
- tc = complex_type_class;
- goto make_const;
- case ATOMIC_TYPE_FLOAT_IMAGINARY:
- case ATOMIC_TYPE_DOUBLE_IMAGINARY:
- case ATOMIC_TYPE_LONG_DOUBLE_IMAGINARY:
- tc = complex_type_class;
- goto make_const;
}
panic("Unexpected atomic type in classify_type_to_firm().");
}
+ case TYPE_COMPLEX: tc = complex_type_class; goto make_const;
+ case TYPE_IMAGINARY: tc = complex_type_class; goto make_const;
case TYPE_BITFIELD: tc = integer_type_class; goto make_const;
case TYPE_ARRAY: /* gcc handles this as pointer */
case TYPE_FUNCTION: /* gcc handles this as pointer */
ir_type *const irtype = get_ir_type(type);
dbg_info *const dbgi = get_dbg_info(&declaration->source_position);
ir_entity *const entity = new_d_entity(parent_type, id, irtype, dbgi);
- set_entity_ld_ident(entity, id);
+ mangle_ent_from_decl(entity, declaration);
declaration->declaration_kind = (unsigned char) declaration_kind;
declaration->v.entity = entity;
panic("unknown initializer");
}
+static void create_dynamic_null_initializer(ir_type *type, dbg_info *dbgi,
+ ir_node *base_addr)
+{
+ ir_mode *mode = get_type_mode(type);
+ tarval *zero = get_mode_null(mode);
+ ir_node *cnst = new_d_Const(dbgi, mode, zero);
+
+ /* TODO: bitfields */
+ ir_node *mem = get_store();
+ ir_node *store = new_d_Store(dbgi, mem, base_addr, cnst);
+ ir_node *proj_m = new_Proj(store, mode_M, pn_Store_M);
+ set_store(proj_m);
+}
+
static void create_dynamic_initializer_sub(ir_initializer_t *initializer,
ir_type *type, dbg_info *dbgi, ir_node *base_addr)
{
ir_type *const irtype = get_ir_type(type);
dbg_info *const dbgi = get_dbg_info(&declaration->source_position);
ir_entity *const entity = new_d_entity(global_type, id, irtype, dbgi);
- set_entity_ld_ident(entity, id);
+ mangle_ent_from_decl(entity, declaration);
if(type->base.qualifiers & TYPE_QUALIFIER_VOLATILE) {
set_entity_volatility(entity, volatility_is_volatile);
/* set inline flags */
if (declaration->is_inline)
set_irg_inline_property(irg, irg_inline_recomended);
- handle_decl_modifier_irg(irg, declaration->modifiers);
+ handle_decl_modifier_irg(irg, declaration->decl_modifiers);
next_value_number_function = 0;
initialize_function_parameters(declaration);