remove #ifdef HAVE_CONFIG_Hs
[libfirm] / ir / be / beemitter.h
1 /*
2  * Copyright (C) 1995-2008 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  * This is a framework for emitting data (usually the final assembly code)
28  */
29 #ifndef FIRM_BE_BEEMITTER_H
30 #define FIRM_BE_BEEMITTER_H
31
32 #include <stdio.h>
33 #include <stdarg.h>
34 #include "firm_types.h"
35 #include "obst.h"
36 #include "be.h"
37
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;
41 extern int             emit_linelength;
42
43 /**
44  * Emit a character to the (assembler) output.
45  *
46  * @param env  the emitter environment
47  */
48 static INLINE void be_emit_char(char c)
49 {
50         obstack_1grow(&emit_obst, c);
51         emit_linelength++;
52 }
53
54 /**
55  * Emit a string to the (assembler) output.
56  *
57  * @param env  the emitter environment
58  * @param str  the string
59  * @param l    the length of the given string
60  */
61 static INLINE void be_emit_string_len(const char *str, size_t l)
62 {
63         obstack_grow(&emit_obst, str, l);
64         emit_linelength += l;
65 }
66
67 /**
68  * Emit a null-terminated string to the (assembler) output.
69  *
70  * @param env  the emitter environment
71  * @param str  the null-terminated string
72  */
73 static INLINE void be_emit_string(const char *str)
74 {
75         size_t len = strlen(str);
76         be_emit_string_len(str, len);
77 }
78
79 /**
80  * Emit a C string-constant to the (assembler) output.
81  *
82  * @param env  the emitter environment
83  * @param str  the null-terminated string constant
84  */
85 #define be_emit_cstring(str) \
86         do { be_emit_string_len(str, sizeof(str)-1); } while(0)
87
88 /**
89  * Initializes an emitter environment.
90  *
91  * @param env  the (uninitialized) emitter environment
92  * @param F    a file handle where the emitted file is written to.
93  */
94 void be_emit_init(FILE *F);
95
96 /**
97  * Destroys the given emitter environment.
98  *
99  * @param env  the emitter environment
100  */
101 void be_emit_exit(void);
102
103 /**
104  * Emit an ident to the (assembler) output.
105  *
106  * @param env  the emitter environment
107  * @param id   the ident to be emitted
108  */
109 void be_emit_ident(ident *id);
110
111 /**
112  * Emit a firm tarval.
113  *
114  * @param env  the emitter environment
115  * @param tv   the tarval to be emitted
116  */
117 void be_emit_tarval(tarval *tv);
118
119 /**
120  * Emit the output of an ir_printf.
121  *
122  * @param env  the emitter environment
123  * @param fmt  the ir_printf format
124  */
125 void be_emit_irprintf(const char *fmt, ...);
126
127 /**
128  * Emit the output of an ir_vprintf.
129  *
130  * @param env  the emitter environment
131  * @param fmt  the ir_printf format
132  */
133 void be_emit_irvprintf(const char *fmt, va_list args);
134
135 /**
136  * Flush the line in the current line buffer to the emitter file.
137  *
138  * @param env  the emitter environment
139  */
140 void be_emit_write_line(void);
141
142 /**
143  * Flush the line in the current line buffer to the emitter file and
144  * appends a gas-style comment with the node number and writes the line
145  *
146  * @param env   the emitter environment
147  * @param node  the node to get the debug info from
148  */
149 void be_emit_finish_line_gas(const ir_node *node);
150
151 /**
152  * Emit spaces until the comment position is reached.
153  *
154  * @param env  the emitter environment
155  */
156 void be_emit_pad_comment(void);
157
158 #endif