diff options
author | Josh Blum | 2012-04-16 21:56:01 -0700 |
---|---|---|
committer | Josh Blum | 2012-04-19 18:13:22 -0700 |
commit | f70cb7901a43c201242399225d31eed83e7d41ce (patch) | |
tree | 974f0dff2071f6539f39297024b52a23498255a7 /volk/gen | |
parent | 4d1ee048a3bac03b0d8ad39e5aa270ff8335941b (diff) | |
download | gnuradio-f70cb7901a43c201242399225d31eed83e7d41ce.tar.gz gnuradio-f70cb7901a43c201242399225d31eed83e7d41ce.tar.bz2 gnuradio-f70cb7901a43c201242399225d31eed83e7d41ce.zip |
volk: use archs.xml to specify compiler flags + support
Diffstat (limited to 'volk/gen')
-rw-r--r-- | volk/gen/archs.xml | 45 | ||||
-rw-r--r-- | volk/gen/volk_arch_defs.py | 19 | ||||
-rw-r--r-- | volk/gen/volk_compile_utils.py | 17 |
3 files changed, 44 insertions, 37 deletions
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml index ac4dd9f7f..2c9ab41a5 100644 --- a/volk/gen/archs.xml +++ b/volk/gen/archs.xml @@ -5,21 +5,21 @@ </arch> <arch name="altivec"> - <flag>maltivec</flag> + <flag compiler="gnu">-maltivec</flag> <alignment>16</alignment> <check name="has_ppc"></check> </arch> <arch name="neon"> - <flag>mfpu=neon</flag> - <flag>mfloat-abi=softfp</flag> - <flag>funsafe-math-optimizations</flag> + <flag compiler="gnu">-mfpu=neon</flag> + <flag compiler="gnu">-mfloat-abi=softfp</flag> + <flag compiler="gnu">-funsafe-math-optimizations</flag> <alignment>16</alignment> <check name="has_neon"></check> </arch> <arch name="32"> - <flag>m32</flag> + <flag compiler="gnu">-m32</flag> </arch> <arch name="64"> @@ -31,7 +31,7 @@ <param>0x80000001</param> <!-- cpuid operation --> <param>29</param> <!-- bit shift --> </check> - <flag>m64</flag> + <flag compiler="gnu">-m64</flag> </arch> <arch name="3dnow"> @@ -40,7 +40,7 @@ <param>0x80000001</param> <param>31</param> </check> - <flag>m3dnow</flag> + <flag compiler="gnu">-m3dnow</flag> <alignment>8</alignment> </arch> @@ -50,7 +50,7 @@ <param>0x80000001</param> <param>5</param> </check> - <flag>msse4.2</flag> + <flag compiler="gnu">-msse4.2</flag> <alignment>16</alignment> </arch> @@ -60,7 +60,8 @@ <param>0x00000001</param> <param>23</param> </check> - <flag>mpopcnt</flag> + <flag compiler="gnu">-mpopcnt</flag> + <flag compiler="msvc">/arch:AVX</flag> </arch> <arch name="mmx"> @@ -69,7 +70,8 @@ <param>0x00000001</param> <param>23</param> </check> - <flag>mmmx</flag> + <flag compiler="gnu">-mmmx</flag> + <flag compiler="msvc">/arch:SSE</flag> <alignment>8</alignment> </arch> @@ -79,7 +81,8 @@ <param>0x00000001</param> <param>25</param> </check> - <flag>msse</flag> + <flag compiler="gnu">-msse</flag> + <flag compiler="msvc">/arch:SSE</flag> <environment>_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);</environment> <include>xmmintrin.h</include> <alignment>16</alignment> @@ -91,7 +94,8 @@ <param>0x00000001</param> <param>26</param> </check> - <flag>msse2</flag> + <flag compiler="gnu">-msse2</flag> + <flag compiler="msvc">/arch:SSE2</flag> <alignment>16</alignment> </arch> @@ -108,7 +112,8 @@ <param>0x00000001</param> <param>0</param> </check> - <flag>msse3</flag> + <flag compiler="gnu">-msse3</flag> + <flag compiler="msvc">/arch:AVX</flag> <environment>_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);</environment> <include>pmmintrin.h</include> <alignment>16</alignment> @@ -120,7 +125,8 @@ <param>0x00000001</param> <param>9</param> </check> - <flag>mssse3</flag> + <flag compiler="gnu">-mssse3</flag> + <flag compiler="msvc">/arch:AVX</flag> <alignment>16</alignment> </arch> @@ -130,7 +136,7 @@ <param>0x80000001</param> <param>6</param> </check> - <flag>msse4a</flag> + <flag compiler="gnu">-msse4a</flag> <alignment>16</alignment> </arch> @@ -140,7 +146,8 @@ <param>0x00000001</param> <param>19</param> </check> - <flag>msse4.1</flag> + <flag compiler="gnu">-msse4.1</flag> + <flag compiler="msvc">/arch:AVX</flag> <alignment>16</alignment> </arch> @@ -150,7 +157,8 @@ <param>0x00000001</param> <param>20</param> </check> - <flag>msse4.2</flag> + <flag compiler="gnu">-msse4.2</flag> + <flag compiler="msvc">/arch:AVX</flag> <alignment>16</alignment> </arch> @@ -168,7 +176,8 @@ </check> <!-- check to see that the OS has enabled AVX --> <check name="get_avx_enabled"></check> - <flag>mavx</flag> + <flag compiler="gnu">-mavx</flag> + <flag compiler="msvc">/arch:AVX</flag> <alignment>32</alignment> </arch> diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py index d64f8def2..8ac99b338 100644 --- a/volk/gen/volk_arch_defs.py +++ b/volk/gen/volk_arch_defs.py @@ -33,7 +33,15 @@ class arch_class: except: setattr(self, key, failval) self.checks = checks assert(self.name) - self.flags = flags + self._flags = flags + + def is_supported(self, compiler): + if not self._flags.keys(): return True + return compiler in self._flags.keys() + + def get_flags(self, compiler): + try: return self._flags[compiler] + except KeyError: return list() def __repr__(self): return self.name @@ -64,17 +72,18 @@ for arch_xml in archs_xml: val = arch_xml.getElementsByTagName(name)[0].firstChild.data kwargs[name] = val except: pass - checks = [] + checks = list() for check_xml in arch_xml.getElementsByTagName("check"): name = check_xml.attributes["name"].value params = list() for param_xml in check_xml.getElementsByTagName("param"): params.append(param_xml.firstChild.data) checks.append([name, params]) - flags = [] + flags = dict() for flag_xml in arch_xml.getElementsByTagName("flag"): - flags.append(flag_xml.firstChild.data) - + name = flag_xml.attributes["compiler"].value + if not flags.has_key(name): flags[name] = list() + flags[name].append(flag_xml.firstChild.data) register_arch(flags=flags, checks=checks, **kwargs) if __name__ == '__main__': diff --git a/volk/gen/volk_compile_utils.py b/volk/gen/volk_compile_utils.py index a62c5657e..cd9f9f0a9 100644 --- a/volk/gen/volk_compile_utils.py +++ b/volk/gen/volk_compile_utils.py @@ -19,21 +19,11 @@ 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)) + if not arch.is_supported(compiler): continue + fields = [arch.name] + arch.get_flags(compiler) output.append(','.join(fields)) print ';'.join(output) @@ -49,8 +39,7 @@ 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)) + output.extend(arch.get_flags(compiler)) print ' '.join(output) def main(): |