2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Interface for assembler output.
23 * @author Matthias Braun
31 #include "beemitter.h"
38 struct obstack emit_obst;
41 void be_emit_init(FILE *file)
45 obstack_init(&emit_obst);
48 void be_emit_exit(void)
50 obstack_free(&emit_obst, NULL);
53 void be_emit_ident(ident *id)
55 size_t len = get_id_strlen(id);
56 const char *str = get_id_str(id);
58 be_emit_string_len(str, len);
61 void be_emit_tarval(tarval *tv)
65 tarval_snprintf(buf, sizeof(buf), tv);
69 void be_emit_irvprintf(const char *fmt, va_list args)
73 ir_vsnprintf(buf, sizeof(buf), fmt, args);
77 void be_emit_irprintf(const char *fmt, ...)
82 be_emit_irvprintf(fmt, ap);
86 void be_emit_write_line(void)
88 char *finished_line = obstack_finish(&emit_obst);
90 fwrite(finished_line, emit_linelength, 1, emit_file);
92 obstack_free(&emit_obst, finished_line);
95 void be_emit_pad_comment(void)
97 while(emit_linelength <= 30) {
100 be_emit_cstring(" ");
103 void be_emit_finish_line_gas(const ir_node *node)
106 const char *sourcefile;
111 be_emit_write_line();
115 be_emit_pad_comment();
116 be_emit_cstring("/* ");
117 be_emit_irprintf("%+F ", node);
119 dbg = get_irn_dbg_info(node);
120 sourcefile = ir_retrieve_dbg_info(dbg, &lineno);
121 if(sourcefile != NULL) {
122 be_emit_string(sourcefile);
123 be_emit_irprintf(":%u", lineno);
125 be_emit_cstring(" */\n");
126 be_emit_write_line();