X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeemitter.h;h=4211382f979b1fa1661603598ecb75fddc3dab98;hb=b603d9c9887767bf890cc53c7284ba583b60c397;hp=1864ffdbebc19226b7a66cb6687f3d8d545f0d68;hpb=8535fe8732b0acf822be252812a7158ce5b8134a;p=libfirm diff --git a/ir/be/beemitter.h b/ir/be/beemitter.h index 1864ffdbe..4211382f9 100644 --- a/ir/be/beemitter.h +++ b/ir/be/beemitter.h @@ -1,58 +1,155 @@ /* - * Author: Matthias Braun - * Date: 12.03.2007 - * Copyright: (c) Universitaet Karlsruhe - * License: This file is protected by GPL - GNU GENERAL PUBLIC LICENSE. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. */ -#ifndef BESPILLMORGAN_H_ -#define BESPILLMORGAN_H_ + +/** + * @file + * @brief Interface for assembler output. + * @author Matthias Braun + * @date 12.03.2007 + * @version $Id$ + * + * This is a framework for emitting data (usually the final assembly code) + */ +#ifndef FIRM_BE_BEEMITTER_H +#define FIRM_BE_BEEMITTER_H #include #include +#include "firm_types.h" #include "obst.h" -#include "ident.h" -#include "irnode.h" #include "be.h" -/* framework for emitting data (usually the final assembly code) */ - -typedef struct be_emit_env_t { - FILE *F; - struct obstack obst; - int linelength; -} be_emit_env_t; +/* don't use the following vars directly, they're only here for the inlines */ +extern FILE *emit_file; +extern struct obstack emit_obst; -static INLINE void be_emit_char(be_emit_env_t *env, char c) +/** + * Emit a character to the (assembler) output. + * + * @param env the emitter environment + */ +static inline void be_emit_char(char c) { - obstack_1grow(&env->obst, c); - env->linelength++; + obstack_1grow(&emit_obst, c); } -static INLINE void be_emit_string_len(be_emit_env_t *env, const char *str, - size_t l) +/** + * Emit a string to the (assembler) output. + * + * @param env the emitter environment + * @param str the string + * @param l the length of the given string + */ +static inline void be_emit_string_len(const char *str, size_t l) { - obstack_grow(&env->obst, str, l); - env->linelength += l; + obstack_grow(&emit_obst, str, l); } -static INLINE void be_emit_string(be_emit_env_t *env, const char *str) +/** + * Emit a null-terminated string to the (assembler) output. + * + * @param env the emitter environment + * @param str the null-terminated string + */ +static inline void be_emit_string(const char *str) { size_t len = strlen(str); - be_emit_string_len(env, str, len); + be_emit_string_len(str, len); } -#define be_emit_cstring(env,x) { be_emit_string_len(env, x, sizeof(x)-1); } +/** + * Emit a C string-constant to the (assembler) output. + * + * @param env the emitter environment + * @param str the null-terminated string constant + */ +#define be_emit_cstring(str) \ + be_emit_string_len(str, sizeof(str) - 1) + +/** + * Initializes an emitter environment. + * + * @param env the (uninitialized) emitter environment + * @param F a file handle where the emitted file is written to. + */ +void be_emit_init(FILE *F); + +/** + * Destroys the given emitter environment. + * + * @param env the emitter environment + */ +void be_emit_exit(void); + +/** + * Emit an ident to the (assembler) output. + * + * @param env the emitter environment + * @param id the ident to be emitted + */ +void be_emit_ident(ident *id); + +/** + * Emit a firm tarval. + * + * @param env the emitter environment + * @param tv the tarval to be emitted + */ +void be_emit_tarval(tarval *tv); -void be_emit_init_env(be_emit_env_t *env, FILE *F); -void be_emit_destroy_env(be_emit_env_t *env); +/** + * Emit the output of an ir_printf. + * + * @param env the emitter environment + * @param fmt the ir_printf format + */ +void be_emit_irprintf(const char *fmt, ...); -void be_emit_ident(be_emit_env_t *env, ident *id); -void be_emit_irprintf(be_emit_env_t *env, const char *fmt, ...); -void be_emit_irvprintf(be_emit_env_t *env, const char *fmt, va_list args); -void be_emit_write_line(be_emit_env_t *env); +/** + * Emit the output of an ir_vprintf. + * + * @param env the emitter environment + * @param fmt the ir_printf format + */ +void be_emit_irvprintf(const char *fmt, va_list args); -/* appends a gas-style comment with the node number and writes the line */ -void be_emit_finish_line_gas(be_emit_env_t *env, const ir_node *node); -void be_emit_pad_comment(be_emit_env_t *env); +/** + * Flush the line in the current line buffer to the emitter file. + * + * @param env the emitter environment + */ +void be_emit_write_line(void); + +/** + * Flush the line in the current line buffer to the emitter file and + * appends a gas-style comment with the node number and writes the line + * + * @param env the emitter environment + * @param node the node to get the debug info from + */ +void be_emit_finish_line_gas(const ir_node *node); + +/** + * Emit spaces until the comment position is reached. + * + * @param env the emitter environment + */ +void be_emit_pad_comment(void); #endif