708d8ec78f63c0a322142ec6eca2f1da8a413446
[libfirm] / ir / be / begnuas.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       Dumps global variables and constants as gas assembler.
23  * @author      Christian Wuerdig, Matthias Braun
24  * @date        04.11.2005
25  * @version     $Id$
26  */
27 #ifndef FIRM_BE_BEGNUAS_H
28 #define FIRM_BE_BEGNUAS_H
29
30 #include <stdbool.h>
31 #include "be.h"
32 #include "beemitter.h"
33
34 /**
35  * Sections.
36  */
37 typedef enum section_t {
38         GAS_SECTION_TEXT,   /**< text section */
39         GAS_SECTION_DATA,   /**< data section */
40         GAS_SECTION_RODATA, /**< rodata section */
41         GAS_SECTION_COMMON, /**< common section */
42         GAS_SECTION_TLS,    /**< thread local storage section */
43         GAS_SECTION_CONSTRUCTORS,   /**< ctors section */
44         GAS_SECTION_DESTRUCTORS,    /**< dtors section */
45         GAS_SECTION_CSTRING, /**< section for constant strings */
46         GAS_SECTION_PIC_TRAMPOLINES, /**< trampolines for pic codes */
47         GAS_SECTION_PIC_SYMBOLS,     /**< contains resolved pic symbols */
48         GAS_SECTION_LAST = GAS_SECTION_PIC_SYMBOLS
49 } be_gas_section_t;
50
51 /**
52  * Support for some GAS "dialects".
53  */
54 typedef enum asm_flavour_t {
55         GAS_FLAVOUR_ELF,     /**< ELF variant */
56         GAS_FLAVOUR_MINGW,   /**< MinGW variant (no-ELF) */
57         GAS_FLAVOUR_YASM,    /**< YASM GNU parser */
58         GAS_FLAVOUR_MACH_O,  /**< Mach-O variant (as found on darwin, OS/X) */
59         GAS_FLAVOUR_LAST = GAS_FLAVOUR_MACH_O
60 } be_gas_flavour_t;
61
62 /** The variable where the GAS dialect is stored. */
63 extern be_gas_flavour_t be_gas_flavour;
64 extern bool             be_gas_emit_types;
65 /**
66  * the .type directive needs to specify @function, #function or %function
67  * depending on the target architecture (yay)
68  */
69 extern char             be_gas_elf_type_char;
70
71 /**
72  * Generate all entities.
73  * @param main_env          the main backend environment
74  * @param emit_commons      if non-zero, emit commons (non-local uninitialized entities)
75  * @param only_emit_marked  if non-zero, external allocated entities that do not have
76  *                          its visited flag set are ignored
77  */
78 void be_gas_emit_decls(const be_main_env_t *main_env,
79                        int only_emit_marked_entities);
80
81 /**
82  * Emit an entity (the entities name or a block label)
83  */
84 void be_gas_emit_entity(ir_entity *entity);
85
86 /**
87  * Switch the current output section to the given out.
88  *
89  * @param section  the new output section
90  */
91 void be_gas_emit_switch_section(be_gas_section_t section);
92
93 /**
94  * emit assembler instructions necessary before starting function code
95  */
96 void be_gas_emit_function_prolog(ir_entity *entity, unsigned po2alignment);
97
98 void be_gas_emit_function_epilog(ir_entity *entity);
99
100 /**
101  * Return the label prefix for labeled blocks.
102  */
103 const char *be_gas_block_label_prefix(void);
104
105 /**
106  * Return the label prefix for labeled instructions.
107  */
108 const char *be_gas_insn_label_prefix(void);
109
110 #endif