From: "George Spelvin" <linux@horizon.com>
To: acme@ghostprotocols.net
Cc: linux@horizon.com, linux-kernel@vger.kernel.org,
torvalds@linux-foundation.org
Subject: Re: [GIT PULL 00/13] Annotation improvements (G+ edition)
Date: 22 Apr 2012 21:17:19 -0400 [thread overview]
Message-ID: <20120423011719.24546.qmail@science.horizon.com> (raw)
A simpler way might just be to use the gas syntax of appending a "b" or
"f" to the branch number, indicating whether the target is in front
or behind.
Gas permits integer branch labels to be re-used, so it's necessary to
specify a direction.
Another thing that might help a reader is a comment indicating the number
of branches to a target, divided by direction. Targets of backward
branches are obviously more interesting from a performance standpoint,
as they're likely to be the start of loops.
If you *want* to re-use branch target labels, there's a simple algorithm
for assigning them, given a list of all branch origins for each target:
First, collapse the list of all branch origins into a range, listing
the first and last reference to the target. (The target itself counts
as a reference.)
Then repeat the following for n=0, 1, 2, ... until there are
no more targets left:
In some arbitrary order (I suggest increasing order of range size),
consider each of the remaining targets. If there are no other targets
within its range, it may be assigned the label n. If there are other
targets within its range, postpone this target for a later pass, and
remove it from the list of remaining targets.
Once the decision has been made to postpone a target to a later pass, it
no longer counts as "in the range" for other targets considered this pass.
This resolves the intersecting branches case:
je 1f
0:
foo
1:
jbe 0b
Here, the 1: target was considered first, and had to be postponed
because the 0: target was in its range. Then the 0: target saw nothing
conflicting it its range, and so was assigned.
Because it's not possible to postpone every target (if this were about
to happen, there will be no remaining targets within the range of the
last target considered, so it will be assigned and not postponed),
each iteration will assign at least one target.
After considering all remaining targets, forget about the assigned ones,
incrmeent n, and go back and re-consider the postponed ones.
While the algorithm is potentially inefficient in contrived cases,
I don't think it'll be a huge problem in practice.
Even if you don't want to assign labels this way, a similar algorithm
can assign columns to branching arrows so they do not overlap.
next reply other threads:[~2012-04-23 1:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-23 1:17 George Spelvin [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-04-19 20:33 =?y?q?=5BGIT=20PULL=2000/13=5D=20Annotation=20improvements=20=28G+=20edition=29?= Arnaldo Carvalho de Melo
2012-04-20 0:01 ` [GIT PULL 00/13] Annotation improvements (G+ edition) David Ahern
2012-04-20 10:51 ` Arnaldo Carvalho de Melo
2012-04-20 0:31 ` Linus Torvalds
2012-04-20 0:40 ` Linus Torvalds
2012-04-20 10:59 ` Arnaldo Carvalho de Melo
2012-04-25 7:05 ` Ingo Molnar
2012-04-25 10:31 ` Arnaldo Carvalho de Melo
2012-04-25 10:48 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120423011719.24546.qmail@science.horizon.com \
--to=linux@horizon.com \
--cc=acme@ghostprotocols.net \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®