• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修訂76a493ab99d9276180db6e791f95d1d6d86d2954 (tree)
時間2017-11-28 08:14:48
作者Max Filippov <jcmvbkbc@gmai...>
CommiterMax Filippov

Log Message

gas: xtensa: reuse trampoline placement code

There's almost exact copy of the trampoline placement code in the
search_trampolines function that is used for jumps generated for relaxed
branch instructions. Get rid of the duplication and reuse
xg_find_best_trampoline function for that.

gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (search_trampolines, get_best_trampoline):
Remove definitions.
(xg_find_best_trampoline_for_tinsn): New function.
(relax_frag_immed): Replace call to get_best_trampoline with a
call to xg_find_best_trampoline_for_tinsn.
* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
as the placement of trampolines for relaxed branches has been
changed.

Change Summary

差異

--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,16 @@
11 2017-11-27 Max Filippov <jcmvbkbc@gmail.com>
22
3+ * config/tc-xtensa.c (search_trampolines, get_best_trampoline):
4+ Remove definitions.
5+ (xg_find_best_trampoline_for_tinsn): New function.
6+ (relax_frag_immed): Replace call to get_best_trampoline with a
7+ call to xg_find_best_trampoline_for_tinsn.
8+ * testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
9+ as the placement of trampolines for relaxed branches has been
10+ changed.
11+
12+2017-11-27 Max Filippov <jcmvbkbc@gmail.com>
13+
314 * config/tc-xtensa.c (trampoline_index): New structure.
415 (trampoline_seg): Replace trampoline list with trampoline index.
516 (xg_find_trampoline, xg_add_trampoline_to_index)
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -9806,99 +9806,20 @@ bytes_to_stretch (fragS *this_frag,
98069806
98079807
98089808 static fragS *
9809-search_trampolines (TInsn *tinsn, fragS *fragP, bfd_boolean unreachable_only)
9809+xg_find_best_trampoline_for_tinsn (TInsn *tinsn, fragS *fragP)
98109810 {
9811+ symbolS *sym = tinsn->tok[0].X_add_symbol;
9812+ addressT source = fragP->fr_address;
9813+ addressT target = S_GET_VALUE (sym) + tinsn->tok[0].X_add_number;
98119814 struct trampoline_seg *ts = find_trampoline_seg (now_seg);
9812- fragS *tf = NULL;
98139815 size_t i;
9814- fragS *best_tf = NULL;
9815- offsetT best_delta = 0;
9816- offsetT best_addr = 0;
9817- symbolS *sym = tinsn->tok[0].X_add_symbol;
9818- offsetT target = S_GET_VALUE (sym) + tinsn->tok[0].X_add_number;
9819- offsetT addr = fragP->fr_address;
9820- offsetT lower = (addr < target) ? addr : target;
9821- offsetT upper = (addr > target) ? addr : target;
9822- offsetT delta = upper - lower;
9823- offsetT midpoint = lower + delta / 2;
9824- offsetT this_delta = -1;
9825- offsetT this_addr = -1;
9826-
9827- if (!ts)
9828- return NULL;
9829-
9830- if (delta > 2 * J_RANGE)
9831- {
9832- /* One trampoline won't do; we need multiple.
9833- Choose the farthest trampoline that's still in range of the original
9834- and let a later pass finish the job. */
9835- for (i = 0; i < ts->index.n_entries; ++i)
9836- {
9837- tf = ts->index.entry[i];
9838- this_addr = tf->fr_address + tf->fr_fix;
9839- if (upper == addr)
9840- {
9841- /* Backward jump. */
9842- if (addr - this_addr < J_RANGE)
9843- break;
9844- }
9845- else if (i + 1 < ts->index.n_entries)
9846- {
9847- /* Forward jump. */
9848- fragS *next = ts->index.entry[i + 1];
9849- offsetT next_addr = next->fr_address + next->fr_fix;
9850-
9851- if (next_addr - addr > J_RANGE)
9852- break;
9853- }
9854- else
9855- {
9856- break;
9857- }
9858- }
9859- if (i < ts->index.n_entries &&
9860- labs (addr - this_addr) < J_RANGE)
9861- return tf;
9862-
9863- return NULL;
9864- }
9865-
9866- for (i = 0; i < ts->index.n_entries; ++i)
9867- {
9868- tf = ts->index.entry[i];
9869- this_addr = tf->fr_address + tf->fr_fix;
9870- this_delta = labs (this_addr - midpoint);
9871- if (unreachable_only && tf->tc_frag_data.needs_jump_around)
9872- continue;
9873- if (!best_tf || this_delta < best_delta)
9874- {
9875- best_tf = tf;
9876- best_delta = this_delta;
9877- best_addr = this_addr;
9878- }
9879- }
9880-
9881- if (best_tf &&
9882- best_delta < J_RANGE &&
9883- labs(best_addr - lower) < J_RANGE &&
9884- labs(best_addr - upper) < J_RANGE)
9885- return best_tf;
9886-
9887- return NULL; /* No suitable trampoline found. */
9888-}
9889-
98909816
9891-static fragS *
9892-get_best_trampoline (TInsn *tinsn, fragS *fragP)
9893-{
9894- fragS *tf = NULL;
9895-
9896- tf = search_trampolines (tinsn, fragP, TRUE); /* Try unreachable first. */
9817+ if (!ts || !ts->index.n_entries)
9818+ return NULL;
98979819
9898- if (tf == NULL)
9899- tf = search_trampolines (tinsn, fragP, FALSE); /* Try ones needing a jump-around, too. */
9820+ i = xg_find_best_trampoline (&ts->index, source, target);
99009821
9901- return tf;
9822+ return ts->index.entry[i];
99029823 }
99039824
99049825
@@ -10154,7 +10075,7 @@ relax_frag_immed (segT segP,
1015410075
1015510076 if (!xg_symbolic_immeds_fit (jinsn, segP, fragP, fragP->fr_offset, total_text_diff))
1015610077 {
10157- fragS *tf = get_best_trampoline (jinsn, fragP);
10078+ fragS *tf = xg_find_best_trampoline_for_tinsn (jinsn, fragP);
1015810079
1015910080 if (tf)
1016010081 {
--- a/gas/testsuite/gas/xtensa/trampoline.d
+++ b/gas/testsuite/gas/xtensa/trampoline.d
@@ -23,11 +23,11 @@
2323 #...
2424 .*49404:.*j.0x49404
2525 .*49407:.*beqz.n.a2,.0x4940c
26-.*49409:.*j.0x693ce
26+.*49409:.*j.0x61aa2
2727 #...
28-.*693ce:.*j.0x7ddd1
28+.*61aa2:.*j.0x7a13b
2929 #...
30-.*7ddd1:.*j.0x927f5
30+.*7a13b:.*j.0x927f5
3131 #...
3232 .*927f5:.*j.0x927f5
3333 #...