tt_align,
tt_allocation,
tt_builtin,
- tt_cond_kind,
tt_cond_jmp_predicate,
tt_initializer,
tt_iro,
tt_keyword,
tt_mode_sort,
tt_mode_arithmetic,
- tt_peculiarity,
tt_pin_state,
tt_tpo,
tt_type_state,
- tt_variability,
- tt_visibility,
tt_volatility,
- tt_segment
+ tt_linkage,
+ tt_segment,
+ tt_visibility
} typetag_t;
typedef enum keyword_t
INSERT(tt_segment, "constructors", IR_SEGMENT_CONSTRUCTORS);
INSERT(tt_segment, "destructors", IR_SEGMENT_DESTRUCTORS);
+ INSERT(tt_linkage, "constant", IR_LINKAGE_CONSTANT);
+ INSERT(tt_linkage, "weak", IR_LINKAGE_WEAK);
+ INSERT(tt_linkage, "garbage_collect", IR_LINKAGE_GARBAGE_COLLECT);
+ INSERT(tt_linkage, "merge", IR_LINKAGE_MERGE);
+ INSERT(tt_linkage, "hidden_user", IR_LINKAGE_HIDDEN_USER);
+
+ INSERT(tt_visibility, "local", ir_visibility_local);
+ INSERT(tt_visibility, "external", ir_visibility_external);
+ INSERT(tt_visibility, "default", ir_visibility_default);
+ INSERT(tt_visibility, "private", ir_visibility_private);
+
INSERTKEYWORD(constirg);
INSERTKEYWORD(entity);
INSERTKEYWORD(irg);
INSERTENUM(tt_align, align_non_aligned);
INSERTENUM(tt_align, align_is_aligned);
- INSERTENUM(tt_allocation, allocation_automatic);
- INSERTENUM(tt_allocation, allocation_parameter);
- INSERTENUM(tt_allocation, allocation_dynamic);
- INSERTENUM(tt_allocation, allocation_static);
-
INSERTENUM(tt_builtin, ir_bk_trap);
INSERTENUM(tt_builtin, ir_bk_debugbreak);
INSERTENUM(tt_builtin, ir_bk_return_address);
INSERTENUM(tt_builtin, ir_bk_outport);
INSERTENUM(tt_builtin, ir_bk_inner_trampoline);
- INSERTENUM(tt_cond_kind, dense);
- INSERTENUM(tt_cond_kind, fragmentary);
-
INSERTENUM(tt_cond_jmp_predicate, COND_JMP_PRED_NONE);
INSERTENUM(tt_cond_jmp_predicate, COND_JMP_PRED_TRUE);
INSERTENUM(tt_cond_jmp_predicate, COND_JMP_PRED_FALSE);
INSERTENUM(tt_mode_arithmetic, irma_ieee754);
INSERTENUM(tt_mode_arithmetic, irma_float_BCD);
- INSERTENUM(tt_peculiarity, peculiarity_description);
- INSERTENUM(tt_peculiarity, peculiarity_inherited);
- INSERTENUM(tt_peculiarity, peculiarity_existent);
-
INSERTENUM(tt_pin_state, op_pin_state_floats);
INSERTENUM(tt_pin_state, op_pin_state_pinned);
INSERTENUM(tt_pin_state, op_pin_state_exc_pinned);
INSERTENUM(tt_type_state, layout_undefined);
INSERTENUM(tt_type_state, layout_fixed);
- INSERTENUM(tt_variability, variability_uninitialized);
- INSERTENUM(tt_variability, variability_initialized);
- INSERTENUM(tt_variability, variability_part_constant);
- INSERTENUM(tt_variability, variability_constant);
-
- INSERTENUM(tt_visibility, visibility_local);
- INSERTENUM(tt_visibility, visibility_external_visible);
- INSERTENUM(tt_visibility, visibility_external_allocated);
-
INSERTENUM(tt_volatility, volatility_non_volatile);
INSERTENUM(tt_volatility, volatility_is_volatile);
return "INVALID_SEGMENT";
}
+static const char *get_visibility_name(ir_visibility visibility)
+{
+ switch (visibility) {
+ case ir_visibility_local: return "local";
+ case ir_visibility_external: return "external";
+ case ir_visibility_default: return "default";
+ case ir_visibility_private: return "private";
+ }
+ return "INVALID_VISIBILITY";
+}
+
/** Returns the according symbol value for the given string and tag, or SYMERROR if none was found. */
static unsigned symbol(const char *str, typetag_t typetag)
{
fputc(' ', env->file);
}
-static void write_cond_kind(io_env_t *env, ir_node *irn)
-{
- fputs(get_cond_kind_name(get_Cond_kind(irn)), env->file);
- fputc(' ', env->file);
-}
-
static void write_cond_jmp_predicate(io_env_t *env, ir_node *irn)
{
fputs(get_cond_jmp_predicate_name(get_Cond_jmp_pred(irn)), env->file);
case IR_INITIALIZER_COMPOUND: {
unsigned i, n = get_initializer_compound_n_entries(ini);
- fprintf(f, "%d ", n);
+ fprintf(f, "%u ", n);
for (i = 0; i < n; i++)
write_initializer(env, get_initializer_compound_value(ini, i));
break;
static void export_type_common(io_env_t *env, ir_type *tp)
{
- fprintf(env->file, "\ttype %ld %s %u %u %s %s %d ",
+ fprintf(env->file, "\ttype %ld %s %u %u %s %u ",
get_type_nr(tp),
get_type_tpop_name(tp),
get_type_size_bytes(tp),
get_type_alignment_bytes(tp),
get_type_state_name(get_type_state(tp)),
- get_visibility_name(get_type_visibility(tp)),
tp->flags);
}
static void export_entity(io_env_t *env, ir_entity *ent)
{
- ir_type *owner = get_entity_owner(ent);
+ FILE *file = env->file;
+ ir_type *owner = get_entity_owner(ent);
+ ir_visibility visibility = get_entity_visibility(ent);
+ ir_linkage linkage = get_entity_linkage(ent);
/* we don't dump array_element_ent entities. They're a strange concept
* and lead to cycles in type_graph.
fprintf(env->file, "NULL ");
}
- fprintf(env->file, "%ld %ld %d %u %d %s %s %s %s %s ",
+ /* visibility + linkage */
+ if (visibility != ir_visibility_default) {
+ fprintf(file, "%s ", get_visibility_name(visibility));
+ }
+ if (linkage & IR_LINKAGE_CONSTANT)
+ fputs("constant ", file);
+ if (linkage & IR_LINKAGE_WEAK)
+ fputs("weak ", file);
+ if (linkage & IR_LINKAGE_GARBAGE_COLLECT)
+ fputs("garbage_collect ", file);
+ if (linkage & IR_LINKAGE_MERGE)
+ fputs("merge ", file);
+ if (linkage & IR_LINKAGE_HIDDEN_USER)
+ fputs("hidden_user ", file);
+
+ fprintf(file, "%ld %ld %d %u %d %s ",
get_type_nr(get_entity_type(ent)),
get_type_nr(owner),
get_entity_offset(ent),
(unsigned) get_entity_offset_bits_remainder(ent),
is_entity_compiler_generated(ent),
- get_allocation_name(get_entity_allocation(ent)),
- get_visibility_name(get_entity_visibility(ent)),
- get_variability_name(get_entity_variability(ent)),
- get_peculiarity_name(get_entity_peculiarity(ent)),
get_volatility_name(get_entity_volatility(ent)));
- /* TODO: inheritance stuff for class entities not supported yet */
- if (is_Class_type(owner) && owner != get_glob_type())
- fprintf(stderr, "Inheritance of class entities not supported yet!\n");
-
- if (get_entity_variability(ent) != variability_uninitialized &&
- get_entity_visibility(ent) != visibility_external_allocated)
- {
- if (is_compound_entity(ent)) {
- if (has_entity_initializer(ent)) {
- fputs("initializer ", env->file);
- write_initializer(env, get_entity_initializer(ent));
- } else {
- int i, n = get_compound_ent_n_values(ent);
- fputs("noninitializer ", env->file);
- fprintf(env->file, "%d ", n);
- for (i = 0; i < n; i++) {
- ir_entity *member = get_compound_ent_value_member(ent, i);
- ir_node *irn = get_compound_ent_value(ent, i);
- fprintf(env->file, "%ld %ld ", get_entity_nr(member), get_irn_node_nr(irn));
- }
- }
- } else {
- ir_node *irn = get_atomic_ent_value(ent);
- fprintf(env->file, "%ld ", get_irn_node_nr(irn));
+ if (ent->initializer != NULL) {
+ fputs("initializer ", env->file);
+ write_initializer(env, get_entity_initializer(ent));
+ } else if (entity_has_compound_ent_values(ent)) {
+ int i, n = get_compound_ent_n_values(ent);
+ fputs("compoundgraph ", env->file);
+ fprintf(env->file, "%d ", n);
+ for (i = 0; i < n; i++) {
+ ir_entity *member = get_compound_ent_value_member(ent, i);
+ ir_node *irn = get_compound_ent_value(ent, i);
+ fprintf(env->file, "%ld %ld ", get_entity_nr(member), get_irn_node_nr(irn));
}
+ } else {
+ fputs("none", env->file);
}
fputc('\n', env->file);
break;
}
- fprintf(env->file, "\tmode \"%s\" %s %d %d %s %d %d ",
+ fprintf(env->file, "\tmode \"%s\" %s %u %d %s %u %u ",
get_mode_name(mode), get_mode_sort_name(get_mode_sort(mode)),
get_mode_size_bits(mode), get_mode_sign(mode),
get_mode_arithmetic_name(get_mode_arithmetic(mode)),
do {
obstack_1grow(&env->obst, env->c);
read_c(env);
- } while(isdigit(env->c));
+ } while (isdigit(env->c));
obstack_1grow(&env->obst, 0);
str = obstack_finish(&env->obst);
case tt_align: return "align";
case tt_allocation: return "allocation";
case tt_builtin: return "builtin kind";
+ case tt_cond_jmp_predicate: return "cond_jmp_predicate";
case tt_initializer: return "initializer kind";
case tt_iro: return "opcode";
- case tt_peculiarity: return "peculiarity";
+ case tt_keyword: return "keyword";
+ case tt_linkage: return "linkage";
+ case tt_mode_arithmetic: return "mode_arithmetic";
+ case tt_mode_sort: return "mode_sort";
case tt_pin_state: return "pin state";
+ case tt_segment: return "segment";
case tt_tpo: return "type";
case tt_type_state: return "type state";
- case tt_variability: return "variability";
- case tt_visibility: return "visibility";
case tt_volatility: return "volatility";
- case tt_cond_kind: return "cond_kind";
- case tt_cond_jmp_predicate: return "cond_jmp_predicate";
- case tt_keyword: return "keyword";
- case tt_mode_sort: return "mode_sort";
- case tt_mode_arithmetic: return "mode_arithmetic";
- case tt_segment: return "segment";
+ case tt_visibility: return "visibility";
}
return "<UNKNOWN>";
}
#define read_align(env) ((ir_align) read_enum(env, tt_align))
#define read_allocation(env) ((ir_allocation) read_enum(env, tt_allocation))
#define read_builtin_kind(env) ((ir_builtin_kind) read_enum(env, tt_builtin))
-#define read_cond_kind(env) ((cond_kind) read_enum(env, tt_cond_kind))
#define read_cond_jmp_predicate(env) ((cond_jmp_predicate) read_enum(env, tt_cond_jmp_predicate))
#define read_initializer_kind(env) ((ir_initializer_kind_t) read_enum(env, tt_initializer))
#define read_mode_arithmetic(env) ((ir_mode_arithmetic) read_enum(env, tt_mode_arithmetic))
#define read_pin_state(env) ((op_pin_state) read_enum(env, tt_pin_state))
#define read_type_state(env) ((ir_type_state) read_enum(env, tt_type_state))
#define read_variability(env) ((ir_variability) read_enum(env, tt_variability))
-#define read_visibility(env) ((ir_visibility) read_enum(env, tt_visibility))
#define read_volatility(env) ((ir_volatility) read_enum(env, tt_volatility))
static ir_cons_flags get_cons_flags(io_env_t *env)
unsigned size = (unsigned) read_long(env);
unsigned align = (unsigned) read_long(env);
ir_type_state state = read_type_state(env);
- ir_visibility vis = read_visibility(env);
unsigned flags = (unsigned) read_long(env);
switch (tpop) {
const char *name = read_quoted_string_null(env);
ident *id = name != NULL ? new_id_from_str(name) : NULL;
- if(typenr == (long) IR_SEGMENT_GLOBAL)
+ if (typenr == (long) IR_SEGMENT_GLOBAL)
type = get_glob_type();
else
type = new_type_class(id);
}
set_type_alignment_bytes(type, align);
- set_type_visibility(type, vis);
type->flags = flags;
if (state == layout_fixed)
/** Reads an entity description and remembers it by its id. */
static void import_entity(io_env_t *env)
{
- long entnr = read_long(env);
- ident *name = read_ident(env);
- ident *ld_name = read_ident_null(env);
- long typenr = read_long(env);
- long ownertypenr = read_long(env);
+ long entnr = read_long(env);
+ ident *name = read_ident(env);
+ ident *ld_name = read_ident_null(env);
+ ir_visibility visibility = ir_visibility_default;
+ ir_linkage linkage = IR_LINKAGE_DEFAULT;
+ long typenr;
+ long ownertypenr;
+ const char *str;
+ ir_type *type;
+ ir_type *ownertype;
+ ir_entity *entity;
+
+ skip_ws(env);
+ while (!isdigit(env->c)) {
+ char *str = read_word(env);
+ unsigned v;
+
+ skip_ws(env);
+
+ v = symbol(str, tt_visibility);
+ if (v != SYMERROR) {
+ visibility = v;
+ continue;
+ }
+ v = symbol(str, tt_linkage);
+ if (v != SYMERROR) {
+ linkage |= v;
+ continue;
+ }
+ printf("Parser error, expected visibility or linkage, got '%s'\n",
+ str);
+ break;
+ }
- ir_type *type = get_type(env, typenr);
- ir_type *ownertype = !ownertypenr ? get_glob_type() : get_type(env, ownertypenr);
- ir_entity *entity = new_entity(ownertype, name, type);
+ typenr = read_long(env);
+ ownertypenr = read_long(env);
+
+ type = get_type(env, typenr);
+ ownertype = !ownertypenr ? get_glob_type() : get_type(env, ownertypenr);
+ entity = new_entity(ownertype, name, type);
if (ld_name != NULL)
set_entity_ld_ident(entity, ld_name);
- set_entity_offset (entity, (int) read_long(env));
+ set_entity_offset(entity, (int) read_long(env));
set_entity_offset_bits_remainder(entity, (unsigned char) read_long(env));
set_entity_compiler_generated(entity, (int) read_long(env));
- set_entity_allocation (entity, read_allocation(env));
- set_entity_visibility (entity, read_visibility(env));
- set_entity_variability(entity, read_variability(env));
- set_entity_peculiarity(entity, read_peculiarity(env));
- set_entity_volatility (entity, read_volatility(env));
-
- if (get_entity_variability(entity) != variability_uninitialized &&
- get_entity_visibility(entity) != visibility_external_allocated) {
-
- if (is_compound_entity(entity)) {
- char *str = read_word(env);
- if (strcmp(str, "initializer") == 0) {
- set_entity_initializer(entity, read_initializer(env));
- } else if (strcmp(str, "noninitializer") == 0) {
- int n = (int) read_long(env);
- int i;
- for (i = 0; i < n; i++) {
- ir_entity *member = get_entity(env, read_long(env));
- ir_node *irn = get_node_or_dummy(env, read_long(env));
- add_compound_ent_value(entity, irn, member);
- }
- } else {
- parse_error(env, "expected 'initializer' or 'noninitializer', got '%s'\n", str);
- exit(1);
- }
- } else {
- ir_node *irn = get_node_or_dummy(env, read_long(env));
- set_atomic_ent_value(entity, irn);
+ set_entity_volatility(entity, read_volatility(env));
+ set_entity_visibility(entity, visibility);
+ set_entity_linkage(entity, linkage);
+
+ str = read_word(env);
+ if (strcmp(str, "initializer") == 0) {
+ set_entity_initializer(entity, read_initializer(env));
+ } else if (strcmp(str, "compoundgraph") == 0) {
+ int n = (int) read_long(env);
+ int i;
+ for (i = 0; i < n; i++) {
+ ir_entity *member = get_entity(env, read_long(env));
+ ir_node *irn = get_node_or_dummy(env, read_long(env));
+ add_compound_ent_value(entity, irn, member);
}
+ } else if (strcmp(str, "none") == 0) {
+ /* do nothing */
+ } else {
+ parse_error(env, "expected 'initializer', 'compoundgraph' or 'none' got '%s'\n", str);
+ exit(1);
}
set_id(env, entnr, entity);