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
27 * This is a framework for emitting data (usually the final assembly code)
29 #ifndef FIRM_BE_BEEMITTER_H
30 #define FIRM_BE_BEEMITTER_H
34 #include "firm_types.h"
38 /* don't use the following vars directly, they're only here for the inlines */
39 extern FILE *emit_file;
40 extern struct obstack emit_obst;
43 * Emit a character to the (assembler) output.
45 * @param env the emitter environment
47 static inline void be_emit_char(char c)
49 obstack_1grow(&emit_obst, c);
53 * Emit a string to the (assembler) output.
55 * @param env the emitter environment
56 * @param str the string
57 * @param l the length of the given string
59 static inline void be_emit_string_len(const char *str, size_t l)
61 obstack_grow(&emit_obst, str, l);
65 * Emit a null-terminated string to the (assembler) output.
67 * @param env the emitter environment
68 * @param str the null-terminated string
70 static inline void be_emit_string(const char *str)
72 size_t len = strlen(str);
73 be_emit_string_len(str, len);
77 * Emit a C string-constant to the (assembler) output.
79 * @param env the emitter environment
80 * @param str the null-terminated string constant
82 #define be_emit_cstring(str) \
83 be_emit_string_len(str, sizeof(str) - 1)
86 * Initializes an emitter environment.
88 * @param env the (uninitialized) emitter environment
89 * @param F a file handle where the emitted file is written to.
91 void be_emit_init(FILE *F);
94 * Destroys the given emitter environment.
96 * @param env the emitter environment
98 void be_emit_exit(void);
101 * Emit an ident to the (assembler) output.
103 * @param env the emitter environment
104 * @param id the ident to be emitted
106 void be_emit_ident(ident *id);
109 * Emit a firm tarval.
111 * @param env the emitter environment
112 * @param tv the tarval to be emitted
114 void be_emit_tarval(tarval *tv);
117 * Emit the output of an ir_printf.
119 * @param env the emitter environment
120 * @param fmt the ir_printf format
122 void be_emit_irprintf(const char *fmt, ...);
125 * Emit the output of an ir_vprintf.
127 * @param env the emitter environment
128 * @param fmt the ir_printf format
130 void be_emit_irvprintf(const char *fmt, va_list args);
133 * Flush the line in the current line buffer to the emitter file.
135 * @param env the emitter environment
137 void be_emit_write_line(void);
140 * Flush the line in the current line buffer to the emitter file and
141 * appends a gas-style comment with the node number and writes the line
143 * @param env the emitter environment
144 * @param node the node to get the debug info from
146 void be_emit_finish_line_gas(const ir_node *node);
149 * Emit spaces until the comment position is reached.
151 * @param env the emitter environment
153 void be_emit_pad_comment(void);