X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeemitter.c;h=31229b7510ef81c0a246acebec6ad675dae66de4;hb=46b1210ed70f149727d212d7bae741ac0ed96028;hp=f0f24811eee7a7445d165708e8e9cce5c6ed46b2;hpb=0fbcef83aa6060534172bb13e71cdadb04428806;p=libfirm diff --git a/ir/be/beemitter.c b/ir/be/beemitter.c index f0f24811e..31229b751 100644 --- a/ir/be/beemitter.c +++ b/ir/be/beemitter.c @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2008 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. + * Copyright (C) 2012 University of Karlsruhe. */ /** @@ -22,11 +8,14 @@ * @brief Interface for assembler output. * @author Matthias Braun * @date 12.03.2007 - * @version $Id$ */ #include "config.h" +#include "bedwarf.h" #include "beemitter.h" +#include "be_t.h" +#include "error.h" +#include "irnode_t.h" #include "irprintf.h" #include "ident.h" #include "tv.h" @@ -34,12 +23,10 @@ FILE *emit_file; struct obstack emit_obst; -int emit_linelength; void be_emit_init(FILE *file) { emit_file = file; - emit_linelength = 0; obstack_init(&emit_obst); } @@ -48,28 +35,9 @@ void be_emit_exit(void) obstack_free(&emit_obst, NULL); } -void be_emit_ident(ident *id) -{ - size_t len = get_id_strlen(id); - const char *str = get_id_str(id); - - be_emit_string_len(str, len); -} - -void be_emit_tarval(tarval *tv) -{ - char buf[64]; - - tarval_snprintf(buf, sizeof(buf), tv); - be_emit_string(buf); -} - void be_emit_irvprintf(const char *fmt, va_list args) { - char buf[256]; - - ir_vsnprintf(buf, sizeof(buf), fmt, args); - be_emit_string(buf); + ir_obst_vprintf(&emit_obst, fmt, args); } void be_emit_irprintf(const char *fmt, ...) @@ -83,28 +51,28 @@ void be_emit_irprintf(const char *fmt, ...) void be_emit_write_line(void) { - char *finished_line = obstack_finish(&emit_obst); + size_t len = obstack_object_size(&emit_obst); + char *line = (char*)obstack_finish(&emit_obst); - fwrite(finished_line, emit_linelength, 1, emit_file); - emit_linelength = 0; - obstack_free(&emit_obst, finished_line); + fwrite(line, 1, len, emit_file); + obstack_free(&emit_obst, line); } void be_emit_pad_comment(void) { - while(emit_linelength <= 30) { - be_emit_char(' '); - } - be_emit_cstring(" "); + size_t len = obstack_object_size(&emit_obst); + if (len > 30) + len = 30; + /* 34 spaces */ + be_emit_string_len(" ", 34 - len); } void be_emit_finish_line_gas(const ir_node *node) { - dbg_info *dbg; - const char *sourcefile; - unsigned lineno; + dbg_info *dbg; + src_loc_t loc; - if(node == NULL) { + if (node == NULL || !be_options.verbose_asm) { be_emit_char('\n'); be_emit_write_line(); return; @@ -114,12 +82,31 @@ void be_emit_finish_line_gas(const ir_node *node) be_emit_cstring("/* "); be_emit_irprintf("%+F ", node); - dbg = get_irn_dbg_info(node); - sourcefile = ir_retrieve_dbg_info(dbg, &lineno); - if(sourcefile != NULL) { - be_emit_string(sourcefile); - be_emit_irprintf(":%u", lineno); + dbg = get_irn_dbg_info(node); + loc = ir_retrieve_dbg_info(dbg); + if (loc.file) { + be_emit_string(loc.file); + if (loc.line != 0) { + be_emit_irprintf(":%u", loc.line); + if (loc.column != 0) { + be_emit_irprintf(":%u", loc.column); + } + } } be_emit_cstring(" */\n"); be_emit_write_line(); } + +void be_emit_nothing(ir_node const *const node) +{ + (void)node; +} + +void be_emit_node(ir_node const *const node) +{ + be_dwarf_location(get_irn_dbg_info(node)); + ir_op *const op = get_irn_op(node); + emit_func *const emit = get_generic_function_ptr(emit_func, op); + DEBUG_ONLY(if (!emit) panic("no emit handler for node %+F (%+G, graph %+F)\n", node, node, get_irn_irg(node));) + emit(node); +}