2 * Copyright (C) 1995-2008 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
29 #include "beemitter.h"
36 struct obstack emit_obst;
38 void be_emit_init(FILE *file)
41 obstack_init(&emit_obst);
44 void be_emit_exit(void)
46 obstack_free(&emit_obst, NULL);
49 void be_emit_ident(ident *id)
51 size_t len = get_id_strlen(id);
52 const char *str = get_id_str(id);
54 be_emit_string_len(str, len);
57 void be_emit_tarval(tarval *tv)
61 tarval_snprintf(buf, sizeof(buf), tv);
65 void be_emit_irvprintf(const char *fmt, va_list args)
69 ir_vsnprintf(buf, sizeof(buf), fmt, args);
73 void be_emit_irprintf(const char *fmt, ...)
78 be_emit_irvprintf(fmt, ap);
82 void be_emit_write_line(void)
84 size_t len = obstack_object_size(&emit_obst);
85 char *line = obstack_finish(&emit_obst);
87 fwrite(line, 1, len, emit_file);
88 obstack_free(&emit_obst, line);
91 void be_emit_pad_comment(void)
93 size_t len = obstack_object_size(&emit_obst);
97 be_emit_string_len(" ", 34 - len);
100 void be_emit_finish_line_gas(const ir_node *node)
103 const char *sourcefile;
108 be_emit_write_line();
112 be_emit_pad_comment();
113 be_emit_cstring("/* ");
114 be_emit_irprintf("%+F ", node);
116 dbg = get_irn_dbg_info(node);
117 sourcefile = ir_retrieve_dbg_info(dbg, &lineno);
118 if(sourcefile != NULL) {
119 be_emit_string(sourcefile);
120 be_emit_irprintf(":%u", lineno);
122 be_emit_cstring(" */\n");
123 be_emit_write_line();