Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 1 | From 9a4253a92a5e1811693ea1707b5fc272908ec556 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 2 | From: Mahesh Bodapati <mbodapat@xilinx.com> |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 3 | Date: Tue, 17 Jan 2017 14:41:58 +0530 |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 4 | Subject: [PATCH 16/58] [Patch, microblaze]: Add INIT_PRIORITY support |
| 5 | |
| 6 | Added TARGET_ASM_CONSTRUCTOR and TARGET_ASM_DESTRUCTOR macros. |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 7 | |
| 8 | These macros allows users to control the order of initialization |
| 9 | of objects defined at namespace scope with the init_priority |
| 10 | attribute by specifying a relative priority, a constant integral |
| 11 | expression currently bounded between 101 and 65535 inclusive. |
| 12 | |
| 13 | Lower numbers indicate a higher priority. |
| 14 | |
| 15 | Changelog |
| 16 | |
| 17 | 2013-11-26 Nagaraju Mekala <nagaraju.mekala@xilinx.com> |
| 18 | |
| 19 | * gcc/config/microblaze/microblaze.c: Add microblaze_asm_constructor, |
| 20 | microblaze_asm_destructor. Define TARGET_ASM_CONSTRUCTOR and |
| 21 | TARGET_ASM_DESTRUCTOR. |
| 22 | |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 23 | Signed-off-by:nagaraju <nmekala@xilix.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 24 | Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 25 | --- |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 26 | gcc/config/microblaze/microblaze.c | 53 ++++++++++++++++++++++++++++++ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 27 | 1 file changed, 53 insertions(+) |
| 28 | |
| 29 | diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 30 | index 0186171c04c..9eae5515c60 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 31 | --- a/gcc/config/microblaze/microblaze.c |
| 32 | +++ b/gcc/config/microblaze/microblaze.c |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 33 | @@ -2634,6 +2634,53 @@ print_operand_address (FILE * file, rtx addr) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 34 | } |
| 35 | } |
| 36 | |
| 37 | +/* Output an element in the table of global constructors. */ |
| 38 | +void |
| 39 | +microblaze_asm_constructor (rtx symbol ATTRIBUTE_UNUSED, int priority) |
| 40 | +{ |
| 41 | + const char *section = ".ctors"; |
| 42 | + char buf[16]; |
| 43 | + |
| 44 | + if (priority != DEFAULT_INIT_PRIORITY) |
| 45 | + { |
| 46 | + sprintf (buf, ".ctors.%.5u", |
| 47 | + /* Invert the numbering so the linker puts us in the proper |
| 48 | + order; constructors are run from right to left, and the |
| 49 | + linker sorts in increasing order. */ |
| 50 | + MAX_INIT_PRIORITY - priority); |
| 51 | + section = buf; |
| 52 | + } |
| 53 | + |
| 54 | + switch_to_section (get_section (section, 0, NULL)); |
| 55 | + assemble_align (POINTER_SIZE); |
| 56 | + fputs ("\t.word\t", asm_out_file); |
| 57 | + output_addr_const (asm_out_file, symbol); |
| 58 | + fputs ("\n", asm_out_file); |
| 59 | +} |
| 60 | + |
| 61 | +/* Output an element in the table of global destructors. */ |
| 62 | +void |
| 63 | +microblaze_asm_destructor (rtx symbol, int priority) |
| 64 | +{ |
| 65 | + const char *section = ".dtors"; |
| 66 | + char buf[16]; |
| 67 | + if (priority != DEFAULT_INIT_PRIORITY) |
| 68 | + { |
| 69 | + sprintf (buf, ".dtors.%.5u", |
| 70 | + /* Invert the numbering so the linker puts us in the proper |
| 71 | + order; constructors are run from right to left, and the |
| 72 | + linker sorts in increasing order. */ |
| 73 | + MAX_INIT_PRIORITY - priority); |
| 74 | + section = buf; |
| 75 | + } |
| 76 | + |
| 77 | + switch_to_section (get_section (section, 0, NULL)); |
| 78 | + assemble_align (POINTER_SIZE); |
| 79 | + fputs ("\t.word\t", asm_out_file); |
| 80 | + output_addr_const (asm_out_file, symbol); |
| 81 | + fputs ("\n", asm_out_file); |
| 82 | +} |
| 83 | + |
| 84 | /* Emit either a label, .comm, or .lcomm directive, and mark that the symbol |
| 85 | is used, so that we don't emit an .extern for it in |
| 86 | microblaze_asm_file_end. */ |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 87 | @@ -3975,6 +4022,12 @@ microblaze_starting_frame_offset (void) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 88 | #undef TARGET_ATTRIBUTE_TABLE |
| 89 | #define TARGET_ATTRIBUTE_TABLE microblaze_attribute_table |
| 90 | |
| 91 | +#undef TARGET_ASM_CONSTRUCTOR |
| 92 | +#define TARGET_ASM_CONSTRUCTOR microblaze_asm_constructor |
| 93 | + |
| 94 | +#undef TARGET_ASM_DESTRUCTOR |
| 95 | +#define TARGET_ASM_DESTRUCTOR microblaze_asm_destructor |
| 96 | + |
| 97 | #undef TARGET_IN_SMALL_DATA_P |
| 98 | #define TARGET_IN_SMALL_DATA_P microblaze_elf_in_small_data_p |
| 99 | |
| 100 | -- |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 101 | 2.17.1 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 102 | |