move backend into libfirm
[libfirm] / ir / be / beemitter.h
1 /*
2  * Author:      Matthias Braun
3  * Date:                12.03.2007
4  * Copyright:   (c) Universitaet Karlsruhe
5  * License:     This file is protected by GPL -  GNU GENERAL PUBLIC LICENSE.
6  */
7 #ifndef BESPILLMORGAN_H_
8 #define BESPILLMORGAN_H_
9
10 #include <stdio.h>
11 #include <stdarg.h>
12 #include "obst.h"
13 #include "ident.h"
14 #include "irnode.h"
15 #include "be.h"
16
17 /* framework for emitting data (usually the final assembly code) */
18
19 typedef struct be_emit_env_t {
20         FILE *F;
21         struct obstack obst;
22         int            linelength;
23 } be_emit_env_t;
24
25 static INLINE void be_emit_char(be_emit_env_t *env, char c)
26 {
27         obstack_1grow(&env->obst, c);
28         env->linelength++;
29 }
30
31 static INLINE void be_emit_string_len(be_emit_env_t *env, const char *str,
32                                       size_t l)
33 {
34         obstack_grow(&env->obst, str, l);
35         env->linelength += l;
36 }
37
38 static INLINE void be_emit_string(be_emit_env_t *env, const char *str)
39 {
40         size_t len = strlen(str);
41         be_emit_string_len(env, str, len);
42 }
43
44 #define be_emit_cstring(env,x) { be_emit_string_len(env, x, sizeof(x)-1); }
45
46 void be_emit_init_env(be_emit_env_t *env, FILE *F);
47 void be_emit_destroy_env(be_emit_env_t *env);
48
49 void be_emit_ident(be_emit_env_t *env, ident *id);
50 void be_emit_irprintf(be_emit_env_t *env, const char *fmt, ...);
51 void be_emit_irvprintf(be_emit_env_t *env, const char *fmt, va_list args);
52 void be_emit_write_line(be_emit_env_t *env);
53
54 /* appends a gas-style comment with the node number and writes the line */
55 void be_emit_finish_line_gas(be_emit_env_t *env, const ir_node *node);
56 void be_emit_pad_comment(be_emit_env_t *env);
57
58 #endif