amd64: small changes w.r.t. stack alignment.
[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 typedef enum {
35         GAS_SECTION_TEXT,            /**< text section - program code */
36         GAS_SECTION_DATA,            /**< data section - arbitrary data */
37         GAS_SECTION_RODATA,          /**< rodata section - read-only data */
38         GAS_SECTION_BSS,             /**< bss section - zero initialized data */
39         GAS_SECTION_CONSTRUCTORS,    /**< ctors section */
40         GAS_SECTION_DESTRUCTORS,     /**< dtors section */
41         GAS_SECTION_CSTRING,         /**< section for constant strings */
42         GAS_SECTION_PIC_TRAMPOLINES, /**< trampolines for pic codes */
43         GAS_SECTION_PIC_SYMBOLS,     /**< contains resolved pic symbols */
44         GAS_SECTION_LAST = GAS_SECTION_PIC_SYMBOLS,
45         GAS_SECTION_TYPE_MASK    = 0xFF,
46
47         GAS_SECTION_FLAG_TLS     = 1 << 8,  /**< thread local flag */
48         GAS_SECTION_FLAG_COMDAT  = 1 << 9   /**< thread local version of _BSS */
49 } be_gas_section_t;
50
51 typedef enum object_file_format_t {
52         OBJECT_FILE_FORMAT_ELF,    /**< Executable and Linkable Format (unixes) */
53         OBJECT_FILE_FORMAT_COFF,   /**< Common Object File Format (Windows) */
54         OBJECT_FILE_FORMAT_MACH_O, /**< Mach Object File Format (OS/X) */
55         OBJECT_FILE_FORMAT_ELF_SPARC, /**< Sparc variant of ELF */
56         OBJECT_FILE_FORMAT_LAST = OBJECT_FILE_FORMAT_ELF_SPARC
57 } object_file_format_t;
58
59 /** The variable where the GAS dialect is stored. */
60 extern object_file_format_t be_gas_object_file_format;
61 extern bool                 be_gas_emit_types;
62
63 /**
64  * the .type directive needs to specify @function, #function or %function
65  * depending on the target architecture (yay)
66  */
67 extern char                 be_gas_elf_type_char;
68
69
70 /**
71  * Generate all entities.
72  * @param main_env          the main backend environment
73  * @param emit_commons      if non-zero, emit commons (non-local uninitialized entities)
74  */
75 void be_gas_emit_decls(const be_main_env_t *main_env);
76
77 /**
78  * Switch the current output section to the given out.
79  *
80  * @param section  the new output section
81  */
82 void be_gas_emit_switch_section(be_gas_section_t section);
83
84 /**
85  * emit assembler instructions necessary before starting function code
86  */
87 void be_gas_emit_function_prolog(const ir_entity *entity,
88                                  unsigned po2alignment);
89
90 void be_gas_emit_function_epilog(const ir_entity *entity);
91
92 char const *be_gas_get_private_prefix(void);
93
94 /**
95  * emit ld_ident of an entity and performs additional mangling if necessary.
96  * (mangling is necessary for ir_visibility_private for example).
97  * Emits a block label for type_code entities.
98  */
99 void be_gas_emit_entity(const ir_entity *entity);
100
101 /**
102  * Emit (a private) symbol name for a firm block
103  */
104 void be_gas_emit_block_name(const ir_node *block);
105
106 /**
107  * Return the label prefix for labeled instructions.
108  */
109 const char *be_gas_insn_label_prefix(void);
110
111 #endif