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
26 * This is a framework for emitting data (usually the final assembly code)
28 #ifndef FIRM_BE_BEEMITTER_H
29 #define FIRM_BE_BEEMITTER_H
33 #include "firm_types.h"
37 /* don't use the following vars directly, they're only here for the inlines */
38 extern FILE *emit_file;
39 extern struct obstack emit_obst;
42 * Emit a character to the (assembler) output.
44 static inline void be_emit_char(char c)
46 obstack_1grow(&emit_obst, c);
50 * Emit a string to the (assembler) output.
52 * @param str the string
53 * @param l the length of the given string
55 static inline void be_emit_string_len(const char *str, size_t l)
57 obstack_grow(&emit_obst, str, l);
61 * Emit a null-terminated string to the (assembler) output.
63 * @param str the null-terminated string
65 static inline void be_emit_string(const char *str)
67 size_t len = strlen(str);
68 be_emit_string_len(str, len);
72 * Emit a C string-constant to the (assembler) output.
74 * @param str the null-terminated string constant
76 #define be_emit_cstring(str) \
77 be_emit_string_len(str, sizeof(str) - 1)
80 * Initializes an emitter environment.
82 * @param F a file handle where the emitted file is written to.
84 void be_emit_init(FILE *F);
87 * Destroys the given emitter environment.
89 void be_emit_exit(void);
92 * Emit an ident to the (assembler) output.
94 * @param id the ident to be emitted
96 void be_emit_ident(ident *id);
101 * @param tv the tarval to be emitted
103 void be_emit_tarval(ir_tarval *tv);
106 * Emit the output of an ir_printf.
108 * @param fmt the ir_printf format
110 void be_emit_irprintf(const char *fmt, ...);
113 * Emit the output of an ir_vprintf.
115 * @param fmt the ir_printf format
117 void be_emit_irvprintf(const char *fmt, va_list args);
120 * Flush the line in the current line buffer to the emitter file.
122 void be_emit_write_line(void);
125 * Flush the line in the current line buffer to the emitter file and
126 * appends a gas-style comment with the node number and writes the line
128 * @param node the node to get the debug info from
130 void be_emit_finish_line_gas(const ir_node *node);
133 * Emit spaces until the comment position is reached.
135 void be_emit_pad_comment(void);