X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fmips%2Fmips_gen_decls.c;h=0957fb363d53d5cc4b890bb5dd9ca47f135a0679;hb=b2dba3350d751a784b350c19ddd839566e0eb3f0;hp=6522110a225c0298c6e6091ee881fc3717baebc1;hpb=05017b84e51d3ceb37f63963925802f482079cd0;p=libfirm diff --git a/ir/be/mips/mips_gen_decls.c b/ir/be/mips/mips_gen_decls.c index 6522110a2..0957fb363 100644 --- a/ir/be/mips/mips_gen_decls.c +++ b/ir/be/mips/mips_gen_decls.c @@ -1,9 +1,32 @@ +/* + * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + /** * Dumps global variables and constants as mips assembler. * @date 14.02.2006 * @version $Id$ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -141,6 +164,10 @@ static void do_dump_atomic_init(struct obstack *obst, ir_node *init) obstack_printf(obst, "%s", get_entity_ld_name(get_SymConst_entity(init))); break; + case symconst_ofs_ent: + obstack_printf(obst, "%d", get_entity_offset(get_SymConst_entity(init))); + break; + case symconst_type_size: obstack_printf(obst, "%d", get_type_size_bytes(get_SymConst_type(init))); break; @@ -149,6 +176,11 @@ static void do_dump_atomic_init(struct obstack *obst, ir_node *init) obstack_printf(obst, "%d", get_type_alignment_bytes(get_SymConst_type(init))); break; + case symconst_enum_const: + tv = get_enumeration_value(get_SymConst_enum(init)); + dump_arith_tarval(obst, tv, bytes); + break; + default: assert(0 && "dump_atomic_init(): don't know how to init from this SymConst"); } @@ -217,7 +249,7 @@ static void dump_atomic_init(struct obstack *obst, ir_node *init) * @param ent The entity * @return 1 if it is a string constant, 0 otherwise */ -static int ent_is_string_const(entity *ent) +static int ent_is_string_const(ir_entity *ent) { int res = 0; ir_type *ty; @@ -268,7 +300,7 @@ static int ent_is_string_const(entity *ent) * @param obst The obst to dump on. * @param ent The entity to dump. */ -static void dump_string_cst(struct obstack *obst, entity *ent) +static void dump_string_cst(struct obstack *obst, ir_entity *ent) { int i, n; @@ -291,7 +323,7 @@ static void dump_string_cst(struct obstack *obst, entity *ent) if (isprint(c)) obstack_printf(obst, "%c", c); else - obstack_printf(obst, "%O", c); + obstack_printf(obst, "\\%o", c); break; } } @@ -308,7 +340,7 @@ struct arr_info { * Dumps the initialization of global variables that are not * "uninitialized". */ -static void dump_global(struct obstack *rdata_obstack, struct obstack *data_obstack, struct obstack *comm_obstack, entity *ent) +static void dump_global(struct obstack *rdata_obstack, struct obstack *data_obstack, struct obstack *comm_obstack, ir_entity *ent) { ir_type *ty = get_entity_type(ent); const char *ld_name = get_entity_ld_name(ent); @@ -319,8 +351,8 @@ static void dump_global(struct obstack *rdata_obstack, struct obstack *data_obst * FIXME: did NOT work for partly constant values */ if (! is_Method_type(ty)) { - ent_variability variability = get_entity_variability(ent); - visibility visibility = get_entity_visibility(ent); + ir_variability variability = get_entity_variability(ent); + ir_visibility visibility = get_entity_visibility(ent); if (variability == variability_constant) { /* a constant entity, put it on the rdata */ @@ -353,7 +385,7 @@ static void dump_global(struct obstack *rdata_obstack, struct obstack *data_obst /* potential spare values should be already included! */ for (i = 0; i < get_compound_ent_n_values(ent); ++i) { - entity *step = get_compound_ent_value_member(ent, i); + ir_entity *step = get_compound_ent_value_member(ent, i); ir_type *stype = get_entity_type(step); if (get_type_mode(stype)) { @@ -403,10 +435,10 @@ static void dump_global(struct obstack *rdata_obstack, struct obstack *data_obst /* We wanna know how many arrays are on the path to the entity. We also have to know how * many elements each array holds to calculate the offset for the entity. */ for (j = 0; j < graph_length; j++) { - entity *step = get_compound_graph_path_node(path, j); - ir_type *step_type = get_entity_type(step); - int ty_size = (get_type_size_bits(step_type) + 7) >> 3; - int k, n = 0; + ir_entity *step = get_compound_graph_path_node(path, j); + ir_type *step_type = get_entity_type(step); + int ty_size = (get_type_size_bits(step_type) + 7) >> 3; + int k, n = 0; if (is_Array_type(step_type)) for (k = 0; k < get_array_n_dimensions(step_type); k++) @@ -421,9 +453,9 @@ static void dump_global(struct obstack *rdata_obstack, struct obstack *data_obst if (aipos) aipos--; for (offset = j = 0; j < graph_length; j++) { - entity *step = get_compound_graph_path_node(path, j); + ir_entity *step = get_compound_graph_path_node(path, j); ir_type *step_type = get_entity_type(step); - int ent_ofs = get_entity_offset_bytes(step); + int ent_ofs = get_entity_offset(step); int stepsize = 0; /* add all positive offsets (= offsets in structs) */ @@ -506,32 +538,6 @@ void mips_dump_globals(struct obstack *rdata_obstack, struct obstack *data_obsta dump_global(rdata_obstack, data_obstack, comm_obstack, get_class_member(gt, i)); } - -static void mips_emit_stdlib_call(FILE *F, const char* name, int num) { - fprintf(F, "%s:\n", name); - fprintf(F, "\tori $v0, $zero, %d\n", num); - fprintf(F, "\tsyscall\n"); - fprintf(F, "\tj $ra\n"); - fprintf(F, "\n"); -} - -/** - * Emits a default library for spim... Hack for now... - */ -static void mips_emit_standard_lib(FILE* F) { - static int output = 0; - if(output) - return; - output = 1; - - mips_emit_stdlib_call(F, "print_int", 1); - mips_emit_stdlib_call(F, "print_string", 4); - mips_emit_stdlib_call(F, "read_int", 5); - mips_emit_stdlib_call(F, "read_string", 8); - mips_emit_stdlib_call(F, "sbrk", 9); - mips_emit_stdlib_call(F, "exit", 10); -} - /************************************************************************/ void mips_gen_decls(FILE *out) { @@ -569,8 +575,4 @@ void mips_gen_decls(FILE *out) { obstack_free(&rodata, NULL); obstack_free(&data, NULL); obstack_free(&comm, NULL); - - fprintf(out, "\t.text\n"); - - mips_emit_standard_lib(out); }