2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Dumps global variables and constants as gas assembler.
23 * @author Christian Wuerdig, Matthias Braun
27 #ifndef FIRM_BE_BEGNUAS_H
28 #define FIRM_BE_BEGNUAS_H
32 #include "beemitter.h"
34 typedef enum section_t {
35 GAS_SECTION_TEXT, /**< text section - contains program code */
36 GAS_SECTION_DATA, /**< data section - contains arbitrary data */
37 GAS_SECTION_RODATA, /**< rodata section - contains read-only data */
38 GAS_SECTION_BSS, /**< bss section - contains uninitialized data */
39 GAS_SECTION_TLS, /**< thread local storage section */
40 GAS_SECTION_CONSTRUCTORS, /**< ctors section */
41 GAS_SECTION_DESTRUCTORS, /**< dtors section */
42 GAS_SECTION_CSTRING, /**< section for constant strings */
43 GAS_SECTION_PIC_TRAMPOLINES, /**< trampolines for pic codes */
44 GAS_SECTION_PIC_SYMBOLS, /**< contains resolved pic symbols */
45 GAS_SECTION_LAST = GAS_SECTION_PIC_SYMBOLS
48 typedef enum object_file_format_t {
49 OBJECT_FILE_FORMAT_ELF, /**< Executable and Linkable Format (unixes) */
50 OBJECT_FILE_FORMAT_COFF, /**< Common Object File Format (Windows) */
51 OBJECT_FILE_FORMAT_MACH_O, /**< Mach Object File Format (OS/X) */
52 OBJECT_FILE_FORMAT_LAST = OBJECT_FILE_FORMAT_MACH_O
53 } object_file_format_t;
55 /** The variable where the GAS dialect is stored. */
56 extern object_file_format_t be_gas_object_file_format;
57 extern bool be_gas_emit_types;
59 * the .type directive needs to specify @function, #function or %function
60 * depending on the target architecture (yay)
62 extern char be_gas_elf_type_char;
65 * Generate all entities.
66 * @param main_env the main backend environment
67 * @param emit_commons if non-zero, emit commons (non-local uninitialized entities)
68 * @param only_emit_marked if non-zero, external allocated entities that do not have
69 * its visited flag set are ignored
71 void be_gas_emit_decls(const be_main_env_t *main_env,
72 int only_emit_marked_entities);
75 * Emit an entity (the entities name or a block label)
77 void be_gas_emit_entity(ir_entity *entity);
80 * Switch the current output section to the given out.
82 * @param section the new output section
84 void be_gas_emit_switch_section(be_gas_section_t section);
87 * emit assembler instructions necessary before starting function code
89 void be_gas_emit_function_prolog(ir_entity *entity, unsigned po2alignment);
91 void be_gas_emit_function_epilog(ir_entity *entity);
94 * Return the label prefix for labeled blocks.
96 const char *be_gas_block_label_prefix(void);
99 * Return the label prefix for labeled instructions.
101 const char *be_gas_insn_label_prefix(void);