bearch: Disallow passing Projs to get_irn_ops().
[libfirm] / ir / be / begnuas.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief       Dumps global variables and constants as gas assembler.
9  * @author      Christian Wuerdig, Matthias Braun
10  * @date        04.11.2005
11  */
12 #ifndef FIRM_BE_BEGNUAS_H
13 #define FIRM_BE_BEGNUAS_H
14
15 #include <stdbool.h>
16 #include "be_types.h"
17 #include "beemitter.h"
18 #include "bedwarf.h"
19
20 typedef enum {
21         GAS_SECTION_TEXT,            /**< text section - program code */
22         GAS_SECTION_DATA,            /**< data section - arbitrary data */
23         GAS_SECTION_RODATA,          /**< rodata section - read-only data */
24         GAS_SECTION_BSS,             /**< bss section - zero initialized data */
25         GAS_SECTION_CONSTRUCTORS,    /**< ctors section */
26         GAS_SECTION_DESTRUCTORS,     /**< dtors section */
27         GAS_SECTION_CSTRING,         /**< section for constant strings */
28         GAS_SECTION_PIC_TRAMPOLINES, /**< trampolines for pic codes */
29         GAS_SECTION_PIC_SYMBOLS,     /**< contains resolved pic symbols */
30         GAS_SECTION_DEBUG_INFO,      /**< dwarf debug info */
31         GAS_SECTION_DEBUG_ABBREV,    /**< dwarf debug abbrev */
32         GAS_SECTION_DEBUG_LINE,      /**< dwarf debug line */
33         GAS_SECTION_DEBUG_PUBNAMES,  /**< dwarf pub names */
34         GAS_SECTION_DEBUG_FRAME,     /**< dwarf callframe infos */
35         GAS_SECTION_LAST = GAS_SECTION_DEBUG_FRAME,
36         GAS_SECTION_TYPE_MASK    = 0xFF,
37
38         GAS_SECTION_FLAG_TLS     = 1 << 8,  /**< thread local flag */
39         GAS_SECTION_FLAG_COMDAT  = 1 << 9   /**< thread local version of _BSS */
40 } be_gas_section_t;
41 ENUM_BITSET(be_gas_section_t)
42
43 typedef enum object_file_format_t {
44         OBJECT_FILE_FORMAT_ELF,    /**< Executable and Linkable Format (unixes) */
45         OBJECT_FILE_FORMAT_COFF,   /**< Common Object File Format (Windows) */
46         OBJECT_FILE_FORMAT_MACH_O, /**< Mach Object File Format (OS/X) */
47         OBJECT_FILE_FORMAT_LAST = OBJECT_FILE_FORMAT_MACH_O
48 } object_file_format_t;
49
50 typedef enum elf_variant_t {
51         ELF_VARIANT_NORMAL,
52         ELF_VARIANT_SPARC
53 } elf_variant_t;
54
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;
58 extern elf_variant_t        be_gas_elf_variant;
59
60 /**
61  * the .type directive needs to specify @function, #function or %function
62  * depending on the target architecture
63  */
64 extern char                 be_gas_elf_type_char;
65
66 /**
67  * Switch the current output section to the given out.
68  *
69  * @param section  the new output section
70  */
71 void be_gas_emit_switch_section(be_gas_section_t section);
72
73 /**
74  * emit assembler instructions necessary before starting function code
75  */
76 void be_gas_emit_function_prolog(const ir_entity *entity,
77                                  unsigned po2alignment,
78                                  const parameter_dbg_info_t *paramter_infos);
79
80 void be_gas_emit_function_epilog(const ir_entity *entity);
81
82 char const *be_gas_get_private_prefix(void);
83
84 /**
85  * emit ld_ident of an entity and performs additional mangling if necessary.
86  * (mangling is necessary for ir_visibility_private for example).
87  * Emits a block label for type_code entities.
88  */
89 void be_gas_emit_entity(const ir_entity *entity);
90
91 /**
92  * Emit (a private) symbol name for a firm block
93  */
94 void be_gas_emit_block_name(const ir_node *block);
95
96 /**
97  * Starts a basic block. Emits an assembler label "blockname:" if needs_label
98  * is true, otherwise a comment with the blockname if verboseasm is enabled.
99  */
100 void be_gas_begin_block(const ir_node *block, bool needs_label);
101
102 /**
103  * emit a string (takes care of escaping special chars)
104  */
105 void be_gas_emit_cstring(const char *string);
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