summaryrefslogtreecommitdiff
path: root/volk/gen
diff options
context:
space:
mode:
Diffstat (limited to 'volk/gen')
-rw-r--r--volk/gen/machines.xml19
-rw-r--r--volk/gen/volk_arch_defs.py3
-rw-r--r--volk/gen/volk_compile_utils.py68
-rw-r--r--volk/gen/volk_machine_defs.py7
4 files changed, 82 insertions, 15 deletions
diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml
index 9c19c91c6..04ffef22b 100644
--- a/volk/gen/machines.xml
+++ b/volk/gen/machines.xml
@@ -10,27 +10,17 @@
</machine>
<machine name="sse">
-<archs>generic 32|64 mmx sse</archs>
+<archs>generic 32|64| mmx sse</archs>
</machine>
-->
-<!--
-Create an SSE2 and AVX only machine (without 64/32 inline assembly support).
-This machine is intended to support the MSVC compiler on x86/amd64.
-The MSVC compiler has intrinsic support for SSE, SSE2, AVX
-however it does not support the gcc style inline assembly.
--->
-
<machine name="neon">
<archs>generic neon</archs>
</machine>
-<machine name="sse2_only">
-<archs>generic mmx sse sse2</archs>
-</machine>
-
+<!-- trailing | bar means generate without either for MSVC -->
<machine name="sse2">
-<archs>generic 32|64 mmx sse sse2</archs>
+<archs>generic 32|64| mmx sse sse2</archs>
</machine>
<machine name="sse3">
@@ -53,8 +43,9 @@ however it does not support the gcc style inline assembly.
<archs>generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount</archs>
</machine>
+<!-- trailing | bar means generate without either for MSVC -->
<machine name="avx">
-<archs>generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx</archs>
+<archs>generic 32|64| mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx</archs>
</machine>
<machine name="avx_only">
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index d29a951eb..4f4796840 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -40,6 +40,9 @@ class arch_class:
except: setattr(self, key, failval)
assert(self.name)
assert(self.type)
+ if self.flag == 'none': self.flag = None
+ self.flags = list()
+ if self.flag: self.flags = map(str.strip, self.flag.split(','))
def __repr__(self): return self.name
diff --git a/volk/gen/volk_compile_utils.py b/volk/gen/volk_compile_utils.py
new file mode 100644
index 000000000..a62c5657e
--- /dev/null
+++ b/volk/gen/volk_compile_utils.py
@@ -0,0 +1,68 @@
+#
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import optparse
+import volk_arch_defs
+import volk_machine_defs
+
+def format_flag(flag, compiler):
+ if compiler == 'msvc' and flag in ('mmmx', 'msse'):
+ return '/arch:SSE'
+ if compiler == 'msvc' and flag in ('msse2',):
+ return '/arch:SSE2'
+ if compiler == 'msvc' and flag in ('msse3', 'mssse3', 'msse4.1', 'msse4.2', 'mpopcnt', 'mavx'):
+ return '/arch:AVX'
+ #otherwise its a gcc compiler
+ return '-' + flag
+
+def do_arch_flags_list(compiler):
+ output = list()
+ for arch in volk_arch_defs.archs:
+ fields = [arch.name]
+ fields += list(map(lambda f: format_flag(f, compiler), arch.flags))
+ output.append(','.join(fields))
+ print ';'.join(output)
+
+def do_machines_list(arch_names):
+ output = list()
+ for machine in volk_machine_defs.machines:
+ machine_arch_set = set(machine.arch_names)
+ if set(arch_names).intersection(machine_arch_set) == machine_arch_set:
+ output.append(machine.name)
+ print ';'.join(output)
+
+def do_machine_flags_list(compiler, machine_name):
+ output = list()
+ machine = volk_machine_defs.machine_dict[machine_name]
+ for arch in machine.archs:
+ for flag in arch.flags:
+ output.append(format_flag(flag, compiler))
+ print ' '.join(output)
+
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option('--mode', type='string', default='')
+ parser.add_option('--compiler', type='string', default='')
+ parser.add_option('--archs', type='string', default='')
+ parser.add_option('--machine', type='string', default='')
+ (opts, args) = parser.parse_args()
+
+ if opts.mode == 'arch_flags': return do_arch_flags_list(opts.compiler.lower())
+ if opts.mode == 'machines': return do_machines_list(opts.archs.split(';'))
+ if opts.mode == 'machine_flags': return do_machine_flags_list(opts.compiler.lower(), opts.machine)
+
+if __name__ == '__main__': main()
diff --git a/volk/gen/volk_machine_defs.py b/volk/gen/volk_machine_defs.py
index 82734679c..b30a480ba 100644
--- a/volk/gen/volk_machine_defs.py
+++ b/volk/gen/volk_machine_defs.py
@@ -24,10 +24,12 @@ class machine_class:
def __init__(self, name, archs):
self.name = name
self.archs = list()
+ self.arch_names = list()
for arch_name in archs:
if not arch_name: continue
arch = arch_dict[arch_name]
self.archs.append(arch)
+ self.arch_names.append(arch_name)
arch_name += '_u'
if arch.alignment > 1 and arch_dict.has_key(arch_name):
arch = arch_dict[arch_name]
@@ -40,7 +42,10 @@ def register_machine(name, archs):
for i, arch_name in enumerate(archs):
if '|' in arch_name: #handle special arch names with the '|'
for arch_sub in arch_name.split('|'):
- register_machine(name+'_'+arch_sub, archs[:i] + [arch_sub] + archs[i+1:])
+ if arch_sub:
+ register_machine(name+'_'+arch_sub, archs[:i] + [arch_sub] + archs[i+1:])
+ else:
+ register_machine(name, archs[:i] + archs[i+1:])
return
machine = machine_class(name=name, archs=archs)
machines.append(machine)