2 * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Dumps global variables and constants as gas assembler.
23 * @author Christian Wuerdig, Matthias Braun
46 #include "beemitter.h"
49 /** by default, we generate assembler code for the Linux gas */
50 object_file_format_t be_gas_object_file_format = OBJECT_FILE_FORMAT_ELF;
51 elf_variant_t be_gas_elf_variant = ELF_VARIANT_NORMAL;
52 bool be_gas_emit_types = true;
53 char be_gas_elf_type_char = '@';
55 static be_gas_section_t current_section = (be_gas_section_t) -1;
56 static pmap *block_numbers;
57 static unsigned next_block_nr;
60 * An environment containing all needed dumper data.
61 * Currently we create the file completely in memory first, then
62 * write it to the disk. This is an artifact from the old C-generating backend
63 * and even there NOT needed. So we might change it in the future.
65 typedef struct be_gas_decl_env {
66 be_gas_section_t section;
67 const be_main_env_t *main_env;
70 static void emit_section_macho(be_gas_section_t section)
72 be_gas_section_t base = section & GAS_SECTION_TYPE_MASK;
73 be_gas_section_t flags = section & ~GAS_SECTION_TYPE_MASK;
76 if (current_section == section)
78 current_section = section;
83 case GAS_SECTION_TEXT: name = "text"; break;
84 case GAS_SECTION_DATA: name = "data"; break;
85 case GAS_SECTION_RODATA: name = "const"; break;
86 case GAS_SECTION_BSS: name = "data"; break;
87 case GAS_SECTION_CONSTRUCTORS: name = "mod_init_func"; break;
88 case GAS_SECTION_DESTRUCTORS: name = "mod_term_func"; break;
89 case GAS_SECTION_PIC_TRAMPOLINES: name = "section\t__IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5"; break;
90 case GAS_SECTION_PIC_SYMBOLS: name = "section\t__IMPORT,__pointers,non_lazy_symbol_pointers"; break;
91 case GAS_SECTION_CSTRING: name = "cstring"; break;
92 case GAS_SECTION_DEBUG_INFO: name = "section __DWARF,__debug_info,regular,debug"; break;
93 case GAS_SECTION_DEBUG_ABBREV: name = "section __DWARF,__debug_abbrev,regular,debug"; break;
94 case GAS_SECTION_DEBUG_LINE: name = "section __DWARF,__debug_line,regular,debug"; break;
95 case GAS_SECTION_DEBUG_PUBNAMES: name = "section __DWARF,__debug_pubnames,regular,debug"; break;
96 case GAS_SECTION_DEBUG_FRAME: name = "section __DWARF,__debug_frame,regular,debug"; break;
97 default: panic("unsupported scetion type 0x%X", section);
99 } else if (flags & GAS_SECTION_FLAG_COMDAT) {
101 case GAS_SECTION_TEXT: name = "section __TEXT,__textcoal_nt,coalesced,pure_instructions"; break;
102 case GAS_SECTION_BSS:
103 case GAS_SECTION_DATA: name = "section __DATA,__datacoal_nt,coalesced"; break;
104 case GAS_SECTION_RODATA: name = "section __TEXT,__const_coal,coalesced"; break;
105 case GAS_SECTION_CSTRING: name = "section __TEXT,__const_coal,coalesced"; break;
106 default: panic("unsupported scetion type 0x%X", section);
108 } else if (flags & GAS_SECTION_FLAG_TLS) {
109 panic("thread local storage not supported on macho (section 0x%X)", section);
111 panic("unsupported section type 0x%X", section);
113 be_emit_irprintf("\t.%s\n", name);
114 be_emit_write_line();
117 static void emit_section_sparc(be_gas_section_t section, const ir_entity *entity)
119 be_gas_section_t base = section & GAS_SECTION_TYPE_MASK;
120 be_gas_section_t flags = section & ~GAS_SECTION_TYPE_MASK;
121 static const char *const basename[GAS_SECTION_LAST+1] = {
129 NULL, /* pic trampolines */
130 NULL, /* pic symbols */
138 if (current_section == section && !(section & GAS_SECTION_FLAG_COMDAT))
140 current_section = section;
142 be_emit_cstring("\t.section\t\".");
144 /* Part1: section-name */
145 if (flags & GAS_SECTION_FLAG_TLS)
147 assert(base < (be_gas_section_t)ARRAY_SIZE(basename));
148 be_emit_string(basename[base]);
150 if (flags & GAS_SECTION_FLAG_COMDAT) {
152 be_gas_emit_entity(entity);
156 /* for the simple sections we're done here */
160 be_emit_cstring(",#alloc");
163 case GAS_SECTION_TEXT: be_emit_cstring(",#execinstr"); break;
164 case GAS_SECTION_DATA:
165 case GAS_SECTION_BSS: be_emit_cstring(",#write"); break;
170 if (flags & GAS_SECTION_FLAG_TLS) {
171 be_emit_cstring(",#tls");
176 be_emit_write_line();
179 static void emit_section(be_gas_section_t section, const ir_entity *entity)
181 be_gas_section_t base = section & GAS_SECTION_TYPE_MASK;
182 be_gas_section_t flags = section & ~GAS_SECTION_TYPE_MASK;
184 static const struct {
188 } sectioninfos[GAS_SECTION_LAST+1] = {
189 { "text", "progbits", "ax" },
190 { "data", "progbits", "aw" },
191 { "rodata", "progbits", "a" },
192 { "bss", "nobits", "aw" },
193 { "ctors", "progbits", "aw" },
194 { "dtors", "progbits", "aw" },
195 { NULL, NULL, NULL }, /* cstring */
196 { NULL, NULL, NULL }, /* pic trampolines */
197 { NULL, NULL, NULL }, /* pic symbols */
198 { "debug_info", "progbits", "" },
199 { "debug_abbrev", "progbits", "" },
200 { "debug_line", "progbits", "" },
201 { "debug_pubnames", "progbits", "" },
202 { "debug_frame", "progbits", "" },
205 if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O) {
206 emit_section_macho(section);
208 } else if(be_gas_elf_variant == ELF_VARIANT_SPARC) {
209 emit_section_sparc(section, entity);
213 if (current_section == section && !(section & GAS_SECTION_FLAG_COMDAT))
215 current_section = section;
220 case GAS_SECTION_TEXT:
221 be_emit_cstring("\t.text\n");
222 be_emit_write_line();
224 case GAS_SECTION_DATA:
225 be_emit_cstring("\t.data\n");
226 be_emit_write_line();
228 case GAS_SECTION_RODATA:
229 be_emit_cstring("\t.section\t.rodata\n");
230 be_emit_write_line();
232 case GAS_SECTION_BSS:
233 be_emit_cstring("\t.bss\n");
234 be_emit_write_line();
241 assert(base < (be_gas_section_t) ARRAY_SIZE(sectioninfos));
242 be_emit_cstring("\t.section\t.");
244 if (flags & GAS_SECTION_FLAG_TLS)
246 be_emit_string(sectioninfos[base].name);
247 if (flags & GAS_SECTION_FLAG_COMDAT) {
249 be_gas_emit_entity(entity);
253 be_emit_cstring(",\"");
254 for (f = sectioninfos[base].flags; *f != '\0'; ++f) {
257 if (flags & GAS_SECTION_FLAG_TLS)
259 if (flags & GAS_SECTION_FLAG_COMDAT)
263 if (be_gas_object_file_format != OBJECT_FILE_FORMAT_COFF) {
264 be_emit_cstring("\",");
265 be_emit_char(be_gas_elf_type_char);
266 be_emit_string(sectioninfos[base].type);
269 if (flags & GAS_SECTION_FLAG_COMDAT) {
271 be_gas_emit_entity(entity);
272 be_emit_cstring(",comdat");
275 be_emit_write_line();
280 void be_gas_emit_switch_section(be_gas_section_t section)
282 /* you have to produce a switch_section call with entity manually
283 * for comdat sections */
284 assert( !(section & GAS_SECTION_FLAG_COMDAT));
286 emit_section(section, NULL);
289 static ir_tarval *get_initializer_tarval(const ir_initializer_t *initializer)
291 if (initializer->kind == IR_INITIALIZER_TARVAL)
292 return initializer->tarval.value;
293 if (initializer->kind == IR_INITIALIZER_CONST) {
294 ir_node *node = initializer->consti.value;
295 if (is_Const(node)) {
296 return get_Const_tarval(node);
299 return get_tarval_undefined();
302 static bool initializer_is_string_const(const ir_initializer_t *initializer)
305 bool found_printable = false;
307 if (initializer->kind != IR_INITIALIZER_COMPOUND)
310 len = initializer->compound.n_initializers;
313 for (i = 0; i < len; ++i) {
317 ir_initializer_t *sub_initializer
318 = initializer->compound.initializers[i];
320 tv = get_initializer_tarval(sub_initializer);
321 if (!tarval_is_constant(tv))
324 mode = get_tarval_mode(tv);
325 if (!mode_is_int(mode) || get_mode_size_bits(mode) != 8)
328 c = get_tarval_long(tv);
329 if (isgraph(c) || isspace(c))
330 found_printable = true;
334 if (i == len - 1 && c != '\0')
338 return found_printable;
341 static bool initializer_is_null(const ir_initializer_t *initializer)
343 switch (initializer->kind) {
344 case IR_INITIALIZER_NULL:
346 case IR_INITIALIZER_TARVAL: {
347 ir_tarval *tv = initializer->tarval.value;
348 return tarval_is_null(tv);
350 case IR_INITIALIZER_CONST: {
351 ir_node *value = initializer->consti.value;
352 if (!is_Const(value))
354 return is_Const_null(value);
356 case IR_INITIALIZER_COMPOUND: {
358 for (i = 0; i < initializer->compound.n_initializers; ++i) {
359 ir_initializer_t *subinitializer
360 = initializer->compound.initializers[i];
361 if (!initializer_is_null(subinitializer))
367 panic("invalid initializer in initializer_is_null");
371 * Determine if an entity is a string constant
372 * @param ent The entity
373 * @return 1 if it is a string constant, 0 otherwise
375 static int entity_is_string_const(const ir_entity *ent)
377 ir_type *type, *element_type;
380 type = get_entity_type(ent);
382 /* if it's an array */
383 if (!is_Array_type(type))
386 element_type = get_array_element_type(type);
388 /* and the array's element type is primitive */
389 if (!is_Primitive_type(element_type))
392 /* and the mode of the element type is an int of
393 * the same size as the byte mode */
394 mode = get_type_mode(element_type);
395 if (!mode_is_int(mode) || get_mode_size_bits(mode) != 8)
398 if (ent->initializer != NULL) {
399 return initializer_is_string_const(ent->initializer);
405 static bool entity_is_null(const ir_entity *entity)
407 ir_initializer_t *initializer = get_entity_initializer(entity);
408 return initializer == NULL || initializer_is_null(initializer);
411 static bool is_comdat(const ir_entity *entity)
413 ir_linkage linkage = get_entity_linkage(entity);
414 return (linkage & IR_LINKAGE_MERGE)
415 && (linkage & IR_LINKAGE_GARBAGE_COLLECT);
418 static be_gas_section_t determine_basic_section(const ir_entity *entity)
422 if (is_method_entity(entity))
423 return GAS_SECTION_TEXT;
425 linkage = get_entity_linkage(entity);
426 if (linkage & IR_LINKAGE_CONSTANT) {
427 /* mach-o is the only one with a cstring section */
428 if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O
429 && entity_is_string_const(entity))
430 return GAS_SECTION_CSTRING;
432 return GAS_SECTION_RODATA;
434 if (entity_is_null(entity))
435 return GAS_SECTION_BSS;
437 return GAS_SECTION_DATA;
440 static be_gas_section_t determine_section(be_gas_decl_env_t *env,
441 const ir_entity *entity)
443 ir_type *owner = get_entity_owner(entity);
445 if (owner == get_segment_type(IR_SEGMENT_GLOBAL)) {
446 be_gas_section_t section = determine_basic_section(entity);
447 if (is_comdat(entity))
448 section |= GAS_SECTION_FLAG_COMDAT;
450 } else if (env != NULL && owner == env->main_env->pic_symbols_type) {
451 return GAS_SECTION_PIC_SYMBOLS;
452 } else if (env != NULL && owner == env->main_env->pic_trampolines_type) {
453 return GAS_SECTION_PIC_TRAMPOLINES;
454 } else if (owner == get_segment_type(IR_SEGMENT_CONSTRUCTORS)) {
455 return GAS_SECTION_CONSTRUCTORS;
456 } else if (owner == get_segment_type(IR_SEGMENT_DESTRUCTORS)) {
457 return GAS_SECTION_DESTRUCTORS;
458 } else if (owner == get_segment_type(IR_SEGMENT_THREAD_LOCAL)) {
459 be_gas_section_t section = determine_basic_section(entity);
460 if (is_comdat(entity))
461 section |= GAS_SECTION_FLAG_COMDAT;
463 return section | GAS_SECTION_FLAG_TLS;
466 /* the java frontend keeps some functions inside classes */
467 if (is_Class_type(owner)) {
468 return determine_basic_section(entity);
471 panic("Couldn't determine section for %+F?!?", entity);
474 static void emit_weak(const ir_entity *entity)
476 if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O) {
477 be_emit_cstring("\t.weak_reference ");
479 be_emit_cstring("\t.weak ");
481 be_gas_emit_entity(entity);
483 be_emit_write_line();
486 static void emit_visibility(const ir_entity *entity)
488 ir_linkage const linkage = get_entity_linkage(entity);
490 if (linkage & IR_LINKAGE_WEAK) {
492 /* Note: .weak seems to imply .globl so no need to output .globl */
493 } else if (get_entity_visibility(entity) == ir_visibility_external
494 && entity_has_definition(entity)) {
495 be_emit_cstring("\t.globl ");
496 be_gas_emit_entity(entity);
498 be_emit_write_line();
501 if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O
502 && (linkage & IR_LINKAGE_HIDDEN_USER)
503 && get_entity_ld_name(entity)[0] != '\0') {
504 be_emit_cstring("\t.no_dead_strip ");
505 be_gas_emit_entity(entity);
507 be_emit_write_line();
511 void be_gas_emit_function_prolog(const ir_entity *entity, unsigned po2alignment, const parameter_dbg_info_t *parameter_infos)
513 be_gas_section_t section;
515 be_dwarf_method_before(entity, parameter_infos);
517 section = determine_section(NULL, entity);
518 emit_section(section, entity);
520 /* write the begin line (makes the life easier for scripts parsing the
522 if (be_options.verbose_asm) {
523 be_emit_cstring("# -- Begin ");
524 be_gas_emit_entity(entity);
526 be_emit_write_line();
529 if (po2alignment > 0) {
530 const char *fill_byte = "";
531 unsigned maximum_skip = (1 << po2alignment) - 1;
532 /* gcc fills space between function with 0x90... */
533 if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O) {
536 be_emit_cstring("\t.p2align ");
537 be_emit_irprintf("%u,%s,%u\n", po2alignment, fill_byte, maximum_skip);
538 be_emit_write_line();
540 emit_visibility(entity);
542 switch (be_gas_object_file_format) {
543 case OBJECT_FILE_FORMAT_ELF:
544 be_emit_cstring("\t.type\t");
545 be_gas_emit_entity(entity);
546 be_emit_cstring(", ");
547 be_emit_char(be_gas_elf_type_char);
548 be_emit_cstring("function\n");
549 be_emit_write_line();
551 case OBJECT_FILE_FORMAT_COFF:
552 be_emit_cstring("\t.def\t");
553 be_gas_emit_entity(entity);
554 be_emit_cstring(";");
555 if (get_entity_visibility(entity) == ir_visibility_local) {
556 be_emit_cstring("\t.scl\t3;");
558 be_emit_cstring("\t.scl\t2;");
560 be_emit_cstring("\t.type\t32;\t.endef\n");
561 be_emit_write_line();
563 case OBJECT_FILE_FORMAT_MACH_O:
566 be_gas_emit_entity(entity);
567 be_emit_cstring(":\n");
568 be_emit_write_line();
570 be_dwarf_method_begin();
573 void be_gas_emit_function_epilog(const ir_entity *entity)
575 be_dwarf_method_end();
577 if (be_gas_object_file_format == OBJECT_FILE_FORMAT_ELF) {
578 be_emit_cstring("\t.size\t");
579 be_gas_emit_entity(entity);
580 be_emit_cstring(", .-");
581 be_gas_emit_entity(entity);
583 be_emit_write_line();
586 if (be_options.verbose_asm) {
587 be_emit_cstring("# -- End ");
588 be_gas_emit_entity(entity);
590 be_emit_write_line();
594 be_emit_write_line();
596 next_block_nr += 199;
597 next_block_nr -= next_block_nr % 100;
603 * @param tv the tarval
604 * @param bytes the width of the tarvals value in bytes
606 static void emit_arith_tarval(ir_tarval *tv, unsigned bytes)
610 be_emit_irprintf("0x%02x", get_tarval_sub_bits(tv, 0));
614 be_emit_irprintf("0x%02x%02x",
615 get_tarval_sub_bits(tv, 1), get_tarval_sub_bits(tv, 0));
619 be_emit_irprintf("0x%02x%02x%02x%02x",
620 get_tarval_sub_bits(tv, 3), get_tarval_sub_bits(tv, 2),
621 get_tarval_sub_bits(tv, 1), get_tarval_sub_bits(tv, 0));
625 be_emit_irprintf("0x%02x%02x%02x%02x%02x%02x%02x%02x",
626 get_tarval_sub_bits(tv, 7), get_tarval_sub_bits(tv, 6),
627 get_tarval_sub_bits(tv, 5), get_tarval_sub_bits(tv, 4),
628 get_tarval_sub_bits(tv, 3), get_tarval_sub_bits(tv, 2),
629 get_tarval_sub_bits(tv, 1), get_tarval_sub_bits(tv, 0));
633 panic("Can't dump a tarval with %d bytes", bytes);
637 * Return the label prefix for labeled instructions.
639 const char *be_gas_insn_label_prefix(void)
645 * Dump an atomic value.
647 * @param env the gas output environment
648 * @param init a node representing the atomic value (on the const code irg)
650 static void emit_init_expression(be_gas_decl_env_t *env, ir_node *init)
652 ir_mode *mode = get_irn_mode(init);
653 int bytes = get_mode_size_bytes(mode);
657 init = skip_Id(init);
659 switch (get_irn_opcode(init)) {
661 emit_init_expression(env, get_Cast_op(init));
665 emit_init_expression(env, get_Conv_op(init));
669 tv = get_Const_tarval(init);
671 /* it's an arithmetic value */
672 emit_arith_tarval(tv, bytes);
676 switch (get_SymConst_kind(init)) {
677 case symconst_addr_ent:
678 ent = get_SymConst_entity(init);
679 be_gas_emit_entity(ent);
682 case symconst_ofs_ent:
683 ent = get_SymConst_entity(init);
684 be_emit_irprintf("%d", get_entity_offset(ent));
687 case symconst_type_size:
688 be_emit_irprintf("%u", get_type_size_bytes(get_SymConst_type(init)));
691 case symconst_type_align:
692 be_emit_irprintf("%u", get_type_alignment_bytes(get_SymConst_type(init)));
695 case symconst_enum_const:
696 tv = get_enumeration_value(get_SymConst_enum(init));
697 emit_arith_tarval(tv, bytes);
701 assert(!"emit_atomic_init(): don't know how to init from this SymConst");
706 if (!mode_is_int(mode) && !mode_is_reference(mode)) {
707 panic("Constant must be int or pointer for '+' to work");
709 emit_init_expression(env, get_Add_left(init));
710 be_emit_cstring(" + ");
711 emit_init_expression(env, get_Add_right(init));
715 if (!mode_is_int(mode) && !mode_is_reference(mode)) {
716 panic("Constant must be int or pointer for '-' to work");
718 emit_init_expression(env, get_Sub_left(init));
719 be_emit_cstring(" - ");
720 emit_init_expression(env, get_Sub_right(init));
724 if (!mode_is_int(mode) && !mode_is_reference(mode)) {
725 panic("Constant must be int or pointer for '*' to work");
727 emit_init_expression(env, get_Mul_left(init));
728 be_emit_cstring(" * ");
729 emit_init_expression(env, get_Mul_right(init));
733 be_emit_cstring("0");
737 panic("unsupported IR-node %+F", init);
742 * Dumps the type for given size (.byte, .long, ...)
744 * @param size the size in bytes
746 static void emit_size_type(size_t size)
749 case 1: be_emit_cstring("\t.byte\t"); break;
750 case 2: be_emit_cstring("\t.short\t"); break;
751 case 4: be_emit_cstring("\t.long\t"); break;
752 case 8: be_emit_cstring("\t.quad\t"); break;
755 panic("Try to dump a type with %u bytes", (unsigned)size);
759 static void emit_string_char(int c)
762 case '"' : be_emit_cstring("\\\""); break;
763 case '\n': be_emit_cstring("\\n"); break;
764 case '\r': be_emit_cstring("\\r"); break;
765 case '\t': be_emit_cstring("\\t"); break;
766 case '\\': be_emit_cstring("\\\\"); break;
771 be_emit_irprintf("\\%03o", c);
776 static size_t emit_string_initializer(const ir_initializer_t *initializer)
778 be_emit_cstring("\t.asciz \"");
780 size_t len = initializer->compound.n_initializers;
781 for (size_t i = 0; i < len-1; ++i) {
782 const ir_initializer_t *sub_initializer
783 = get_initializer_compound_value(initializer, i);
785 ir_tarval *tv = get_initializer_tarval(sub_initializer);
786 int c = get_tarval_long(tv);
789 be_emit_cstring("\"\n");
790 be_emit_write_line();
792 return initializer->compound.n_initializers;
795 void be_gas_emit_cstring(const char *string)
797 be_emit_cstring("\t.asciz \"");
798 for (const char *c = string; *c != '\0'; ++c) {
799 emit_string_char(*c);
801 be_emit_cstring("\"\n");
802 be_emit_write_line();
805 typedef enum normal_or_bitfield_kind {
810 } normal_or_bitfield_kind;
813 normal_or_bitfield_kind kind;
818 unsigned char bf_val;
819 const ir_initializer_t *string;
821 } normal_or_bitfield;
823 static size_t get_initializer_size(const ir_initializer_t *initializer,
826 switch (get_initializer_kind(initializer)) {
827 case IR_INITIALIZER_TARVAL:
828 assert(get_tarval_mode(get_initializer_tarval_value(initializer)) == get_type_mode(type));
829 return get_type_size_bytes(type);
830 case IR_INITIALIZER_CONST:
831 case IR_INITIALIZER_NULL:
832 return get_type_size_bytes(type);
833 case IR_INITIALIZER_COMPOUND:
834 if (is_Array_type(type)) {
835 if (is_array_variable_size(type)) {
836 ir_type *element_type = get_array_element_type(type);
837 unsigned element_size = get_type_size_bytes(element_type);
838 unsigned element_align
839 = get_type_alignment_bytes(element_type);
840 unsigned misalign = element_size % element_align;
842 = get_initializer_compound_n_entries(initializer);
843 element_size += element_align - misalign;
844 return n_inits * element_size;
846 return get_type_size_bytes(type);
849 assert(is_compound_type(type));
850 size_t size = get_type_size_bytes(type);
851 if (is_compound_variable_size(type)) {
852 /* last initializer has to be an array of variable size */
853 size_t l = get_initializer_compound_n_entries(initializer)-1;
854 const ir_initializer_t *last
855 = get_initializer_compound_value(initializer, l);
856 const ir_entity *last_ent = get_compound_member(type, l);
857 ir_type *last_type = get_entity_type(last_ent);
858 assert(is_array_variable_size(last_type));
859 size += get_initializer_size(last, last_type);
865 panic("found invalid initializer");
869 static normal_or_bitfield *glob_vals;
870 static size_t max_vals;
873 static void emit_bitfield(normal_or_bitfield *vals, size_t offset_bits,
874 const ir_initializer_t *initializer, ir_type *type)
876 static const size_t BITS_PER_BYTE = 8;
877 ir_mode *mode = get_type_mode(type);
878 ir_tarval *tv = NULL;
882 bool big_endian = be_get_backend_param()->byte_order_big_endian;
884 switch (get_initializer_kind(initializer)) {
885 case IR_INITIALIZER_NULL:
887 case IR_INITIALIZER_TARVAL:
888 tv = get_initializer_tarval_value(initializer);
890 case IR_INITIALIZER_CONST: {
891 ir_node *node = get_initializer_const_value(initializer);
892 if (!is_Const(node)) {
893 panic("bitfield initializer not a Const node");
895 tv = get_Const_tarval(node);
898 case IR_INITIALIZER_COMPOUND:
899 panic("bitfield initializer is compound");
902 panic("Couldn't get numeric value for bitfield initializer");
904 tv = tarval_convert_to(tv, get_type_mode(type));
906 value_len = get_type_size_bytes(get_primitive_base_type(type));
908 end = get_mode_size_bits(mode);
909 while (bit_offset < end) {
910 size_t src_offset = bit_offset / BITS_PER_BYTE;
911 size_t src_offset_bits = bit_offset % BITS_PER_BYTE;
912 size_t dst_offset = (bit_offset+offset_bits) / BITS_PER_BYTE;
913 size_t dst_offset_bits = (bit_offset+offset_bits) % BITS_PER_BYTE;
914 size_t src_bits_len = end-bit_offset;
915 size_t dst_bits_len = BITS_PER_BYTE-dst_offset_bits;
916 unsigned char curr_bits;
917 normal_or_bitfield *val;
918 if (src_bits_len > dst_bits_len)
919 src_bits_len = dst_bits_len;
922 val = &vals[value_len - dst_offset - 1];
924 val = &vals[dst_offset];
927 assert((val-glob_vals) < (ptrdiff_t) max_vals);
928 assert(val->kind == BITFIELD ||
929 (val->kind == NORMAL && val->v.value == NULL));
930 val->kind = BITFIELD;
931 curr_bits = get_tarval_sub_bits(tv, src_offset);
932 curr_bits = curr_bits >> src_offset_bits;
933 if (src_offset_bits + src_bits_len > 8) {
934 unsigned next_bits = get_tarval_sub_bits(tv, src_offset+1);
935 curr_bits |= next_bits << (8 - src_offset_bits);
937 curr_bits &= (1 << src_bits_len) - 1;
938 val->v.bf_val |= curr_bits << dst_offset_bits;
940 bit_offset += dst_bits_len;
944 static void emit_ir_initializer(normal_or_bitfield *vals,
945 const ir_initializer_t *initializer,
948 assert((size_t) (vals - glob_vals) <= max_vals);
950 if (initializer_is_string_const(initializer)) {
951 assert(vals->kind != BITFIELD);
953 vals->v.string = initializer;
957 switch (get_initializer_kind(initializer)) {
958 case IR_INITIALIZER_NULL:
960 case IR_INITIALIZER_TARVAL: {
963 assert(vals->kind != BITFIELD);
966 vals->v.tarval = get_initializer_tarval_value(initializer);
967 assert(get_type_mode(type) == get_tarval_mode(vals->v.tarval));
968 for (i = 1; i < get_type_size_bytes(type); ++i) {
969 vals[i].kind = NORMAL;
971 vals[i].v.value = NULL;
975 case IR_INITIALIZER_CONST: {
978 assert(vals->kind != BITFIELD);
981 vals->v.value = get_initializer_const_value(initializer);
982 for (i = 1; i < get_type_size_bytes(type); ++i) {
983 vals[i].kind = NORMAL;
985 vals[i].v.value = NULL;
989 case IR_INITIALIZER_COMPOUND: {
991 size_t n = get_initializer_compound_n_entries(initializer);
993 if (is_Array_type(type)) {
994 ir_type *element_type = get_array_element_type(type);
995 size_t skip = get_type_size_bytes(element_type);
996 size_t alignment = get_type_alignment_bytes(element_type);
997 size_t misalign = skip % alignment;
999 skip += alignment - misalign;
1002 for (i = 0; i < n; ++i) {
1003 ir_initializer_t *sub_initializer
1004 = get_initializer_compound_value(initializer, i);
1006 emit_ir_initializer(vals, sub_initializer, element_type);
1011 size_t n_members, i;
1012 assert(is_compound_type(type));
1013 n_members = get_compound_n_members(type);
1014 for (i = 0; i < n_members; ++i) {
1015 ir_entity *member = get_compound_member(type, i);
1016 size_t offset = get_entity_offset(member);
1017 ir_type *subtype = get_entity_type(member);
1018 ir_mode *mode = get_type_mode(subtype);
1019 ir_initializer_t *sub_initializer;
1021 assert(i < get_initializer_compound_n_entries(initializer));
1023 = get_initializer_compound_value(initializer, i);
1027 = get_entity_offset_bits_remainder(member);
1029 if (is_Primitive_type(subtype)
1030 && get_primitive_base_type(subtype) != NULL) {
1031 emit_bitfield(&vals[offset], offset_bits,
1032 sub_initializer, subtype);
1035 assert(offset_bits == 0);
1039 emit_ir_initializer(&vals[offset], sub_initializer, subtype);
1046 panic("invalid ir_initializer kind found");
1049 static void emit_tarval_data(ir_type *type, ir_tarval *tv)
1051 size_t size = get_type_size_bytes(type);
1053 /* this should be an x86 extended float */
1054 assert(be_get_backend_param()->byte_order_big_endian == 0);
1056 /* Beware: Mixed endian output! One little endian number emitted as
1057 * three longs. Each long initializer is written in big endian. */
1059 "\t.long\t0x%02x%02x%02x%02x\n"
1060 "\t.long\t0x%02x%02x%02x%02x\n"
1061 "\t.long\t0x%02x%02x%02x%02x\n",
1062 get_tarval_sub_bits(tv, 3), get_tarval_sub_bits(tv, 2),
1063 get_tarval_sub_bits(tv, 1), get_tarval_sub_bits(tv, 0),
1064 get_tarval_sub_bits(tv, 7), get_tarval_sub_bits(tv, 6),
1065 get_tarval_sub_bits(tv, 5), get_tarval_sub_bits(tv, 4),
1066 get_tarval_sub_bits(tv, 11), get_tarval_sub_bits(tv, 10),
1067 get_tarval_sub_bits(tv, 9), get_tarval_sub_bits(tv, 8)
1069 be_emit_write_line();
1070 } else if (size == 16) {
1071 if (be_get_backend_param()->byte_order_big_endian) {
1073 "\t.long\t0x%02x%02x%02x%02x\n"
1074 "\t.long\t0x%02x%02x%02x%02x\n"
1075 "\t.long\t0x%02x%02x%02x%02x\n"
1076 "\t.long\t0x%02x%02x%02x%02x\n",
1077 get_tarval_sub_bits(tv, 15), get_tarval_sub_bits(tv, 14),
1078 get_tarval_sub_bits(tv, 13), get_tarval_sub_bits(tv, 12),
1079 get_tarval_sub_bits(tv, 11), get_tarval_sub_bits(tv, 10),
1080 get_tarval_sub_bits(tv, 9), get_tarval_sub_bits(tv, 8),
1081 get_tarval_sub_bits(tv, 7), get_tarval_sub_bits(tv, 6),
1082 get_tarval_sub_bits(tv, 5), get_tarval_sub_bits(tv, 4),
1083 get_tarval_sub_bits(tv, 3), get_tarval_sub_bits(tv, 2),
1084 get_tarval_sub_bits(tv, 1), get_tarval_sub_bits(tv, 0)
1087 /* Beware: Mixed endian output! One little endian number emitted as
1088 * three longs. Each long initializer is written in big endian. */
1090 "\t.long\t0x%02x%02x%02x%02x\n"
1091 "\t.long\t0x%02x%02x%02x%02x\n"
1092 "\t.long\t0x%02x%02x%02x%02x\n"
1093 "\t.long\t0x%02x%02x%02x%02x\n",
1094 get_tarval_sub_bits(tv, 3), get_tarval_sub_bits(tv, 2),
1095 get_tarval_sub_bits(tv, 1), get_tarval_sub_bits(tv, 0),
1096 get_tarval_sub_bits(tv, 7), get_tarval_sub_bits(tv, 6),
1097 get_tarval_sub_bits(tv, 5), get_tarval_sub_bits(tv, 4),
1098 get_tarval_sub_bits(tv, 11), get_tarval_sub_bits(tv, 10),
1099 get_tarval_sub_bits(tv, 9), get_tarval_sub_bits(tv, 8),
1100 get_tarval_sub_bits(tv, 15), get_tarval_sub_bits(tv, 14),
1101 get_tarval_sub_bits(tv, 13), get_tarval_sub_bits(tv, 12)
1104 be_emit_write_line();
1108 emit_size_type(size);
1109 emit_arith_tarval(tv, size);
1111 be_emit_write_line();
1116 * Emit an atomic value.
1118 * @param env the gas output environment
1119 * @param init a node representing the atomic value (on the const code irg)
1121 static void emit_node_data(be_gas_decl_env_t *env, ir_node *init, ir_type *type)
1123 size_t size = get_type_size_bytes(type);
1124 if (size == 12 || size == 16) {
1126 if (!is_Const(init)) {
1127 panic("12/16byte initializers only support Const nodes yet");
1129 tv = get_Const_tarval(init);
1130 emit_tarval_data(type, tv);
1134 emit_size_type(size);
1135 emit_init_expression(env, init);
1137 be_emit_write_line();
1140 static void emit_initializer(be_gas_decl_env_t *env, const ir_entity *entity)
1142 const ir_initializer_t *initializer = entity->initializer;
1144 normal_or_bitfield *vals;
1148 if (initializer_is_string_const(initializer)) {
1149 emit_string_initializer(initializer);
1153 type = get_entity_type(entity);
1154 size = get_initializer_size(initializer, type);
1160 * In the worst case, every initializer allocates one byte.
1161 * Moreover, initializer might be big, do not allocate on stack.
1163 vals = XMALLOCNZ(normal_or_bitfield, size);
1170 emit_ir_initializer(vals, initializer, type);
1172 /* now write values sorted */
1173 for (k = 0; k < size; ) {
1175 normal_or_bitfield_kind kind = vals[k].kind;
1179 if (vals[k].v.value != NULL) {
1180 emit_node_data(env, vals[k].v.value, vals[k].type);
1181 elem_size = get_type_size_bytes(vals[k].type);
1187 emit_tarval_data(vals[k].type, vals[k].v.tarval);
1188 elem_size = get_type_size_bytes(vals[k].type);
1191 elem_size = emit_string_initializer(vals[k].v.string);
1194 be_emit_irprintf("\t.byte\t%d\n", vals[k].v.bf_val);
1195 be_emit_write_line();
1199 panic("internal compiler error (invalid normal_or_bitfield_kind");
1203 while (k < size && vals[k].kind == NORMAL && vals[k].v.value == NULL) {
1210 be_emit_irprintf("\t.space\t%d, 0\n", space);
1211 be_emit_write_line();
1217 static void emit_align(unsigned p2alignment)
1219 be_emit_irprintf("\t.p2align\t%u\n", log2_floor(p2alignment));
1220 be_emit_write_line();
1223 static unsigned get_effective_entity_alignment(const ir_entity *entity)
1225 unsigned alignment = get_entity_alignment(entity);
1226 if (alignment == 0) {
1227 ir_type *type = get_entity_type(entity);
1228 alignment = get_type_alignment_bytes(type);
1233 static void emit_common(const ir_entity *entity)
1235 unsigned size = get_type_size_bytes(get_entity_type(entity));
1236 unsigned alignment = get_effective_entity_alignment(entity);
1238 if (get_entity_linkage(entity) & IR_LINKAGE_WEAK) {
1242 switch (be_gas_object_file_format) {
1243 case OBJECT_FILE_FORMAT_MACH_O:
1244 be_emit_cstring("\t.comm ");
1245 be_gas_emit_entity(entity);
1246 be_emit_irprintf(",%u,%u\n", size, log2_floor(alignment));
1247 be_emit_write_line();
1249 case OBJECT_FILE_FORMAT_ELF:
1250 be_emit_cstring("\t.comm ");
1251 be_gas_emit_entity(entity);
1252 be_emit_irprintf(",%u,%u\n", size, alignment);
1253 be_emit_write_line();
1255 case OBJECT_FILE_FORMAT_COFF:
1256 be_emit_cstring("\t.comm ");
1257 be_gas_emit_entity(entity);
1258 be_emit_irprintf(",%u # %u\n", size, alignment);
1259 be_emit_write_line();
1262 panic("invalid object file format");
1265 static void emit_local_common(const ir_entity *entity)
1267 unsigned size = get_type_size_bytes(get_entity_type(entity));
1268 unsigned alignment = get_effective_entity_alignment(entity);
1270 if (get_entity_linkage(entity) & IR_LINKAGE_WEAK) {
1274 switch (be_gas_object_file_format) {
1275 case OBJECT_FILE_FORMAT_MACH_O:
1276 be_emit_cstring("\t.lcomm ");
1277 be_gas_emit_entity(entity);
1278 be_emit_irprintf(",%u,%u\n", size, log2_floor(alignment));
1279 be_emit_write_line();
1281 case OBJECT_FILE_FORMAT_ELF:
1282 be_emit_cstring("\t.local ");
1283 be_gas_emit_entity(entity);
1284 be_emit_cstring("\n");
1285 be_emit_write_line();
1286 be_emit_cstring("\t.comm ");
1287 be_gas_emit_entity(entity);
1288 be_emit_irprintf(",%u,%u\n", size, alignment);
1289 be_emit_write_line();
1291 case OBJECT_FILE_FORMAT_COFF:
1292 be_emit_cstring("\t.lcomm ");
1293 be_gas_emit_entity(entity);
1294 be_emit_irprintf(",%u # %u\n", size, alignment);
1295 be_emit_write_line();
1298 panic("invalid object file format");
1301 static void emit_indirect_symbol(const ir_entity *entity, be_gas_section_t section)
1303 /* we can only do PIC code on macho so far */
1304 assert(be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O);
1306 be_gas_emit_entity(entity);
1307 be_emit_cstring(":\n");
1308 be_emit_write_line();
1309 be_emit_irprintf("\t.indirect_symbol %I\n", get_entity_ident(entity));
1310 be_emit_write_line();
1311 if (section == GAS_SECTION_PIC_TRAMPOLINES) {
1312 be_emit_cstring("\thlt ; hlt ; hlt ; hlt ; hlt\n");
1313 be_emit_write_line();
1315 assert(section == GAS_SECTION_PIC_SYMBOLS);
1316 be_emit_cstring("\t.long 0\n");
1317 be_emit_write_line();
1321 char const *be_gas_get_private_prefix(void)
1323 return be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O ? "L" : ".L";
1326 void be_gas_emit_entity(const ir_entity *entity)
1328 if (entity->type == get_code_type()) {
1329 ir_label_t label = get_entity_label(entity);
1330 be_emit_irprintf("%s_%lu", be_gas_get_private_prefix(), label);
1334 if (get_entity_visibility(entity) == ir_visibility_private) {
1335 be_emit_string(be_gas_get_private_prefix());
1337 be_emit_irprintf("%I", get_entity_ld_ident(entity));
1340 void be_gas_emit_block_name(const ir_node *block)
1342 ir_entity *entity = get_Block_entity(block);
1343 if (entity != NULL) {
1344 be_gas_emit_entity(entity);
1346 void *nr_val = pmap_get(void, block_numbers, block);
1348 if (nr_val == NULL) {
1349 nr = next_block_nr++;
1350 pmap_insert(block_numbers, block, INT_TO_PTR(nr+1));
1352 nr = PTR_TO_INT(nr_val)-1;
1354 be_emit_irprintf("%s%d", be_gas_get_private_prefix(), nr);
1358 void be_gas_begin_block(const ir_node *block, bool needs_label)
1361 be_gas_emit_block_name(block);
1364 if (!be_options.verbose_asm)
1366 be_emit_cstring("/*");
1367 be_gas_emit_block_name(block);
1368 be_emit_cstring(":*/");
1371 if (be_options.verbose_asm) {
1372 be_emit_pad_comment();
1373 be_emit_irprintf("/* %+F preds:", block);
1375 int arity = get_irn_arity(block);
1377 be_emit_cstring(" none");
1380 for (i = 0; i < arity; ++i) {
1381 ir_node *predblock = get_Block_cfgpred_block(block, i);
1383 be_gas_emit_block_name(predblock);
1386 be_emit_irprintf(", freq: %.3f */", get_block_execfreq(block));
1389 be_emit_write_line();
1393 * Dump a global entity.
1395 * @param env the gas output environment
1396 * @param ent the entity to be dumped
1398 static void emit_global(be_gas_decl_env_t *env, const ir_entity *entity)
1400 ir_type *type = get_entity_type(entity);
1401 ident *ld_ident = get_entity_ld_ident(entity);
1402 unsigned alignment = get_effective_entity_alignment(entity);
1403 be_gas_section_t section = determine_section(env, entity);
1404 ir_visibility visibility = get_entity_visibility(entity);
1405 ir_linkage linkage = get_entity_linkage(entity);
1407 /* Block labels are already emitted in the code. */
1408 if (type == get_code_type())
1411 /* we already emitted all methods with graphs in other functions like
1412 * be_gas_emit_function_prolog(). All others don't need to be emitted.
1414 if (is_Method_type(type) && section != GAS_SECTION_PIC_TRAMPOLINES) {
1418 be_dwarf_variable(entity);
1420 if (section == GAS_SECTION_BSS) {
1421 switch (visibility) {
1422 case ir_visibility_local:
1423 case ir_visibility_private:
1424 emit_local_common(entity);
1426 case ir_visibility_external:
1427 if (linkage & IR_LINKAGE_MERGE) {
1428 emit_common(entity);
1435 emit_visibility(entity);
1437 if (!is_po2(alignment))
1438 panic("alignment not a power of 2");
1440 emit_section(section, entity);
1442 if (section == GAS_SECTION_PIC_TRAMPOLINES
1443 || section == GAS_SECTION_PIC_SYMBOLS) {
1444 emit_indirect_symbol(entity, section);
1448 /* nothing left to do without an initializer */
1449 if (!entity_has_definition(entity))
1453 if (alignment > 1) {
1454 emit_align(alignment);
1456 if (be_gas_object_file_format == OBJECT_FILE_FORMAT_ELF
1457 && be_gas_emit_types
1458 && visibility != ir_visibility_private) {
1459 be_emit_cstring("\t.type\t");
1460 be_gas_emit_entity(entity);
1461 be_emit_cstring(", ");
1462 be_emit_char(be_gas_elf_type_char);
1463 be_emit_cstring("object\n\t.size\t");\
1464 be_gas_emit_entity(entity);
1465 be_emit_irprintf(", %u\n", get_type_size_bytes(type));
1468 if (get_id_str(ld_ident)[0] != '\0') {
1469 be_gas_emit_entity(entity);
1470 be_emit_cstring(":\n");
1471 be_emit_write_line();
1474 if (entity_is_null(entity)) {
1475 /* we should use .space for stuff in the bss segment */
1476 unsigned size = get_type_size_bytes(type);
1478 be_emit_irprintf("\t.space %u, 0\n", get_type_size_bytes(type));
1479 be_emit_write_line();
1482 assert(entity->initializer != NULL);
1483 emit_initializer(env, entity);
1488 * Dumps declarations of global variables and the initialization code.
1490 * @param gt a global like type, either the global or the TLS one
1491 * @param env an environment
1493 static void be_gas_emit_globals(ir_type *gt, be_gas_decl_env_t *env)
1495 size_t i, n = get_compound_n_members(gt);
1497 for (i = 0; i < n; i++) {
1498 ir_entity *ent = get_compound_member(gt, i);
1499 emit_global(env, ent);
1503 /* Generate all entities. */
1504 static void emit_global_decls(const be_main_env_t *main_env)
1506 be_gas_decl_env_t env;
1507 memset(&env, 0, sizeof(env));
1509 /* dump global type */
1510 env.main_env = main_env;
1511 env.section = (be_gas_section_t) -1;
1513 be_gas_emit_globals(get_glob_type(), &env);
1514 be_gas_emit_globals(get_tls_type(), &env);
1515 be_gas_emit_globals(get_segment_type(IR_SEGMENT_CONSTRUCTORS), &env);
1516 be_gas_emit_globals(get_segment_type(IR_SEGMENT_DESTRUCTORS), &env);
1517 be_gas_emit_globals(main_env->pic_symbols_type, &env);
1518 be_gas_emit_globals(main_env->pic_trampolines_type, &env);
1521 * ".subsections_via_symbols marks object files which are OK to divide
1522 * their section contents into individual blocks".
1523 * From my understanding this means no label points in the middle of an
1524 * object which we want to address as a whole. Firm code should be fine
1527 if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O) {
1528 be_emit_cstring("\t.subsections_via_symbols\n");
1529 be_emit_write_line();
1533 void be_emit_jump_table(const ir_node *node, const ir_switch_table *table,
1534 ir_entity *entity, get_cfop_target_func get_cfop_target)
1536 unsigned n_outs = arch_get_irn_n_outs(node);
1537 const ir_node **targets = XMALLOCNZ(const ir_node*, n_outs);
1538 size_t n_entries = ir_switch_table_get_n_entries(table);
1539 unsigned long length = 0;
1542 const ir_node **labels;
1544 /* go over all proj's and collect their jump targets */
1545 foreach_out_edge(node, edge) {
1546 ir_node *proj = get_edge_src_irn(edge);
1547 long pn = get_Proj_proj(proj);
1548 ir_node *target = get_cfop_target(proj);
1549 assert(targets[pn] == NULL);
1550 targets[pn] = target;
1553 /* go over table to determine max value (note that we normalized the
1554 * ranges so that the minimum is 0) */
1555 for (e = 0; e < n_entries; ++e) {
1556 const ir_switch_table_entry *entry
1557 = ir_switch_table_get_entry_const(table, e);
1558 ir_tarval *max = entry->max;
1562 if (!tarval_is_long(max))
1563 panic("switch case overflow (%+F)", node);
1564 val = (unsigned long) get_tarval_long(max);
1570 /* the 16000 isn't a real limit of the architecture. But should protect us
1571 * from seamingly endless compiler runs */
1572 if (length > 16000) {
1573 /* switch lowerer should have broken this monster to pieces... */
1574 panic("too large switch encountered (%+F)", node);
1578 labels = XMALLOCNZ(const ir_node*, length);
1579 for (e = 0; e < n_entries; ++e) {
1580 const ir_switch_table_entry *entry
1581 = ir_switch_table_get_entry_const(table, e);
1582 ir_tarval *min = entry->min;
1583 ir_tarval *max = entry->max;
1584 const ir_node *target = targets[entry->pn];
1585 assert(entry->pn < (long)n_outs);
1587 unsigned long val = (unsigned long)get_tarval_long(max);
1588 labels[val] = target;
1590 unsigned long min_val;
1591 unsigned long max_val;
1593 if (!tarval_is_long(min))
1594 panic("switch case overflow (%+F)", node);
1595 min_val = (unsigned long)get_tarval_long(min);
1596 max_val = (unsigned long)get_tarval_long(max);
1597 assert(min_val <= max_val);
1598 for (i = min_val; i <= max_val; ++i) {
1605 if (entity != NULL) {
1606 be_gas_emit_switch_section(GAS_SECTION_RODATA);
1607 be_emit_cstring("\t.align 4\n");
1608 be_gas_emit_entity(entity);
1609 be_emit_cstring(":\n");
1612 for (i = 0; i < length; ++i) {
1613 const ir_node *block = labels[i];
1616 be_emit_cstring("\t.long ");
1617 be_gas_emit_block_name(block);
1619 be_emit_write_line();
1623 be_gas_emit_switch_section(GAS_SECTION_TEXT);
1629 static void emit_global_asms(void)
1631 size_t n = get_irp_n_asms();
1634 be_gas_emit_switch_section(GAS_SECTION_TEXT);
1635 for (i = 0; i < n; ++i) {
1636 ident *asmtext = get_irp_asm(i);
1638 be_emit_cstring("#APP\n");
1639 be_emit_write_line();
1640 be_emit_irprintf("%I\n", asmtext);
1641 be_emit_write_line();
1642 be_emit_cstring("#NO_APP\n");
1643 be_emit_write_line();
1647 void be_gas_begin_compilation_unit(const be_main_env_t *env)
1650 be_dwarf_unit_begin(env->cup_name);
1652 block_numbers = pmap_create();
1658 void be_gas_end_compilation_unit(const be_main_env_t *env)
1660 emit_global_decls(env);
1662 pmap_destroy(block_numbers);
1664 be_dwarf_unit_end();