removed unused header
[libfirm] / ir / be / beemitter.h
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Interface for assembler output.
23  * @author      Matthias Braun
24  * @date        12.03.2007
25  * @version     $Id$
26  */
27 #ifndef FIRM_BE_BEEMITTER_H
28 #define FIRM_BE_BEEMITTER_H
29
30 #include <stdio.h>
31 #include <stdarg.h>
32 #include "obst.h"
33 #include "ident.h"
34 #include "irnode.h"
35 #include "be.h"
36
37 /* framework for emitting data (usually the final assembly code) */
38
39 /** The emitter environment. */
40 typedef struct be_emit_env_t {
41         FILE           *F;         /**< The handle of the (assembler) file that is written to. */
42         struct obstack obst;       /**< An obstack for temporary storage. */
43         int            linelength; /**< The length of the current line. */
44 } be_emit_env_t;
45
46 /**
47  * Emit a character to the (assembler) output.
48  *
49  * @param env  the emitter environment
50  */
51 static INLINE void be_emit_char(be_emit_env_t *env, char c) {
52         obstack_1grow(&env->obst, c);
53         env->linelength++;
54 }
55
56 /**
57  * Emit a string to the (assembler) output.
58  *
59  * @param env  the emitter environment
60  * @param str  the string
61  * @param l    the length of the given string
62  */
63 static INLINE void be_emit_string_len(be_emit_env_t *env, const char *str,
64                                       size_t l)
65 {
66         obstack_grow(&env->obst, str, l);
67         env->linelength += l;
68 }
69
70 /**
71  * Emit a null-terminated string to the (assembler) output.
72  *
73  * @param env  the emitter environment
74  * @param str  the null-terminated string
75  */
76 static INLINE void be_emit_string(be_emit_env_t *env, const char *str)
77 {
78         size_t len = strlen(str);
79         be_emit_string_len(env, str, len);
80 }
81
82 /**
83  * Emit a C string-constant to the (assembler) output.
84  *
85  * @param env  the emitter environment
86  * @param str  the null-terminated string constant
87  */
88 #define be_emit_cstring(env, str) { be_emit_string_len(env, str, sizeof(str)-1); }
89
90 /**
91  * Initializes an emitter environment.
92  *
93  * @param env  the (uninitialized) emitter environment
94  * @param F    a file handle where the emitted file is written to.
95  */
96 void be_emit_init_env(be_emit_env_t *env, FILE *F);
97
98 /**
99  * Destroys the given emitter environment.
100  *
101  * @param env  the emitter environment
102  */
103 void be_emit_destroy_env(be_emit_env_t *env);
104
105 /**
106  * Emit an ident to the (assembler) output.
107  *
108  * @param env  the emitter environment
109  * @param id   the ident to be emitted
110  */
111 void be_emit_ident(be_emit_env_t *env, ident *id);
112
113 /**
114  * Emit the output of an ir_printf.
115  *
116  * @param env  the emitter environment
117  * @param fmt  the ir_printf format
118  */
119 void be_emit_irprintf(be_emit_env_t *env, const char *fmt, ...);
120
121 /**
122  * Emit the output of an ir_vprintf.
123  *
124  * @param env  the emitter environment
125  * @param fmt  the ir_printf format
126  */
127 void be_emit_irvprintf(be_emit_env_t *env, const char *fmt, va_list args);
128
129 /**
130  * Flush the line in the current line buffer to the emitter file.
131  *
132  * @param env  the emitter environment
133  */
134 void be_emit_write_line(be_emit_env_t *env);
135
136 /**
137  * Flush the line in the current line buffer to the emitter file and
138  * appends a gas-style comment with the node number and writes the line
139  *
140  * @param env   the emitter environment
141  * @param node  the node to get the debug info from
142  */
143 void be_emit_finish_line_gas(be_emit_env_t *env, const ir_node *node);
144
145 /**
146  * Emit spaces until the comment position is reached.
147  *
148  * @param env  the emitter environment
149  */
150 void be_emit_pad_comment(be_emit_env_t *env);
151
152 #endif /* FIRM_BE_BEEMITTER_H */