diff options
author | Matthias Braun <matze@braunis.de> | 2016-03-26 00:23:59 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2016-03-26 00:23:59 +0000 |
commit | 7111bb5206c64a38d4e0a03c70bb3878cda50ddc (patch) | |
tree | 5eb02fa31d5910eae1e2f2ef140b6f93fc752713 /llvm/utils/abtest/mark_armfns.py | |
parent | b48f8f09b17b16edb01d4f71e9b398cdc972df2a (diff) | |
download | bcm5719-llvm-7111bb5206c64a38d4e0a03c70bb3878cda50ddc.tar.gz bcm5719-llvm-7111bb5206c64a38d4e0a03c70bb3878cda50ddc.zip |
Put my abtest scripts into the util directory
See http://lists.llvm.org/pipermail/llvm-dev/2016-March/097640.html
There is also a description/tutorial in the comments of the abtest.py
file.
llvm-svn: 264482
Diffstat (limited to 'llvm/utils/abtest/mark_armfns.py')
-rwxr-xr-x | llvm/utils/abtest/mark_armfns.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/llvm/utils/abtest/mark_armfns.py b/llvm/utils/abtest/mark_armfns.py new file mode 100755 index 00000000000..0edf42e8a83 --- /dev/null +++ b/llvm/utils/abtest/mark_armfns.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# Mark functions in an arm assembly file. This is done by surrounding the +# function with "# -- Begin Name" and "# -- End Name" +# (This script is designed for arm ios assembly syntax) +import sys +import re + +inp = open(sys.argv[1], "r").readlines() + +# First pass +linenum = 0 +INVALID=-100 +last_align = INVALID +last_code = INVALID +last_globl = INVALID +begin = INVALID +begins = dict() +for line in inp: + linenum += 1 + if ".align" in line: + last_align = linenum + if ".code" in line: + last_code = linenum + if ".globl" in line: + last_globl = linenum + m = re.search(r'.thumb_func\s+(\w+)', line) + if m: + funcname = m.group(1) + if last_code == last_align+1 and (linenum - last_code) < 4: + begin = last_align + if last_globl+1 == last_align: + begin = last_globl + if line == "\n" and begin != INVALID: + end = linenum + triple = (funcname, begin, end) + begins[begin] = triple + begin = INVALID + +# Second pass: Mark +out = open(sys.argv[1], "w") +in_func = None +linenum = 0 +for line in inp: + linenum += 1 + if in_func is not None and linenum == end: + out.write("# -- End %s\n" % in_func) + in_func = None + + triple = begins.get(linenum) + if triple is not None: + in_func, begin, end = triple + out.write("# -- Begin %s\n" % in_func) + out.write(line) |