From fe6c2f1b6409867a03dd32214679dd825f74ec48 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Sat, 11 Nov 2017 04:15:55 -0800 Subject: gas: xtensa: rewrite xg_relax_trampoline Replace linked list of trampoline frags with an ordered array, so that instead of indexing fixups trampolines could be indexed. Keep each array in the trampoline_seg structure, so there's no need to rebuild it for every new processed segment. Don't run relaxation for each trampoline frag, instead run it for each fixup in the current segment that needs relaxation at the beginning of each relaxation pass. This way the complexity of this process drops from about O(n^2 * m) to about O(log n * m), where n is the number of trampoline frags and m is the number of fixups that need relaxation in the segment. gas/ 2017-11-27 Max Filippov * config/tc-xtensa.c (trampoline_index): New structure. (trampoline_seg): Replace trampoline list with trampoline index. (xg_find_trampoline, xg_add_trampoline_to_index) (xg_remove_trampoline_from_index, xg_add_trampoline_to_seg) (xg_is_trampoline_frag_full, xg_get_fulcrum) (xg_find_best_trampoline, xg_relax_fixup, xg_relax_fixups) (xg_is_relaxable_fixup): New functions. (J_MARGIN): New macro. (xtensa_create_trampoline_frag): Use xg_add_trampoline_to_seg instead of open-coded addition to the linked list. (dump_trampolines): Iterate through the trampoline_seg::index. (cached_fixupS, cached_fixup, fixup_cacheS, fixup_cache) (fixup_order, xtensa_make_cached_fixup) (xtensa_realloc_fixup_cache, xtensa_cache_relaxable_fixups) (xtensa_find_first_cached_fixup, xtensa_delete_cached_fixup) (xtensa_add_cached_fixup, check_and_update_trampolines): Remove definitions. (xg_relax_trampoline): Extract logic into separate functions, replace body with a call to xg_relax_fixups. (search_trampolines): Replace search in linked list with search in index. Change data type of address-tracking variables from int to offsetT. Replace abs with labs. (xg_append_jump): Finish the trampoline frag if it's full. (add_jump_to_trampoline): Remove trampoline frag from the index if the frag is full. * config/tc-xtensa.h (xtensa_frag_type): Remove next_trampoline. * testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses as the placement of trampolines has slightly changed. * testsuite/gas/xtensa/trampoline.s: Add _nop so that objdump stays in sync with instruction stream. --- gas/testsuite/gas/xtensa/trampoline.d | 30 ++++++++++++++---------------- gas/testsuite/gas/xtensa/trampoline.s | 1 + 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'gas/testsuite') diff --git a/gas/testsuite/gas/xtensa/trampoline.d b/gas/testsuite/gas/xtensa/trampoline.d index 5ae32a6..c0bac6d 100644 --- a/gas/testsuite/gas/xtensa/trampoline.d +++ b/gas/testsuite/gas/xtensa/trampoline.d @@ -7,29 +7,27 @@ .*0:.*j.0x1194c .*3:.*j.0x1194f .*6:.*j.0x11952 -.*9:.*j.0x1d4e4 +.*9:.*j.0x11955 #... -.*11949:.*j.0x11955 -.*1194c:.*j.0x24a0e -.*1194f:.*j.0x24a0e -.*11952:.*j.0x24a11 -#... -.*1d4e1:.*j.0x1d4e7 -.*1d4e4:.*j.0x33462 +.*11949:.*j.0x11958 +.*1194c:.*j.0x24a0b +.*1194f:.*j.0x24a0b +.*11952:.*j.0x24a0e +.*11955:.*j.0x2d687 #... +.*24a0b:.*j.0x24a0b .*24a0e:.*j.0x24a0e -.*24a11:.*j.0x24a11 #... -.*3345f:.*ret -.*33462:.*j.0x49407 +.*2d684:.*ret +.*2d687:.*j.0x49404 #... -.*49407:.*j.0x49407 -.*4940a:.*beqz.n.a2,.0x4940f -.*4940c:.*j.0x693d1 +.*49404:.*j.0x49404 +.*49407:.*beqz.n.a2,.0x4940c +.*49409:.*j.0x693ce #... -.*693d1:.*j.0x7ddd4 +.*693ce:.*j.0x7ddd1 #... -.*7ddd4:.*j.0x927f5 +.*7ddd1:.*j.0x927f5 #... .*927f5:.*j.0x927f5 #... diff --git a/gas/testsuite/gas/xtensa/trampoline.s b/gas/testsuite/gas/xtensa/trampoline.s index 3cfbe97..997a7f9 100644 --- a/gas/testsuite/gas/xtensa/trampoline.s +++ b/gas/testsuite/gas/xtensa/trampoline.s @@ -24,6 +24,7 @@ and a2, a2, a3 _ret .endr + _nop 4: j 4b -- cgit v1.1