summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiarhei Siamashka <siarhei.siamashka@nokia.com>2009-11-18 16:53:05 +0200
committerSiarhei Siamashka <siarhei.siamashka@nokia.com>2009-11-18 16:53:05 +0200
commit7eab8ae70780974bddff4b623549647f536011ca (patch)
tree056418d09a519ec81833caab597e3abeca4af8cf
parent98bb0a509f401563b8e6e15f4ee26947e9c3d419 (diff)
Added a script to convert objdump output to compilable assembyobjdump2s
It can be used to extract implementations of separate NEON optimized functions for use in the other projects.
-rwxr-xr-xtools/objdump2s.rb62
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/objdump2s.rb b/tools/objdump2s.rb
new file mode 100755
index 0000000..988460c
--- /dev/null
+++ b/tools/objdump2s.rb
@@ -0,0 +1,62 @@
+#!/usr/bin/env ruby
+
+$data = {}
+$func_name = nil
+
+File.open(ARGV[0]).each_line {|l|
+ if l =~ /[0-9a-fA-f]{8} \<(.*)\>/ then
+ $func_name = $1
+ $data[$func_name] = [] if !$data.has_key?($func_name)
+ else
+ if $func_name && l =~ /\s*\w+\:\s+\w+\s+/ then
+ $data[$func_name].push(l.strip)
+ end
+ end
+}
+
+def process_func(func_name, a)
+ # collect information about labels
+ labels = {}
+ label_index = 0
+ a.each {|l|
+ next if not l =~ /(\w+)\s+\<([^\+]+).*\>$/
+ if $2 != func_name then
+ printf("\n/* %s has an external reference - skipped */\n", func_name)
+ return
+ end
+ if !labels.has_key?($1) then
+ labels[$1] = label_index
+ label_index += 1
+ end
+ }
+ # print code
+ printf("\n.global %s\n", func_name)
+ printf("%s:\n", func_name)
+ a.each {|l|
+ next if not l =~ /\s*(\w+)\:\s+\w+\s+(.*)/
+ addr = $1
+ cmd = $2
+ if labels.has_key?(addr) then
+ printf("%d:", labels[addr])
+ end
+ if cmd =~ /(.*?)(\w+)\s+\<.*\>$/ then
+ prefix = $1
+ target_addr = $2
+ if target_addr.to_i(16) > addr.to_i(16) then
+ cmd = prefix + labels[target_addr].to_s + "f"
+ else
+ cmd = prefix + labels[target_addr].to_s + "b"
+ end
+ end
+ cmd.gsub!(/\s*\;\s*\w+/, "")
+ printf("\t%s\n", cmd)
+ }
+end
+
+printf(".text\n")
+printf(".fpu neon\n")
+printf(".syntax unified\n\n")
+
+$data.each {|func_name, a|
+ process_func(func_name, a)
+}