diff options
author | Pirama Arumuga Nainar <pirama@google.com> | 2015-05-06 11:46:36 -0700 |
---|---|---|
committer | Pirama Arumuga Nainar <pirama@google.com> | 2015-05-18 10:52:30 -0700 |
commit | 2c3e0051c31c3f5b2328b447eadf1cf9c4427442 (patch) | |
tree | c0104029af14e9f47c2ef58ca60e6137691f3c9b /utils/create_ladder_graph.py | |
parent | e1bc145815f4334641be19f1c45ecf85d25b6e5a (diff) | |
download | external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.zip external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.tar.gz external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.tar.bz2 |
Update aosp/master LLVM for rebase to r235153
Change-Id: I9bf53792f9fc30570e81a8d80d296c681d005ea7
(cherry picked from commit 0c7f116bb6950ef819323d855415b2f2b0aad987)
Diffstat (limited to 'utils/create_ladder_graph.py')
-rw-r--r-- | utils/create_ladder_graph.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/utils/create_ladder_graph.py b/utils/create_ladder_graph.py new file mode 100644 index 0000000..d29e3ad --- /dev/null +++ b/utils/create_ladder_graph.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +"""A ladder graph creation program. + +This is a python program that creates c source code that will generate +CFGs that are ladder graphs. Ladder graphs are generally the worst case +for a lot of dominance related algorithms (Dominance frontiers, etc), +and often generate N^2 or worse behavior. + +One good use of this program is to test whether your linear time algorithm is +really behaving linearly. +""" + +import argparse +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('rungs', type=int, + help="Number of ladder rungs. Must be a multiple of 2") + args = parser.parse_args() + if (args.rungs % 2) != 0: + print "Rungs must be a multiple of 2" + return + print "int ladder(int *foo, int *bar, int x) {" + rung1 = xrange(0, args.rungs, 2) + rung2 = xrange(1, args.rungs, 2) + for i in rung1: + print "rung1%d:" % i + print "*foo = x++;" + if i != rung1[-1]: + print "if (*bar) goto rung1%d;" % (i+2) + print "else goto rung2%d;" % (i+1) + else: + print "goto rung2%d;" % (i+1) + for i in rung2: + print "rung2%d:" % i + print "*foo = x++;" + if i != rung2[-1]: + print "goto rung2%d;" % (i+2) + else: + print "return *foo;" + print "}" + +if __name__ == '__main__': + main() |