make unique types/entities part of irprog
[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  */
26 #ifndef FIRM_BE_BEGNUAS_H
27 #define FIRM_BE_BEGNUAS_H
28
29 #include <stdbool.h>
30 #include "be_types.h"
31 #include "beemitter.h"
32
33 typedef enum {
34         GAS_SECTION_TEXT,            /**< text section - program code */
35         GAS_SECTION_DATA,            /**< data section - arbitrary data */
36         GAS_SECTION_RODATA,          /**< rodata section - read-only data */
37         GAS_SECTION_BSS,             /**< bss section - zero initialized data */
38         GAS_SECTION_CONSTRUCTORS,    /**< ctors section */
39         GAS_SECTION_DESTRUCTORS,     /**< dtors section */
40         GAS_SECTION_CSTRING,         /**< section for constant strings */
41         GAS_SECTION_PIC_TRAMPOLINES, /**< trampolines for pic codes */
42         GAS_SECTION_PIC_SYMBOLS,     /**< contains resolved pic symbols */
43         GAS_SECTION_DEBUG_INFO,      /**< dwarf debug info */
44         GAS_SECTION_DEBUG_ABBREV,    /**< dwarf debug abbrev */
45         GAS_SECTION_DEBUG_LINE,      /**< dwarf debug line */
46         GAS_SECTION_DEBUG_PUBNAMES,  /**< dwarf pub names */
47         GAS_SECTION_LAST = GAS_SECTION_DEBUG_PUBNAMES,
48         GAS_SECTION_TYPE_MASK    = 0xFF,
49
50         GAS_SECTION_FLAG_TLS     = 1 << 8,  /**< thread local flag */
51         GAS_SECTION_FLAG_COMDAT  = 1 << 9   /**< thread local version of _BSS */
52 } be_gas_section_t;
53 ENUM_BITSET(be_gas_section_t)
54
55 typedef enum object_file_format_t {
56         OBJECT_FILE_FORMAT_ELF,    /**< Executable and Linkable Format (unixes) */
57         OBJECT_FILE_FORMAT_COFF,   /**< Common Object File Format (Windows) */
58         OBJECT_FILE_FORMAT_MACH_O, /**< Mach Object File Format (OS/X) */
59         OBJECT_FILE_FORMAT_LAST = OBJECT_FILE_FORMAT_MACH_O
60 } object_file_format_t;
61
62 typedef enum elf_variant_t {
63         ELF_VARIANT_NORMAL,
64         ELF_VARIANT_SPARC
65 } elf_variant_t;
66
67 /** The variable where the GAS dialect is stored. */
68 extern object_file_format_t be_gas_object_file_format;
69 extern bool                 be_gas_emit_types;
70 extern elf_variant_t        be_gas_elf_variant;
71
72 /**
73  * the .type directive needs to specify @function, #function or %function
74  * depending on the target architecture
75  */
76 extern char                 be_gas_elf_type_char;
77
78 /**
79  * Switch the current output section to the given out.
80  *
81  * @param section  the new output section
82  */
83 void be_gas_emit_switch_section(be_gas_section_t section);
84
85 /**
86  * emit assembler instructions necessary before starting function code
87  */
88 void be_gas_emit_function_prolog(const ir_entity *entity,
89                                  unsigned po2alignment);
90
91 void be_gas_emit_function_epilog(const ir_entity *entity);
92
93 char const *be_gas_get_private_prefix(void);
94
95 /**
96  * emit ld_ident of an entity and performs additional mangling if necessary.
97  * (mangling is necessary for ir_visibility_private for example).
98  * Emits a block label for type_code entities.
99  */
100 void be_gas_emit_entity(const ir_entity *entity);
101
102 /**
103  * Emit (a private) symbol name for a firm block
104  */
105 void be_gas_emit_block_name(const ir_node *block);
106
107 /**
108  * Starts emitting a compilation unit. This emits:
109  *  - global assembler snippets
110  *  - debug info
111  */
112 void be_gas_begin_compilation_unit(const be_main_env_t *env);
113
114 /**
115  * ends a compilation unit. This emits:
116  *  - global declarations/variables
117  *  - debug info
118  */
119 void be_gas_end_compilation_unit(const be_main_env_t *env);
120
121 /**
122  * Return the label prefix for labeled instructions.
123  */
124 const char *be_gas_insn_label_prefix(void);
125
126 typedef ir_node* (*get_cfop_target_func)(const ir_node *cfop);
127
128 /**
129  * Emits a jump table for switch operations
130  */
131 void be_emit_jump_table(const ir_node *node, const ir_switch_table *table,
132                         ir_entity *entity,
133                         get_cfop_target_func get_cfop_target);
134
135 #endif