2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Dumps global variables and constants as gas assembler.
9 * @author Christian Wuerdig, Matthias Braun
12 #ifndef FIRM_BE_BEGNUAS_H
13 #define FIRM_BE_BEGNUAS_H
17 #include "beemitter.h"
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,
38 GAS_SECTION_FLAG_TLS = 1 << 8, /**< thread local flag */
39 GAS_SECTION_FLAG_COMDAT = 1 << 9 /**< thread local version of _BSS */
41 ENUM_BITSET(be_gas_section_t)
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;
50 typedef enum elf_variant_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;
58 extern elf_variant_t be_gas_elf_variant;
61 * the .type directive needs to specify @function, #function or %function
62 * depending on the target architecture
64 extern char be_gas_elf_type_char;
67 * Switch the current output section to the given out.
69 * @param section the new output section
71 void be_gas_emit_switch_section(be_gas_section_t section);
74 * emit assembler instructions necessary before starting function code
76 void be_gas_emit_function_prolog(const ir_entity *entity,
77 unsigned po2alignment,
78 const parameter_dbg_info_t *paramter_infos);
80 void be_gas_emit_function_epilog(const ir_entity *entity);
82 char const *be_gas_get_private_prefix(void);
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.
89 void be_gas_emit_entity(const ir_entity *entity);
92 * Emit (a private) symbol name for a firm block
94 void be_gas_emit_block_name(const ir_node *block);
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.
100 void be_gas_begin_block(const ir_node *block, bool needs_label);
103 * emit a string (takes care of escaping special chars)
105 void be_gas_emit_cstring(const char *string);
108 * Starts emitting a compilation unit. This emits:
109 * - global assembler snippets
112 void be_gas_begin_compilation_unit(const be_main_env_t *env);
115 * ends a compilation unit. This emits:
116 * - global declarations/variables
119 void be_gas_end_compilation_unit(const be_main_env_t *env);
122 * Return the label prefix for labeled instructions.
124 const char *be_gas_insn_label_prefix(void);
126 typedef ir_node* (*get_cfop_target_func)(const ir_node *cfop);
129 * Emits a jump table for switch operations
131 void be_emit_jump_table(const ir_node *node, const ir_switch_table *table,
133 get_cfop_target_func get_cfop_target);