2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Interface for assembler output.
9 * @author Matthias Braun
12 * This is a framework for emitting data (usually the final assembly code)
14 #ifndef FIRM_BE_BEEMITTER_H
15 #define FIRM_BE_BEEMITTER_H
19 #include "firm_types.h"
24 /* don't use the following vars directly, they're only here for the inlines */
25 extern FILE *emit_file;
26 extern struct obstack emit_obst;
29 * Emit a character to the (assembler) output.
31 static inline void be_emit_char(char c)
33 obstack_1grow(&emit_obst, c);
37 * Emit a string to the (assembler) output.
39 * @param str the string
40 * @param l the length of the given string
42 static inline void be_emit_string_len(const char *str, size_t l)
44 obstack_grow(&emit_obst, str, l);
48 * Emit a null-terminated string to the (assembler) output.
50 * @param str the null-terminated string
52 static inline void be_emit_string(const char *str)
54 size_t len = strlen(str);
55 be_emit_string_len(str, len);
59 * Emit a C string-constant to the (assembler) output.
61 * @param str the null-terminated string constant
63 #define be_emit_cstring(str) \
64 be_emit_string_len(str, sizeof(str) - 1)
67 * Initializes an emitter environment.
69 * @param F a file handle where the emitted file is written to.
71 void be_emit_init(FILE *F);
74 * Destroys the given emitter environment.
76 void be_emit_exit(void);
79 * Emit the output of an ir_printf.
81 * @param fmt the ir_printf format
83 void be_emit_irprintf(const char *fmt, ...);
86 * Emit the output of an ir_vprintf.
88 * @param fmt the ir_printf format
90 void be_emit_irvprintf(const char *fmt, va_list args);
93 * Flush the line in the current line buffer to the emitter file.
95 void be_emit_write_line(void);
98 * Flush the line in the current line buffer to the emitter file and
99 * appends a gas-style comment with the node number and writes the line
101 * @param node the node to get the debug info from
103 void be_emit_finish_line_gas(const ir_node *node);
106 * Emit spaces until the comment position is reached.
108 void be_emit_pad_comment(void);
111 * The type of a emitter function.
113 typedef void emit_func(ir_node const *node);
115 static inline void be_set_emitter(ir_op *const op, emit_func *const func)
117 set_generic_function_ptr(op, func);
120 void be_emit_nothing(ir_node const *node);
123 * Emit code for a node.
125 void be_emit_node(ir_node const *node);